This wiki does not contain official documentation and is currently deprecated and read only. Please try reading the documentation on the Liferay Developer Network, the new site dedicated to Liferay documentation. DISCOVER Build your web site, collaborate with your colleagues, manage your content, and more. DEVELOP Build applications that run inside Liferay, extend the features provided out of the box with Liferay's APIs. DISTRIBUTE Let the world know about your app by publishing it in Liferay's marketplace. PARTICIPATE Become a part of Liferay's community, meet other Liferay users, and get involved in the open source project. Build a GWT Portlet
Table of Contents [-]
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.