This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes GWT and the fly likes CRUD + Hibernate + GWT Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » GWT
Bookmark "CRUD + Hibernate + GWT" Watch "CRUD + Hibernate + GWT" New topic
Author

CRUD + Hibernate + GWT

matias casal
Ranch Hand

Joined: Oct 18, 2009
Posts: 61
Hello,

I am making a crud example with hibernate and gwt.
I made the following to delete and read:



They work perfectly, the information change on my mysql database, but the problem is that when I execute them the page/tables does not refresh automatically.

Does anyone knows how to make the dynamic update when the table is changed ?

Thank you!
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10268
    
    8

The code you have posted is the server side code. To refresh the UI, you will need to write the update UI operations explicitly.
You can have these methods return the POJO which was affected and use that to refresh your UI.


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
matias casal
Ranch Hand

Joined: Oct 18, 2009
Posts: 61
you will need to write the update UI operations explicitly

I did not make that.

Can you explain me shortly how to write the update UI operations ? Or give any tutorial about this ?
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10268
    
    8

In pseudo code:
1) Initiate the server call from the UI, typically on a button click or some similar user action
2) The server call method is defined by you, so you can have whatever return types you want. In your case it can return the required POJO
3) Once you get the POJO back, you can modify your UI accordingly.

The steps and code required to do this cannot be posted here. Instead, check out the GWT site which has code samples and a detailed explanation.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10268
    
    8

You might also find this useful
http://code.google.com/webtoolkit/articles/using_gwt_with_hibernate.html
matias casal
Ranch Hand

Joined: Oct 18, 2009
Posts: 61
I could not understand correctly.
My delete UI is something like this



What should I add to this to make it works ?
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10268
    
    8

The code looks OK.
You get a list of POJOs and you update the flex table with the ID, name and a delete button.

You can store a copy of the account list as an instance variable. Populate it when your UI is built the first time.
When you add a new account, add the newly created POJO to this list and rebuild the UI.
When you delete an account, remove the POJO from this list and rebuild the UI.
For this you will need to remove all existing data using the appropriate remove methods, or better yet just create a new instance of the FlexTable and (re)populate it
matias casal
Ranch Hand

Joined: Oct 18, 2009
Posts: 61
When you add a new account, add the newly created POJO to this list and rebuild the UI.
When you delete an account, remove the POJO from this list and rebuild the UI.


I have my different flextables in different classes that exteds composites.

Thats what I would like to know, how should I rebuild the UI ???

Thanks!
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10268
    
    8

As per your code, after a successful async call, you are adding rows containing the data for id, number and the button. For every UI refresh, you can invoke FlextTable#removeAllRows and then use your existing code to populate it.
Deepak Agarwal
Greenhorn

Joined: Oct 22, 2005
Posts: 3
You should use 'Store' and 'Loader' to bind your data with grid, that way after successfully update you would just call load method on your loader and changes will be reflected immediately and with no extra coding.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: CRUD + Hibernate + GWT