Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Issue with Portal Sitemap

Hi All,

package com.drl;

import java.util.Hashtable;

import java.util.Iterator;

import java.util.Locale;

import com.sapportals.htmlb.Form;

import com.sapportals.htmlb.GridLayout;

import com.sapportals.htmlb.GridLayoutCell;

import com.sapportals.htmlb.Group;

import com.sapportals.htmlb.Tree;

import com.sapportals.htmlb.TreeNode;

import com.sapportals.htmlb.enum.CellVAlign;

import com.sapportals.htmlb.enum.GroupDesign;

import com.sapportals.htmlb.page.DynPage;

import com.sapportals.htmlb.page.PageException;

import com.sapportals.portal.htmlb.page.PageProcessorComponent;

import com.sapportals.portal.navigation.INavigationNode;

import com.sapportals.portal.navigation.INavigationService;

import com.sapportals.portal.navigation.NavigationNodes;

import com.sapportals.portal.prt.component.IPortalComponentRequest;

import com.sapportals.portal.prt.component.IPortalComponentResponse;

import com.sapportals.portal.prt.runtime.PortalRuntime;

import com.sapportals.portal.prt.session.IUserContext;

public class drlSiteMap extends PageProcessorComponent {

public DynPage getPage() {

return new drlSiteMapDynPage();

}

public static class drlSiteMapDynPage extends DynPage {

/**

  • Initialization code executed once per user.

*/

public void doInitialization() {

}

/**

  • Input handling code. In general called the first time with the second page request from the user.

*/

public void doProcessAfterInput() throws PageException {

}

/**

  • Create output. Called once per request.

*/

public void doProcessBeforeOutput() throws PageException {

Form myForm = this.getForm(); // get the form from DynPage

Group group = new Group();

group.setDesign(GroupDesign.SAPCOLOR);

group.setTitle("Site Map");

myForm.addComponent(group);

GridLayout gl = new GridLayout();

gl.setWidth("100%");

group.addComponent(gl);

IPortalComponentRequest request = (IPortalComponentRequest) this.getRequest();

IPortalComponentResponse response = (IPortalComponentResponse) this.getResponse();

try {

NavigationNodes rootNodes = getNavNodes(request);

int i = 1;

for(Iterator it = rootNodes.iterator(); it.hasNext();){

INavigationNode rootNode = (INavigationNode)it.next();

String title = rootNode.getTitle(Locale.ENGLISH);

Tree tree = new Tree(title, "");

tree.setRootNodeIsVisible(true);

GridLayoutCell cell = new GridLayoutCell(rootNode.getName());

String text = "<a href=\"" + "/irj/portal?NavigationTarget=" + rootNode.getName() + "\" style=\"BORDER-RIGHT: #676e75 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: #676e75 1px solid; PADDING-LEFT: 5px; FONT-WEIGHT: normal; FONT-SIZE: 1.0em; PADDING-BOTTOM: 0px; BORDER-LEFT: #676e75 1px solid; CURSOR: hand; COLOR: #000; PADDING-TOP: 0px; BORDER-BOTTOM: #676e75 1px solid; WHITE-SPACE: nowrap; HEIGHT: 14px; TEXT-ALIGN: center; TEXT-DECORATION:none;BACKGROUND-COLOR: #faeeb1\" >" + title + "</a>";

TreeNode root = new TreeNode(rootNode.getName(), text);

root.setEncode(false);

root.setOpen(true);

tree.setRootNode(root);

getRestofNodes(rootNode,root);

cell.setVAlignment(CellVAlign.TOP);

cell.setContent(tree);

gl.addCell(1, i, cell);

i = i + 1;

}

} catch (Exception e) {}

}

public Hashtable getEnvironment(IPortalComponentRequest request) {

Hashtable environment = new Hashtable();

IUserContext userContext = request.getUser();

if (userContext != null) {

environment.put("NavigationPrincipal", userContext);

String user = userContext.getUniqueName();

if (user != null && !user.equals("")) {

environment.put("User", user);

}

}

return environment;

}

private NavigationNodes getNavNodes(IPortalComponentRequest request) {

INavigationService service = (INavigationService) PortalRuntime.getRuntimeResources().getService(INavigationService.KEY);

NavigationNodes initialNodes = null;

try {

initialNodes = service.getInitialNodes(getEnvironment(request));

} catch (Exception ne) {

ne.printStackTrace();

}

return initialNodes;

}

private void getRestofNodes(INavigationNode rootnode, TreeNode parent) throws Exception {

NavigationNodes childrenNodes = rootnode.getChildren();

for(Iterator it = childrenNodes.iterator(); it.hasNext();){

INavigationNode newNode = (INavigationNode)it.next();

String text = "<a class=urLnk href=\"" + "/irj/portal?NavigationTarget=" + newNode.getName() + "\">" + newNode.getTitle(Locale.ENGLISH) + "</a>";

TreeNode newTreeNode = new TreeNode(newNode.getName(), text,parent);

newTreeNode.setOpen(true);

getRestofNodes(newNode, newTreeNode);

}

}

}

}

portalapp.xml

<?xml version="1.0" encoding="UTF-8"?>

<application>

<application-config>

<property name="PrivateSharingReference" value="com.sap.portal.htmlb"/>

<property name="SharingReference" value="com.sap.portal.navigation.service"/>

</application-config>

<components>

<component name="drlSiteMap">

<component-config>

<property name="ClassName" value="com.drl.drlSiteMap"/>

<property name="SecurityZone" value="com.ust.sitemap/high_safety"/>

</component-config>

<component-profile/>

</component>

</components>

<services/>

</application>

Former Member
Not what you were looking for? View more on this topic or Ask a question