cancel
Showing results for 
Search instead for 
Did you mean: 

Getting the page name(title) of an Iview..

Former Member
0 Kudos

How to read the name of a page of an iview currently executing?

I have IviewA assigned to pageA. I need to display name of PageA in IviewA and if i assign the same IviewA on PageB then IviewA shud display name of PageB.(Meaning, Iview shud read itz assigned Page name and display page name accordingly)

Got some code logic from Detlev and prakash!

Iam able to pass iview's pcd path and display itz title but how to get it name of the page to which this iview has been assigned?

<b>Detlev's code:</b>public static Object getPCDObject(IPortalComponentRequest req, String pcdURL) throws NamingException {

IPcmObjectService pcdFactory =

(IPcmObjectService) PortalRuntime.getRuntimeResources().getService(IPcmObjectService.KEY);

Hashtable env = new Hashtable();

env.put(Context.INITIAL_CONTEXT_FACTORY, IPcdContext.PCD_INITIAL_CONTEXT_FACTORY);

env.put(Context.SECURITY_PRINCIPAL, req.getUser());

IPcmObjectBuilder pcmSrv = pcdFactory.getInitialContext(env);

try {

Object o = pcmSrv.lookup(pcdURL);

return o;

} catch (NamingException e) {

throw e;

}

}

<b>Prakash's code:</b>

public InitialContext getEnvironment(IPortalComponentRequest request) {

InitialContext initialContext = null;

try{

IUser principalObj = null;

principalObj = this.getServiceUser("pcd_service");

Hashtable env = new Hashtable();

env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sapportals.portal.pcd.gl.PcdInitialContextFactory");

if(principalObj!=null){

env.put(Context.SECURITY_PRINCIPAL,principalObj);

}

env.put("com.sap.portal.jndi.requested_aspect","com.sap.portal.pcd.gl.PersistencyAspect");

env.put("java.naming.factory.object","_IPcdContext_");

initialContext = new InitialContext(env);

}catch(NamingException e){

}

return initialContext;

}

public IUser getServiceUser(String username) {

IUser serviceUser = null;

IUserManagementEngine ume =

(IUserManagementEngine)PortalRuntime

.getRuntimeResources()

.getService(IUserManagementEngine.KEY);

IServiceUserFactory sufactory = ume.getServiceUserFactory();

try {

serviceUser = sufactory.getServiceUser(username);

} catch (UMException e) {

e.printStackTrace();

}

return serviceUser;

}

public void readTitle()throws PageException{

try {

String iviewPath = request.getNode().getNodeName();

Context initialContext = getEnvironment(request);

IPcdContext targetObject = (IPcdContext)initialContext.lookup(iviewPath);

Object object = targetObject.getAttributes("").get("com.sap.portal.pcm.Title");

if(object instanceof IPcdAttribute){

IPcdAttribute att = (IPcdAttribute)object;

objtitle = att.get(request.getLocale());

}

} catch (NamingException e) {

e.printStackTrace();

}

response.write("Name:" + objtitle);

}

Thanks,

Accepted Solutions (1)

Accepted Solutions (1)

detlev_beutner
Active Contributor
0 Kudos

Hi Explorer,

two possibilities:

Use NavigationEventsHelperService, this at least works for embedded iView and you'll directly get the page information. If you need more details, use the path found to lookup the corresponding object within the PCD. See and/or search on SDN for the term "NavigationEventsHelperService".

Or if you got the iView in the PCD already, just climb the path one level up, that's the page (if you have set the iView into a page).

Hope it helps

Detlev

PS: If my answer in helped... please consider rewarding points there...

Former Member
0 Kudos

>Or if you got the iView in the PCD already, just climb >the path one level up, that's the page (if you have set >the iView into a page).

Could you please explain more here...

I tried the javascript from the first post in your reply..it didn't work...duno y!

Could you please look into this post and tweak to get the page the iview is running @

<b>

Could you plz send me the com.sap.portal.navigation.helperserviceapi.jar if u have.</b>

Thanks Detlev!

detlev_beutner
Active Contributor
0 Kudos

Hi Explorer,

first, I really appreciate if my time is appreciated when I try to help others. So: Thanks for rewarding points. But at the same time: I have asked you if my answer in the thread referred to was of help, and I would appreciate some reaction...

> Could you plz send me the

> com.sap.portal.navigation.helperserviceapi.jar

I have answered in a third thread by yours where it is to be found as well as gave some additional remarks on such an issue.

> Could you please explain more here...

If your iView has the PCD patch portal_content/a/b/c/role/workset/page/iview, and if you got this string (or with some prefix like "pcd:"), just cut from the last slash on to get the page, which would be portal_content/a/b/c/role/workset/page in the example given. Now lookup the corresponding object within the PCD, and you're done.

> I tried the javascript from the first post in your reply

I also thought of the latter server side coding...

> Could you please look into this post and tweak

If you use NavEventsHelperServ, use getCurrentNavNode(request) plus one time getParentNode() on the node retrieved, as indicated by Daniel's last posting.

Hope it helps

Detlev

Former Member
0 Kudos

Detlev,

Thanks a lot for your time..Really Appreciate your continous help on SDN!

The other Thread referred was the source..so itz not simply a helper thread!! Thanks!

your reply now, did solve my problem if i cut the url path to page id and pass it to JNDI lookup, but it doesn't seem to be generic. wat you think here?

Iam unable to get the other way using NavEventsHelperServ working.

Iam getting runtime errors if i use this..do i need to put something in the portalapp.xml other than com.sap.portal.pcd.glservice?

Can you also explain when and what type of classes do we need to mention for PrivateSharingReferece type in portalapp.xml?

Thanks a bunch!

detlev_beutner
Active Contributor
0 Kudos

Hi Explorer,

===> ===> Please check if it was helpful! (It's a totally other thread)

Ok, I hope you'll get it sometimes...

Back to your "problem of the day":

> but it doesn't seem to be generic. wat you think here

It is "more or less", but it's not "the API way", which the NavEvHelperServ provides.

> do i need to put something in the portalapp.xml other

> than com.sap.portal.pcd.glservice

Of course. In general:

If you habe some JAR used which is part of usrsap<ID><INST>j2eecluster<NODE>appssap.comirjservlet_jspirj ootWEB-INFportalportalapps<SOME_PORTAL_APPlib<SOME_LIB>.jar, then you need to put a SharingReference to <SOME_PORTAL_LIB>.

Each portal app has it's own classloader (exactly: two, one public, and one private). To get access to the public classloader, i.e. to inlcude it into your own app, you must set the SharingReference to that app.

Hope it helps

Detlev

Answers (0)