Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No easy way to "reset" an input component #67

Closed
eclipse-faces-bot opened this issue Feb 3, 2005 · 13 comments
Closed

No easy way to "reset" an input component #67

eclipse-faces-bot opened this issue Feb 3, 2005 · 13 comments

Comments

@eclipse-faces-bot
Copy link

I've seen a lot of users looking for a way to take an input field and "reset" it back to its initial state
(talking back to the ValueBinding).

This processing code commonly would live in an actionListener for an immediate UICommand. The first
problem they run into (but don't understand) is that submittedValue is non-null at this point, so their
attempts to call setValue(), etc., are futile. If they get past that (and ignore the Javadoc warning users
not to call setSubmittedValue()!), then there's the subtleties of isLocalValueSet().

A band-aid for the problem would be adding some sort of "reset()" or "resetValue()" to UIInput that
would call the following three methods:

  • setValue(null)
  • setSubmittedValue(null)
  • setLocalValueSet(false)

Environment

Operating System: All
Platform: All

Affected Versions

[1.1]

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
Reported by adamwiner

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
Issue-Links:
blocks
JAVASERVERFACES_SPEC_PUBLIC-566

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
@edburns said:
Seems reasonable and won't break backwards compatability.

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
@edburns said:
accept.

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
@edburns said:
It's too bad we can't add this method to EditableValueHolder.

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
@edburns said:
[67-UIInputReset]

This checkin implements the reset feature for UIInput.

idea: adam.winer
r=edburns

M src/javax/faces/component/UIInput.java

  • add resetValue()

  • Convenience method to reset this component's value to the

  • un-initialized state. This method does the following:


    *

  • Call {@link #setValue} passing null.

    * *

    Call {@link #setSubmittedValue} passing null.

    * *

    Call {@link #setLocalValueSet} passing false.

    * *

    Call {@link #setValid} passing true.

    * *

    Upon return from this call if the instance had a * ValueBinding associated with it for the "value" * property, this binding is evaluated when {@link * UIOutput#getValue} is called. Otherwise, null is * returned from getValue().

    M test/javax/faces/component/UIInputTestCase.java

    • test resetValue()

    Index: src/javax/faces/component/UIInput.java

    RCS file:
    /cvs/javaserverfaces-sources/jsf-api/src/javax/faces/component/UIInput.java,v
    retrieving revision 1.77
    diff -u -r1.77 UIInput.java
    — src/javax/faces/component/UIInput.java 10 Mar 2005 21:39:14 -0000 1.77
    +++ src/javax/faces/component/UIInput.java 22 Mar 2005 20:32:00 -0000
    @@ -179,6 +179,32 @@
    }

    /**

      • Convenience method to reset this component's value to the

      • un-initialized state. This method does the following:

    passing null.

      • Call

    {@link #setSubmittedValue}

    passing null.

      • Call

    {@link #setLocalValueSet}

    passing false.

      • Call

    {@link #setValid}

    passing true.

      • Upon return from this call if the instance had a

      • ValueBinding associated with it for the "value"
      • property, this binding is evaluated when

    {@link + * UIOutput#getValue}

    is called. Otherwise, null is

      • returned from getValue().

    • */
    • public void resetValue()

    { + this.setValue(null); + this.setSubmittedValue(null); + this.setLocalValueSet(false); + this.setValid(true); + }

    • /**
  • The "localValueSet" state for this component. */ private boolean localValueSet; Index: test/javax/faces/component/UIInputTestCase.java =================================================================== RCS file: /cvs/javaserverfaces-sources/jsf-api/test/javax/faces/component/UIInputTestCase.java,v retrieving revision 1.35 diff -u -r1.35 UIInputTestCase.java * * test/javax/faces/component/UIInputTestCase.java 7 Mar 2005 21:50:28 -0000 1.35 +++ test/javax/faces/component/UIInputTestCase.java 22 Mar 2005 20:32:01 -0000 @@ -333,6 +333,12 @@ assertNull(input.getLocalValue()); assertTrue(input.isValid()); checkMessages(0); + input.resetValue(); + assertNull(input.getLocalValue()); + assertEquals("new command", input.getValue()); + assertNull(input.getSubmittedValue()); + assertTrue(input.isValid()); + assertTrue(!input.isLocalValueSet());

// Skip update on an invalid value
input.setValid(false);

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
@edburns said:
fixed

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
@edburns said:
Prepare to delete api subcomponent

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
@edburns said:
Move all to 1.2

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
Marked as fixed on Thursday, March 4th 2010, 6:09:29 am

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
@manfredriem said:
Closing resolved issue out

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
This issue was imported from java.net JIRA JAVASERVERFACES_SPEC_PUBLIC-67

@eclipse-faces-bot
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant