Skip to Content
0
Former Member
Oct 16, 2006 at 09:00 AM

Null value in Propery

24 Views

I want to access a property from KM content. But getting null value. Following is my code.

//my java file

package Test1;

import com.sapportals.htmlb.page.DynPage;

import com.sapportals.htmlb.page.PageException;

import com.sapportals.portal.htmlb.page.JSPDynPage;

import com.sapportals.portal.htmlb.page.PageProcessorComponent;

import com.sapportals.portal.prt.component.IPortalComponentRequest;

import com.sapportals.portal.security.usermanagement.IUser;

import com.sapportals.wcm.repository.IProperty;

import com.sapportals.wcm.repository.IPropertyName;

import com.sapportals.wcm.repository.IResource;

import com.sapportals.wcm.repository.PropertyName;

import com.sapportals.wcm.repository.ResourceContext;

import com.sapportals.wcm.repository.ResourceFactory;

import com.sapportals.wcm.util.uri.RID;

import com.sapportals.wcm.util.usermanagement.WPUMFactory;

public class Test1 extends PageProcessorComponent {

public DynPage getPage(){

return new Test1DynPage();

}

public static class Test1DynPage extends JSPDynPage{

public void doInitialization(){

}

public void doProcessAfterInput() throws PageException {

}

public void doProcessBeforeOutput(){

final String OriginProp = "Country";

final String CREATED_BY_PROP_PREFIX ="http://sapportals.com/xmlns/cm/";

try{

IPortalComponentRequest request =

(IPortalComponentRequest) this.getRequest();

IUser user = WPUMFactory.getUserFactory().getEP5User(request.getUser());

ResourceContext ctxt = new ResourceContext(user);

RID rid = RID.getRID("/documents");

IResource res =ResourceFactory.getInstance().getResource(rid, ctxt);

IPropertyName propName =new PropertyName(CREATED_BY_PROP_PREFIX,OriginProp);

IProperty p = res.getProperty(propName);

request.getComponentSession().putValue("key1","property : " + p);

}

catch (Exception e) {

e.printStackTrace();

}

setJspName("Test1.jsp");

}

}

}

//jsp file

<%@ page language="java" %>

<%@ page import="java.util.*"%>

<%@ page import="javax.servlet.http.*"%>

<%@ page import="com.sapportals.htmlb.*" %>

<%@ page import="javax.servlet.jsp.*" %>

<%@ page import ="com.sapportals.portal.prt.component.*"%>

<%

IPortalComponentRequest currentRequest =(IPortalComponentRequest)pageContext.getAttribute(javax.servlet.jsp.PageContext.REQUEST);

String text1=currentRequest.getComponentSession().getValue("key1").toString();

%>

<%=text1%>

//portal xml file

<?xml version="1.0" encoding="utf-8"?>

<application>

<application-config>

<property name="PrivateSharingReference" value="com.sap.portal.htmlb,com.sap.km.application"/>

</application-config>

<components>

<component name="Test1">

<component-config>

<property name="ClassName" value="Test1.Test1"/>

</component-config>

<component-profile/>

</component>

</components>

<services/>

</application>

I getting property= null

Please tell me solution.