Friday, October 26, 2007

Angus Bottom Round Roast Recipes

GWT - module or an entry-point

The programming is often so, do the basic stuff that is quick and easy, especially with regard to frameworks. The distribution of the library there is often plenty of examples, which are characterized by one feature - they are simple, sometimes too simple. Similarly, he is with most tutorials. However, there is a problem. At the outset, but later, yes. Because at that, after hearing the examples, or courses can do a form if you do not know how to design and then program the entire application. Of course, intuition suggests the programmer, in which direction to follow, but he always asks himself the question whether this is right direction, consistent with the art and architecture and its application is optimal.

I encountered such a problem by creating an application in GWT. My application was to consist of two components: the panel for the user and the administrator panel. However, certain elements of the panels were to be common: both display elements such as DialogBox, as well as RPC services. So here I was faced with the dilemma of how to solve the GWT - whether to create one module with several elements of an entry-point, or several modules. At first I was inclined to create more entry-points, until I realized that after the modules can inherit. Then it was over the hill, I decided stowrzyc a general module, which put the common code for both panels, and two modules of a specific code, one for the admin panel, and one for the front office. Of course, these two modules inherit the general module. Everything was within a single Eclipse project.

Now I is on the technical side.
First create a general module, which will be as follows:

Packets:
  com.blogspot.coderlife.app.common 
com.blogspot.coderlife.app.common.client
com.blogspot.coderlife.app.common.server
com . blogspot.coderlife.app.common.public
content packages:
  com.blogspot.coderlife.app.common 
Common.gwt.xml

com.blogspot.coderlife.app.common.client
CommonService.java
CommonServiceAsync.java
CommonDialogBox.java

com.blogspot.coderlife.app.common.server
CommonServiceImpl.java

com.blogspot.coderlife.app.common.public
(empty)
Content Common.gwt.xml file:
  \u0026lt;module> 
\u0026lt;inherits name="com.google.gwt.user.User">
\u0026lt;
servlet class = "com.blogspot.coderlife.app.common. server.CommonServiceImpl "
path =" / commonService ">
\u0026lt;/ module>
Please note that this module does not contain any element of an entry-point, because it will store all the elements in common, and he will not run, and therefore the package is empty com.blogspot.coderlife.app.common.public contains no html pages.

In the second step we create a module administrator which will be as follows:

Packets:
  com.blogspot.coderlife.app.adminpanel 
com.blogspot.coderlife.app.adminpanel.client
com.blogspot.coderlife.app.adminpanel.server
com.blogspot.coderlife . app.adminpanel.public
content packages:
  com.blogspot.coderlife.app.adminpanel 
AdminPanel.gwt.xml

com.blogspot.coderlife.app.adminpanel.client
AdminPanel.java

com.blogspot . coderlife.app.adminpanel.server
(empty)

com.blogspot.coderlife.app.adminpanel.public
AdminPanel.html
AdminPanel.css
AdminPanel.gwt.xml File Contents:
  \u0026lt;module> 
\u0026lt;inherits name="com.google.gwt.user.User">
\u0026lt;inherits name="com.blogspot.coderlife.app.common.server.Common">
\u0026lt;
entry-point class = "com.blogspot.coderlife.app.adminpanel.client.AdminPanel">
\u0026lt;/ module>
This module will no longer run through the file AdminPanel.html hence it contains an entry-point. The most important is the inheritance of common-module here.

I will not because he published content Userpanel is analogous to adminpanel.

summary by me if the application has two independent panels (screens) should create two modules for each of them, but the common elements in the third to put the common module (which does not contain any entry-point).

encourage you to share opinions about the correct model for building applications in GWT.

0 comments:

Post a Comment