« Oracle Proposes Open Source Persistence Project at Eclipse Foundation | Main | EJB 3 in Action »

ADF Binding 10.1.3.x: Clearing the input values

Today, I was facing a surpring problem with my ADF application.

My application contains a number of pages for creating new entries in a database (I call them "create" pages). This sounds like a common usage and it is. The interesting part showed up when I called the "create" page again (after doing some other stuff in the application).

The "create" page was not an empty page as expected, but had the values previously entered to create a new entry. This is quite handy for testing but unintentional.

The hint for the solution came from Frank Nimphius:

In an actionListener for the "Create" button do something like this:
FacesCtrlAttrsBinding o =
  (FacesCtrlAttrsBinding)bindings.get("nameSrch");
o.setInputValue("%");


Although this sounds fairly easy, it becomes quite tedious for many different pages.

Digging deeper in the ADF Binding API, I found the generic solution:

protected void resetForm(BindingContainer bindings) {
  List l = bindings.getAttributeBindings();
  for (Iterator it = l.iterator(); it.hasNext();) {
    Object o = it.next();
    if (o != null) {
      if (o instanceof FacesCtrlAttrsBinding) {
        ((FacesCtrlAttrsBinding)o).setInputValue(null);
      }
    }
  }
}


Calling this method in your Action Listener just before you return the desired outcome will do the trick.

TrackBack

TrackBack URL for this entry:
http://blogs.oracle.com/mte1521/mt-tb.cgi/614

Comments (2)

Vimalan Balan:

Hi Heimburger,

Your code is super.Its cleared the values. Now i want to clear the table rows and make it has a new empty table.

And also how to clear the inputHiddenValues.

Thanks & Regards
Vimalan Balan

Vimalan Balan:

Hi Heimburger,

Need help to resolve the problem.

In my page, i have menubar with couple of command menu item. One is for to enter new record and another is for to search the record.

When i click the search menubar, it will take to search screen and i can able to search the record with input criteria. After fetching the result, i am selecting the record to view full complete details and return back to search screen. At this time i need to maintain entered search criteria value and also result in the table.

What i need is after search , if i navigate to creation form using menubar item and then again coming back to search screen. At this time i want to clear the form. I want to display the screen without any values.

How to clear the values when we navigate through menubar item.

Kindly suggest tips or any sample for to fix it.

Thanks & Regards
Vimalan Balan

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

About This Entry

This page contains a single entry from the blog posted on April 10, 2007 3:27 PM.

The previous post in this blog was Oracle Proposes Open Source Persistence Project at Eclipse Foundation.

The next post in this blog is EJB 3 in Action.

Many more can be found on the main index page or by looking through the archives.

Top Tags

Powered by
Movable Type and Oracle