Monday, April 11, 2011

Hide or Show LOV Based on LOV RowSet Size

If you were ever wondering, how to show or hide LOV component dynamically, depending if there are values in LOV or if it is empty - I will describe it in this post. Sample application contains Departments LOV VO with View Criteria and Bind Variable to filter based on Manager ID:

LOV is defined for Department ID attribute, it will be rendered as Choice List and displays Department Name:

This LOV is filtered through View Accessor, it provides current Employee ID for filtering. This means, LOV will bring all such departments, where current employee is a manager:

According our requirement, we want to show Department ID attribute, only if associated LOV contains values. This can be achieved by declaring custom method inside View Object Row Implementation class and exposing this method through Client Row Interface into Data Control:

This custom method is not doing anything, except it checking Estimated Row Count for Departments LOV View Accessor. Its how we can check if our Choice List contains any values (if current employee manages any departments):

This method is exposed through Data Control and is accessible from Page Definition:

I would recommend not to call custom Data Control method directly from ADF Rich Faces component, instead create accessor method in managed bean and call it from there through bindings layer:

ADF Rich Faces component should reference bean accessor method for boolean type:

Department ID Choice List is shown for Employee ID = 108, this employee is a manager for Department  = Finance:

Another employee, is not a manager and Department ID Choice List becomes hidden automatically:

Download sample application -


oceans said...


I am trying to create rowSet (Secondary) which should filter out rows that are updated in ViewObject from UI (probably transient attribute updation). I tried to set the quey mode of the viewObject to "ViewObject.QUERY_MODE_SCAN_VIEW_ROWS" and tried executing the query and get the rowSet. But instead of providing the filtered vlaued form the ViewObject, it queries form database and provide me false rowSet as follows,

ViewObject view = this.getEmp1();
RowSet rowSet = view.createRowSet(null); //secondary rowSet


Instead of me getting 2 in the sop I get 107 as result. But I am able to see my updated records in the ViewObject. Is there a way to get out a filtered secondary row set form the updated transient values.


Andrej Baranovskij said...

I'm not sure about use case, but I better would use another VO instance to search.


oceans said...

Hi Andrejus,

Querying another VO instance with RowMatch is fine way to do it. But the challenge how the transient attribute updations done in one view instance will be reflected in another to query them ?


oceans said...

Sorry the UseCase is,

I have a VO where transient attributes are updated. Now I need to query the ViewObject to get a RowSet (Secondary which doesnt affect the UI default RowSet) with a different filter and use them in the backend processing.

Andrej Baranovskij said...

It looks like you need to specify View Criteria for the secondary VO (detail VO), supply Bind Variable values and execute query to get data from DB.