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 - ChoiceListRendering.zip
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 - ChoiceListRendering.zip
Hi,
ReplyDeleteI 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
rowSet.setNamedWhereClauseParam("BindFirstName","Jenifer");
view.setQueryMode(ViewObject.QUERY_MODE_SCAN_VIEW_ROWS);
rowSet.executeQuery();
System.out.println(rowSet.getEstimatedRowCount());
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.
Regards,
Vijai
I'm not sure about use case, but I better would use another VO instance to search.
ReplyDeleteAndrejus
Hi Andrejus,
ReplyDeleteQuerying 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 ?
Regards,
Vijai
Sorry the UseCase is,
ReplyDeleteI 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.
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.
ReplyDeleteAndrejus