JSF: Reload request scope property after ajax-request
I have a hidden input field, which value is read from a property of the request scope:
<h:inputHidden id="myHiddenField" value="#{requestScope['myVar']}" />
I trigger an Ajax-Request where I change the value of myVar
.
<p:commandButton value="submit" action="#{myController.doSomething}" update="myHiddenField">
But my input field still contains the old value.
Any idea how I can solve this?
UPDATE:
Maybe I have to explain it a little bit more.. myVar
contains t开发者_StackOverflow社区he IDs of all input fields with an error message (facesContext.getClientIdsWithMessages()
).
When I first submit the form (with some validation errors) it works as expected. When I resubmit the form with some other validation errors the value of myVar
doesn't get updated... (Still contains the IDs of the 'old' errors) When I resubmit the form with no validation errors myVar
gets updated. (myVar
is empty now)
If you want to access a bean after the page has been loaded it needs to be at least ViewScoped. RequestScoped beans are destroyed when the page is loaded (the request is handled and there is no need for it anymore).
精彩评论