主题效果

本文介绍了一个用于渲染页面左侧导航栏的JSP片段,详细展示了如何通过条件判断和循环来生成响应式的导航菜单。该菜单支持展开和折叠,并能够根据当前选中的节点调整样式。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

转载请注明出处 http://jjs-love.iteye.com

<%-- Licensed Materials - Property of IBM, 5724-E76, (C) Copyright IBM Corp. 2001, 2004, 2006 - All Rights reserved.

 NOTE: See notes in Default.jsp for information regarding editing theme JSP fragments. 

--%>
<%--
    This JSP renders the navigation bar on the left side of the page.
    By default, this will continue rendering the navigation where the
    previous navigation entity left off.
--%>
<c-rt:if test = "${themePolicy.renderSideNavigation}">
<portal-logic:if navigationAvailable="yes" screen="Home,LoggedIn,LoggedOut">
<table cellspacing=0 cellpadding=0 border=0 width="188"  height="100%" >
 <tr>
  <td valign="top" height=64 width=188><img src='<portal-logic:urlFindInTheme file="themeimage/tu_3.jpg" />' height=64 width=188></td>
 </tr>

<portal-navigation:navigation  startLevel="${themePolicy.sideNavigationStartLevel}">

<% int previousNavLevel=0;%>
<portal-navigation:navigationLoop>
<%--
 basic logic required:
  if node is selected give selected style
  if node has children, show expand/collapse
  if node is unselectable(label), don't render anchor
  if node is external url, open in new window
  if navlevel changed, open/close uls as needed.
--%>
<% // variables
 boolean isNodeSelected = wpsSelectionModel.isNodeSelected(wpsNavNode);
        String rowCssClass = isNodeSelected ? "wpsNavItem selected" : "wpsNavItem";
 boolean nodeHasChildren = wpsNavModel.hasChildren(wpsNavNode);
 boolean isExpanded = ((Boolean)((com.ibm.portal.state.StateModel)wpsNavModel).getState(wpsNavNode, com.ibm.portal.state.StateType.EXPANSION)).booleanValue() ;
        boolean openInNewWindow = com.ibm.portal.content.ContentNodeType.EXTERNALURL.equals(wpsNavNode.getContentNode().getContentNodeType());
        boolean isLabel = com.ibm.portal.content.ContentNodeType.LABEL.equals(wpsNavNode.getContentNode().getContentNodeType());
 int currentNavLevel = wpsNavLevel.intValue();
%>

 


<span class="<%=rowCssClass%>">
<tr>

<%--  ******************   render expand/collapse  ******************  --%>
<c-rt:choose>
<c-rt:when test="<%=nodeHasChildren && isExpanded %>">
    <td width=188 valign="middle" height="31" background='<portal-logic:urlFindInTheme file="themeimage/unselected.gif" />' style="background-repeat: repeat-y">
 <a href='<portal-navigation:navigationUrl type="collapse"/>'><portal-fmt:title/></a>
 </td>
</c-rt:when>
<c-rt:when test="<%=nodeHasChildren && !isExpanded %>">
   <td width=188 valign="middle" height="31" background='<portal-logic:urlFindInTheme file="themeimage/unselected.gif" />' style="background-repeat: repeat-y">
   <a href='<portal-navigation:navigationUrl type="expand"/>'><portal-fmt:title/></a>
  </td>
</c-rt:when>

</c-rt:choose>

</tr>
<tr>
<td>
    <table cellspacing=0 cellpadding=0 border=0>
    <tr>
<%--  ******************  render node  ******************  --%>
  <c-rt:choose>
  <c-rt:when test="<%=isLabel%>">

    
  </c-rt:when>
  <c-rt:otherwise>
        <td width=188 valign="middle"  height="31" bgColor='#F8F8FA' style="border:1px solid #728B90;border-bottom:1px solid #728B90;border-top:none; ">
    <a href="<portal-navigation:navigationUrl type="launch"/>" <% if (openInNewWindow) {%>target="_blank"<% } %> <% if (isNodeSelected) { %>οnfοcus="showPageAffordance()" <% } %> >
     <portal-fmt:title/>
    </a>
      </td>


  </c-rt:otherwise>
  </c-rt:choose>
     </td>
    </tr>
    </table>
    </td>
    </tr>
</span>
<%-- the list item is closed if the node does not have children or it is not expanded --%>
<c-rt:if test="<%=(!nodeHasChildren || !isExpanded)%>">
 </li>
</c-rt:if>

<%previousNavLevel = currentNavLevel;%> 
</portal-navigation:navigationLoop>
<%-- When no more nodes are left to be processed by the nav loop, it exits but leaves the
  lists and list items open, there is a check to see if there is more than one level, if true,
  the lists and list items are closed.  There is a </ul> tag after the for loop to close the initial
   list that is opened.  This initial <ul> is created when a side nav page is created  --%>
<c-rt:if test="<%=previousNavLevel > 0 %>"><% for(int i = previousNavLevel; i > 1; i--){%></ul></li><%} %></ul></c-rt:if>


</portal-navigation:navigation>
<tr>
 <td valign="top" width=188 height=413  background='<portal-logic:urlFindInTheme file="themeimage/nav3.gif" />'>
  <img src='<portal-logic:urlFindInTheme file="themeimage/bottom.gif" />' border=0  >
 </td>
</tr>
<tr height="100%"><td width=188  background='<portal-logic:urlFindInTheme file="themeimage/nav3.gif" />' ></td></tr>
</table>
</portal-logic:if>

<portal-theme-ext:themeExtension id="com.ibm.portal.theme.plugin.VerticalPageBarItems" >
  <portal-theme-ext:themeExtensionLoop>
   <portal-theme-ext:themeExtensionRenderInclude />
  </portal-theme-ext:themeExtensionLoop>
</portal-theme-ext:themeExtension>       


</c-rt:if>

 

 

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值