Top-Level Navigation iView

The following creates a one- or two-level top-level navigation iView, depending on the value in the NumOfDisplayLevels property of the navigation iView portal component. The page does the following:

  • Iterates through the initial nodes.

  • Saves the node that is selected.

  • After iterating through all the initial nodes, recalls the selected node and iterates through its children.

<%@ page import = "com.sapportals.portal.navigation.*" %>
<%@ page import = "com.sapportals.portal.prt.resource.IResource" %>
<%@ page import = "com.sapportals.portal.prt.runtime.PortalRuntime" %>
<%@ page import = "com.sapportals.portal.navigation.INavigationGenerator"%>
<%@ page import = "com.sapportals.portal.prt.component.IPortalComponentRequest" %>

<%@ taglib uri="NavigationTagLibrary" prefix="nav" %>

<%
INavigationGenerator service =
  (INavigationGenerator)PortalRuntime.getRuntimeResources().getService(
  INavigationService.KEY);

IPortalComponentRequest currentRequest =
  (IPortalComponentRequest)pageContext.getAttribute(
  javax.servlet.jsp.PageContext.REQUEST);

IPortalComponentResponse currentResponse =
  (IPortalComponentResponse)pageContext.getAttribute(
  javax.servlet.jsp.PageContext.RESPONSE);

IPortalComponentContext componentContext =
   currentRequest.getComponentContext();

IPortalComponentProfile profile = componentContext.getProfile();

boolean previewMode = false;
String mode = (String)componentRequest.getNode().getValue("mode");
if(mode!=null && mode.equals("preview")) {
  previewMode = true;
}

String strLevels = profile.getProperty("NumOfDisplayLevels");
int levels = 2;
try {
  levels = Integer.parseInt(strLevels);
} catch(NumberFormatException e) {
}

if(levels<0 || levels>2) {
  levels = 2;
}
if(levels>0) { %>

<TABLE border="0" cellspacing="0" cellpadding="0" class="mainTable">
  <TR>
  <TD nowrap class="notch">&nbsp;</TD>
  <TD>
  <TABLE border="0" cellspacing="0" cellpadding="0" class="table1">
  <TR>

   <!-- Iterate initial nodes -->
  <nav:iterateInitialNavNodes>
  <nav:ifNavNodeInSelectedPath>
  <TD nowrap class="chosenTDLevel1">
  <% if(previewMode) { %>
  <A class="chosenOnLevel1"><nav:navNodeTitle/></A>
  <% } else { %>
  <nav:navNodeAnchor navigationMethod="byURL"
   anchorAttributes="class='chosenOnLevel1'"/>
  <% } %>
  </TD>
  <% if(levels==2) { %>
     <!-- Save selected node -->
  <nav:storeNavNode/>
  <% } %>
  </nav:ifNavNodeInSelectedPath>
  <nav:ifNotNavNodeInSelectedPath>
  <TD nowrap class="unChosenTDLevel1">
   <% if(previewMode) { %>
  <A class="chosenOnLevel1"><nav:navNodeTitle/></A>
  <% } else { %>
  <nav:navNodeAnchor navigationMethod="byURL"
   anchorAttributes="class='unChosenOnLevel1'"/>
  <% } %>
  </TD>
  </nav:ifNotNavNodeInSelectedPath>
  </nav:iterateInitialNavNodes>
  <TD nowrap class="spacingTDLevel1">&nbsp;</TD>
  </TR>
  </TABLE>
  <TABLE border="0" cellspacing="0" cellpadding="0" class="table2">
  <TR>

   <!—Recall initial selected node and iterate children -->
  <nav:recallNavNode>
  <nav:iterateNavNodeChildren>
  <nav:ifNavNodeInSelectedPath>
  <TD nowrap class="chosenTDLevel2">
  <% if(previewMode) { %>
  <A class="chosenOnLevel2"><nav:navNodeTitle/></A>
  <% } else { %>
  <nav:navNodeAnchor navigationMethod="byURL"
   anchorAttributes="class='chosenOnLevel2'"/>
  <% } %>
  </TD>
  </nav:ifNavNodeInSelectedPath>
  <nav:ifNotNavNodeInSelectedPath>
  <TD nowrap class="unChosenTDLevel2">
  <% if(previewMode) { %>
  <A class="unChosenOnLevel2"><nav:navNodeTitle/></A>
  <% } else { %>
  <nav:navNodeAnchor navigationMethod="byURL"
   anchorAttributes="class='unChosenOnLevel2'"/>
  <% } %>
  </TD>
  </nav:ifNotNavNodeInSelectedPath>
  <nav:ifHasMoreIterations>
  <TD nowrap class="spacingTDPipeLevel2"> | </TD>
  </nav:ifHasMoreIterations>
  </nav:iterateNavNodeChildren>
  <TD nowrap class="spacingTDLevel2">&nbsp;</TD>
  </nav:recallNavNode>
  </TR>
  </TABLE>
  </TD>
  </TR>
</TABLE>

<% } %>