In JSF 2 you can pass around ids, Strings other things that can be sent as request parameters with either f:viewParam
or @ManagedProperty
(i.e. discussion here).
However, I would like to pass around objects between views, from view1 to view2. My backing beans are @ViewScoped
. I have tried the following:
<f:setPropertyActionListener value="#{view1Bean.myObject}" target="#{view2Bean.myObject}" />
This creates a view2Bean
on view1, which no longer exists when viewing view2. So, the view2Bean.myObject
is null
, because the property was never set on the specific instance of view2bean
.
I considered using the Flash scope, which seems to be exactly the tool for this. However, I read BalusC somewhere saying that it is broken in Mojarra, which I'm using.
What is the best way to pass around objects between views?