Vik
Vik

Reputation: 9289

GWT is making an unexpected event call

My code is below: I am seeing that on running the app the loadWidget method gets invoked even when the adminLink is not clicked. This is not want I want, but I'm not sure what is causing the issue. Please advise

public class LoginModule implements EntryPoint {
    LoginPopup loginPopup;

      private class LoginPopup extends PopupPanel {

            public LoginPopup() {
              super(true);      
            }    

            public void loadWidget(){
                System.out.println("I am called 1");

                CommonUi cUi = new CommonUi();
                  //#342 moved code to common area
                  FormPanel loginForm = cUi.getLoginFormUi();
                  setWidget(loginForm);
            }
     }


    @Override
    public void onModuleLoad() {
        //#251 improved login popup ui.
        final Anchor adminLink = new Anchor("User Login");
    //  final Label adminLink = new Label("User Login");
        adminLink.addClickHandler(new ClickHandler() {
              public void onClick(ClickEvent event) {
                // Instantiate the popup and show it.
                loginPopup =   new LoginPopup();
                loginPopup.loadWidget();
                loginPopup.showRelativeTo(adminLink);
                loginPopup.show();
              }
            });

        if(RootPanel.get("admin") !=null)
            RootPanel.get("admin").add(adminLink);

    }

}

Upvotes: 0

Views: 49

Answers (1)

Colin Alworth
Colin Alworth

Reputation: 18331

Running Dev Mode, set a breakpoint in that method in your Java IDE, and take a look at the current stack, what code is calling that method. If that is the only code in your app, then this only appears to be invokable from that onClick handlers, so it is a matter of figuring out why that is being invoked.

Upvotes: 1

Related Questions