You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Kaeri Johnson (JIRA)" <de...@myfaces.apache.org> on 2009/03/06 20:37:56 UTC

[jira] Created: (MYFACES-2161) MyFaces-API issue: getValue of UIInput

MyFaces-API issue: getValue of UIInput
--------------------------------------

                 Key: MYFACES-2161
                 URL: https://issues.apache.org/jira/browse/MYFACES-2161
             Project: MyFaces Core
          Issue Type: Bug
          Components: JSR-252
    Affects Versions: 1.2.6
            Reporter: Kaeri Johnson


Issue was seen and fixed in Myfaces 1.1.6 already- but seems to still exist in 1.2.6 

UIOutput currently has the following code:

     public Object getValue()
     {
         if (_value != null) return _value;
         ValueBinding vb = getValueBinding("value");
         return vb != null ? (Object)vb.getValue(getFacesContext()) : null;
     }

UIInput has the following code:

     public void setValue(Object value)
     {
         setLocalValueSet(true);
         super.setValue(value);
     }

My problem (pseudo code):

1) user enters an empty string in an input-component: ""
2) conversion and validation phase: "" --> setValue(null);
isLocalValueSet = true; setSubmittedValue(null);
3) validation fails in some component on the page --> update model
phase is skipped
4) renderer calls getValue(); --> getValue() evaluates the
value-binding, as the local-value is 'null', and I get the
default-value of the bean shown again

proposed solution:

UIInput overwrites getValue of UIOutput:

     public Object getValue()
     {
         if (isLocalValueSet()) return _value;
         ValueBinding vb = getValueBinding("value");
         return vb != null ? (Object)vb.getValue(getFacesContext()) : null;
     }


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (MYFACES-2161) MyFaces-API issue: getValue of UIInput

Posted by "Leonardo Uribe (JIRA)" <de...@myfaces.apache.org>.
     [ https://issues.apache.org/jira/browse/MYFACES-2161?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Leonardo Uribe resolved MYFACES-2161.
-------------------------------------

       Resolution: Fixed
    Fix Version/s: 1.2.7-SNAPSHOT
         Assignee: Leonardo Uribe

> MyFaces-API issue: getValue of UIInput
> --------------------------------------
>
>                 Key: MYFACES-2161
>                 URL: https://issues.apache.org/jira/browse/MYFACES-2161
>             Project: MyFaces Core
>          Issue Type: Bug
>          Components: JSR-252
>    Affects Versions: 1.2.6
>            Reporter: Kaeri Johnson
>            Assignee: Leonardo Uribe
>             Fix For: 1.2.7-SNAPSHOT
>
>
> Issue was seen and fixed in Myfaces 1.1.6 already- but seems to still exist in 1.2.6 
> UIOutput currently has the following code:
>      public Object getValue()
>      {
>          if (_value != null) return _value;
>          ValueBinding vb = getValueBinding("value");
>          return vb != null ? (Object)vb.getValue(getFacesContext()) : null;
>      }
> UIInput has the following code:
>      public void setValue(Object value)
>      {
>          setLocalValueSet(true);
>          super.setValue(value);
>      }
> My problem (pseudo code):
> 1) user enters an empty string in an input-component: ""
> 2) conversion and validation phase: "" --> setValue(null);
> isLocalValueSet = true; setSubmittedValue(null);
> 3) validation fails in some component on the page --> update model
> phase is skipped
> 4) renderer calls getValue(); --> getValue() evaluates the
> value-binding, as the local-value is 'null', and I get the
> default-value of the bean shown again
> proposed solution:
> UIInput overwrites getValue of UIOutput:
>      public Object getValue()
>      {
>          if (isLocalValueSet()) return _value;
>          ValueBinding vb = getValueBinding("value");
>          return vb != null ? (Object)vb.getValue(getFacesContext()) : null;
>      }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (MYFACES-2161) MyFaces-API issue: getValue of UIInput

Posted by "Leonardo Uribe (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/MYFACES-2161?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12680685#action_12680685 ] 

Leonardo Uribe commented on MYFACES-2161:
-----------------------------------------


 This problem suppose that UIInput component uses a converter that convert empty strings to null values. It seems that the solution done in 1.1.x branch were not applied on 1.2.x. Maybe it was because default converter for HtmlInputText does not convert empty strings to null values.

The solution committed is put this code on UIInput:

    public Object getValue()
    {
        if (isLocalValueSet()) return super.getLocalValue();
        return super.getValue();
    }

I have committed a test that reproduce this scenario too.

> MyFaces-API issue: getValue of UIInput
> --------------------------------------
>
>                 Key: MYFACES-2161
>                 URL: https://issues.apache.org/jira/browse/MYFACES-2161
>             Project: MyFaces Core
>          Issue Type: Bug
>          Components: JSR-252
>    Affects Versions: 1.2.6
>            Reporter: Kaeri Johnson
>             Fix For: 1.2.7-SNAPSHOT
>
>
> Issue was seen and fixed in Myfaces 1.1.6 already- but seems to still exist in 1.2.6 
> UIOutput currently has the following code:
>      public Object getValue()
>      {
>          if (_value != null) return _value;
>          ValueBinding vb = getValueBinding("value");
>          return vb != null ? (Object)vb.getValue(getFacesContext()) : null;
>      }
> UIInput has the following code:
>      public void setValue(Object value)
>      {
>          setLocalValueSet(true);
>          super.setValue(value);
>      }
> My problem (pseudo code):
> 1) user enters an empty string in an input-component: ""
> 2) conversion and validation phase: "" --> setValue(null);
> isLocalValueSet = true; setSubmittedValue(null);
> 3) validation fails in some component on the page --> update model
> phase is skipped
> 4) renderer calls getValue(); --> getValue() evaluates the
> value-binding, as the local-value is 'null', and I get the
> default-value of the bean shown again
> proposed solution:
> UIInput overwrites getValue of UIOutput:
>      public Object getValue()
>      {
>          if (isLocalValueSet()) return _value;
>          ValueBinding vb = getValueBinding("value");
>          return vb != null ? (Object)vb.getValue(getFacesContext()) : null;
>      }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.