on 05-23-2011 9:34 AM
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>
answered
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi All,
I had an issue with Site map we need to change look and feel and this application every time calling Long URL, but it has to cal short URL can anybody help on this issue.
I didnt have any issue with application wise it's working fine.
The above code is entire code for Sitemap , which is using in my application
Here I am giving xml code also
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>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Robin,
Thanks for your reply , Can you explain bit detail, Where I need to mention getHashedname()
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);
}
}
}
}
Hi Robin
I put that Method in below code
String text = "<a href=\"" + "/irj/portal?NavigationTarget=" + rootNode.getHashedName() + "\" 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>";
But still when I am clicking first time the Sitemap its calling long url , after that if I click on the internal contents its calling Short Url , but here the thing is The sitemap starting onwards it has to cal shore Url.
http://epsdcs1s.mydrreddys.com:51100/irj/portal?NavigationTarget=ROLES://portal_content/Dr_Reddys/Company/Roles/PCON_Role_Company/Company/Enabling_You_2
Hi All,
I had one query rearding Masthead & Sitemap
We had Sitemap application , we need to link this Sitemap application to Masthead so we put it one image in Masthead Par file,
And we link up with this Site Map application , already we deployed Sitemap par file and we created one iview in portal
The problem is : when we are click on that image its opening fine but it has to come with MastHead and Toplevel
Already I posted Sitemap code as above
Here I am Giving Masthead Par file code which is related to Sitemap.
Headeriview.jsp
<%
String SiteMap = profile.getProperty("SiteMapURL");
%>
<td valign="top">
<a href="<%=SiteMap%>"><img title="SiteMap" src="/irj/portalapps/com.drl.masthead/images/DRL/sitemap.jpg" border="0"/></a> </td>
portalappa.xml
<property name="SiteMapURL" value="/irj/servlet/prt/portal/prtmode/preview/prtroot/pcd!3aportal_content!2fdrl_portal!2fiviews!2fcom.drl.sitemap?sap-config-mode=true">
<property name="category" value="Custom"/>
</property>
what ever I provided the Url ,I get it from Iview preview
Can any body suggest on this
Thanks
Renu
Hi,
From the URL, it seems you are 1) using the preview URL and 2) you are previewing the iView, not a page.
You should create a page containing the sitemap iView, and use the link to that page (make sure Everyone has access to that page) with an URL in the format
/irj/portal?NavigationTarget=pcd:portal_content/<pcd path of page>
Cheers,
Robin
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.