integrate gwt with jsp

1,755 views
Skip to first unread message

dumidu

unread,
Feb 22, 2008, 5:08:48 AM2/22/08
to Google Web Toolkit
Dear All,

I am new to gwt, i want to know how i can put gwt control within with
jsp. in my jsp page i want to add
gwt tree control .

Thank you
Dumidu

k-e-n

unread,
Feb 24, 2008, 3:16:52 PM2/24/08
to Google Web Toolkit
Basically you should not do this.

This question has been asked and answered in another post.

I am appending here my response to the other post

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

It is not impossible, nor even difficult to integrate GWT with other
technologies, nor am I against it.

However, it is not advisable to mix multiple/conflicting control
mechanisms in any application.

There are some specific notes about GWT integration towards the end of
this post.
Web frameworks provide two main functionalities:
1. Retrieval and display of data from a remote source
2. Control / flow of the application control

While it is quite legitimate to have multiple mechanisms for
retrieving and displaying data, which is I think the most basic
problem you are facing (display excel spreadsheets, or various other
generated data), it is not a good idea to have multiple forms of
control within your application.

It would be rather like having a large car in which you can transport
all sorts of different things, but you would not want to have two
people trying to driving the car at the same time.

And you are correct, GWT is a younger technology than say JSP and
there may not be 'out of the box' code for displaying all of the
different data formats that you require nor coverage of integration
with all other useful technologies.

Currently GWT is mostly a programmer's toolkit; if the solutions are
not there you are expected to create your own using GWT as the base of
those solutions.
However, many people have already done this, so there are already
quite a few 'extension-libraries' (see below.)

The library G4JSF which seems to offer GWT and JSF integration appears
not to be an active project. The most recent version I could find was
from Jan 2007, over 12 months old.
The article covering G4JSF mentions only using GWT as a library of UI
components, not as an RPC or integration mechanism, thus I would
gather the library was (attempting) only to use the 'client' side of
GWT.
There are references to the 'current' G4JSF project website being
moved to a couple of different places, but following the prescribed
links I found no trace of G4JSF.

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

GWT INTEGRATION / EXTENSION:

There are various extension & integration techniques available for
GWT.

Perhaps the most obvious is that you can generate HTML and drop it
into a GWT widget, however, the HTML should be considered only as a
technique for containing & formatting the data, the HTML should not
contain links to other HTML otherwise you will lose control of the
application.

You can create new 'widgets' (client objects), which can exhibit both
'presentation' and 'behavior', by extending or combining existing GWT
widgets, you can also do this by implementing a 'native JavaScript'
method. These techniques are covered in the standard GWT
documentation.

In addition there are various and a growing number of freely available
GWT extension libraries.

GWT - Spring integration:
http://gwt-widget.sourceforge.net/
The above website has both a server library (SL) which covers Spring
integration and a widget library (WL) which contains a number of
useful widgets, in particular allowing the use of SVG within GWT.

GWT - Hibernate integration:
http://hibernate4gwt.sourceforge.net/

Useful widgets and examples of implementing 'native JavaScript'
methods:
http://gwt.components.googlepages.com/

Extensive and sophisticated UI components:
http://gwt-ext.com/

Other useful widgets
http://www.asquare.net/gwttk/

One other suggestion, if you need integration with other technologies,
search for integration between them and Java rather than between them
and GWT.
Since GWT calls Java on the server-side you can build your integration
from there.

For example there are Java / Excel integrations provided by:

http://www.jxcell.net/
I have not used the above software; it offers Java to Excel connection
& a Swing Excel 'look-alike'

http://poi.apache.org/
The above library I have used & it works well (this was in a pre-GWT
project).
The library gives access to many file types produced by Microsoft
products.

http://www.rgagnon.com/javadetails/java-0516.html
This lists many other Java/Excel options, one of which allows SQL to
be used to read Excel as if it were a database (I have not used this
and cannot comment on its usability, but it sounds like an interesting
idea.)

I hope this helps.

Sumit Chandel

unread,
Feb 25, 2008, 8:19:49 PM2/25/08
to Google-We...@googlegroups.com
Hi Dumidu,

Adding a GWT control to your JSP page is a straightforward process.

The RootPanel class represents the main application, and typically developers would add their GWT panels and widgets to the RootPanel using the RootPanel.get().add(myPanel) call.

When the GWT compiler translates your GWT code to JavaScript, it creates a <module>.nocache.js file and other <md5>.cache.js files that represent your application. All you would need to do to load your application is include the <module>.nocache.js bootstrap file in your host JSP page via a <script> tag, ensuring that the rest of the GWT generated files are being served in the same path as the .nocache.js file, and your application will load up in the host page.

However, in cases where you only want your GWT application to load as a component in another JSP page, which as I understand it is what you're trying to accomplish, you can simply add an id to an element in your JSP page and reference it in the RootPanel.get("id").add(myPanel) call.

So for example, let's say you defined a "<div id="gwtComponent"></div>" in your host JSP page. In your GWT entry point class, you would call RootPanel.get("gwtComponent").add(myPanel) to add your panel to the specified element in your host JSP page. In this way, the GWT bootstrap procedure will find and bind itself to the "gwtComponent" element you've defined in your host JSP page and load up as a component of the page.

For more information on building your GWT component, the "Getting Started" guide is a good place to start. For implementing a Tree control, you might find the Tree widget useful.

Getting Started guide:
http://code.google.com/webtoolkit/gettingstarted.html

Tree widget:
http://google-web-toolkit.googlecode.com/svn/javadoc/1.4/com/google/gwt/user/client/ui/Tree.html

Hope that helps,
-Sumit Chandel

dumidu

unread,
Mar 5, 2008, 1:12:22 AM3/5/08
to Google Web Toolkit
Dear All,

Thank you for reply,

i have add gwt controls using the way Chandel mentioned tree control
is work fine but rpc controls are not working after i add it to jsp
(it is worked when i run it using gwt shell).
i need to save the content in tree as a xml file i have manage to do
it by using gwt rpc call but when i place this within jsp rpc doesn't
work

Thanks

Dumidu.

Sumit Chandel

unread,
Mar 6, 2008, 2:52:03 PM3/6/08
to Google-We...@googlegroups.com
Hi Dumidu,

If the RPC calls are working in hosted mode, it's very likely that the problem has to do with the way your web.xml has configured the URL mappings to your RPC servlets. Could you post up both your servlet configuration in your module XML file as well as your web.xml file to see if that's the case?

Also, a code snippet showing the URL you're setting in your RPC service interface's setServiceEntryPoint() call would help to verify if the request is going where you expect.

Cheers,
-Sumit Chandel

dumidu

unread,
Mar 13, 2008, 10:52:16 PM3/13/08
to Google Web Toolkit
dear Chandel,

i use gwt shell to create the gwt project so their is no web.xml
file(i couldn't find) here with i attach module xml file
i dont know how to add gwt servlet to my normal jsp servlet projects
web.xml

<module>

<!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User'/>
<inherits name='com.google.gwt.xml.XML'/>

<!-- Specify the app entry point class. -->
<entry-point
class='com.amber.ambercontrols.editmenu.client.EditMenuItems'/>

<servlet path='/server'
class='com.amber.ambercontrols.editmenu.server.EditMenuServiceImpl'/>

</module>

thanks
Dumidu.
Reply all
Reply to author
Forward
0 new messages