Gwt-Ext example “loading data from database”
Sep 28th, 2008 by Dariusz
After seen a good example of how to save data into the database. I decided to write an example how to fetch data coming from a database.
For this example I will use hibernate to make it more easy for loading the data. In this example I won’t go too much in detail how hibernate works, instead how a server call populates data on front end.
If you take a look on my previous posts, you should be able to follow this application. I will just populate the data in the grid, as soon the user see the page. Basically, I will just present the manager class, which is responsible for getting the data and make it accessible in my Service class.
The example shown here is based on the demo, you can see on GWT-Ext Showcase.
If you are interested in my first posts (Setting up & Login example), here are the links:
Lets do it…
Database
My ‘contacts‘ database is setup as follow:
And here are the tables:
user:
gender:
Values of user table:
Values of gender table:
Eclipse structure
First of all I want to show the end result, after the application is up and running. Here is the structure of my ‘Data Grid’ application.
My libraries I’m using are as follow:
CSS (under: org.mypackage.public.css) grid.css:
-
.db_icon
-
{
-
background-image: url(../js/ext/resources/icons/database.gif) !important;
-
padding-right: 5px;
-
margin: 0 !important;
-
}
Main module Main.gwt.xml:
-
<module>
-
-
<!– Inherit the core Web Toolkit stuff. –>
-
<inherits name=‘com.google.gwt.user.User’/>
-
<!– Inherit the GWTExt Toolkit library configuration. –>
-
<inherits name=‘com.gwtext.GwtExt’ />
-
-
<!– Set our own css file –>
-
<stylesheet src="css/grid.css" />
-
-
<!– Specify the app entry point class. –>
-
<entry-point class=‘org.mypackage.client.Main’/>
-
-
<stylesheet src="js/ext/resources/css/ext-all.css" />
-
<script src="js/ext/adapter/ext/ext-base.js" />
-
<script src="js/ext/ext-all.js" />
-
-
</module>
Java:
Here is my Main.java class, which is the main module:
-
package org.mypackage.client;
-
-
import com.google.gwt.core.client.EntryPoint;
-
import com.google.gwt.core.client.GWT;
-
-
import com.google.gwt.user.client.rpc.AsyncCallback;
-
import com.google.gwt.user.client.rpc.ServiceDefTarget;
-
import com.google.gwt.user.client.ui.RootPanel;
-
-
import com.gwtext.client.core.TextAlign;
-
import com.gwtext.client.data.BooleanFieldDef;
-
import com.gwtext.client.data.FieldDef;
-
import com.gwtext.client.data.IntegerFieldDef;
-
import com.gwtext.client.data.JsonReader;
-
import com.gwtext.client.data.Record;
-
import com.gwtext.client.data.RecordDef;
-
import com.gwtext.client.data.Store;
-
import com.gwtext.client.data.StringFieldDef;
-
import com.gwtext.client.widgets.MessageBox;
-
-
import com.gwtext.client.widgets.Panel;
-
-
import com.gwtext.client.widgets.grid.CellMetadata;
-
import com.gwtext.client.widgets.grid.ColumnConfig;
-
import com.gwtext.client.widgets.grid.ColumnModel;
-
import com.gwtext.client.widgets.grid.GridPanel;
-
import com.gwtext.client.widgets.grid.Renderer;
-
-
public class Main implements EntryPoint {
-
private DataServiceAsync dataService = ( DataServiceAsync )GWT.create( DataService.class );
-
-
private Store store = null;
-
-
public void onModuleLoad() {
-
-
ServiceDefTarget endpoint = ( ServiceDefTarget )dataService;
-
endpoint.setServiceEntryPoint( moduleRelativeURL );
-
-
loadData();
-
-
dataPanel.setBorder( false );
-
dataPanel.setPaddings( 15 );
-
-
final RecordDef recordDef = new RecordDef( new FieldDef[] {
-
new StringFieldDef( "firstName", "firstName" ),
-
new StringFieldDef( "lastName", "lastName" ),
-
new IntegerFieldDef( "age", "age" ),
-
new StringFieldDef( "gender", "gender" ),
-
new BooleanFieldDef( "married", "married"),
-
});
-
-
JsonReader reader = new JsonReader( recordDef );
-
reader.setRoot( "users" );
-
reader.setTotalProperty( "totalCount" );
-
-
store = new Store( reader );
-
-
ColumnModel columnModel = new ColumnModel( getColumnConfig() );
-
-
GridPanel grid = new GridPanel();
-
grid.setTitle( "Loading content from Database" );
-
grid.setStore( store );
-
grid.setColumnModel( columnModel );
-
grid.setFrame( true );
-
grid.setWidth( 440 );
-
grid.setHeight( 350 );
-
grid.stripeRows( true );
-
grid.setIconCls( "db_icon" );
-
-
dataPanel.add( grid );
-
-
RootPanel.get( "grid_widget" ).add( dataPanel );
-
}
-
-
/** Method responsible for loading data */
-
private void loadData() {
-
AsyncCallback callback = new AsyncCallback()
-
{
-
{
-
jsonData = null;
-
jsonData = result.toString();
-
store.loadJsonData( jsonData, true );
-
// must commit changes to see the data
-
// inside the grid!!!
-
store.commitChanges();
-
}
-
{
-
MessageBox.alert( "Error", "Error while loading data" );
-
}
-
};
-
dataService.getUsers( callback );
-
}
-
-
/**
-
* Column config setup
-
* @return the column config
-
*/
-
private ColumnConfig[] getColumnConfig() {
-
ColumnConfig fNameCol = new ColumnConfig( "First Name", "firstName", 100, true );
-
ColumnConfig lNameCol = new ColumnConfig( "Last Name", "lastName", 100, true );
-
ColumnConfig ageCol = new ColumnConfig( "Age", "age", 50, true );
-
ColumnConfig genderCol = new ColumnConfig( "Gender", "gender", 100, true );
-
Record record, int rowIndex, int colNum, Store store ) {
-
-
String openStatus = "style=\"font-weight: bold; color: blue;\"";
-
String closeStatus = "style=\"font-weight: bold; color: #CC0066;\"";
-
-
if( value.toString().equals( "Male" ) )
-
{
-
cellMetadata.setHtmlAttribute( openStatus );
-
}
-
else
-
{
-
cellMetadata.setHtmlAttribute( closeStatus );
-
}
-
return value.toString();
-
}
-
});
-
-
ColumnConfig marriedCol = new ColumnConfig( "Married", "married", 70, true );
-
marriedCol.setAlign( TextAlign.CENTER );
-
Record record, int rowIndex, int colNum, Store store) {
-
return "<img class="\" src="\" alt="" />";
-
}
-
});
-
-
ColumnConfig[] columnConfigs = {
-
fNameCol,
-
lNameCol,
-
ageCol,
-
genderCol,
-
marriedCol
-
};
-
-
return columnConfigs;
-
}
-
}
My peristent classes User.java and Gender.java classes, are regular objects with getters and setters. No need to go deeper into it.
DataService.java looks like this:
-
package org.mypackage.client;
-
-
import com.google.gwt.core.client.GWT;
-
import com.google.gwt.user.client.rpc.RemoteService;
-
import com.google.gwt.user.client.rpc.ServiceDefTarget;
-
-
public interface DataService extends RemoteService {
-
-
-
public static DataServiceAsync getInstance() {
-
-
DataServiceAsync instance = (DataServiceAsync) GWT
-
.create(DataService.class);
-
ServiceDefTarget target = (ServiceDefTarget) instance;
-
target.setServiceEntryPoint(GWT.getModuleBaseURL() + SERVICE_URI);
-
-
return instance;
-
}
-
}
-
-
// Gets the JSON data
-
}
DataServiceAsync.java :
-
package org.mypackage.client;
-
-
import com.google.gwt.user.client.rpc.AsyncCallback;
-
-
public interface DataServiceAsync {
-
// Gets the JSON data
-
public void getUsers( AsyncCallback callback );
-
}
The manager class (UserManager.java) takes care of creating a JSON object to be able to populate it on the front end. I decided to use JSON simple, with a nice documentation. You can download it here:
Now, here is the whole UserManager.java
-
package org.mypackage.manager;
-
-
import java.util.ArrayList;
-
import java.util.Iterator;
-
import java.util.List;
-
-
import org.hibernate.Session;
-
import org.json.simple.JSONArray;
-
import org.json.simple.JSONObject;
-
import org.mypackage.pojo.Gender;
-
import org.mypackage.pojo.User;
-
import org.mypackage.util.HibernateUtil;
-
-
public class UserManager {
-
-
/** The user list */
-
-
/** The instance */
-
private static UserManager instance = null;
-
-
/** Class constructor just to defeat instantiation */
-
protected UserManager() {}
-
-
/** Gets the instance. */
-
public static UserManager getInstance() {
-
if( instance == null ) {
-
instance = new UserManager();
-
}
-
return instance;
-
}
-
-
/** Gets a json list of all users. */
-
public JSONObject getUsers() {
-
-
Session session = HibernateUtil.getSessionFactory().openSession();
-
session.beginTransaction();
-
-
userList = session.createQuery( "from User" ).list();
-
-
JSONObject root = new JSONObject();
-
JSONArray users = new JSONArray();
-
-
{
-
User user = ( User )iterator.next();
-
Gender gender = user.getGender();
-
-
JSONObject jsonUser = new JSONObject();
-
-
jsonUser.put( "firstName", user.getFirstName() );
-
jsonUser.put( "lastName", user.getLastName() );
-
jsonUser.put( "gender", gender.getTitle() );
-
-
users.add( jsonUser );
-
}
-
-
session.close();
-
root.put( "users", users );
-
-
return root;
-
}
-
}
A clean JSON output would be this:
-
{
-
"users": [
-
{
-
"married": false,
-
"gender": "Male",
-
"age": 25,
-
"firstName": "John",
-
"lastName": "Doe"
-
},
-
{
-
"married": true,
-
"gender": "Male",
-
"age": 32,
-
"firstName": "Foo",
-
"lastName": "Bar"
-
},
-
{
-
"married": true,
-
"gender": "Female",
-
"age": 28,
-
"firstName": "Mandy",
-
"lastName": "Boo"
-
},
-
{
-
"married": false,
-
"gender": "Male",
-
"age": 45,
-
"firstName": "Joe",
-
"lastName": "Black"
-
}
-
]
-
}
If you now open your DataServiceImpl.java, then you can easily start using your manager class to get the data from the database.
-
package org.mypackage.server;
-
-
import org.mypackage.client.DataService;
-
import org.mypackage.manager.UserManager;
-
-
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
-
-
public class DataServiceImpl extends RemoteServiceServlet implements DataService {
-
-
private UserManager userManager = null;
-
-
-
userManager = UserManager.getInstance();
-
-
return users;
-
}
-
}
If you run your application, you should see this result:
I hope this example was helpful.
Dariusz











