GWT and struts integration

133 views
Skip to first unread message

rpelluru

unread,
Aug 6, 2009, 4:46:14 AM8/6/09
to Google Web Toolkit
Hi all,
We have existing web application implemented using Struts
1.1.
We want to integrate GWT in our existing struts application.
I didn't find any articles or sample code on GWT + struts integration.

Could any one please provide the articles or sample code about the GWT
+ struts integration.

Regards,
Rajesh

Kamal Chandana Mettananda

unread,
Aug 6, 2009, 5:35:42 AM8/6/09
to Google-We...@googlegroups.com
Hi Rajesh,

There's an article about using GWT with Servlets; not quite sure whether that will help you a lot. May be you can have a look.

http://lkamal.blogspot.com/2008/09/java-gwt-servlets-web-app-tutorial.html

Cheers.
Kamal

---------------------------------------

http://lkamal.blogspot.com

mariyan nenchev

unread,
Aug 6, 2009, 5:51:47 AM8/6/09
to Google-We...@googlegroups.com
Just create struts action that directs you to the gwt host page (jsp for example).
You may have multiple entry points, use one action and pass the desired module id to the action and with switch decide where to go. Not so hard?

Rajesh Pelluru

unread,
Aug 6, 2009, 6:47:47 AM8/6/09
to Google-We...@googlegroups.com
Hi mariyan,
        Thanks for your reply. Can you please explain me more detail.
Could you please share the sample code do u have .
 
Regards,
Rajesh

mariyan nenchev

unread,
Aug 6, 2009, 7:43:14 AM8/6/09
to Google-We...@googlegroups.com
public class GwtEntryPointAction extends Action {
   
    @Override
    protected ActionForward lexecute(ActionMapping mapping, ActionForm theForm, HttpServletRequest request, HttpServletResponse response)
            throws Exception {
         Integer entrypointId = Integer.parseInt(request.getAttribute("epid"));
         swtich(entrypointId) {
         ....
        return mapping.findForward("hostpage1");
        .....
        return mapping.findForward("hostpage2");
........................
          }

    }

}


hostpage1.jsp :
<script type="text/javascript" language="javascript" src="/hostpage1.nocache.js"></script>
<DIV id="hostpage1"></DIV>

hostpage2.jsp
<script type="text/javascript" language="javascript" src="/hostpage2.nocache.js"></script>
<DIV id="hostpage2"></DIV>


Or even you may use one jsp, but the switch logic must be in it, which is better :)

There is nothing special about struts.
It's more complicated if you want mixed struts + gwt ui that are connected and weather the gwt components are client side only or not. You should think how to integrate that. My be with some custom js, but i can't give you an example for that, i have never done this. My gwt part was independent from the struts part.

mikedshaffer

unread,
Aug 6, 2009, 4:14:08 PM8/6/09
to Google Web Toolkit
Similar to what Mariyan says, it really depends on how integrated you
want GWT to be inside your Struts app. Dave Geary devotes a whole
chapter to this topic in his book "Google Web Toolkit Solutions". It
was written for GWT 1.4, but it remains very relevent. Pick it up at
Amazon or your favorite book source. For additional information, just
remember that GWT is really an AJAX toolkit, so Google for "how to
integrate AJAX into Struts". Again, and lastly, it really depends how
much integration between the two worlds you are trying to do. Struts
is a stateful server form post solution and GWT is a thick and
stateful Javascript client with AJAX server communication solution...
Reply all
Reply to author
Forward
0 new messages