How do you reset inputText values in a dataTable?

I'm having what must be a simple and common problem,
but nothing I've tried has solved it. I want to be
able to refresh (reset) the inputText field values in a dataTable.
I have a dataTable that holds required inputText components.
I want to have a "cancel" button which would abandon any edits
on these components and refresh (reset) them with their backing values,
as well as removing the last row from the table (used to enter a
new record). Because the inputText components are required,
I made the cancel button immediate. I don't know what code I can
put in the button's actionListener. Right now, the displayed values
survive the round trip to the server and back to the browser, but
I want them to be reset to their backing values.
Here is the page, and the backing bean of a test example:
<%@ include file="../include/taglibs.jsp" %>
<h:dataTable id="table" value="#{pc_Test.list}" var="x">
    <h:column>
        <h:panelGroup>
            <h:inputText id="label_value" required="true" value="#{x.value}" />
            <h:message for="label_value"/>
        </h:panelGroup>
    </h:column>
    <f:facet name="footer">
        <h:panelGroup>
            <h:commandButton id = "btnn" value="new row" actionListener="#{pc_Test.newRow}" /> 
            <f:verbatim>  </f:verbatim>
            <h:commandButton id = "btnu" value="update" actionListener="#{pc_Test.update}" />  
            <f:verbatim>  </f:verbatim>
            <h:commandButton id = "btnr" value="cancel" immediate="true" actionListener="#{pc_Test.cancel}"/>
        </h:panelGroup>
    </f:facet>
