myfaces-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Martin Marinschek" <martin.marinsc...@gmail.com>
Subject Re: MyFaces-API issue: getValue of UIInput
Date Sun, 04 Mar 2007 00:33:34 GMT
I forwarded the thread to Ed, as neither Adam, Craig, Kito or Manfred
had anything to say on this... or do they?

There is an alternative workaround: I checked it in RendererUtils
yesterday - for you to review. However, I think it makes the value
lookup code in the renderer very complicated. It might cause less
issues with compatibility to the RI behaviour, though.

regards,

Martin

On 3/2/07, Cagatay Civici <cagatay.civici@gmail.com> wrote:
> > Yeah, exactly. Did you read my mail from before? Plus my new
> issue-evaluation?
>
> No, I read your mail after sending a reply about the converter, anyway
> you're right about the bug Martin.
>
> > In this case, I'd strongly recommend that you run this by the spec
> > folks.   If nothing else, we should get a clarification for the next
> > revision.
>
> I agree with Mike
>
>  On 3/2/07, Mike Kienenberger <mkienenb@gmail.com> wrote:
> > In this case, I'd strongly recommend that you run this by the spec
> > folks.   If nothing else, we should get a clarification for the next
> > revision.
> >
> > On 3/1/07, Martin Marinschek < martin.marinschek@gmail.com> wrote:
> > > I didn't find anything in the spec.
> > >
> > > JavaDoc of getValue in UIOutput says:
> > >
> > > Gets the value of this UIComponent. First, consult the local value
> > > property of this component. If non-null return it. If non-null, see if
> > > we have a ValueBinding for the value  property. If so, return the
> > > result of evaluating the property, otherwise return null.
> > >
> > > This description is obviously wrong (two times "If non-null.."), but
> > > if you correct this obvious  mistake, it speaks against my solution.
> > >
> > > But then, reading the spec on a more general level it says:
> > >
> > > 3.1.4 Value Binding Expressions
> > >
> > > Properties and attributes of standard concrete component classes may be
> value
> > > binding enabled. This means that, rather than specifying a literal value
> as the
> > > parameter to a property or attribute setter, the caller instead
> associates a
> > > ValueBinding (see Section 5.3.3 "ValueBinding") whose getValue() method
> must
> > > be called (by the property getter) to return the actual property value
> > > to be returned
> > > if no value has been set via the corresponding property setter. If a
> property or
> > > attribute value has been set, that value must be returned by the
> property getter
> > > (shadowing any associated value binding expression for this property).
> > >
> > > and this would clearly indicate I'm on the right track. Properly
> > > reading this would mean we are wrong-doers for every component
> > > attribute of every component, even if the chance is rather small that
> > > the issue arises for normal attributes (it might definitely happen
> > > though).
> > >
> > > regards,
> > >
> > > Martin
> > >
> > > On 3/1/07, Mike Kienenberger < mkienenb@gmail.com> wrote:
> > > > What's the spec say about UIInput's getValue()?   If it's silent, I'd
> > > > say your solution makes sense.
> > > >
> > > >
> > > > On 3/1/07, Martin Marinschek < martin.marinschek@gmail.com> wrote:
> > > > > Wanted to discuss a small thing with you:
> > > > >
> > > > > 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;
> > > > >       }
> > > > >
> > > > > everyone d'accord?
> > > > >
> > > > > regards,
> > > > >
> > > > > Martin
> > > > >
> > > > > --
> > > > >
> > > > > http://www.irian.at
> > > > >
> > > > > Your JSF powerhouse -
> > > > > JSF Consulting, Development and
> > > > > Courses in English and German
> > > > >
> > > > > Professional Support for Apache MyFaces
> > > > >
> > > >
> > >
> > >
> > > --
> > >
> > > http://www.irian.at
> > >
> > > Your JSF powerhouse -
> > > JSF Consulting, Development and
> > > Courses in English and German
> > >
> > > Professional Support for Apache MyFaces
> > >
> >
>
>


-- 

http://www.irian.at

Your JSF powerhouse -
JSF Consulting, Development and
Courses in English and German

Professional Support for Apache MyFaces

Mime
View raw message