« GWT に戻る

Build a GWT Portlet

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 添付ファイル
70382 参照数
平均 (1 投票)
平均評価は5.0星中の5です。
コメント
コメント 作成者 日時
u had given How to build a GWT Portlet in... Ramesh Gandreti 2008/11/06 1:09
Hi All, I am creating portals using IFrame.its... Chirag Suthar 2008/12/13 11:12
thanks for the wiki, it's really helpfull Ranjib Dey 2009/11/14 22:18
Does this work with gwt applications that use... Luca Rubino 2010/02/08 11:10
Those two possibilitys are absolutely easy to... Frank Grieshaber 2010/03/11 6:20
If you try to add it the GWT Portlet first time... Massimiliano Assante 2010/04/30 3:52
Hello everyone... I am trying to integrate... Chitrabhanu Das 2010/06/01 6:17
i have same problem, did someone know any... Andrej Kumor 2011/02/17 8:59
See example at... Mdu Mdu 2011/02/23 11:38
How does GWT Activites and places work with... Vijay Akkineni 2012/06/12 8:03

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
投稿日時:08/11/06 1:09
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?
投稿日時:08/12/13 11:12
thanks for the wiki, it's really helpfull
投稿日時:09/11/14 22:18
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?
投稿日時:10/02/08 11:10
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
Luca Rubinoへのコメント。投稿日時:10/03/11 6:20
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
投稿日時:10/04/30 3:52
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...
投稿日時:10/06/01 6:17
i have same problem, did someone know any solution ? or how can i integrate smartgwt to liferay ?

lot of thanks for any hit
Chitrabhanu Dasへのコメント。投稿日時:11/02/17 8:59
See example at http://forums.smartclient.com/showthread.php?t=6070&highlight=liferay+portlet
投稿日時:11/02/23 11:38
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.
投稿日時:12/06/12 8:03