Friday, May 24, 2013

Adding Multiple LOV's to a single ViewObject attribute

There is a requirement like i need to show different LOV(different LOV i mean LOV deriving data from different sources) defined  on one attribute based on the value selected from another attribute.

Requirement :

 Implementation:

I have a VO called SearchPanelVO in which i have 2 attributes called CriteriaAttr and CriteriaVal.
On CriteriaAttr  attribute i have defined a drop down from a static list as shown below :


So based on the value selected from this static list i need to invoke different LOVs defined on CriteriaVal attribute which means if i select "AIT #" i should show AitNameLOV, if i select "App Manager #" i should show AppManagerContactLOV and similarly AppMgmtContactLOV  and so on.

Open the SearchPanelVO , and in order to switch LOVs I defined new transient attribute LovSwitcher.(shown in snapshot below) The value of this attribute is a groovy expression which when evaluated should give proper LOV's name. Then i defined 5 LOVs on CriteriaVal attribute as shown in snapshot below.



 The groovy expression on the value property of the new transient attribute is like :


On the page add partialtrigger on the CriterVal attribute so that it can refresh based on the value selected in CriterAttr drop down.

Next you need to add a small piece of code which will clear the value selected from any LOV on the CriterVal attribute on changing value in CriteriaAttr attribute. Implement a ValueChangeListener on CriteriaAttr attribute which will clear the value from CriteriaVal attribute.

Done !!!

No comments:

Post a Comment