cancel
Showing results for 
Search instead for 
Did you mean: 

Deprecated methods of IPortalComponentProfile leading to ClassCastException

Former Member
0 Kudos

IPortalComponentProfile profile = ((IPortalComponentRequest) getRequest()).getComponentContext().getProfile();

                    Object o = profile.getProperty("myBean");

 

                    if (o == null || !(o instanceof SortBean) || myBean == null) {

                              myBean = new SortBean();

                              profile.setProperty("myBean", myBean.toString());

                              //profile.putValue("myBean", myBean);

                    } else {

 

                              myBean = (SortBean) o;

 

                    }

------------

This code worked fine in EO 7.01. But when we migrated to EP 7.3 then I am getting ClassCastException. Came to know that getValue and putValue of IPortalComponentProfile are deprecated. I suspect this is causing the issue. Can anyone tell me what I can use instead and give me the code if you have.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

See the attached Javadoc link. The documentation instructs you to use relevant methods of IPortalComponentContext.

http://help.sap.com/javadocs/NW73EHP1/SPS07/EP/com/sapportals/portal/prt/component/IPortalComponentP...

Former Member
0 Kudos

Thnx Samuli.

I used it and now it works fine. But I am stuck at one more place. This code also worked fine in EP 7.0 but fails in EP 7.3. I am basically trying to get "com.sap.portal.pcm.Title". I am getting it as null. Below is the complete code I used to get it. The last line which is in bold gives me null value. Can you please tell if anyone of the api used in below code is deprecated? Becoz, this works fine in 7.0 but not in 7.3

------------------

PCDenv = new Hashtable();

                    PCDenv.put(Context.SECURITY_PRINCIPAL, user);

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

PCDenv.put(com.sap.portal.directory.Constants.REQUESTED_ASPECT,PcmConstants.ASPECT_SEMANTICS);

PCDenv.put(com.sap.portal.directory.Constants.REQUESTED_ASPECT,IPcdAttribute.PERSISTENCY_ASPECT);

PCDenv.put(Context.SECURITY_PRINCIPAL, user);

PCDenv.put(com.sap.portal.directory.Constants.REQUESTED_ASPECT, PcmConstants.ASPECT_ADMINISTRATION);

PCDenv.put(IPcdContext.PCD_PERSONALIZATION_PRINCIPAL, user);

initialContext = new InitialContext(env);

dirCtx         = (DirContext) initialContext.lookup(pcd_startFolder + "/");

PcdSearchControls pcdSearchControls = new PcdSearchControls();

pcdSearchControls.setReturningObjFlag(false);

pcdSearchControls.setSearchScope( PcdSearchControls.SUBTREE_ONLY_SCOPE);

NamingEnumeration ne = dirCtx.search("",

"(com.sap.portal.pcd.gl.ObjectClass=com.sapportals.portal.*)", pcdSearchControls);

IPcdSearchResult searchResult = (IPcdSearchResult) ne.nextElement();

searchResult.getAttributes().get("com.sap.portal.pcm.Title");

Former Member
0 Kudos

My guess is you will have to specify the locale when querying the value for attribute com.sap.portal.pcm.Title, see the attached link for details.

http://help.sap.com/saphelp_nw73ehp1/helpdata/en/4a/01fc94aad219cde10000000a42189c/frameset.htm

Answers (0)