The <o:viewParam> is a component that extends the standard <f:viewParam> and
provides a stateless mode of operation and fixes the issue wherein null model values are converted to empty string
parameters in query string (e.g. when includeViewParams=true) and the (bean) validation never being
triggered when the parameter is completely absent in query string, causing e.g. @NotNull to fail.
The standard UIViewParameter implementation calls the model setter again after postback. This is not always
desired when being bound to a view scoped bean and can lead to performance problems when combined with an expensive
converter. To solve this, this component by default stores the submitted value as a component property instead of in
the model (and thus in the view state in case the binding is to a view scoped bean).
The standard UIViewParameter implementation calls the converter and validators again on postbacks. This is
not always desired when you have e.g. a required="true", but the parameter is not retained on form
submit. You would need to retain it on every single command link/button by <f:param>. To solve
this, this component doesn't call the converter and validators again on postbacks.
The <o:viewParam> also provides a default for the label atrribute. When the
label attribute is omitted, the name attribute will be used as label.
The standard UIViewParameter implementation calls the converter regardless of whether the evaluated model
value is null or not. As converters by specification return an empty string in case of null
value, this is being added to the query string as an empty parameter when e.g. includeViewParams=true is
used. This is not desired. The workaround was added in OmniFaces 1.8.
The standard UIViewParameter implementation uses in JSF 2.0-2.2 an internal "is required" check when the
submitted value is null, hereby completely bypassing the standard UIInput validation, including
any bean validation annotations and even the PreValidateEvent and PostValidateEvent events. This is
not desired. The workaround was added in OmniFaces 2.0. In JSF 2.3, this has been fixed and has only effect when
jakarta.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL context param is set to true.
The <o:viewParam> also supports providing a default value via the default
attribute. When the parameter is not available, then the value specified in default attribute will be
set in the model instead. The support was added in OmniFaces 2.2.
You can use it the same way as <f:viewParam>, you only need to change f: to
o:.
<o:viewParam name="foo" value="#{bean.foo}" />
| Info | Value |
|---|---|
| Component Type | org.omnifaces.component.input.ViewParam |
| Handler Class | None |
| Renderer Type | None |
| Description | None |
| Name | Required | Type | Description |
|---|---|---|---|
binding | false | jakarta.el.ValueExpression
(must evaluate to jakarta.faces.component.UIComponent)
| The ValueExpression linking this component to a property in a backing bean. |
converter | false | jakarta.el.ValueExpression
(must evaluate to jakarta.faces.convert.Converter)
| Converter instance registered with this component. |
converterMessage | false | jakarta.el.ValueExpression
(must evaluate to java.lang.String)
| No Description |
default | false | jakarta.el.ValueExpression
(must evaluate to java.lang.String)
| The default value in case the actual request parameter is null or empty. |
id | false | jakarta.el.ValueExpression
(must evaluate to java.lang.String)
| The component identifier for this component. This value must be unique within the closest parent component that is a naming container. |
immediate | false | jakarta.el.ValueExpression
(must evaluate to boolean)
| No Description |
name | true | jakarta.el.ValueExpression
(must evaluate to java.lang.String)
| The resourceName for this resource. This attribute is required if the script is NOT inline. |
rendered | false | jakarta.el.ValueExpression
(must evaluate to boolean)
| Flag indicating whether or not this component should be rendered (during Render Response Phase), or processed on any subsequent form submit. The default value for this property is true. |
required | false | jakarta.el.ValueExpression
(must evaluate to boolean)
| No Description |
requiredMessage | false | jakarta.el.ValueExpression
(must evaluate to java.lang.String)
| No Description |
validator | false | jakarta.el.MethodExpression
(signature must match void validate(jakarta.faces.context.FacesContext, jakarta.faces.component.UIComponent, java.lang.Object))
| MethodExpression representing a validator method that will be called during Process Validations to perform correctness checks on the value of this component. The expression must evaluate to a public method that takes FacesContext, UIComponent, and Object parameters, with a return type of void. |
validatorMessage | false | jakarta.el.ValueExpression
(must evaluate to java.lang.String)
| No Description |
value | false | jakarta.el.ValueExpression
(must evaluate to java.lang.Object)
| The current value of this component. |
valueChangeListener | false | jakarta.el.MethodExpression
(signature must match void valueChange(jakarta.faces.event.ValueChangeEvent))
| MethodExpression representing a value change listener method that will be notified when a new value has been set for this input component. The expression must evaluate to a public method that takes a ValueChangeEvent parameter, with a return type of void, or to a public method that takes no arguments with a return type of void. |
Output generated by Vdldoc View Declaration Language Documentation Generator.