But Enterprise wants portal with portlets (and me too). So how to make a "standalone" portlet in a nice .war file, while using GWT and such for this? I use GlassFish server and NetBeans IDE, so my sharing here towards these components only. Here is how I managed this to work:
Now, how to create a portlet with GWT:
- Create a new project, called "Java Web Application" in your NetBeans with GWT and PortalPack support enabled. Nothing else is needed for our example.
- Let's say, the name of our project is "GWTPortlet" and let's say it is in "net.maryniuk.portlet" package.
- NetBeans will generate for you a skeleton for your portlet. It is all what you actually need from non-GWT part.
- Add a <div id="foo"></div> tag with an ID (in our example "foo") somewhere inside that JSP page.
- In your GWT entry point, change RootPanel.get()... to RootPanel.get("foo")... so then GWT can lookup an element with an ID "foo" and place itself there.
- Build your project. You're done — subdirectory "dist" contains your .war file with GWT portlet!
- Now just deploy it inside your Portlet Driver and see the result.
Here how it looks like for me:
Later on, after you sure your portlet works as expected, you can deploy it on Liferay or Sun Webspace: