gwtuibindergwt2

Can we write clickhandler on com.google.gwt.user.client.ui.Frame in GWT? is there any option to load PDF file in GWT?


I want to load multiple PDF file in thumbnail style, which will be clickable. when user click on thumbnail PDF this should be open in another window using GWT.

HorizontalPanel panel = new HorizontalPanel();

Frame frame= new Frame(url);

frame.addDomHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            Window.alert("do action");
        }
}, ClickEvent.getType());

panel.add(frame);

Solution

  • You cannot add click handlers to another document like that - the Frame creates an iframe element, which the PDF is loaded in, and you can't listen to content running in there.

    However, you can put an element over top of the Frame (by sizing it to match the Frame and positioning it appropriately), making it completely transparent, and adding a click handler to it. This way, when the user tries to click on the PDF, their event is seen by the "pane" in front of it, and can be handled appropriately (hiding the frame and opening another window).