on 07-19-2007 9:15 PM
Hi,
How Can I use byEPCM instead of byURL in a <a href></a> statement.
Richard
Richard,
I have already tried this, its worked with me.....
here is the code..
package com.sap;
import java.util.Hashtable;
import java.util.Iterator;
import javax.naming.NamingException;
import com.sapportals.htmlb.Link;
import com.sapportals.htmlb.TreeNode;
import com.sapportals.htmlb.page.DynPage;
import com.sapportals.htmlb.page.PageException;
import com.sapportals.portal.htmlb.page.JSPDynPage;
import com.sapportals.portal.htmlb.page.PageProcessorComponent;
import com.sapportals.portal.navigation.INavigationConstants;
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.runtime.PortalRuntime;
import com.sapportals.portal.prt.session.IUserContext;
public class Navigation extends PageProcessorComponent {
public DynPage getPage() {
return new NavigationDynPage();
}
public class NavigationDynPage extends JSPDynPage {
private NavigationBean treeBean;
public void doInitialization() throws PageException {
}
public void doProcessAfterInput() throws PageException {
}
public void doProcessBeforeOutput() throws PageException {
try {
IPortalComponentRequest request = (IPortalComponentRequest) this.getRequest();
treeBean = new NavigationBean();
TreeNode navigation = createNavigationTree(request);
treeBean.setOutput("Navigation Component Example");
treeBean.setTree(navigation);
request.getServletRequest().setAttribute("navigationBean", treeBean);
this.setJspName("Navigation.jsp");
} catch (NamingException e) {
throw new PageException(e);
}
}
private TreeNode createNavigationTree(IPortalComponentRequest request) throws NamingException {
TreeNode rootNode = new TreeNode("rootNode", "Navigation Tree");
rootNode.setTooltip("Click the tree node to expand/collapse it.");
INavigationService navigationService = (INavigationService) PortalRuntime.getRuntimeResources().getService(INavigationService.KEY);
NavigationNodes initialNodes = navigationService.getInitialNodes(getEnvironment(request));
Iterator initialIterator = initialNodes.iterator();
recursivelyAddChildrenToParentNode(initialIterator, request, rootNode, 0);
return rootNode;
}
private Hashtable getEnvironment(IPortalComponentRequest request) {
Hashtable environment = new Hashtable();
IUserContext userContext = request.getUser();
environment.put(INavigationConstants.ENV_PRINCIPAL, userContext);
return environment;
}
private int recursivelyAddChildrenToParentNode(Iterator navigationNodeIterator, IPortalComponentRequest request, TreeNode parentTreeNode, int nodeCount) throws NamingException {
while (navigationNodeIterator.hasNext()) {
Hashtable environment = new Hashtable();
TreeNode childTree;
INavigationNode initialNode = (INavigationNode) navigationNodeIterator.next();
childTree = new TreeNode(Integer.toString(nodeCount++));
childTree.setOpen(true);
createTreeEntry(request, childTree, initialNode, nodeCount);
parentTreeNode.addChildNode(childTree);
INavigationNode childNode = (INavigationNode) initialNode.getChildren(environment);
Iterator childIterator = (Iterator) childNode.getChildren(environment);
nodeCount = recursivelyAddChildrenToParentNode(childIterator, request, childTree, nodeCount);
}
return nodeCount;
}
private void createTreeEntry(IPortalComponentRequest request, TreeNode treeNode, INavigationNode node, int nodeCount) {
String title = node.getTitle(request.getLocale());
Link l = new Link("LINK_" + nodeCount, title);
String navigationAction = "EPCM.doNavigate('" + node.getName() + "',2)";
l.setOnClientClick(navigationAction);
treeNode.setComponent(l);
}
}
}
JagadishBabu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.