Google Web Toolkit (GWT) 2.0 Application Development

Using the HomePage instance in EntryPoint

To see the output of the created home page layout, we must add the HomePage instance in
the root panel at the entry point class.

Getting ready

Open the file MainEntryPoint.java.

How to do it…

    1. Remove all previous code from the method onModuleLoad:
    2. Create an instance of the HomePage class in this method:

 HomePage homePage =new HomePage();
 
    1. Add the homepage instance in the RootPanel:

 RootPanel.get().a dd(homePage);
 

How it works…

After adding the HomePage instance in the RootPanel, if we run the project, we will get the
following output:

EntryPoint

EntryPoint is an interface that allows a class to act as a module entry point. When a
module is loaded, each entry point class listed in the Main.gwt.xml file is instantiated and
its onModuleLoad method is called. When the host page is accessed by the browser, the
onModuleLoad function is called to display the first panels and widgets.

RootPanel

RootPanel corresponds to an HTML element on the host page. It can be used to add other
panels and widgets. A RootPanel is accessed by calling RootPanel.get(id), where id is
the value of the HTML ID attribute. The <body> element of the host page can be accessed by
calling RootPanel.get().


 RootPanels are never created directly. Instead, they are accessed via get().
 

Class and packages

The following table shows the class and its corresponding package

See also

  • The Creating the home page layout class recipe
  • The Adding the banner recipe
  • The Adding menus recipe
  • The Creating the left-hand sidebar recipe
  • The Creating the right-hand sidebar recipe
  • The Creating the main content panel recipe
  • The Creating the footer recipe

GWT Articles & Books

Comments

comments

Pages: 1 2 3 4

About Krishna Srinivasan

He is Founder and Chief Editor of JavaBeat. He has more than 8+ years of experience on developing Web applications. He writes about Spring, DOJO, JSF, Hibernate and many other emerging technologies in this blog.

Speak Your Mind

*