Forum Stats

  • 3,874,259 Users
  • 2,266,716 Discussions
  • 7,911,792 Comments

Discussions

Triggering Validation in a Region Through a Contextual Event

mBaldwin
mBaldwin Member Posts: 47
edited Jan 29, 2013 10:31AM in JDeveloper and ADF
I am using JDeveloper 11.1.1.6.0.
I am trying to find out how to trigger the built in validation that occurs normally when a "submit" action occurs, but have the submit action occur outside of a region, and the validation also occur in the region itself.

I have a page that contains a dynamic region in it. I will refer to the containing page as the parent and the region as the child. The parent region and child region both have different business objects bound to them, though they are part of the same application module. The parent page contains a submit button that needs commit the user entered data in both the parent and child pages. This action must not proceed if there are any validation errors in the parent or the child. The validation should trigger on the parent page without any work from me because of how ADF handles the situation. The child page is notified of the submit action via contextual events. I currently have it where this event can trigger the "commit" action successfully, but I have no idea how to go about ensuring that it triggers a validation check as well.

The overall flow that I think will happen in the final version is likely:
1: submit button pressed.
2: parent page validation is checked (if success, proceed)
3: contextual event is fired
4: contextual event is received by the child.
5: the child triggers its own validation (if success, proceed, else stop)
6: the child triggers a commit action
7: the child sends a response contextual event (signalling that it was successful)
8: the parent receives the response contextual event
9: the parent performs a "commit" action.


I do not know how to cause step 5 to occur, and I do not know if steps 7 through 9 are needed yet (I haven't tested to see if causing the commit in either the parent or the child ends up causing all modified entity objects to be committed). Any help would be greatly appreciated.

Thank you

Best Answer

  • Frank Nimphius-Oracle
    Frank Nimphius-Oracle Member Posts: 29,689 Bronze Badge
    Answer ✓
    Hi,

    you can access a command button on the page fragment and queue its action event. For this you access a managed bean (backingBean Scope) that contains a handler to the command button and queue the event (this then will perform validation as if the user clicked it. The command button can also be hidden on the fragment.

    Have a look here for how you can integrate the managed bean as the contextual event handler

    http://www.oracle.com/technetwork/developer-tools/adf/learnmore/regionpayloadcallbackpattern-1865094.pdf

    Frank

Answers

  • Frank Nimphius-Oracle
    Frank Nimphius-Oracle Member Posts: 29,689 Bronze Badge
    Answer ✓
    Hi,

    you can access a command button on the page fragment and queue its action event. For this you access a managed bean (backingBean Scope) that contains a handler to the command button and queue the event (this then will perform validation as if the user clicked it. The command button can also be hidden on the fragment.

    Have a look here for how you can integrate the managed bean as the contextual event handler

    http://www.oracle.com/technetwork/developer-tools/adf/learnmore/regionpayloadcallbackpattern-1865094.pdf

    Frank
  • mBaldwin
    mBaldwin Member Posts: 47
    edited Jan 29, 2013 10:03AM
    Frank,
    First off, thanks for your fast reply. I already have a bean that has been turned into a data control for handling the contextual events. Thank you for the link though as it looks like it might have some additional information that I can use. As for the hidden button, are you suggesting a button that is rendered but not visible?

    EDIT: I just tested it that way and it appears to be working as it needs to. Thank you again Frank.

    Edited by: mBaldwin on Jan 29, 2013 9:02 AM
  • Frank Nimphius-Oracle
    Frank Nimphius-Oracle Member Posts: 29,689 Bronze Badge
    thanks for the feedback

    Frank
This discussion has been closed.