EMEA A&C CCOE Partner Technology Cloud Engineering

Sample of declarative components in ADF - Confirm Button

Guest Author

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?"
                            <f:facet name="DialogContent">
                                <af:outputText id="ot12"
                                               value="Are you sure to delete employee #{bindings.FirstName.inputValue} #{bindings.LastName.inputValue}?"/>

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

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.