« Voltar para 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 Anexos
70360 Visualizações
Média (1 Votar)
A média da avaliação é 5.0 estrelas de 5.
Comentários
Respostas do tópico Autor Data
u had given How to build a GWT Portlet in... Ramesh Gandreti 6 de Novembro de 2008 01:09
Hi All, I am creating portals using IFrame.its... Chirag Suthar 13 de Dezembro de 2008 11:12
thanks for the wiki, it's really helpfull Ranjib Dey 14 de Novembro de 2009 22:18
Does this work with gwt applications that use... Luca Rubino 8 de Fevereiro de 2010 11:10
Those two possibilitys are absolutely easy to... Frank Grieshaber 11 de Março de 2010 06:20
If you try to add it the GWT Portlet first time... Massimiliano Assante 30 de Abril de 2010 03:52
Hello everyone... I am trying to integrate... Chitrabhanu Das 1 de Junho de 2010 06:17
i have same problem, did someone know any... Andrej Kumor 17 de Fevereiro de 2011 08:59
See example at... Mdu Mdu 23 de Fevereiro de 2011 11:38
How does GWT Activites and places work with... Vijay Akkineni 12 de Junho de 2012 08: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
Postado em 06/11/08 01: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?
Postado em 13/12/08 11:12.
thanks for the wiki, it's really helpfull
Postado em 14/11/09 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?
Postado em 08/02/10 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
Postado em 11/03/10 06:20 em resposta a 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
Postado em 30/04/10 03: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...
Postado em 01/06/10 06:17.
i have same problem, did someone know any solution ? or how can i integrate smartgwt to liferay ?

lot of thanks for any hit
Postado em 17/02/11 08:59 em resposta a Chitrabhanu Das.
See example at http://forums.smartclient.com/showthread.php?t=6070&highlight=liferay+portlet
Postado em 23/02/11 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.
Postado em 12/06/12 08:03.