How To Reset a Form (Not as easy as you would think)?

Hi All,
I'm unable to get a form to reset its value when using a commandButton that has immediate set to true.
I've got a simple little jsf page that has a form and a datatable. The form is bound to an object in a class I'm using to handle the view, the datatable is bound to a dataModel from the same handler class. The functionality I have is quite simple:
a user clicks on a commandLink in a row of the datatable
the corresponding object is loaded into a "currentObject" property of the handler class
the form fields are mapped to the "currentObject" property of the handler.
The user may update or reset the form.
The goal is to have the reset commandButton set the "currentObject" property of the handler class to null (or a new, unpopulated object) so that the fields of the form are set to blank again on render. This works fine as long as I don't use immediate="true". When I do use the immediate=true attribute, the "currentObject" variable is, indeed, set to null, but the form still renders with the old "currentObject" values in it!!
I have to use immediate="true" because there is validation going on for the form that I want to avoid.
If I use a commandButton type="reset", the fields are not cleared because the reset functionality of the browser (ie6 and firefox) resets the fields to the values they were at the time the form was displayed--the very values I wish to totally remove!
This seems like such a common, simple thing to do. What am I missing?
Thanks,
John

I have a similiar problem, and maybe putting buttons in a different form is the answer:
I have a page with a selectOneListbox on the left, and a set of inputs on the right. The listbox represents the available beans to select, and the set of inputs contains all the editable fields for the beans. Basically this is just a bean editor.
There is a command Button beneath the listbox for viewing a bean. When this button is clicked, the set of inputs are populated with that bean's data.
There is also a command button beneath the set of inputs that allows the user to save their changes.
All of these elements are in the same form tag.
JSF jsp:
<f:view>
  <h:form>
    <h:panelGrid columns="2">
      <h:panelGrid columns="2">
        <h:selectOneListbox size="10" value="#{editor.selectedBean}" >
          <f: selectItems value="#{editor.beanSelectItemCollection}" />
        </h:selectOneListbox>
        <h:commandButton actionListener="#{editor.view}" value="View" />
      </h:panelGrid>
      <h:panelGrid  columns="2">
        <h:inputText value="#{editor.editingBean.property}" />
        <h:commandButton actionListener="#{editor.save}" value="Save" />
      </h:panelGrid>
    </h:panelGrid>
  </h:form>
