« Back to GWT

Build a GWT Portlet

(Redirected from How to build a GWT Portlet in Liferay)

Introduction #

There are two possibilities for integrating GWT into the portlet: using a div container, and using an iFrame.

Using a div-Container #

1. Create a simple JSP Portlet by using the Liferay Plugins SDK. In the subfolder portlets of the SDK run:

ant -Dportlet.name=helloGWT-portlet -Dportlet.display.name="Hello GWT" create

2. Open the view.jsp (/plugin/portlets/helloGWT-portlet/docroot) of the JSP portlet and add this part:

<script src="<%=request.getContextPath()%>/html/com.google.gwt.sample.hello.Hello.nocache.js"></script><div id="uniqueID"></div>

3. As an example use the Hello example application from the GWT bundle. Edit the class Hello of the GWT Hello example to:

RootPanel.get("uniqueID").add(b);

4. Compile the GWT application

5. Copy all the files from the folder

gwt-linux-1.5.0/samples/Hello/www/com.google.gwt.sample.hello.Hello to your JSP portlet

into

helloGWT-portlet/docroot/html

6. Run ant deploy and test your portlet in your Liferay Portal

Using an IFrame #

1. Create a simple JSP Portlet by using the Liferay Plugins SDK. In the subfolder portlets of the SDK run:

ant -Dportlet.name=helloGWT-portlet -Dportlet.display.name="Hello GWT" create

2. As an example use the Hello example application from the GWT bundle. Copy all the files from the folder

gwt-linux-1.5.0/samples/Hello/www/com.google.gwt.sample.hello.Hello to your JSP portlet

into

helloGWT-portlet/docroot/html

3. Open the view.jsp (/plugin/portlets/helloGWT-portlet/docroot) of the JSP portlet and add this part:

<iframe src="<%=request.getContextPath()%>/html/Hello.html" frameborder="0"></iframe>

4. Run ant deploy and test your portlet in your Liferay Portal

Exceptions & Handling #

This is observed in Liferay 5.2 , when we deploy the portlet and try to add it to our application then the widget from GWT is not visible. On subsequent refresh the widget becomes visible. This makes the following corrective steps

  • Ensure cache is cleared , the best way is to have the JSP do it rather than depending on the browser
  • Clear browser cache manually.

It must be remembered that GWT finally compiles to Javascript and hence caching might be a problem for the latest widgets to display.

0 Attachments
65955 Views
Average (1 Vote)
The average rating is 5.0 stars out of 5.
Comments
Threaded Replies Author Date
u had given How to build a GWT Portlet in... Ramesh Gandreti November 6, 2008 1:09 AM
Hi All, I am creating portals using IFrame.its... Chirag Suthar December 13, 2008 11:12 AM
thanks for the wiki, it's really helpfull Ranjib Dey November 14, 2009 10:18 PM
Does this work with gwt applications that use... Luca Rubino February 8, 2010 11:10 AM
Those two possibilitys are absolutely easy to... Frank Grieshaber March 11, 2010 6:20 AM
If you try to add it the GWT Portlet first time... Massimiliano Assante April 30, 2010 3:52 AM
Hello everyone... I am trying to integrate... Chitrabhanu Das June 1, 2010 6:17 AM
i have same problem, did someone know any... Andrej Kumor February 17, 2011 8:59 AM
See example at... Mdu Mdu February 23, 2011 11:38 AM
How does GWT Activites and places work with... Vijay Akkineni June 12, 2012 8:03 AM

u had given How to build a GWT Portlet in Liferay can u pls provide me build.xml

my mail id.is ramesh.liferay@gmail.com
Posted on 11/6/08 1:09 AM.
Hi All,

I am creating portals using IFrame.its very simple and handy too.
As GWT is allow on fly code changing from browser. I am using facade design pattern at client side with combination with EJB stateless bean.
Is any buddy know better way to maintaining security so please let me know?
Posted on 12/13/08 11:12 AM.
thanks for the wiki, it's really helpfull
Posted on 11/14/09 10:18 PM.
Does this work with gwt applications that use rpc calls? I've tried, but it seems to not work..I'm missing something or this is not the way to do it?
Posted on 2/8/10 11:10 AM.
Those two possibilitys are absolutely easy to do if u don't need RPC calls.

Today i was abled to get GWT RPC Calls to work. The following tutorial was really helpfull:

http://xantorohara.blogspot.com/2007/07/portlets-and-gwt.html
Posted on 3/11/10 6:20 AM in reply to Luca Rubino.
If you try to add it the GWT Portlet first time is not visible. clearing the cache does NOT solve the problem.
Adopting iFrames partially solves it, depending on your needs (the GWT page is just linked)
If you use
<layout-cacheable>false</layout-cacheable> in liferay-portlet.xml caching is NOT a problem for the latest widgets to display
Posted on 4/30/10 3:52 AM.
Hello everyone... I am trying to integrate smartgwt with liferay by using a div container.... but there seems to be some problem.... the skins and css are not loading... actually the problem is in the relative path to the resources(images)... is there any way to handle this??? thanks in advance...
Posted on 6/1/10 6:17 AM.
i have same problem, did someone know any solution ? or how can i integrate smartgwt to liferay ?

lot of thanks for any hit
Posted on 2/17/11 8:59 AM in reply to Chitrabhanu Das.
See example at http://forums.smartclient.com/showthread.php?t=6070&highlight=liferay+portlet
Posted on 2/23/11 11:38 AM.
How does GWT Activites and places work with this approach as Placehistoryhandler needs to check the hash of the url to drive the place. Any inputs woul dbe greatly appreciated. Thank you for the post.
Posted on 6/12/12 8:03 AM.