[
https://issues.apache.org/jira/browse/MYFACES-2645?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12854436#action_12854436
]
Jakob Korherr commented on MYFACES-2645:
----------------------------------------
I just found out that Mojarra has kinda the same problem here (tested Mojarra
2.0.2 (FCS b10)).
I used the following facelet page to test this one:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets">
<f:metadata>
<f:viewParam required="true" name="input" value="#{myBean.input}" />
</f:metadata>
<h:head>
<title>View param</title>
</h:head>
<h:body>
<h1>View param example by jakobk</h1>
<h:form>
<h:messages id="messages" />
<h:commandButton value="normal button" />
<h:commandButton value="ajax-button">
<f:ajax render="output messages" execute="@this" />
</h:commandButton>
<h:outputText id="output" value="#{myBean.input}" />
</h:form>
<ui:debug />
</h:body>
</html>
Now when I use exactly this facelet the same problem comes up in Mojarra,
because it also does not invoke encodeAll() on the UIViewParameters and so they
also lose their value after the second request. While setting render to @all
did not solve this problem in MyFaces (because we are just rendering the
contents of HtmlBody here), it would theoretically work in Mojarra (because
they render the whole view), however I got a malformedXML error on the client
side.
The easiest solution to this problem is to make PartialViewContextImpl aware of
the right usage of UIViewParameters. However I don't really like this solution,
because we have to think of handling UIViewParameters in a special way every
time we change something on any render mechanism. Maybe the "value-saving-code"
of the UIViewParameters should not be included in every different rendering
code, but in the state-saving part. Or maybe there is even a better way to save
the value of a view parameter. But this has to be decided by the EG and changed
in the spec.
For now I will commit the easiest solution to this problem and open a spec bug.
> The view state is saved before encodeAll() is called on every UIViewParameter
> in an AJAX request
> ------------------------------------------------------------------------------------------------
>
> Key: MYFACES-2645
> URL: https://issues.apache.org/jira/browse/MYFACES-2645
> Project: MyFaces Core
> Issue Type: Bug
> Components: JSR-314
> Affects Versions: 2.0.0-beta-3
> Reporter: Jakob Korherr
> Assignee: Jakob Korherr
>
> UIViewParameter calls setSubmittedValue() in encodeAll() to store the current
> value of the view parameter in the state as the submitted value (this helps
> UIViewParameter to restore its value on a postback).
> UIViewParameter.encodeAll() itself is called by UIViewRoot.encodeEnd() for
> every UIViewParameter in the view.
> If the current request is an ajax-request, the view state is currently
> already generated in UIViewRoot.encodeChildren() (before
> UIViewRoot.encodeEnd()). At this time the submitted value for every
> UIViewParameter is null, because its encodeAll()-method was not called yet.
> Later, when UIViewRoot.encodeEnd() is called, UIViewParameter.encodeAll() is
> called and it sets the submitted value correctly, but due to the fact that
> the state has already been generated, these changes are dropped.
> This causes the value of every UIViewParameter to be set to null in the next
> request, which will most likely end in validation problems with the required
> validator.
> The related thread to this issue from the mailing list can be found at:
> http://www.junlu.com/list/43/611590.html
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.