WPS - creating a breadcrumb trail
The following code snippet shows how to render a breadcrumb trail that shows the current selection path.
****************************************************************





<%@ taglib uri="/WEB-INF/tld/portal.tld" prefix="portal" %>

<%@ page import="com.ibm.portal.model.NavigationSelectionModelHome" %>

<%@ page import="com.ibm.portal.model.NavigationSelectionModelProvider" %>

<%@ page import="com.ibm.portal.navigation.NavigationSelectionModel" %>

<%@ page import="com.ibm.portal.navigation.NavigationNode" %>

<%@ page import="com.ibm.portal.ModelException" %>

<%@ page import="java.util.Iterator" %>

<%@ page import="javax.naming.InitialContext" %>

<%@ page import="javax.naming.Context" %>

<%@ page import="javax.naming.NamingException" %>


<%

try{

  Context ctx = new InitialContext();

  NavigationSelectionModelHome home = (NavigationSelectionModelHome)

  ctx.lookup("portal:service/model/NavigationSelectionModel");

  if (home != null) {

    NavigationSelectionModelProvider provider =

    home.getNavigationSelectionModelProvider();

    NavigationSelectionModel model =

    provider.getNavigationSelectionModel(request, response);

    for (java.util.Iterator i = model.iterator(); i.hasNext(); )

    {

      NavigationNode node = (NavigationNode) i.next();

      if (i.hasNext()) {

        %>

        <a href="<portal:navigationUrl type="link" varname="<%=node%>"/>">

        <portal:title varname="<%=node%>"/>

        </a>

        <

        <%

      }

      else

      {

      %>

      <wps:title varname="<%=node%>"/>

      <%

      }

    }

  }

}

catch (ModelException mx) {

%>

< p> < span style="color:#ff0000">A model exception occured</span></p>

<%

}

catch (NamingException nx) {

%>

< p > < span style="color:#ff0000"> A naming exception occured</span></p >

< %

}

%>


****************************************************************

The example uses a JNDI lookup to obtain the navigation selection model. The model is then iterated and for each node a title is produced using the <portal:title/> tag. Until the last node is reached the <portal:navigationUrl/> tag is used to generate links to the referenced pages. The code can be put in
the WebSphere Portal default theme (Default.jsp)


Filed in:
0 Comments To ' WPS - creating a breadcrumb trail '

Post a Comment