24 Generic Toolbar Component 169163
24 Generic Toolbar Component 169163
Abstract:
twitter.com/adfcodecorner
Oracle ADF Code Corner is a loose blog-style series of how-to documents that provide solutions
to real world coding problems.
Disclaimer: All samples are provided as is with no guarantee for future upgrades or error
correction. No support can be given through Oracle customer support.
Please post questions or report problems related to the samples in this series on the OTN forum
for Oracle JDeveloper: http://forums.oracle.com/forums/forum.jspa?forumID=83
Introduction
When building an ADF application you will no doubt come across specific cases where a
component and functionality could be reused throughout the application. For example, you might
decide data pages should have a specific toolbar so that navigation through your data is
presented and handled in a specific way. Obviously, each instance of the toolbar would be
working on a different data set and so the goal is to create a reusable toolbar that can be
parameterised to that it works with different data sets when it it used
2
How-to build a reusable toolbar with Oracle ADF
ADF CODE CORNER Declarative Components
You can optionally define an Attribute (by clicking on the Attributes tab) with the name DataSet of type
string. This will be used to optionally add a suffix to each button label (so the label could be Next Emp or
it could be Next Dept with Emp and Dept being parameters supplied in the toolbar instance)
Click OK and you can now design the declarative component as you would with any ADF Faces Page.
3
How-to build a reusable toolbar with Oracle ADF
ADF CODE CORNER Declarative Components
The next step is to hook up the method parameters to the specific attributes to which you want them
associated. So, in the case of toolbar buttons, this is the ActionListener attribute. Do do this, select the
button, and in the property palette go to ActionListener and click on the down arrow to the right and
bring up the expression/method builder. Then under JSP Objects -> Components you will find the
method parameters defined earlier. Hook up each button to the appropriate parameter.
4
How-to build a reusable toolbar with Oracle ADF
ADF CODE CORNER Declarative Components
You can optionally define the Text property as [a string] JSP Objects -> attrs ->DataSet which is the
string parameter you set up earlier.
5
How-to build a reusable toolbar with Oracle ADF
ADF CODE CORNER Declarative Components
You are now able to start designing your new page. Build your page as you normally would (we'll assume
an instance of a Dept table with the generic toolbar) and on the component palette you will now see a
new library which includes you toolbar component.
6
How-to build a reusable toolbar with Oracle ADF
ADF CODE CORNER Declarative Components
The next step is to hook up the parameters of your toolbar so that they navigate through the Dept table.
To do this you must first create the bindings. Right click on the page you are designing and select Go to
Page Definition. On this page click the green plus sign on Bindings and create an actionBinding. You
then select data collection/iterator and the appropriate operation. You should create action bindings for
first, last, next and previous.
The final step is to hook those bindings to the method parameters of the declarative component. Select
the toolbar component in the visual editor and in the property inspector you will see the method and
attribute parameters you set up when you created the component. Select each of these and using
expression language, assign to the appropriate bindings.
7
How-to build a reusable toolbar with Oracle ADF
ADF CODE CORNER Declarative Components
With the bindings now assigned to your declarative component you can now run the page and navigate
your data set using the generic toolbar.
RELATED DOCOMENTATION