Skip to main content

developerWorks >  WebSphere  >  Forums  >  WebSphere Portal  >  developerWorks

Q: How to get page name from theme    Point your RSS reader here for a feed of the latest messages in this thread


Tags for this thread: 

     

 
 

My developerWorks
 Welcome, Guest
Sign in or register
Permlink Replies: 7 - Pages: 1 - Last Post: Nov 12, 2009 3:25 AM Last Post By: JP_Singh
bb2j3z

Posts: 17
Registered: Jun 18, 2007 01:52:28 PM
Q: How to get page name from theme
Posted: Sep 17, 2007 07:55:13 AM
Click to report abuse...   Click to reply to this thread Reply
Can someone tell me how to figure out what portal page name I am on in the theme? I would like to be able to do this outside of the navigation tags. Basically I want to display a customized message based on what portal page you are in using jsp.
MohanR

Posts: 100
Registered: Mar 05, 2006 02:58:02 AM
Re: Q: How to get page name from theme
Posted: Sep 17, 2007 08:37:11 AM   in response to: bb2j3z in response to: bb2j3z's post
Click to report abuse...   Click to reply to this thread Reply
Hi,

You should be able to get the selected node by calling getSelectedNode() on the NavigationSelectionModel. Check the SPI.
getSelectedNode() should return a NavigationNode. Get the ContentNode from the NavigationNode and call getTitle() on it.

Thanks,
Mohan
bb2j3z

Posts: 17
Registered: Jun 18, 2007 01:52:28 PM
Re: Q: How to get page name from theme
Posted: Sep 18, 2007 09:01:36 AM   in response to: MohanR in response to: MohanR's post
Click to report abuse...   Click to reply to this thread Reply
Is there a code sample I can look at? Sorry I am having some problems with the syntax working in the portal page. Been banging my head against it all day.
RuneH

Posts: 258
Registered: Sep 26, 2005 02:46:49 PM
Re: Q: How to get page name from theme
Posted: Sep 18, 2007 09:41:49 AM   in response to: bb2j3z in response to: bb2j3z's post
Click to report abuse...   Click to reply to this thread Reply
Take a look in sideNav.jspf, it might be that the answer to your question is there, at least it should give you the necessary hints...

R.
bb2j3z

Posts: 17
Registered: Jun 18, 2007 01:52:28 PM
Re: Q: How to get page name from theme
Posted: Sep 18, 2007 02:06:38 PM   in response to: MohanR in response to: MohanR's post
Click to report abuse...   Click to reply to this thread Reply
okay stuck on one issue.

boolean isNodeSelected = wpsSelectionModel.isNodeSelected(wpsNavNode);
Object cn = wpsSelectionModel.getSelectedNode();
String pageTitle = cn.getContentNode().getTitle();

is giving me an error.

_Default.java:497: cannot resolve symbol : method getContentNode ()location: class java.lang.Object
String pageTitle = cn.getContentNode().getTitle();

Any ideas?
Michael Harris
Re: Q: How to get page name from theme
Posted: Sep 18, 2007 04:20:08 PM   in response to: bb2j3z in response to: bb2j3z's post
Click to report abuse...   Click to reply to this thread Reply
You have probably figured this out by now... but the error is because
your "cn" object is defined of type "java.lang.Object" and
java.lang.Object does not have a getContentNode() method.

A simpler example to look at would be to examine banner_crumbtrail.jspf.
The only difference is that you don't want to output every node in the
path of selected nodes. You only want the leaf node. So, use the
iterator to locate the last node in the list and that will be the
selected page.
MohanR

Posts: 100
Registered: Mar 05, 2006 02:58:02 AM
Re: Q: How to get page name from theme
Posted: Sep 19, 2007 02:02:15 AM   in response to: Michael Harris in response to: Michael Harris's post
Click to report abuse...   Click to reply to this thread Reply
Even though the Portal 6 themes still seem to be using a deprecated way of
doing this I think it would be simpler to avoid the iteration if you actually use the SPI ( a tag handler, probably )

Context ctx = new InitialContext();
NavigationSelectionModelHome home = (NavigationSelectionModelHome) ctx.lookup("portal:service/model/NavigationSelectionModel");
if (home != null) {
NavigationSelectionModel model =
home.getNavigationModelProvider().getNavigationModel(aRequest, aResponse);

//model.getSelectedNode();

Thanks,
Mohan
JP_Singh

Posts: 1
Registered: Nov 12, 2009 03:24:01 AM
Re: Q: How to get page name from theme
Posted: Nov 12, 2009 03:25:07 AM   in response to: bb2j3z in response to: bb2j3z's post
Click to report abuse...   Click to reply to this thread Reply
To get the Unique Namee, here is the code:

com.ibm.wps.model.ModelUtil util = com.ibm.wps.model.ModelUtil.from((javax.servlet.ServletRequest)request);

com.ibm.portal.navigation.NavigationNode node = (com.ibm.portal.navigation.NavigationNode) util.getNavigationSelectionModel().getSelectedNode();

if(node != null && node.getContentNode() != null &&

node.getContentNode().getObjectID().getUniqueName() != null)
{

pageName= node.getContentNode().getObjectID().getUniqueName().trim();

}

Can anyone tell how to get teh friendly URL ?
 Tags
Help

Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular type of content or application that you're viewing.

My tags shows your tags for this particular type of content or application that you're viewing.

 

MoreLess 


Point your RSS reader here for a feed of the latest messages in all forums