</f:view>Editor bean:
public class Editor {
  // use a blank bean as default
  // so the editor is populated with blanks
  private Bean editingBean = new Bean();
  // don't initially select any beans
  private Bean selectedBean = null;
  private Map beans = new HashMap();
  public Editor() {
  public void save(ActionEvent e) {
    beans.put(editingBean.getId(), editingBean);
  public void view (ActionEvent e) {
    editingBean = (Bean)selectedBean.clone();
  // getters and setters
  public Bean getEditingBean() {
    return editingBean;
  public void setEditingBean(Bean b) {
    editingBean = b;
  public Bean getSelectedBean() {
    return selectedBean;
  public void setSelectedBean(Bean b) {
    selectedBean = b;
  // before entering the JSP for this bean, this method should be called
  // to populate the editor
  public void setBeans(Collection c) {
    beans.clear();
    for (Iterator i = c.iterator(); i.hasNext(); ) {
      Bean b = (Bean)i.next();
      beans.put(b.getId(), b);
  public Collection getBeans() {
    return beans.values();
  public Collection getBeanSelectItemCollection() {
    Collection items = new ArrayList(beans.size());
    for (Iterator i = beans.values().iterator(); i.hasNext(); ) {
      items.add(new SelectItem(bean, bean.getProperty());
    return items;
}Here comes the problem:
If I want to set fields as required or use any of the JSF validation functionality, my view usecase breaks. This happens if the user views bean1 changes some data to be invalid/not existant and then tries to view bean2. If they don't click the save button, validation/required should not be checked. My initial thought is that I should be able to set my view button and view listbox to be immediate. This does properly update the view listbox, but then if I change the values in the backing bean for the set of inputs, those changes are never updated to the screen, and the set of inputs is still populated with bean1's data even though the backing bean for all those inputs is now bean2.
It appears that the view never requeries the backing bean when responseComplete() is called (which happens with an immediate command). Is this a bug in faces, or is this how the spec says it is supposed to behave? If this is the correct behavior what is a better practice to acheieve my usecase?
My current workaround is to ignore faces validation and manually validate when the user clicks the save command, and then manually set the messages for the bad components. Obviously, this is not an ideal solution, but I was hoping that this faces behavior was incorrect and thus my solution would be temporary.
I'm not tied to a specific solution, but I am discouraged that Adam says in order to reset the set of inputs, we have to manually update the model during the apply request values phase.

Similar Messages

  • I do not like inbox search and want to use google but i cannot find any way to remove inbox--in fact when i search for it to remove you would think it is not there--but it is and i cant get it off. anyone know how?

    Question
    i do not like inbox search and want to use google but i cannot find any way to remove inbox--in fact when i search for it to remove you would think it is not there--but it is and i cant get it off. anyone know how? edit
    Details

    What you should see on a restart is a black screen followed by a screen with the Apple (at which point you let go of the two buttons). There is no progress bar, just the Apple. The Apple will stay there for 15 seconds or so, then the "Slide to Unlock" screen will redisplay.
    But, I don't think the reset will fix it for you. I just tested it, and it comes back on with the zoom still on. The only way to get it to zoom out is the tapping with the 3 fingers.
    I said to double-tap....MY BAD! You need to triple-tap with three fingers!
    Try that and see if it will display the zoom menu for you, or if it will zoom back out.
    Cheers,
    GB

  • How to keep first form window state maximize when you called the second for

    HI,
    how to keep first form window state maximize when you called the second form ?
    Thanks

    Here is sample of doing this.
    Chris

  • How do you get time machine to reset your computer to the specific date you would like?

    How do you get time machine to reset your computer to the specific date you would like?

    Hey carlleeh,
    Thanks for the question. The following resource may guide you through that process:
    OS X Mountain Lion: Recover your entire system
    http://support.apple.com/kb/PH11192
    Thanks,
    Matt M.

  • My Macbook pro is very slow in oening folders, it does not open immediatly as you would expect and takes about 30s or more. Please help!   Here is the spec: OS X 10.8.3 2,3 Gz Intel Core i7 8GB 1600 MHz DDR3

    My Macbook pro is very slow in oening folders, it does not open immediatly as you would expect and takes about 30s or more. Please help!
    Here is the spec:
    OS X 10.8.3
    2,3 Gz Intel Core i7
    8GB 1600 MHz DDR3

    Did u try to rebuild spotlight index? repair permissions? verify disk and repair if needed?
    if now, try it out.

  • How do I get the notes back after an iOS update?  Not as easy as you think....

    This is a strange case.  I had a previous iPad 1 synced to my pc, 2 years ago.  That iPad is long gone.  I now have a different iPad 1 that was never synced to any pc, and actually had a couple of apps purchased from different users.  The apps aren't the problem. 
    I synced this second iPad to my pc and it seemed happy as can be.  I then updated the iOS. When it was done it had nothing other than factory apps and no data.  So I restored it.....
    But it restored the OLD iPad!  It even renamed this iPad to the old name.   It replaced my notes with the notes from that old iPad.
    I've fixed all the app problems.  But how can I get those notes back?  I've looked at the backups, but note that it never had me back it up, it only synced.

    Good morning Gandrin
    There is quite a difference between syncing and back-up and they are different features in iTunes, although some people combine them together.
    1.  The first thing that happens when you connect your device is that a photo manager asks if you want to offload your photos.  I always do this because it is the most valuable way to back-up your photos only.
    2.  Then Itunes will come up and if you have automatic sync turned on it will begin to sync FROM your computer to your device.  It's a one-way sync and is the primary way to keep photos, music and some apps managed on your device.   New apps are synced onto your Itunes app tab. If you add or delete items in your iTunes folders then those changes are synced to your device.  I always check to make sure my new apps are now in my iTunes library and specific device tab.
    4.  There is also a back-up step where you can back your device onto your computer.  I think this is the step that should have been done when you got your new PC.  It doesn't save the apps here but does save their setting and data. I prefer to set this up to be a manual back-up process.
    http://support.apple.com/kb/HT4946.
    5.  There is also a a "Automatically sync new apps checkbox in your itunes device apps tabs.  That should be checked "on".
    6.  If the missing apps were purchased through iTunes then I think you can download them again (make sure you use the same Apple Id).  If you then resync with itunes those apps should appear in iTunes for you.
    Maybe there is something in my rambling that will help

  • How to make a form not running offline

    Hi, I've built my own form, which need to be submitted to a java servlet.
    Is there a way to avoid that a user saves the pdf form and submit it when he shouldn't?
    I've tryed with "preSave" event, but it cannot be canceled.
    Any suggestions?
    Thank you.

    If the form is not reader extended, the user can save only a copy of the blank form (not with filled data), provided the end user should use only Adobe Reader.
    Nith

  • I can't remember my security questions and the email that is supposed to send on how to reset them is not being sent to me

    Help!!

    katelynwatt wrote:
    Help!!
    How to reset your Apple ID security questions.
    Go to appleid.apple.com, click on the blue button that says 'Manage Your Apple ID'.
    Log in with your Apple ID and password. (If you have forgotten your Apple ID password, go to iforgot.apple.com first to reset your password with a password recovery email)
    Go to the Password & Security section on the left side, and click on the link underneath the security questions that says 'Forgot your answers? Send reset security info email to [email]'.  This will generate an automated e-mail that will allow you to reset your security questions.
    If that doesn't work, or  there is no rescue email link available, then click on 'Temporary Support PIN' that is in the bottom left side, and generate a 4-digit PIN for the Apple Account Security Advisor you will be contacting later.
    Next, go to https://getsupport.apple.com
    (If you see a message that says 'There are no products registered to this Apple ID, simply click on 'See all products and services')
    Choose 'More Products & Services', then 'Apple ID'.
    A new page will open.
    Choose 'Other Apple ID Topics', then 'Forgotten Apple ID Security Questions'.
    Click the blue 'Continue' button.
    Select the contact option that suits your needs best.

  • I am in process of unlocking my iphone and need to restore my phone backed it up already but ituenes will not let me restore keeps telling me ituenes can not get on the internet no connection with is not true cause otherwise you would not have gotten this

    I have contacted at&t and they did what was nessary to unlock my phone was told to backup my phone and did that so know I just need to restore my phone with ituens which ituenes will not let me do cause I get message can not connect to cause of no internet connection wich is not true cause other wise you would not have gotten this

    Try restoring the iPhone to factory settings. If you are having difficult restoring, put the iPhone into Recovery Mode and see if that then works:
    http://support.apple.com/kb/ht1808
    If not, or if a restore to factory settings does not fix the problem, then your iPhone may have a hardware problem. You can only get the iPhone serviced by Apple in Canada, so you will have to take the iPhone there or send it to someone you know in Canada who can get the iPhone serviced and send it back to you. The only option for getting service in Pakistan would be to pay some unauthorized repair shop to attempt a repair, after which Apple will no longer provide any service even in Canada.
    Regards.

  • HT2736 I do not understand why the simplest of tasks do not appear next to each other in a list of links. You would think tht "Reedem" an item would be right next to "Gift" an item, burt for some reason that just does not make sense to Apple.

    I never did find the "Gift Certificate" link even thoug support said where it "should" be, and "No" Nowhere near where you would reedem them.

    mojaleski wrote:
    When I want to read something in e-mail or which I downloaded and want the font large enough for me to see and expand with my fingers...the content then doesn't resize the shape to fit on the screen and I have to keep going from left to right to left back and forth in order to read it. Seems like it should automatically become an elongated column to fit the viewing area with just less words per line. PLEASE fix this so I can enjoy reading with larger type size to accomodate my eyesight.
    Double tap the column to make it size to fit. It will make it fit the width but not make the font larger by putting less word on a line.
    Hard to make corrections as it is hit or miss to get in between letters in a word.
    Tap and hold to get the magnifying glass or better still get the iPad User Guide which is free in iBooks - it has pictures and will save me having to type so many words to try and answer your questions
    Is there no way to scroll up or down deleting as you go...so far all I can do is delete one word/line at a time, ie in forwarding e-mail and trying to get rid of the long list of other people's contacts.
    Yes, I'm replying to this on my iPad - again, much better described in the User Guide.
    Thank you
    You're welcome. But please do have a look at the iPad User Guide - it will make things clearer and you may even find something new that you didn't already know.
    Regards,
    Colin R.

  • How to reset a form

    How do I reset the input values to the originals on a form? I am using JDev 10.1.3.3. The code below seems not working because autoSubmit=true:
    <af:inputText id="id1" value="#{someValue}" autoSubmit="true"/>
    <af:InputText partialTriggers="id1" render="someCondition"/>
    <af:commandButton type="reset" text="Reset"/>
    Do I need to explicitly set the component's value like the following:
    inputText.setValue(originalValue);
    inputText.setSubmittedValue(null);
    Thanks.

    Hi,
    Rollback undo the whole transaction, incase if you need to undo only the current row changes, then, here is one way.
    - Inside ViewObjectImpl have a method to undo the current row changes
    public void undoCurrentRow(){
         Row row = this.getCurrentRow();
         if (row != null)
             row.refresh(row.REFRESH_UNDO_CHANGES | row.REFRESH_FORGET_NEW_ROWS);
    }- Expose it to the client interface
    - Add it as an ADF button into the jsf page and set immediate property to true(Incase of createInsert, it doesn't allow to do undo if valid values are not provided for required fields, to avoid this we need to set immediate property to true)
    References:
    http://andrejusb.blogspot.com/2008/09/jdeveloper-11g-crud-in-adf-form.html
    http://one-size-doesnt-fit-all.blogspot.com/2007/02/jdeveloper-and-art-of-rollback.html
    -Arun

  • How to make a form not create a second entry

    I'm using the PDF entry for a form. Very cool. But if a user submits it, then adds more data and submits again it creates two entries. How can I 'key' the form so it only updates the same entry?

    Sorry, we do not support this feature at this time.
    If your form as a unique idenfier fields like an Email field or a First Name and a Last Name fields then sort by that column and look at the latest submission by a same user and delete other row manually. Each submission has a "Time Submitted" column in the response table (View Responses Tab).
    Gen

  • How do I setup Forms not to ask RAD username/password when opening a form

    Good day
    I have setup oid and sso and they work I can sign on to database with an oid user using sqlplus.
    If I set SsoDynamicResourceCreate=true and enter the user id and password in at the popup it works correct and won’t even ask it again
    What I want to know how can set portal to use a RAD/DAS without prompting for a username password.
    We need to do this for all +/- 30000 users and if so how do we do it pragmatically.
    I think because I don’t have much APPS experience I basically don’t know where this must be set globally
    APPS is version 10.1.2
    Regards
    Cliff
    Message was edited by:
    cliffnel

    Got solution in metalink note 262686.1
    Goto <infrastructure :port>/oiddas
    Click Configuration Tab
    Click Preference Tab
    Create Default RAD for database

  • How to reset a form instead of all the forms in the document?

    I installed a button in each page of my file my (ten pages, each one with a different one form) to give the user the faculty of clear specifically through a single choice
    But this reset button resets all the pages. I took care to rename this button in each page but Acrobat proceeds to execute a massive reset operation.
    Thank you.

    Mr Try,
    You wrote the whole thing...
    Thank you.
    Could you please give me the last breath?
    My real page numberin PDF  is 25 an I tried this (placing the two pieces) without success...
    function resetFieldsOnPage(p) {
        var fields = [];
        for (var i=0; i<this.numFields; i++) {
            var f = this.getField(this.getNthFieldName(i));
            if (f==null) continue;
            if (f.page==p)
                fields.push(f.name);
        this.resetForm(fields);
    And then to reset all the fields on the first page, call:
    resetFieldsOnPage(25);

  • How to Reset Auto Forms

    Hi,
    1.) I was wondering if one can reset the auto forms fill out in Tiger one by one.
    I have mistyped on occasion and the pesky thing keeps offering it as a choice. I would like to get it to where the only choices when I type the first letter are what I want.
    Specifically applications, like on my browser -- FireFox 2.
    2.) What can you toss out in OSX and have it regenerate each time: like .plists and so forth? And where could I study up on that part of OSX?
    Thanks.

    Never answered.
    Sweeping out old questions from my list.

Maybe you are looking for

  • Bank charges on Vendor invoices to be borne by Vendor during F110- How ?

    Hi FICO Gurus, I have a scenario as below. While doing F110, for some vendors my client wants the bank charges(Wire/TT charges) to be deducted from the invoice amount. For instance if I have to pay USD 1000 to ABC vendor, for the relevant wiretransfe

  • Sharing my iTunes Library with other Users on my computer?

    ...hi guys! Nice to find this friendly commumity! I wonder if any of you have worked out how to share the library across other users on the computer yet? I share a PC with my girlfriend, and all of our downloads on iTunes are from our CD collection.

  • Why can't i sync videos to my ipod touch

    hi everytime i connect my ipod and drag videos nothing happens their all mp4 format

  • Where can I buy final cut pro 7

    Does anyone know where to buy final cut pro 7 and if it is compatible with mountain lion. If I installed mountain lion and used to have snow leaport. I used to have final cut pro 5 and live text...is it anyway I can go back to snowleapard after insta

  • PeopleSoft 9.1 recruitment (TAM) letters are empty or blank.

    When we try to open/display letters in PeopleSoft recruiting (TAM) somehow they are empty or blank and not showing any content or details. All BIP report file definitions and template definitions are fine. Thanks.