Technote (FAQ)
Question
In the WebSphere® Portal 6.0 themes, you notice that there is a link for expanding children nodes, then another link for selecting a page. You can either expand the children, or select a page, but not both.
Answer
Many times you will want portal to both open the page and expand its children when selecting a page. With the current navigation tags, you cannot do this. Now you can use the Navigation SPI to do this. For more information on the Navigational State SPI, refer to "Leveraging WebSphere Portal V6 programming model: Part 2. Advanced URL generation in themes and portlets"
In the example below, we have modified the SPI to select the page as well as expand the node if it has children.
In the sidenav.jspf, we modified the code to generate the links to the pages as follows:
<c-rt:choose>
<c-rt:when test="<%=nodeHasChildren && !isExpanded %>">
<%String url = "";
url = ServletURLGenerator.generateUrlStringWithExpansion(wpsNavNode, true, request, response); %>
<a class="<%=rowCssClass%> wpsNavLevel<%=wpsNavLevel%>" href="<%=url%>"><c:out value='${sideNavItemTitle}' escapeXml='true' /></a>
</c-rt:when>
<c-rt:otherwise>
<a class="<%=rowCssClass%> wpsNavLevel<%=wpsNavLevel%>" href="<portal-navigation:navigationUrl type="launch"/>" <% if (openInNewWindow) {%>target="_blank"<% } %> <% if (isNodeSelected) { %>onfocus="showPageAffordance()" <% } %> >
<c:out value='${sideNavItemTitle}' escapeXml='true' />
</a>
</c-rt:otherwise>
</c-rt:choose>
This code calls the SPI to create a URL to a page and expand the node.
Attached is the jspf and the URL that calls the helper classes. To use this example, you need to put the helper class jar into shared/app and then replace the sidenav jspf with the attached one. This code will also cause the unselected page to collapse.
Rate this page:
Copyright and trademark information
IBM, the IBM logo and ibm.com are trademarks of International Business Machines Corp., registered in many jurisdictions worldwide. Other product and service names might be trademarks of IBM or other companies. A current list of IBM trademarks is available on the Web at "Copyright and trademark information" at www.ibm.com/legal/copytrade.shtml.