The <o:viewAction> is a component that extends the standard <f:viewAction> and
changes the if attribute to be evaluated during INVOKE_APPLICATION phase instead of the
APPLY_REQUEST_VALUES phase. This allows developers to let the if attribute check the
converted and validated model values before performing the view action, which results in much more intuitive behavior.
In below example, the FooConverter may convert a non-null parameter to null without causing
a validation or conversion error, and the intent is to redirect the current page to otherpage.xhtml when
the converted result is null.
<f:viewParam name="foo" value="#{bean.foo}" converter="fooConverter" />
<f:viewAction action="otherpage" if="#{bean.foo eq null}" />
This is however not possible with standard <f:viewAction> as it evaluates the if
attribute already before the conversion has taken place. This component solves that by postponing the evaluation of
the if attribute to the INVOKE_APPLICATION phase.
<f:viewParam name="foo" value="#{bean.foo}" converter="fooConverter" />
<o:viewAction action="otherpage" if="#{bean.foo eq null}" />
Only when you set immediate="true", then it will behave the same as the standard
<f:viewAction>.
You can use it the same way as <f:viewAction>, you only need to change f: to
o:.
<o:viewAction action="otherpage" if="#{bean.property eq null}" />
You can use the message attribute to add a global flash warning message.
<o:viewAction ... message="Please use a valid link from within the site" />
Note that the message will only be shown when the redirect has actually taken place. The support was added in OmniFaces 3.2.
| Info | Value |
|---|---|
| Component Type | org.omnifaces.component.input.ViewAction |
| Handler Class | None |
| Renderer Type | None |
| Description | None |
| Name | Required | Type | Description |
|---|---|---|---|
action | false | jakarta.el.MethodExpression
(signature must match java.lang.Object action())
| MethodExpression representing the application action to invoke when this component is activated. The expression must evaluate to a public method that takes no parameters, and returns an Object (the logical outcome) which is passed to the NavigationHandler for this application. |
actionListener | false | jakarta.el.MethodExpression
(signature must match void processAction(jakarta.faces.event.ActionEvent))
| MethodExpression representing an action listener method that will be notified when this component is activated. The expression must evaluate to a public method that takes an ActionEvent parameter, with a return type of void. |
binding | false | jakarta.el.ValueExpression
(must evaluate to jakarta.faces.component.UIComponent)
| The ValueExpression linking this component to a property in a backing bean. |
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. |
if | false | jakarta.el.ValueExpression
(must evaluate to boolean)
| Invoke the application action only when this attribute evaluates true during the specified phase. The default is true. |
immediate | false | jakarta.el.ValueExpression
(must evaluate to boolean)
| Flag indicating that, if this component is activated by the user, notifications should be delivered to interested listeners and actions immediately (that is, during Apply Request Values phase) rather than waiting until Invoke Application phase. |
message | false | jakarta.el.ValueExpression
(must evaluate to java.lang.String)
| The global flash warning message to be shown in the redirected page. |
onPostback | false | jakarta.el.ValueExpression
(must evaluate to boolean)
| View actions are most commonly used on the initial view request. Therefore, view actions do not operate on postback, by default. This attribute enables a view action to operate on postback. |
phase | false | jakarta.el.ValueExpression
(must evaluate to java.lang.String)
| Specifies the phase in which the action invocation should occur using the name of the phase constant in the PhaseId class (the case does not matter). The value must be one of APPLY_REQUEST_VALUES, PROCESS_VALIDATIONS, UPDATE_MODEL_VALUES, or INVOKE_APPLICATION. The default is INVOKE_APPLICATION. |
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. |
Output generated by Vdldoc View Declaration Language Documentation Generator.