f:viewParam doesn’t pass required parameter when new xmlns.jcp.org namespace is used

The way how the new xmlns.jcp.org XML namespaces are been handled is broken in the first Mojarra releases 2.2.0 and 2.2.1. It has been fixed in Mojarra 2.2.2 (note: ticket in the link describes different problem symptom, but under the covers, it’s essentially the same cause). It’s recommended to upgrade to Mojarra 2.2.2. GlassFish 4.0 … Read more

Process f:viewParam only on page load

You can achieve this by creating a custom tag extending <f:viewParam> wherein you store the submitted value as an instance variable which isn’t stored in JSF view state instead of in the JSF view state as the <f:viewParam> by default does. By end of request, all UI component instances are destroyed. They are recreated in … Read more

ViewParam vs @ManagedProperty(value = “#{param.id}”)

<f:viewParam>: Sets the value during update model values phase only (since it extends UIInput). The set value is not available during @PostConstruct, so you need an additional <f:event type=”preRenderView” listener=”#{bean.init}” /> inside the <f:metadata> to do initialization/preloading based on the set values. Since JSF 2.2 you could use <f:viewAction> for that instead. Allows for nested … Read more

What can , and be used for?

Process GET parameters The <f:viewParam> manages the setting, conversion and validation of GET parameters. It’s like the <h:inputText>, but then for GET parameters. The following example <f:metadata> <f:viewParam name=”id” value=”#{bean.id}” /> </f:metadata> does basically the following: Get the request parameter value by name id. Convert and validate it if necessary (you can use required, validator … Read more