« 返回到 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 附件
70383 查看
平均 (1 投票)
满分为 5,平均得分为 5.0。
评论
讨论主题回复 作者 日期
u had given How to build a GWT Portlet in... Ramesh Gandreti 2008年11月6日 上午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日 下午10:18
Does this work with gwt applications that use... Luca Rubino 2010年2月8日 上午11:10
Those two possibilitys are absolutely easy to... Frank Grieshaber 2010年3月11日 上午6:20
If you try to add it the GWT Portlet first time... Massimiliano Assante 2010年4月30日 上午3:52
Hello everyone... I am trying to integrate... Chitrabhanu Das 2010年6月1日 上午6:17
i have same problem, did someone know any... Andrej Kumor 2011年2月17日 上午8:59
See example at... Mdu Mdu 2011年2月23日 上午11:38
How does GWT Activites and places work with... Vijay Akkineni 2012年6月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-6 上午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 下午10: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-2-8 上午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
在 10-3-11 上午6:20 发帖以回复 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
在 10-4-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-6-1 上午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
在 11-2-17 上午8:59 发帖以回复 Chitrabhanu Das
See example at http://forums.smartclient.com/showthread.php?t=6070&highlight=liferay+portlet
在 11-2-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-6-12 上午8:03 发帖。