Skip to Content
0
Former Member
Nov 28, 2006 at 10:33 AM

Problem in adding attributes to an iView

30 Views

I am facing some problems while working with PCD api.

My requirement is to get an existing iView and add attributes to that. I am using the below code to do this.

My problem is that

1. I am not able to add attributes using obj.addToEnvironment("test",myAttrs);

2. Using IPcdContext obj = (IPcdContext)myPcdContext.lookup(iView_ID); when I do a lookup, I was supposed to get an object of type IiView. But getting IPcdContext.

IUser user = null;

try {

user = WDClientUser.getCurrentUser().getSAPUser();

} catch (WDUMException e) {}

Hashtable env = new Hashtable();

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

env.put(Context.SECURITY_PRINCIPAL, user);

env.put(Constants.REQUESTED_ASPECT, IPcdAttribute.PERSISTENCY_ASPECT);

InitialContext iCtx = null;

try {

iCtx = new InitialContext(env);

// Get the top-level context

IPcdContext myPcdContext = (IPcdContext) iCtx.lookup("");

<b>IPcdContext obj = (IPcdContext)myPcdContext.lookup(iView_ID);</b>

Attribute attr1 = new BasicAttribute("attribute_created_by_figi1","one");

attr1.add("two");

Attribute attr2 = new BasicAttribute("attribute_created_by_figi2","three");

Attributes myAttrs = new BasicAttributes();

myAttrs.put(attr1);

myAttrs.put(attr2);

<b>obj.addToEnvironment("test",myAttrs); </b>

} catch (NamingException e) {

// TODO Auto-generated catch block

e.printstacktrace();

}

Regards

Figi