Reading Dynamically Added Attributes from a View Object

You can use the the PDefViewObject::getAttributeDefs2() to read the dynamically added attributes (attributes added by calling ViewObject::addDynamicAttribute or using PDefViewObject )  from  a view object. The relevant code snippet is shown here:

PDefViewObject pDef = (PDefViewObject)((ViewDefImpl) 
 getDepartmentsVO().getDef()).getPersDef();
if (pDef != null) {
 AttributeDef[] attributes = pDef.getAttributeDefs2();
 for (AttributeDef acttrib : attributes) {
  System.out.println(acttrib.getName());
 }
}

Comments

anjana said…
Hi Jobinesh,

Good Post.. Thanks a lot for sharing so much.

I just needed your help with another scenario which I am facing:

I have a master detail relationship between 2 VOs. The parent view object is executed with a bind variable say bParentKey.
Now in the Child VO I need to create a LOV for an attribute for which I need to pass the value in view accessor of the LOV. That value needs to come from an attribute of Parent VO,say Attr1, which I am trying to access using the following groovy expression: ParentVO.Attr1. But this is not working out and I am getting an error stating: "Cannot get property 'Attr1' on null object".

While debugging, I could see that for some reason, the bind parameter of the parent VO is being set as null due to which this issue is coming.

Please give your thoughts on how I can resolve this and implement correctly.

Disclaimer

The views expressed on this blog are my own and do not necessarily reflect the views of my employer.