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 10.5.5.3 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 :-)
Comments (5)
hi,
also you can create a "adf creation form" since data control palette.
Regards
Posted by fetishcode | July 26, 2007 2:11 AM
Posted on July 26, 2007 02:11
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?
Posted by Lana | August 28, 2007 8:21 AM
Posted on August 28, 2007 08:21
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.
Posted by Shay Shmeltzer | August 28, 2007 1:48 PM
Posted on August 28, 2007 13:48
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???
Posted by Ebtehal | May 22, 2008 5:37 AM
Posted on May 22, 2008 05:37
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:
http://radio.weblogs.com/0118231/stories/2004/09/23/notYetDocumentedAdfSampleApplications.html#60
Posted by Shay Shmeltzer | May 22, 2008 1:05 PM
Posted on May 22, 2008 13:05