</h:dataTable>
<f:verbatim>Summary=</f:verbatim>
<h:outputText value="#{pc_Test.listString}" />
package pagecode;
import java.util.ArrayList;
import java.util.List;
import javax.faces.event.ActionEvent;
public class TestPage {
    public static class Example {
        public Example(String value){this.value = value;}
        public String getValue() {return value;}
        public void setValue(String value) {this.value = value;}
        public String toString(){return getValue();}
        private String value;
    public TestPage(){
        list.add(new Example("a"));
        list.add(new Example("b"));
        list.add(new Example("c"));
    public List getList() {return list;}
    public String getListString() {return list.toString();}
    public void update(ActionEvent event){}
    public void cancel(ActionEvent event){
        if (list.size()>3)
            list.remove(list.size()-1);
    public void newRow(ActionEvent event){
        list.add(new Example(""));
    private boolean readOnly;
    private List list = new ArrayList();
}If it makes a difference, my implementation of JSF is MyFaces. Thanks!

bump
I'm not happy with having javascript reseting fields in a table before submitting:
there's a noticable screen flash, and I'd like a server-side solution anyway.
Question: UIInput has methods getSubmittedValue and setSubmittedValue,
so I can use these to ignore or clear submitted values when I press an
immediate command button. This takes care of subclasses like HtmlInputText
but not for data tables. Is there a way to manipulate all the submitted values
of a data table?

Similar Messages

  • How can I reset the value of an array?

    How can I reset the value of an array at the beginning of my program?

    There is a option in LV,
    "Edit --> Make current value defult"
    Every time you reopen your VI, it will set to your custom default value.
    There are many ways of doing this.
    Another way of doing this is, You can use "sequence structure and property node". Make the property node of your array and choose "value". Then mark it to write. See attach.
    When you feel sad, laugh
    Attachments:
    x.GIF ‏4 KB

  • From two given tables, how do you fetch the values from two columns using values from one column(get values from col.A if col.A is not null and get values from col.B if col.A is null)?

    From two given tables, how do you fetch the values from two columns using values from one column(get values from col.A if col.A is not null and get values from col.B if col.A is null)?

    Hi,
    Use NVL or COALESCE:
    NVL (col_a, col_b)
    Returns col_a if col_a is not NULL; otherwise, it returns col_b.
    Col_a and col_b must have similar (if not identical) datatypes; for example, if col_a is a DATE, then col_b can be another DATE or it can be a TIMESTAMP, but it can't be a VARCHAR2.
    For more about NVL and COALESCE, see the SQL Language manual: http://docs.oracle.com/cd/E11882_01/server.112/e26088/functions119.htm#sthref1310
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
    See the forum FAQ: https://forums.oracle.com/message/9362002

  • How can you reset your password if you forget it?

    Hello my name is khadesha I have a question how do you reset your password if you forgot your pass code?

    Connect the iPod to the computer and restore via iTunes. If necessary, place the iPod inRecovery Mode to allow the restore.

  • HT1414 how do you reset my ipod touch..daughter try passcode too many times now its disabled

    how do you reset my ipod touch..daughter try passcode too many times now its disabled

    Passcode Locked or Disabled
    If nothing else will let you unlock the device - after so many unsuccessful attempts will be locked out - You have to restore the device within iTunes. You want to use the same computer that you always sync with so that you can restore your app data and settings. You can restore with any other computer, but you will lose everything on the Device.
    Instructions can be found here.
    http://support.apple.com/kb/ht1808

  • How do you reset an ipad mini without knowing the password?

    I have just recently changed my password, but know i have forgot the new one. How do you reset the ipad without knowing the password?

    If you mean the passcode to unlock the iPad then you will need to connect it to the computer that you normally sync to and you should then be able to reset the iPad and restore/re-sync your content to it (http://support.apple.com/kb/HT1212) - you may need to put the iPad into recovery mode in order to be able to reset it : http://support.apple.com/kb/ht1808
    If you do it via a different computer then :
    If you restore on a different computer that was never synced with the device, you will be able to unlock the device for use and remove the passcode, but your data will not be present.

  • How do you reset your autolock password?

    my phone has been disabled for an hour and i recently changed my password so how do you reset it

    Options for when an iOS device gets locked because of forgotten password:
    Restore (and reset password) on your device by connecting it to the last computer to which it was connected:
    iTunes: Backing up, updating, and restoring iOS software - http://support.apple.com/kb/HT1414
    If you cannot connect it to the computer to which the device was last connected you will have to use recovery mode to completely reset the device, losing all data:
    iOS: Unable to update or restore - http://support.apple.com/kb/HT1808 - recovery mode (e.g., cannot connect to computer last used to sync device, iTunes still asks for a password)
    By the way, you posted in the Applworks (realy old software) forum.  You'll get a response from other iPhone users if you post in the iPhone forum next time.

  • How do you reset your email password?

    How do you reset your email password?

    Email for what account?
    For iCloud/Apple ID:
    How do I change or recover a forgotten Apple ID Password?
    If you've forgotten your Apple ID Password or want to change it, go to My Apple ID and follow the instructions. See Changing your Apple ID password if you'd like more information.

  • HT204291 How do you reset your password?

    How do you reset your password on iPad to use airplay?

    I copied this from another discussion - from a pretty knowledgable Apple TV user.
    If you have forgotten your password, you'll need to reset it from the Apple TV. (settings > AirPlay)

  • How do you Reset iPad to factory defaults

    How do you reset an iPad to factory defaults?

    Go into Recovery Mode per the instructions here.  You WILL lose all of your data (game scores, etc,) but, for the most part, you can redownload apps and music without being charged again.  Also, if you have IOS-7, read this.

  • How do you resets your apple I'd security question with out calling apple

    How do you resets your apple I'd security question with out calling apple

    See Kappy's great User Tips.
    See my User Tip for some help: Some Solutions for Resetting Forgotten Security Questions: Apple Support Communities https://discussions.apple.com/docs/DOC-4551
    Rescue email address and how to reset Apple ID security questions
    http://support.apple.com/kb/HT5312
    Send Apple an email request for help at: Apple - Support - iTunes Store - Contact Us http://www.apple.com/emea/support/itunes/contact.html
    Call Apple Support in your country: Customer Service: Contacting Apple for support and service http://support.apple.com/kb/HE57
     Cheers, Tom

  • HT3965 how do you reset the apple ID on an iPhone 4s. my aunt's husband passed away and took the password with him.

                   my aunt's husband passed away and took his apple ID and password with him. how do you reset a apple ID password?

    If it's runniong iOS 7 then when he left he left activation lock behind. Without hte proper credentials you cannot remove the apple id off the device if he turned on "Find my iPhone" via iCloud.

  • HT201304 how do you reset the restriction password on an ipod touch

    How do you reset a forgotten restriction password on an ipod touch

    They will be erased from the iPod along with everything else, but since those songs must have originated from a source other than the iPod, they must still exist on the computer you used to sync it.
    After you restore the iPod, you just have to sync it with that same computer again.

  • How do you reset the faders in the mixer panel in PPro CC

    how do you reset the faders in the mixer panel in PPro CC? I want to reset my channel faders and start my mix fresh but can find no way to reset them

    Dble Click / or right Click on the slider knob or the O
    One of those I think from memory.
    Correct.

  • TS2220 How do you reset the network password for Airport wireless?

    How do you reset the network password for Airport wireless?

    Use AirPort Utility...select the AirPort Express and in the menu select Base Station...Restore Default Settings...

Maybe you are looking for