You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by Sylvain Vieujot <sv...@apache.org> on 2004/12/09 06:09:41 UTC

Commun error on restoring submitted values

While playing with the htmlEditor component, I found that if a page is
only refreshed (like when you click on a tab of an x:panelTab), then the
submitted value was lost, and replaced with the component's backing bean
value.
The reason, for that is that I was using a code like this in the
renderer :

String textToRender = uiComponent.getValue();

Doing this, the textToRender is always the same until the form is
validated, and the Update Model Values phase is run. And any
intermediary rendering will just reset the data entered by the user.
A better code would be :

String textToRender = uiComponent.getSubmittedValue()!=null ?
uiComponent.getSubmittedValue() : uiComponent.getValue();

For a really correct code, look at the following helper function in :
org.apache.myfaces.renderkit.RendererUtils.getStringValue

I'm sending this email to the mailing list because it is quite easy to
fall for this bug, and I think I've already found 2 places in the
extensions renderers where we have this bug : in the calendar renderer,
and in the date renderer.
I've marked the places in the sources where I think is the bug, but we
might find other occurrences.

Sylvain.

Re: Commun error on restoring submitted values

Posted by Martin Marinschek <ma...@gmail.com>.
thanks for the info,

did you already correct the bug in the calendar renderer?

regards,

Martin


On Thu, 09 Dec 2004 01:09:41 -0400, Sylvain Vieujot <sv...@apache.org> wrote:
>  While playing with the htmlEditor component, I found that if a page is only
> refreshed (like when you click on a tab of an x:panelTab), then the
> submitted value was lost, and replaced with the component's backing bean
> value.
>  The reason, for that is that I was using a code like this in the renderer :
>  
>  String textToRender = uiComponent.getValue();
>  
>  Doing this, the textToRender is always the same until the form is
> validated, and the Update Model Values phase is run. And any intermediary
> rendering will just reset the data entered by the user.
>  A better code would be :
>  
>  String textToRender = uiComponent.getSubmittedValue()!=null ?
> uiComponent.getSubmittedValue() : uiComponent.getValue();
>  
>  For a really correct code, look at the following helper function in :
>  org.apache.myfaces.renderkit.RendererUtils.getStringValue
>  
>  I'm sending this email to the mailing list because it is quite easy to fall
> for this bug, and I think I've already found 2 places in the extensions
> renderers where we have this bug : in the calendar renderer, and in the date
> renderer.
>  I've marked the places in the sources where I think is the bug, but we
> might find other occurrences.
>  
>  Sylvain.