I need to set a value to bean that was retrieved on page via a request scoped managed bean #{pim}(when the page initially loaded) to #{requestScope} when commandButton is pressed.
However when the command button is pressed it uses the value of freshly instantiated #{pim} bean which would be empty.
#{pim.targetId}
<p:commandButton value="View">
<f:setPropertyActionListener value="#{pim.targetId}" target="#{requestScope.id}" />
</p:commandButton>
But this doesn’t work as #{pim} bean containing value got destroyed after request. I expected it to work hoping that it would assign the value that was retrieved when the page loaded but it doesnt work that way.
Use
<f:param>instead of<f:setPropertyActionListener>. The former sets the request parameter directly in the generated ajax script during rendering the command button, while the latter sets the property entirely in the server side during processing the form submit (which is thus already lost as this concerns a brand new request and it’s a request scoped property).with