How to execute a VO on click of a button on an OAF page

Here we will discuss the execution of a VO on click of a submit button.

Now, before starting the discussion I assume that you have created a VO and have the same attached to AM. Also, I assume that you have imported the VOImpl and AMImpl to the controller attached to the page.
One more assumption I would like to make is that the VO name is xxTrialVo, AM name is xxTrialAm and the id of the submit button is xxSubmitButton.

After these assumptions, we are ready to learn how to execute a VO on click of a submit button.

First of all you need to check the click of the submit button. As submit button will post an HTTP request, hence you need to handle the click of the submit button in processFormRequest method. Just see the code below for reference.

pageContext.setForewardURLtoCurrentPage(//pass the required parameters);

Now the code above shows that you have caught the event of submit button click.
But our purpose was to execute the VO after submit button click, as we know that once the submit button is clicked the control travels from processFormRequst to processRequest method. Hence, now we will take the advantage of sessionValue that we have put in the code to check whether the control is coming back after submit button click or not. If it is then we will execute the VO.

In order to do this, in the processRequest method, refer to the code below.
XXTrialVOImpl TrialVO = (XXTrialVOImpl)am.get XXTrialVO1();

Hope you find this informative.
Thanks for reading 🙂

Tagged , , , , . Bookmark the permalink.