Sample of declarative components in ADF - Confirm Button

Oracle Application Development FrameworkVery often we need to provide the same functionality in various places in our ADF application.Quite common example could be a confirmation dialog which needs to be displayed after pressing some buttons (e.g. for deleting rows in a table). Of course most of us know the recipe for that: af:button + af:popup + af:showPopupBehavior + backing bean method. In order to simplify our lives it would be nice to wrap those pieces in something which we could simply drop on the page once and configure only the necessary parts. That's the use case for ADF Declarative Components feature.

I have created a simple example (using the latest and greatest ADF 12c) of how to use declarative components to provide a new composite button with confirmation dialog. You can find the source code here. Because declarative components create their own tag libraries it is necessary to define them in a separate workspace and deploy in a form of ADF library. The provided sample consist of two workspaces: MyComponents (with the definition of declarative component packaged as an ADF Library) and MyApplication (with the consuming page). The ConfirmButton component is an extremely simplified version of af:button - it has only three properties and one method which you need to define in the consuming page:

  • DialogContent: a facet you can use to place whatever content you want to be displayed inside the confirmation dialog (e.g. output text with a message)
  • ButtonText: an attribute defining the text on the button
  • ConfirmationMessage: a title for the dialog
  • onDialogReturn: a method with a signature of DialogListener to be invoked after the dialog is dismissed.

All you need to do to use this sample library is to import the ADF Library jar into your ViewController project. Once you do it you will find an additional panel (MyComponents) in the Component Palette:

and a lonely ConfirmButton component inside:

You just need to drop it onto the page and define necessary properties:


                    <af:toolbar id="t2">

                        <mycomps:ConfirmButton id="cb1" ButtonText="Delete" ConfirmationMessage="Are you sure?"
onDialogReturn="#{backingBeanScope.emps_bb.onDelete}">
                            <f:facet name="DialogContent">
                                <af:outputText id="ot12"
                                               value="Are you sure to delete employee #{bindings.FirstName.inputValue} #{bindings.LastName.inputValue}?"/>
                            </f:facet>
                        </mycomps:ConfirmButton>
                    </af:toolbar>


If you want learn more about the declarative components feature I recommend reading the documentation as well as searching for other blog posts, there are plenty of them. Some examples below:

Fun with Declarative Components

Custom Declarative Components in ADF Faces Rich Client

Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
About

Oracle ECEMEA Partner Hubs Migration Center Team

We share our skills to maximize your revenue!
Our dedicated team of consultants can rapidly and successfully assist you to adopt and implement the latest of Oracle Technology in your solutions.

Stay Connected
partner.imc
@
beehiveonline.oracle-DOT-com
Google+

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
2
3
4
5
6
9
10
11
12
13
14
16
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today