jMaki in portlets
By gregz on Feb 22, 2007
The latest version of jMaki 1.0 beta (v.8.3.1) fixes a problem that was preventing jMaki widgets from working in portlets. jMaki is a powerful, lightweight AJAX web application framework. jMaki wraps other UI libraries providing an extensive library of widgets from Dojo, Flickr, Google, Mochikit, Scriptaculous, Spry, and Yahoo. Now you can use all these widgets in your portlet applications.
I would highly recommend using the jMaki Netbeans plugin (1.6.9+), paired with the Portal Pack plugin. You can watch Greg and Ludo's screencast. And use the following different steps to get it working with your portlet application:
- Create a new portlet application project.
- Open project properties (right-click on project, Properties)
- Choose Frameworks, Add, jMaki Ajax Framework (CSS Layout does not apply here as the view.jsp for the portlet will not use it.)
- While in properties, check that the Run (under categories) lists Open Source Portlet Container as the server.
- Open Web Pages->WEB-INF->jsp->view.jsp
- Now you can drag-n-drop jMaki widgets and use the properties editor just like you saw in the screencast.
- Build, deploy, and test. Repeat. (The portlet container will require the portlet application be redeployed, unlike web app in the screencast.)
flickr.search, google.mappopup, yahoo.geocoder, and any other custom widgets that use the XmlHttpProxy. Due to a limitation in the portlet spec (JSR-168), the session-based restriction to the XmlHttpProxy fails. This will present itself only by the Ajax request failing and the portlet showing no response. (Firebug users will see the HTTP 403 error
"Access to the specified resource () has been forbidden."in the Ajax response.)
In order to work around this, you will need to set the
requireSessioncontext parameter in the
web.xmlfor the portlet application.
However, it is important that you understand the security implications of allowing unrestricted access to these services. This means that you are opening up the defined XmlHttpProxy services to any other applications that know the appropriate URL for your portlet application. Please read Greg Murray's blog on Restricting Access to your Ajax Services.
The jMaki widgets may seem like so many bells and whistles (Sudoku portlet anyone ), but Patrice Goutin shows how to use the Dojo table widget for easily creating the UI for a SAP name search portlet.
Update (20070508): Notice the change to the
requireSessioncontext parameter. This is effective from jMaki 0.9.2 (bundled with Netbeans module 184.108.40.206)