Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Inline af:message in a dialog popup of the page fragment (BTF)

rade.todorovichSep 3 2015 — edited Sep 4 2015

JDeveloper 12.1.3

Big picture: I am trying to implement complex form validation. The input form in question contains several input texts, select one choices and date inputs. It is also inside the popup dialog, and to makes things fun, this is all in one jsff page fragment (BTF) part of the global jsf page. My goal is to show inline message of a certain component if the validation fails and prevent closing the dialog popup. In the course of troubleshooting unwanted behavior, I found this example from Frank: https://blogs.oracle.com/jdevotnharvest/entry/strategies_for_controlling_the_af

Basically popup dialog will NOT close if an af:message shows a message. Frank's example works fine when button and popup are on the main jsf page. But what if all is inside the page fragment? So I modified Frank's example a bit:

1. I built test BTF with jsff page fragment, placed button and popup dialog. I further simplified Frank's code just to make sure that whenever user clicks 'ok' it will show the inline message.

<?xml version='1.0' encoding='UTF-8'?>

<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:af="http://xmlns.oracle.com/adf/faces/rich">

\<af:panelGroupLayout id="pgl1">

    \<af:button text="Open Popup (in fragment)" id="cb1">

        \<af:showPopupBehavior popupId="p5"/>

    \</af:button>

    \<af:popup id="p5" contentDelivery="lazyUncached">

        \<af:dialog id="d5" title="whatever" dialogListener="#{backingBeanScope.backing\_test.testme}">

            \<af:panelGroupLayout id="pgl5" layout="vertical">

                \<af:inputText label="whatever" id="it555"/>

                \<af:message id="m5" for="it555"/>

                \<!--af:message id="m5" for="0:it555"/-->

            \</af:panelGroupLayout>

        \</af:dialog>

    \</af:popup>

\</af:panelGroupLayout>

</ui:composition>

then in the backing bean (tested with both backing request scopes):

public class Test {

public void testme(DialogEvent dialogEvent) {

    if(dialogEvent.getOutcome().name().equals("ok")){

            FacesContext fctx = FacesContext.getCurrentInstance();

            FacesMessage fm = new FacesMessage(FacesMessage.SEVERITY\_ERROR,"Validation Failed", "I am not letting you out of here");

            fctx.addMessage("it555", fm);

    }

}

}

2. I modified and simplified the main jsf page code from Frank's example just to make SURE it is identical for both cases (jsf and jsff fragment)

<?xml version='1.0' encoding='UTF-8'?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<f:view xmlns:f="http://java.sun.com/jsf/core" xmlns:af="http://xmlns.oracle.com/adf/faces/rich">

\<af:document title="MainPage.jsf" id="d1">

    \<af:form id="f1">

        \<af:button text="Open Popup (in top jsf)" id="cb1">

            \<af:showPopupBehavior popupId="p1"/>

        \</af:button>

        \<af:popup id="p1" contentDelivery="lazyUncached">

            \<af:dialog id="d2" title="whatever"

                       dialogListener="#{backingBeanScope.DialogContentHandler.onDialogAction}">

                  \<af:panelGroupLayout id="pgl1" layout="vertical">

                            \<af:inputText label="whatever" id="it555"/>

                            \<af:message id="m5" for="it555"/>

                  \</af:panelGroupLayout>

            \</af:dialog>

        \</af:popup>

        \<af:region value="#{bindings.test\_me1.regionModel}" id="r1"/>

    \</af:form>

\</af:document>

</f:view>

public void onDialogAction(DialogEvent dialogEvent) {

    if(dialogEvent.getOutcome().name().equals("ok")){

            FacesContext fctx = FacesContext.getCurrentInstance();

            FacesMessage fm = new FacesMessage(FacesMessage.SEVERITY\_ERROR,"Validation Failed", "I am not letting you out of here");

            fctx.addMessage("it555", fm);

    }

}

So here we go with testing:

jdev932015_1.jpg

A) Page opens for the FIRST time and user clicks on "Open Popup (in top jsf)" which is Frank's example. Works as expected.

jdev932015_2.jpg

B) If now we restart the test and click on the second button "Open Popup (in fragment)", which is inside the fragment, and try to click 'ok', the message shows but is NOT inline, it is another dialog popup.

jdev932015_3.jpg

C) Another test case that actually diminishes my entire purpose of this approach is:

- User opens the page for the first time and clicks on the 1st button. Then cancels the dialog or closes on x

- Then user clicks on the second button (the one inside BTF), popup dialog opens and user clicks OK. The dialog closes without ANY message.

So I searched online, mostly these forums, found several people experienced same issue and one poster suggested solution and implied this is a bug

Is it possible to use <af:message> to display adf model validations instead of default note window

However, proposed solution did not work in my case.

Any ideas?

This post has been answered by Frank Nimphius-Oracle on Sep 4 2015
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 2 2015
Added on Sep 3 2015
2 comments
591 views