FAQ
I have a form with 2 fields field1 and field2. During validation field2
inspects the value of field1 for a null value:
UIInput uiField1 = (UIInput) toValidate.findComponent("field1");
String field1Value = (String) uiField1.getValue();
if (field1Value == null) {
uiField1.setValid(false);
message = "Error";
context.addMessage(uiField1.getClientId(context), new
FacesMessage(message));
}
The problem is that uiField1.getValue() returns the old value instead of
the updated value. This only happens when the user deletes the value of
field1. If the user specifies antoher (not null) value in field1
uiField1.getValue() does return the correct new value.

Am I doing something wrong? Is this a bug?

Jan Bols

Search Discussions

  • Martin Marinschek at May 25, 2005 at 2:39 pm
    Another one. ;)

    this is a known bug (or a feature ;).

    good, it will be necessary to look into that very soon, I'll see if I
    get around to do that tonight.

    regards,

    Martin

    On 5/25/05, Jan Bols wrote:
    I have a form with 2 fields field1 and field2. During validation field2
    inspects the value of field1 for a null value:
    UIInput uiField1 = (UIInput) toValidate.findComponent("field1");
    String field1Value = (String) uiField1.getValue();
    if (field1Value == null) {
    uiField1.setValid(false);
    message = "Error";
    context.addMessage(uiField1.getClientId(context), new
    FacesMessage(message));
    }
    The problem is that uiField1.getValue() returns the old value instead of
    the updated value. This only happens when the user deletes the value of
    field1. If the user specifies antoher (not null) value in field1
    uiField1.getValue() does return the correct new value.

    Am I doing something wrong? Is this a bug?

    Jan Bols
  • Sean Schofield at May 25, 2005 at 4:25 pm
    Jan,

    I think Martin fixed this last night. Can you check the latest source
    code (SVN or tonight's upcoming nightly build)?

    sean
    On 5/25/05, Martin Marinschek wrote:
    Another one. ;)

    this is a known bug (or a feature ;).

    good, it will be necessary to look into that very soon, I'll see if I
    get around to do that tonight.

    regards,

    Martin

    On 5/25/05, Jan Bols wrote:
    I have a form with 2 fields field1 and field2. During validation field2
    inspects the value of field1 for a null value:
    UIInput uiField1 = (UIInput) toValidate.findComponent("field1");
    String field1Value = (String) uiField1.getValue();
    if (field1Value == null) {
    uiField1.setValid(false);
    message = "Error";
    context.addMessage(uiField1.getClientId(context), new
    FacesMessage(message));
    }
    The problem is that uiField1.getValue() returns the old value instead of
    the updated value. This only happens when the user deletes the value of
    field1. If the user specifies antoher (not null) value in field1
    uiField1.getValue() does return the correct new value.

    Am I doing something wrong? Is this a bug?

    Jan Bols
  • Jan Bols at May 27, 2005 at 2:40 pm
    Hey thanks!

    this solved the validation problem but created another one:

    1. When the user fills nothing in field1, uiField1.getValue() doesn't
    return null, but returns an empty String object. I don't know if this was
    intented.

    2. When I attach a valueChangelistener to a field that the user didn't
    change, it still triggers the valueChangeListener. The event.getOldValue()
    returns null as should be but the event.getNewValue() returns an empty
    string which isn't the same thing as null.

    Greetings
    Jan

    On Wed, 25 May 2005 18:18:14 +0200, Sean Schofield
    wrote:
    Jan,

    I think Martin fixed this last night. Can you check the latest source
    code (SVN or tonight's upcoming nightly build)?

    sean
    On 5/25/05, Martin Marinschek wrote:
    Another one. ;)

    this is a known bug (or a feature ;).

    good, it will be necessary to look into that very soon, I'll see if I
    get around to do that tonight.

    regards,

    Martin

    On 5/25/05, Jan Bols wrote:
    I have a form with 2 fields field1 and field2. During validation field2
    inspects the value of field1 for a null value:
    UIInput uiField1 = (UIInput)
    toValidate.findComponent("field1");
    String field1Value = (String) uiField1.getValue();
    if (field1Value == null) {
    uiField1.setValid(false);
    message = "Error";
    context.addMessage(uiField1.getClientId(context), new
    FacesMessage(message));
    }
    The problem is that uiField1.getValue() returns the old value instead of
    the updated value. This only happens when the user deletes the value of
    field1. If the user specifies antoher (not null) value in field1
    uiField1.getValue() does return the correct new value.

    Am I doing something wrong? Is this a bug?

    Jan Bols
  • Martin Marinschek at May 30, 2005 at 6:36 am
    Hi Jan,

    Sorry for the late answer:

    1. that is intended - if you enter an empty string into the
    input-field, this empty string should be delivered through to your
    managed bean.

    2. strange - you mean that validation fails and the
    valueChangeListener is still triggered?

    regards,

    Martin
    On 5/27/05, Jan Bols wrote:
    Hey thanks!

    this solved the validation problem but created another one:

    1. When the user fills nothing in field1, uiField1.getValue() doesn't
    return null, but returns an empty String object. I don't know if this was
    intented.

    2. When I attach a valueChangelistener to a field that the user didn't
    change, it still triggers the valueChangeListener. The event.getOldValue()
    returns null as should be but the event.getNewValue() returns an empty
    string which isn't the same thing as null.

    Greetings
    Jan

    On Wed, 25 May 2005 18:18:14 +0200, Sean Schofield
    wrote:
    Jan,

    I think Martin fixed this last night. Can you check the latest source
    code (SVN or tonight's upcoming nightly build)?

    sean
    On 5/25/05, Martin Marinschek wrote:
    Another one. ;)

    this is a known bug (or a feature ;).

    good, it will be necessary to look into that very soon, I'll see if I
    get around to do that tonight.

    regards,

    Martin

    On 5/25/05, Jan Bols wrote:
    I have a form with 2 fields field1 and field2. During validation field2
    inspects the value of field1 for a null value:
    UIInput uiField1 = (UIInput)
    toValidate.findComponent("field1");
    String field1Value = (String) uiField1.getValue();
    if (field1Value == null) {
    uiField1.setValid(false);
    message = "Error";
    context.addMessage(uiField1.getClientId(context), new
    FacesMessage(message));
    }
    The problem is that uiField1.getValue() returns the old value instead of
    the updated value. This only happens when the user deletes the value of
    field1. If the user specifies antoher (not null) value in field1
    uiField1.getValue() does return the correct new value.

    Am I doing something wrong? Is this a bug?

    Jan Bols
  • Jan Bols at May 30, 2005 at 8:24 am

    On Mon, 30 May 2005 08:36:24 +0200, Martin Marinschek wrote:

    2. strange - you mean that validation fails and the
    valueChangeListener is still triggered?
    No that's not what I mean. When you have a field with only a
    valueChangeListener attached to it, I would expect it to only trigger the
    valueChange method when the field is changed. However with my application
    the valueChange method of that field is also triggered when nothing is
    filled in. The ValueChangeEvent's oldValue is null and the newValue is an
    empty string "".

    Hope this is clearer.

    Greetings
    Jan
  • Srikanth Madarapu at May 25, 2005 at 5:12 pm
    I think you should be calling getSubmittedValue method.



    -----Original Message-----
    From: Jan Bols
    Sent: Wednesday, May 25, 2005 10:33 AM
    To: users@myfaces.apache.org
    Subject: UIInput.getValue returns old value


    I have a form with 2 fields field1 and field2. During validation field2
    inspects the value of field1 for a null value:
    UIInput uiField1 = (UIInput) toValidate.findComponent("field1");
    String field1Value = (String) uiField1.getValue();
    if (field1Value == null) {
    uiField1.setValid(false);
    message = "Error";
    context.addMessage(uiField1.getClientId(context), new
    FacesMessage(message));
    }
    The problem is that uiField1.getValue() returns the old value instead of
    the updated value. This only happens when the user deletes the value of
    field1. If the user specifies antoher (not null) value in field1
    uiField1.getValue() does return the correct new value.

    Am I doing something wrong? Is this a bug?

    Jan Bols
  • Martin Marinschek at May 26, 2005 at 5:22 am
    Well, I think it should now be fixed. Try out the nightly build now
    and tell us if any problems occurr with that version!

    regards,

    Martin
    On 5/25/05, Srikanth Madarapu wrote:
    I think you should be calling getSubmittedValue method.



    -----Original Message-----
    From: Jan Bols
    Sent: Wednesday, May 25, 2005 10:33 AM
    To: users@myfaces.apache.org
    Subject: UIInput.getValue returns old value


    I have a form with 2 fields field1 and field2. During validation field2
    inspects the value of field1 for a null value:
    UIInput uiField1 = (UIInput) toValidate.findComponent("field1");
    String field1Value = (String) uiField1.getValue();
    if (field1Value == null) {
    uiField1.setValid(false);
    message = "Error";
    context.addMessage(uiField1.getClientId(context), new
    FacesMessage(message));
    }
    The problem is that uiField1.getValue() returns the old value instead of
    the updated value. This only happens when the user deletes the value of
    field1. If the user specifies antoher (not null) value in field1
    uiField1.getValue() does return the correct new value.

    Am I doing something wrong? Is this a bug?

    Jan Bols

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupusers @
categoriesmyfaces
postedMay 25, '05 at 2:32p
activeMay 30, '05 at 8:24a
posts8
users4
websitemyfaces.apache.org

People

Translate

site design / logo © 2019 Grokbase