this code part looks a little confusing:
- where comes the checkbox?
- the escape of ” looks not ok.
ColumnConfig marriedCol = new ColumnConfig( “Married”, “married”, 70, true );
marriedCol.setAlign( TextAlign.CENTER );
marriedCol.setRenderer( new Renderer() {
public String render(Object value, CellMetadata cellMetadata,
Record record, int rowIndex, int colNum, Store store) {
boolean checked = ( ( Boolean )value ).booleanValue();
return “”;
}
});
Arno,
I just saw, that while I was copying the source from my Eclipse, part of them just disappeared… I make the changes now.
By the way, the whole grid comes from the official gwt-ext demo. You can take a look on the source code there: http://www.gwt-ext.com/demo/#localXmlGrid
Thanks,
Dariusz
thx
How about an eclipse project file or war file? Having trouble getting GWT and Eclipse WTP working together. Thanks for posting this!
I’m using this version of Eclipse.
Did you read this post?
And this shows how to start developing GWT with Cypal:
Dariusz
Dariusz, that was a great tutorial, it worked with a few minor corrections.
Few comments:
Main.gwt.xml: replace , with <!– –>
Perhaps Wordpress was fixing those? Maybe you can use & gt; — and & lt;
In “public JSONObject getUSers()”
Instead of:
session.getSessionFactory().close();
It should be:
session.close();
before
root.put( “users”, users );
So that we can keep refreshing the browser window and keep getting valid JSON requests from the server. Once the SessionFactory is closed, we get NullPointerExceptions when requerying.
The database.gif icon was not found in the ExtJS 2.0.2 distribution.
I used this one instead:
../js/ext/resources/images/default/dd/drop-yes.gif
And with all those changes, I got rid of all errors and warnings.
Thanks Dariusz!
Keep up with the great work!!!
Thanks Pedro!
I made the changes in the Main.gwt.xml. It should be fine now.
You can download great icons on this page.
I see the point with closing session, but if I take a look in the log file I can see that the way I did it, I’m closing the hibernate session. If I do your way, I can’t see the closing statement.
Could you tell me the advantage of using it your way?
Thanks a lot!
OK, never mind. I made the changes in closing the hibernate session before I add users to the root.
Thanks Pedro!
Dear Dar,
I received this error
[ERROR] Unable to instantiate ‘org.mypackage.server.DataServiceImpl’
Do i miss something
Please help, tq
Hi!
If you could send the whole exception message, that would be a help. Did you check the web.xml file? Maybe it’s not mentioned in it. Are you using Cypal Plugin?
Hi Dariusz,
I don’t come to this web page often, so it’s hard to get your question.
I happen to revisit your site, and find your question now.
I would be very glad to answer it here.
You probably have some code that creates the SessionFactory in HibernateUtil.
There should be a single SessionFactory for the lifecyle of the Servlet:
http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/Servlets4.html
http://www.stardeveloper.com/articles/display.html?article=2001111901&page=1
That’s where you should create and destroy SessionFactory.
Hibernate’s SessionFactory can create many instances of Session.
For every HttpServletRequest, there should be a single Session with a short lifespan.
Another possibility is attaching the Hibernate Session to the HttpSession, and making sure the Session is destroyed when the HttpSession is destroyed (use and register HttpSessionListener)
You should register all the appropriate in the web.xml file.
You can take a look at the Spring framework to get cleaner dependency injection for more complicated and realistic cases. That’s another big subject =)
I hope I have answered your question.
Your tutorials on gwt-ext are really good contributions to the many developers.
Regards,
Pedro
In the line:
You should register all the appropriate in the web.xml file.
It should be:
You should register all the appropriate “listeners” in the web.xml file.
Wordpress deleted my word, since I used the “greater than” and “less than” symbols conflicting with HTML.
Cheers,
Pedro
Pedro,
Thanks a lot. I’m glad you answered my question. I think I have to improve my hibernate implementation in future.
Cheers,
Dariusz
Dariusz,
Think of SessionFactory as a database connection pool, and Hibernate\’s Session as database transactions where you want to finish your database operations quickly with commit/rollback.
SessionFactory is an expensive object to create, Session\’s are cheap.
I have been addicted to iBATIS for some years, but now I\’m looking into Hibernate and Spring.
Persistence in Java is moving too fast with too many options:
Hibernate, JPA, Spring 2.5 integration, and options to use JDK 5 annotations or not.
I recommend a really good practical book on Hibernate: \"Harnessing Hibernate\",
and for Spring 2.5: \"Spring Recipes\".
Happy learning,
Pedro
hi,
this tutorial is very nice.but for me the grid headings are coming but data inside are not coming and also i am not getting any error.i checked the database part also for data,please tell me what is the problem
thanks
usman.sk
I had the same problem, but it was due to a function I didn’t call after loading data. Take a look in the Main.java.
You see in line: 89 that I am calling: “store.commitChanges();” If I don’t use this method, I don’t see any errors, but neither the data inside the grid.
hi,
i got the solution.there is a mismatch between root.put( “users1″, users ); and reader.setRoot( “users” ); .thanks to answered my question
Hey Usman,
Glad you sorted it out!
Hi Dariusz,
I have an GWT RPC based app where I wanted to replace an old Grid with a nice GridPanel. I’d like to keep the GWT RPC mechanism to fetch the data just like you’ve done it. I also want to use a PagingToolbar to navigate in a large data set, so I thought of subclassing DataProxy [that in my view should be responsible for paging] and possibly Reader. What I can’t figure out is how these messages “next”, “prev”, etc. are communicated from the toolbar to the proxy. I’d appreciate your insight. Or maybe you know how to get to the source code of the classes in the com.gwtext.client.data package. I think I’d be able to figure it out from the source.
Thank you in advance,
Mark
Hi,
How to setup Ext js-GWT : GXT and Example on Eclipse Ganymede 3.4
Follow this: http://www.gwt-ext.com/wiki/index.php/Using_Eclipse
like this: http://extjs-gwt.blogspot.com/
Hi,
I found your description very helpful, can u please tell me how can i setup Hibernate ??
thx
Hi,I was wondering if u could share your working source because I can\’t set it work!
I am a newbie to GWT and would like to ask for some help!
By the way u can use JPA for making the query:
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.Query;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.unimasters.plc.entities.Gender;
import org.unimasters.plc.entities.User;
public class UserManager {
private static final long serialVersionUID = 370732473547L;
private EntityManager em;
private EntityManagerFactory emf;
private String persistenceUnit = \"TestExample\";
/** The user list */
private List userList = null;
/** The instance */
private static UserManager instance = null;
/** Class constructor just to defeat instantiation */
protected UserManager() {
}
/** Gets the instance. */
public static UserManager getInstance() {
if (instance == null) {
instance = new UserManager();
}
return instance;
}
/** Gets a json list of all users. */
public JSONObject getUsers() {
userList = new ArrayList();
emf = Persistence.createEntityManagerFactory(persistenceUnit);
em = emf.createEntityManager();
Query q = em.createQuery(\"Select u from User u\");
List<User> results = (List<User>)q.getResultList();
userList = (ArrayList<User>) results;
JSONObject root = new JSONObject();
JSONArray users = new JSONArray();
for (Iterator iterator = userList.iterator(); iterator.hasNext();) {
User user = (User) iterator.next();
Gender gender = user.getGenderid();
JSONObject jsonUser = new JSONObject();
jsonUser.put(\"firstName\", user.getFirstname());
jsonUser.put(\"lastName\", user.getLastname());
jsonUser.put(\"age\", new Integer(user.getAge()));
jsonUser.put(\"gender\", gender.getTitle());
jsonUser.put(\"married\", new Boolean(user.getMarried()));
users.add(jsonUser);
}
// session.close();
root.put(\"users\", users);
return root;
}
}
Hi Dariusz,
i’m interested in how to develop a connection pool vith the GWT.
In my project i’m not using Hibernate so, i’m looking for a solution in Tomcat.
Do you know how, or can you redirect me somehow better solution ?
thanx for the attention.
bye
Hi Swario,
I’m not sure what you mean? Can you describe it more in detail? Give me a scenario and I’ll see if I can help you. I can’t promise anything.
Well, i want to build an app that it can run in real world…
I mean, right now i’m getting a connection to my Oracle db directly in my servlet class in a “getConnection()” method. But, as you know, this is not a well formed connection implementation.
I wanto to implement a connection pool for the db but i don’t know how…
i hope you understand
thank you again.
hi Dariusz,
below complete error is given——-
com.google.gwt.user.client.rpc.InvocationException:
at com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.onResponseReceived(RequestCallbackAdapter.java:201)
at com.google.gwt.http.client.Request.fireOnResponseReceivedImpl(Request.java:264)
at com.google.gwt.http.client.Request.fireOnResponseReceivedAndCatch(Request.java:236)
at com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:227)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.ie.IDispatchImpl.callMethod(IDispatchImpl.java:126)
at com.google.gwt.dev.shell.ie.IDispatchProxy.invoke(IDispatchProxy.java:155)
at com.google.gwt.dev.shell.ie.IDispatchImpl.Invoke(IDispatchImpl.java:294)
at com.google.gwt.dev.shell.ie.IDispatchImpl.method6(IDispatchImpl.java:194)
at org.eclipse.swt.internal.ole.win32.COMObject.callback6(COMObject.java:117)
at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1925)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2966)
at com.google.gwt.dev.SwtHostedModeBase.processEvents(SwtHostedModeBase.java:235)
at com.google.gwt.dev.HostedModeBase.pumpEventLoop(HostedModeBase.java:558)
at com.google.gwt.dev.HostedModeBase.run(HostedModeBase.java:405)
at com.google.gwt.dev.GWTShell.main(GWTShell.java:140)
in the rpc log file it says..
com.google.gwt.user.client.rpc.IncompatibleRemoteServiceException
please help me
Where are you running this request? In your web or hosted mode?
If your Exception is in webmode, then you probably forgot to implement your call in the web.xml.
It should be something like this:
<servlet>
<servlet-name>AccountService</servlet-name>
<servlet-class>org.yourpackage.server.AccountServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>AccountService</servlet-name>
<url-pattern>/accountservice</url-pattern>
</servlet-mapping>
</code>
hi Dariusz,
Thanks for the prompt reply. but I m running this in hosted mode.
please help.
I m using GWT 1.7 and GWTEXT 2.0.2
Congratulations and very much thanks for your article!
so clear, so good, excelent!!
It helps me so much
thankfully, Me =)
Thanks you so much dude….. Ur article really helped me alot…
how can i add paging toolbar this example.
I’ve added paging toolbar to this example but the textfield which shows current page number has not been changed by navigating between pages. how can i access it? what’s it name?
Can I use SQL Server 2005 as database server in GWT?
Hi John,
Of course you can. You can use any database you want. You just need to change the layer, which communicates with your database and hook it up to you business logic. I never used SQL Server, so I can’t really help you out with that.
Excellent Tutorial. Fetched some Idea.
Hi, could you please help me gwt-ext with struts2 integration sample login application with eclipse. thanks
Sorry, but I don’t have any experience with struts(2).
Hi Dariusz, ur application integrate with Hybernate is good. i am new to gwt-ext and i need to create multiple jsps in my webproject.i need to do forward and redirect like that.pls let me know if you have experience gwt-ext with any other framework integration. thanks
how can i change the total number of records on pagingToolbar on every server call?
is there any way i can do that. Any suggestions?
Thanks in Advance
Hi,
If you are talking from the hibernate perspective, you should use setFirstResult and setMaxResults. A typical example would be:
int startingPoint = 50; userList = new ArrayList ();
int amountOfResults = 50; // this is the number of the results you would like to get
Session session = HibernateUtil.getSessionFactory().openSession();
session.beginTransaction();
List
Query query = session.createQuery( “from User” );
query.setFirstResult( startingPoint );
query.setMaxResult( );
session.close();
Of course, you need to do some calculation, how many entries in the database you have (for paging) and where the starting point at the given time is.
I hope it helps!
Actaully i want to implement the total number of record on Client side by using GWT-Ext PaginationToolbar.
i have implemented the server side code.
after every 1000 record i want to make a server call then display it on the client using GWT-ext.
Scenario:
page size is set to 25 so for page number 1 to 40 i am displaying the 0 to 999 records once the user clicks on next page or last page i am making a server call and getting the response back now the real problem is it pagination toolbar should show me 41 to 80 page(1000 to 2000 record)
this is where i am badly stuck.
Oh, I see it’s more a client site issue. Unfortunately, I haven’t been working on GWT-Ext for a while and therefore I can’t really tell you the best approach.
I would recommend you try to post this question to the GWT-Ext forum.
The only thing wrong with this is the ordering of development. I don’t think this is the order that you put this together. All of the required data services, hibernate, etc should be explained first. The last thing shown should probably be the completed Main.java. In other words, it should be layed out in the order that the various configuration and code elements were developed.
Still, thanks for your efforts.
Hi Dariusz,
can i create the new package in gwt application? i.e com.web.client, com.web.server like new package (com.web.dao)?.please let me know. Thanks
Hi narsimhamudiraj,
I’m not sure if I understand your question, but you can create any package structure you want. You just need to be sure, that you have ‘client’ and ’server’ package name for the compiler. I assume you want to split your dao layer to ‘com.web.dao’, which is a good approach. Now, if you want to use your dao layer in your gwt components, you need to inherit them in your *.gwt.xml file.
Thanks Dariusz.
but i have one question how to inherit require module(com.web.dao package) in *.gwt.xml file. please let me know with small sample.because i am getting following error :
did you forget to inherit a required module? Thanks
Sorry narsimhamudiraj, but right now I am on vacation, but you should visit the following site and download the sources. Inside, you’ll find a good example how they are doing it.
http://development.lombardi.com/?p=734
I hope it helps!
Thanks Dariusz. I resolved it. thanks
Hi Dariusz, please help me ListBox selected Item move up and down sample code.thanks
narsimhamudiraj,
I’m not sure if I understand what you are looking for, but it seems like you want to implement a ‘drag and drop’ solution, right?
If this is the case, then you might want to check out this:http://allen-sauer.com/com.allen_sauer.gwt.dnd.demo.DragDropDemo/DragDropDemo.html#FlowPanelExample
Dariusz