You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Simon Kitching (JIRA)" <de...@myfaces.apache.org> on 2005/11/16 22:08:29 UTC

[jira] Commented: (MYFACES-833) HtmlFormRendererBase saves form state before components have been rendered - breaks auto id generation

    [ http://issues.apache.org/jira/browse/MYFACES-833?page=comments#action_12357815 ] 

Simon Kitching commented on MYFACES-833:
----------------------------------------

Are you aware that the ViewHandler.writeState method simply writes a special marker string into the response stream, not the actual state?
Once the entire page has been processed, code goes back and finds those special state markers and replaces them with the actual state.

That's why the comment is there on that line of code.

See JspViewHandlerImpl.java method writeState, and ViewTag.java method doAfterBody.

> HtmlFormRendererBase saves form state before components have been rendered - breaks auto id generation
> ------------------------------------------------------------------------------------------------------
>
>          Key: MYFACES-833
>          URL: http://issues.apache.org/jira/browse/MYFACES-833
>      Project: MyFaces
>         Type: Bug
>   Components: Implementation
>     Versions: 1.1.0
>  Environment: Sun JDK 1.5
> Windows XP
> Facelets 1.0d/1.0e
> Tomcat 5.x
>     Reporter: Max Muermann
>  Attachments: HtmlFormRendererBase.java.diff
>
> In HtmlFormRendererBase, the following code is executed in the encodeBegin() method:
> //write state marker at the beginning of the form
> ViewHandler viewHandler = facesContext.getApplication().getViewHandler();
> viewHandler.writeState(facesContext);
> This causes problems (especially when using facelets), as some components first call getClientId() - which causes a new id for the component to be generated by the ViewRoot - in their own encodeBegin() method.
> If this is the case, as the form encodeBegin() is called before any of its child components are rendered, those components that do not yet have an id assigned save their state with a null id. When the view state is restored in the next request, these ids will be regenerated, starting with _id0. However, if there are other components in the page that also require autogenerated ids, some ids will be duplicated and the "problem" components will receive different ids to when they were first rendered.
> Attached is a patch to HtmlFormRendererBase which moves the state saving operation of the form to the encodeEnd() method, where all child components will have been rendered and therefore will have called getClientId() at least once.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira