Question

With this code :

<f:metadata>
   <f:viewParam name="aParameter" value="#{myBean.aParameter}" /> 
</f:metadata>

...

<h:commandLink  value="commandLink" action="#{myBean.navigate()}">
   <f:param name="aParameter" value="TEST" />
</h:commandLink>

When I submit with the commandLink, myBean.aParameter is updated by the viewParam (seen in debug) with the value from the f:param in the UPDATE_MODEL phase.

Is this normal ?

And yes, I know the viewParam and the param have the same name, I have no choice on that.

I use Mojarra 2.1.27

Was it helpful?

Solution

I think I pieced together the reasons why it's normal :

  • commandLink's f:param's are submitted to the server (I didn't think so) and are part of the requestParametersMap
  • f:viewParam's do the entire JSF livecycle, even on postbacks
  • f:viewParam's then update their values, with what's in the requestParametersMap
  • if the requestParametersMap happens to have keys corresponding to viewParam's names, the viewParam does its thing (uses the value to update the model)

So... that's normal. I'll modify this behaviour with stateless viewParam's (like OmniFaces' o:viewParam) : no update on postbacks, no more problems !


But I don't know why my problem appeared with mojarra 2.1.27 whereas everything seemed fine with 2.1.25. Well...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top