This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes GWT and the fly likes Integrating GWT with Struts 2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » GWT
Bookmark "Integrating GWT with Struts 2" Watch "Integrating GWT with Struts 2" New topic
Author

Integrating GWT with Struts 2

shukla raghav
Ranch Hand

Joined: Aug 03, 2008
Posts: 200
I want to integrate GWT with struts 2 how should i do it. Can anyone tell me how should i configure the environment for it in My Eclipse
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10167
    
    8

http://struts.apache.org/2.1.6/docs/struts-2-gwt.html


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

Joined: Aug 03, 2008
Posts: 200
Thanks Maneesh, This one seems to be the only resource for Struts + GWT. Although the features GWT provides are amazing but then it seems we get these RIA features at the cost of loosing the clean and clear methodology adopted by the Struts 2.

1. One of the powers of struts 2 is its clean and clear presentation of the "View Component". All you need to do is use a short and sweet OGNL expression to get the data from the Value Stack.

2. Second issue is regarding the Use of Struts 2 UI tags.Struts 2 UI tags are simple and clear easy to debug.

3. Mapping of UI components with Action Property is very easy all you need to do is have the same name for the UI component as the action tag.

I have still not understood Mapping of Data, how will the data sent from the browser through AJAX will be mapped to the Action Property. lets take a scenario.

assume we have two drop down A and B menus on our form.

A contains names of Batches and B will contain its corresponding List of students

as the user selects Batch from A, GWT needs to do two Things

1. Set the Property called "batch" to the value selected by the user.
2. automatically fetch the correspoing list of Student.

This should be automatically done through ajax.

in point 1, mapping is performed Between Combo box A and User property batch in say UserAction Class. this mapping is very easy in Struts 2



and the selected value of batch will be set to the batch property in the UserAction class.




we can see the batch selected by the user is so easily mapped to the Propery in the UserAction class all we needed to do was specify the name attribute of the <s:select> tag as property name i.e. batch

how will this be performed using GWT ?


Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10167
    
    8

Raghav,
Unfortunately I am not a Struts developer so I am unable to help you out here. However, I do have a question for you as an answer to your question

Why do you want to integrate GWT and Struts2. What problem are you trying to solve here which cannot be done with pure GWT?
shukla raghav
Ranch Hand

Joined: Aug 03, 2008
Posts: 200
i had already created the model part using the Struts 2 framework (Action classes, Beans, DAO classes). once i was done with the model part i thought of using the RIA frameworks for the front end. I had following options

1. Flex - Excellent, but difficult and not full fledged integration with Struts 2. Just a work around rather than confirmed solution
2. YUI - requires lot of javascripting and CSS
3. Dojo - has an advantage that it ships in with struts 2, But i found DOJO to have performance issue.
4. Backbase - good but no resources for integrating with Struts 2
5. GWT - Best option amongst all for following reasons

- Provides Eclipse Plugin for Struts 2
- Has amazign third party tools like the one provided by Ext GWT specifically for Struts 2
- Does not require you to be a JavaScript expert

The only issue with GWT is there are very few resources available for integration of Struts 2 and GWT although the plugins and tools are available for the same.
shukla raghav
Ranch Hand

Joined: Aug 03, 2008
Posts: 200
and yes Why Struts 2. ITs simply the best

1. Declarative mechanism for mapping requests directly to Model classes
2. XML based Validation
3. XML based Type conversion
4. XML based I18n support
5. very easy resource access (session, request, config, app context)
6. very high level abstaction using Interceptor support
7. Simplest MVC flow.

Thanks
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10167
    
    8

GWT follows MVC. If you have the model ready, I do not see any problem integrating with GWT. Of course it is easy for me to say so

GWT exchanges data with the server in the form of POJOs via asynchronous calls. Under the hood it is finally a servlet. Unfortunately, not being a Struts developer, I am unable to comment more, except that you can try posting the question in our Struts forum with a link to this thread for clarification of your problem.
shukla raghav
Ranch Hand

Joined: Aug 03, 2008
Posts: 200
Yes i think i should do that. I am taking this GWT-Struts 2 issue ceriously because it is a very much sought after requirement on the internet. If this integration could be provided with the same ease as Struts 2 then i think this combination will be the front runner.

Thanks
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Integrating GWT with Struts 2
 
Similar Threads
DWR and Struts
Using Struts2 + GWT
Integrating GWT with struts 1.3
Is GWT compatible with JDK version higher than 1.5
gwt and struts