Search code examples
javaoracle-adf

Overridding the label of "ok" button in <af:dialog> component in ADF


In web layer of my project I am using ADF Faces component.In places I have used ADF popup element nested with dialog.

<af:popup id="myPopup" popupFetchListener="#{.....}">
        <af:dialog contentWidth="400" title="Dialog Title" contentHeight="100" closeIconVisible="true"
                   modal="true" type="okCancel" id="d3" 
                   dialogListener="#{mybean.myDialogListener}">
        </af:dialog>
 </af:popup>

In my backing bean I'm trapping the "ok"/"cancel" event with the help of DialogEvent class.

I want to change the label of framework build "ok" button to some custom label based upon my project requirement.If I add the desired label in message bundle how to reflect that in framework generated button?

Can anyone provide any clue for this?


Solution

  • You have to use the Type, AffirmativeTextAndAccessKey and CancelTextAndAccessKey properties of the dialog element. To have the "ok" display "yes please" :

    <af:popup id="myPopup" popupFetchListener="#{.....}">
        <af:dialog contentWidth="400" title="Dialog Title" contentHeight="100" closeIconVisible="true"
                   modal="true" type="okCancel" id="d3" 
                   dialogListener="#{mybean.myDialogListener}" type="yesNo" affirmativeTextAndAccessKey="yes please">
        </af:dialog>
    

    Note : it will change the type of the response in your dialog listener from

    dialogEvent.Outcome.ok
    

    to

    dialogEvent.Outcome.yes