myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Toppac <>
Subject Re: Converter.getAsString not called?
Date Fri, 06 Jul 2007 21:27:30 GMT

Ok I follow. There a couple of problems here though. let's say my converter
is for java.lang.Integer and the submitted value from the POST is "abc". I
can't use the default converter since it will throw an exception and try to
skip directly to renderResponse, not what i want to happen. Right now my
converter is just returning null at this point and caches the submitted
value. The rest of the lifecycle goes through and during update model the
submitted value is set to null since updateModel succeeds.

During renderResponse it appears that it tries to get the value from the
component first, and if the component does not have a value it tries to get
it from evaluating the value binding (see UiOutput.getValue). In this case
they are both null, which is expected. But it never tries to call my
converter which would restore the cached submitted valued.

Andrew Robinson-5 wrote:
> Typical UIInput behavior:
> Decode phase ->
> Is there a value in the POST values with the current component's client
> ID?
> If so, set the submitted value to that
> Validate phase ->
> If there is a submitted value, get the converter
> If there is a converter, convert the submitted value using getAsObject
> Validate the submitted value
> If valid, set the local value
> Update phase ->
> If there is a local value, update the value binding property
> Render phase ->
> If there is a submitted value, render that
> Otherwise, get the value from the component
> If there is a converter, convert the value using getAsString
> Render the value
> So as you can see, as long as a UIInput control has a submitted value,
> it will never render the value from the value attribute of the
> component. Typically submitted values are only cleared in the validate
> method of UIInput (if the converted value is valid)
> On 7/6/07, Toppac <> wrote:
>> I don't think I follow what you are saying exactly. Can you elaborate?
>> Andrew Robinson-5 wrote:
>> >
>> > Converter will only be called if there is no submitted value.
>> > Submitted values are already technically converted as they came from
>> > the client, so there is no need to use the converter.
>> >
>> > On 7/6/07, Toppac <> wrote:
>> >>
>> >> Just for a small background. I am trying to find a way to fail
>> validation
>> >> and/or conversion without dumping out of the JSF lifecycle to render
>> >> response. I'd like to inject a custom converter that when it fails to
>> >> convert it saves the submitted value to a session scoped Map and then
>> >> during
>> >> render response, when it tries to render the component that failed
>> >> conversion, the getAsString method would see that the incoming value
>> is
>> >> null
>> >> and would go to the session map to grab the last submitted value.
>> >>
>> >> Sounds easy enough and should work. But when I tried it, it appears
>> that
>> >> during render response, if the value on the domain model is null (or
>> if
>> >> the
>> >> component value is null, not sure) it does not call the
>> >> converter.getAsString method. I am not sure why. If someone can tell
>> me
>> >> why
>> >> and where it makes this decision that would be great. If this is a bug
>> >> then
>> >> great also. But if it is not a bug then can anyone suggest a way to do
>> >> what
>> >> I am trying to do?
>> >> --
>> >> View this message in context:
>> >>
>> >> Sent from the MyFaces - Users mailing list archive at
>> >>
>> >>
>> >
>> >
>> --
>> View this message in context:
>> Sent from the MyFaces - Users mailing list archive at

View this message in context:
Sent from the MyFaces - Users mailing list archive at

View raw message