Shay Shmeltzer's Oracle Development Tools Tips

  • July 25, 2007

Executing An Action on JSF Page Startup with Pagedef

Shay Shmeltzer
Director of Product Management - Oracle

Someone asked this on the OTN forum:

Create an JSF page with an ADF Form and a Create button - now when you run it - you first have to click the create button to get an empty record in the screen that you can insert data into.

The question is how do I get the form to load up with an empty record.

Here is a trick that will do it.

Go to your JSF page's pagedef.xml file and look in the structure pane - you'll see this:


Notice that you have a binding already in place for the Create action.

Next add an invokeAction executable BEFORE the iterator executable.


In the dialog that pop-up specify a name for the binding - and then specify the Create operation.


Now when you'll run the page you'll get an empty record ready for you to work on.

[small update based on some comments]

However, if you'll run the page now you'll see that after you press commit - another new record is created. This is because the action is being executed again after the postback.

The solution for this is to restrict the execution of the method through the refresh condition of the action in the pagedef.

You set it to be ${!adfFacesContext.postback}

You also need to set the Refresh property to be renderModel (see chapter in the ADF Developer Guide)


Now run the page and you'll get an empty form when you start and after you press commit there is no additional insert.

Now that you have the understanding of how this technique works behind the scene, I should probably mention that there is a simpler way to create this form.

In your first step, instead of dropping the view as an ADF Form drop it as an "ADF Creation Form".

When you look at the code that was created you'll see the same thing we have created manually in this blog :-)

Join the discussion

Comments ( 8 )
  • fetishcode Thursday, July 26, 2007
    also you can create a "adf creation form" since data control palette.
  • Lana Tuesday, August 28, 2007
    I have a different problem. I get my new record when I run my page, but I also get two more, when I come back froma popup window my page is calling. Any suggestions?
  • Shay Shmeltzer Tuesday, August 28, 2007
    Lana, I would suggest that you post your question on the JDev forum on OTN with a bit more details about what you are doing specifically.
    As well as the information about the refresh condition set for your action binding.
  • Ebtehal Thursday, May 22, 2008
    Hi, well done.. i have a different problem if u can help me?? i need to set the where clause for my view objects at runtime , because they depend on a runtime variable, but i want this to be at pages load not according to a client invoke???
  • Shay Shmeltzer Thursday, May 22, 2008
    If this approach doesn't work for you (you can replace the create method in this sample with any AM service method that you expose). Then maybe go for sample 60 on Steve Muench's blog:
  • guest Monday, May 23, 2011
    Hi.. Thanks for this post Its very helpful to me.
    I follow the step and its work but i face one problem when page load the only label of input textbox is appear, textbox not appear .
    I am not able to identify the problem please help me.
  • Leonardo Betancourt Thursday, July 7, 2011

    I will like to know, when I have an ADF Forms and I want to save the information on it, but I have some fields not visible because they have a default value on the DB i got some errors and do not let me save my info on the DB. I'm new on ADF but I really want to know, or if I have those fields with a default value on the DB I should not include the fields on my entities or what can I do?. Thanks

  • Shay Thursday, July 7, 2011

    Leonardo, this type of questions should be posted on the JDeveloper discussion forum on OTN. In general if your attribute can be sent empty to the database and it will get a default value there, you can probably mark the attribute as not being mandatory in the EO definition.

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