Monday, June 21, 2010

Changing Rich Components during Runtime in ADF 11g

In ADF sometimes you need to access Rich Components like RichInputDate, RichOutputText, RichShowDetailItem, UIGauge and many more. Not only access, we may need to change some property of those Rich components during runtime. As an example we can frame one requirement like visibility of a component depends on some Condition. More preciously in a report page if we have report layout in table format and that table will be populated using a query if inputs are feed properly to the same.

The Query as follows
SELECT Order_Number, Order_line_number, Order_type, Line_type, creation_date, Quantity, Price, Model_NBR
FROM cci_order_monitor_points
WHERE TRUNC (creation_date) BETWEEN TO_DATE (:frmdate, 'MM/DD/YYYY') AND TO_DATE (:todate, 'MM/DD/YYYY') AND
division = :division AND
destinationsystem = :destination AND
monitor_ref = :ref AND
originatingsystem = :origin

Now in User Interface we need to have

  • one <af:commandLink> or <af:commandButton> for firing event

  • two RichInputDate one for frmdate and another for todate.

  • Other values can be feed using RichInputText or RichSelectOneChoice as per designer choice.

When that Command Button is pressed or Command Link is clicked then its corresponding ActionListener method will execute and this is the place where we can evaluate all validation and check whether right input is feed to that query or not.
So First of all we need to get hold of those Rich components. Select the rich component and go to it's property

Select Binding property and edit its value by clicking the down arrow just beside of that input box.

We can create a new Managed bean or use an existing one ; it will create one Private variable and two methods one for setter and another for getter of the same.
In the method for that Action Listener public void actionListenerImpl(ActionEvent actionEvent) we can refer that property and create our own validation logic.

No comments:

Post a Comment