开发者

GWT designing using java programming

I have created one gwt application. In the client package i inculded two java file contains gwt coding. In the first java program i included one Hyperlink when this Hyperlink is clicked it should redircted to Second file which also contains some GWT coding. I dont know how to redirect the java file.

Help me on this iss开发者_Python百科ue...

Regards, Raji


Bakkal is correct, you want to think about swapping out Widgets instead of navigating to a different web page. Here is some code to illustrate this point:

  /** The main panel associated with your GWT app's content */
  private Panel contentPanel;      

  public void onModuleLoad() {
    PageA pageA = new PageA();

    // When the user clicks 'GotoB' navigate to pageB.
    pageA.onButtonClickedHandler(new ClickHandler() {
      @Override
      public void onClick(ClickEvent event) {

        PageB pageB = new PageB();
        contentPanel.clear();
        contentPanel.add(pageB);
      }
    });

    contentPanel = new VerticalPanel();
    contentPanel.add(pageA);

    RootPanel.get("gwtAppBody").add(contentPanel);
  }


You can use a Hyperlink that switches a panel from PageA to PageB. You have to think more like an application developer instead of a web "pages" developer with GWT.


Check out the MVP pattern for creating GWT web apps. This is the answer to all your "gwt page switching questions" ;)

The pattern integrate an history managing system with some view while respecting the MVC (Model-View-Controller). They called it MVP (Model-View-Presenter) and gave it their own flavor. Add some UiBinder (new in GWT since 2.0) to create your view and you're in for a good ride! If you don't know what is a design pattern, don't be afraid to ask, people will be happy to answer


As mentioned by bakkal, you should probably focus the Events and responding to those events by taking some action on backend, returning some Model and updating your View. In conventional web applications, most of the time(if not using AJAX), you don't deal with events. However, when working with AJAX and GWT it will be helpful to introduce MVC in the GWT's part. This HMVC Pattern may be useful.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