Adding custom dynamic content spot in your PageBuilder2 theme

In the Creating a new PageBuilder2 Theme entry i mentioned the steps to create a Custom PageBuilder2 Theme, but in that case we only changed the static html file in the theme, but what if you want to add a new dynamic content spot or you want to override functionality in say Default.jsp or some other JSP, follow these steps


  1. Create a new .war file say WPNotesTheme which should be a servlet specification 2.4 compliant web application.

  2. Copy content of WebSphere\PortalServer\theme\wp.mashup.cc.theme\installedApps\wp.mashup.cc.theme.ear\PageBuilder2.war, into your war file. I always make sure to copy the WebContent\themes, WebContent\skins folder and also content inside the WEB-INF such as tld folder and other files


  3. Once your .war file is ready deploy it on the WebSphere Portal server as .war file using either WebSphere Application Server Admin Console or using RAD, If your deploying on RAD, it might fail saying the application has errors(It happens because we are using the portal theme Tags that RAD is not able to find ), To fix this issue go to Windows -> Preferences and check "Allow applications containing errors to be published on server" check box

    In my case i am deploying the WPNotesTheme at WPNotesTheme context root

  4. Once the WPNotesTheme.ear application is installed, next step is to change the theme to use the WPNotesTheme.ear instead of default PageBuilder2. In order to do that first take full export of your portal

  5. Create UpdateTheme.xml file by copying the csa2.websphereNotes related theme element in it. Change value of context-root element and WPNotesTheme element to WPNotesTheme because thats where the theme is installed, your xmlaccess should look something like this

    <?xml version="1.0" encoding="UTF-8"?>
    <request build="wpnext_528_01" type="update" version="7.0.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="PortalConfig_7.0.0.xsd">
    <portal action="locate">
    <theme action="update" active="false" context-root="/WPNotesTheme" default="false" domain="rel"
    objectid="ZJ_CCBRVKG10GE2D0IEJ69NID3082" resourceroot="WPNotesTheme">
    <localedata locale="en">
    <title>WebSphere Notes Theme</title>
    <description/>
    </localedata>
    <parameter name="com.ibm.portal.themetype" type="string"
    update="set"><![CDATA[CSA2]]></parameter>
    <parameter name="theme.capability.oneUI" type="string"
    update="set"><![CDATA[2.1]]></parameter>
    <parameter name="theme.capability.dojo" type="string"
    update="set"><![CDATA[1.4.3]]></parameter>
    <parameter name="com.ibm.portal.friendly.name" type="string"
    update="set"><![CDATA[csa2.websphereNotes]]></parameter>
    <parameter name="theme.capability.mashups.enabler" type="string"
    update="set"><![CDATA[2.4]]></parameter>
    <parameter name="com.ibm.portal.theme.template.ref" type="string"
    update="set"><![CDATA[dav:fs-type1/themes/csa2.websphereNotes/]]></parameter>
    </theme>
    </portal>
    </request>


  6. Import the updatetheme.xml in your websphere portal server, and now if you access the theme test page you will notice that Default.jsp from your WPNotesTheme.war is getting executed, when you hit the THeme test page you should see that Default.jsp in your .war file is getting compile

    [3/18/11 19:33:02:501 PDT] 00000055 servlet I com.ibm.ws.webcontainer.servlet.ServletWrapper init SRVE0242I: [WPNotesThemeEAR] [/WPNotesTheme] [/themes/html/Default.jsp]: Initialization successful.

    You can also verify this by adding couple of System.out lines in your Default.jsp



  7. But you will notice that if you make change in any other JSP say bannerNav.jsp then your bannerNav.jsp is not getting executed instead the one in PageBuilder2.war is getting executed that is because your dynamic content spot in theme.html is still pointing to the PageBuilder2.war. YOu can fix this by changing the theme.html like this


    <a rel="dynamic-content" href="res:/WPNotesTheme/themes/html/PageBuilder2/bannerNav.jsp"></a>
    <%--
    <a rel="dynamic-content" href="dyn-cs:id:bannerNav@tl:oid:csa2.theme"></a>
    --%>


    In this case i am commenting out the bannerNav dynamic spot and replacing it with URL to res:/WPNotesTheme/themes/html/PageBuilder2/bannerNav.jsp, if you want you can actually change the value of dynamicContentSpot in the WAS Admin Console but it will require a server restart so may be you can make the changes before going to production

  8. Last step would be copy your modified theme_en.html to the WebDav store



Once your changes are uploaded on the server you can hit your theme test page and you should see your changes

2 comments:

luisrojas17 said...

Hi.

I have a question, what's the path custom theme once it's deploy from administration console. Other thing, the file that I have that deploy is war or ear.

luisrojas17 said...

Thanks for your answer and sorry'me for my english.