Skip to Content
author's profile photo Former Member
Former Member

Accessing profiles of other components

Hi,

Is there any way of accessing the profile of another component from a component? The two components are in the same namespace.

rgds

kiran

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Sep 30, 2005 at 04:00 PM

    This is how you do it,

    Give the component's path (including pcd..) of the component whose profile u need to access..like this:

    IPortalComponentContext context = request.getComponentContext("pcd:/portal_content/xxxx/iview");

    IPortalComponentProfile profile = context.getProfile();

    String thisColor = profile.getProperty("color");

    Let me know if u need more.

    Regards,

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      (Or) Try this:

      <b>iviewPath</b>: if u can pass the iviewpath dynamically using EPCM bag or cookies to this application then u cud find the title.

      try {
      		   Context initialContext = getEnvironment(request);
      		   IPcdContext targetObject = (IPcdContext)initialContext.lookup(<b>iviewPath</b>);
      		
      			Object object = targetObject.getAttributes("").get("com.sap.portal.pcm.Title");
      			//Object object1 = targetObject.getAttributes("").get("com.sap.portal.pcm.Description");
      			if(object instanceof IPcdAttribute){
      				IPcdAttribute att = (IPcdAttribute)object;
      				objtitle = att.get(request.getLocale());
      			}
      		/*	
      			if(object1 instanceof IPcdAttribute){
      				IPcdAttribute att = (IPcdAttribute)object1;
      				objdesc = att.get(request.getLocale());
      			}
              */
      			
      	   } catch (NamingException e) {
      			   e.printStackTrace();
      	   } 
      }
      
      	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;
      		}

      <b>PS: Please award points for helpful answers</b>

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.