Code generated by portlet-client-model:init tags

Starting from version 6.1, WebSphere Portal server ships with client side API, that lets you do following things

  • Get and Set preferences

  • Change portlet modes and window states

  • Manipulate user profile



The Rational Application Server 7.5 provides you with tools to work with the client side API, You might have noticed that when you create a JSP inside portlet it includes these portlet-client-model tags

<portlet-client-model:init>
<portlet-client-model:require module="ibm.portal.xml.*" />
<portlet-client-model:require module="ibm.portal.portlet.*" />
</portlet-client-model:init>


If you look at the generated source code you will notice that the above JSP code generates following HTML code

<script>
if(typeof dojo=='undefined') {
document.writeln("<scr"+"ipt src='/wps/themes/dojo/portal_dojo/dojo/dojo.js' >
</scr"+"ipt>");
}
</script>
<script>
dojo.require('ibm.portal.xml.xpath');
dojo.require('ibm.portal.xml.xslt');
</script>
<script>
dojo.require('ibm.portal.portlet.portlet');
</script>
<script>
if(typeof(ibmPortalConfig) == "undefined") {
ibmPortalConfig = {contentHandlerURI: "/wps/mycontenthandler/!ut/p/digest!p3CnkU0nAEWw1oYE_wKYdg/nm/oid:wps.portal.root"};} else if(!ibmPortalConfig["contentHandlerURI"])
{ibmPortalConfig["contentHandlerURI"] = "/wps/mycontenthandler/!ut/p/digest!p3CnkU0nAEWw1oYE_wKYdg/nm/oid:wps.portal.root";} </script>
<div id='com.ibm.wps.web2.portlet.root.7_8000CB1A00QN00IC8BRUOG00O5' style='display: none;'>/wps/mycontenthandler/!ut/p/digest!p3CnkU0nAEWw1oYE_wKYdg/pm/oid:--portletwindowid--@oid:6_8000CB1A00QN00IC8BRUOG00O4</div>
<div id='com.ibm.wps.web2.portlet.preferences.7_8000CB1A00QN00IC8BRUOG00O5' style='display: none;' pageid='6_8000CB1A00QN00IC8BRUOG00O4' configid='3_8000CB1A00QN00IC8BRUOG0081' editdefaultsid='5_8000CB1A00QN00IC8BRUOG00O3'
editid='5_8000CB1A00QN00IC8BRUOG00O7'
>
</div>
<div id='com.ibm.wps.web2.portlet.user.7_8000CB1A00QN00IC8BRUOG00O5' style='display: none;'>/wps/mycontenthandler/!ut/p/digest!p3CnkU0nAEWw1oYE_wKYdg/um/secure/currentuser/profile?expandRefs=true</div>


As you can see the start of portlet-client-model:init tag is used for initializing the client side API on your page, it is checking if dojo is included on page already if not including it.

The call to portlet-client-model:require is getting converted into one or many dojo.require calls, the dojo.require is similar to import statement in the java it is used for importing classes into your code. In my case we are including classes from ibm.portal.xml and ibm.portal.portlet packages. In case of Dojo the dojo.require() call is used for including a .js file in your page.
The dojo classes are stored in the Wps.ear folder like this. You can create your custom classes and add theme to wps.ear



The portlet-client-model:init tag also generates some div tags that hold information required for client side API. For example the <div id='com.ibm.wps.web2.portlet.user.7_8000CB1A00QN00IC8BRUOG00O5' style='display: none;'>/wps/mycontenthandler/!ut/p/digest!p3CnkU0nAEWw1oYE_wKYdg/um/secure/currentuser/profile?expandRefs=true</div> holds information about how to load user profile information for current user.