The <o:hashParam>
is a component that extends the standard <f:viewParam>
with support for setting hash query parameter values in bean and automatically reflecting updated model values in
hash query string.
The "hash query string" is the part in URL after the #
which could be formatted in the same format
as a regular request query string (the part in URL after the ?
). An example:
https://example.com/page.xhtml#foo=baz&bar=kaz
This specific part of the URL (also called hash fragment identifier) is by default not sent to the server. This component will on page load send it anyway and on every ajax request update the hash query string in client side when the model value has changed in server side. *
It's very similar to the <o:viewParam>
.
<f:metadata> <o:hashParam name="foo" value="#{bean.foo}" /> <o:hashParam name="bar" value="#{bean.bar}" /> </f:metadata>
This only requires that the JSF page has at least one {@link UIForm} component, such as <h:form>
or <o:form>
, otherwise the <o:hashParam>
won't be able to fire the ajax
request which sets the with hash query parameter values in bean. In such case an error will be printed to JS console
when the project stage is Development
.
You can use the render
attribute to declare which components should be updated when a hash parameter
value is present.
<f:metadata> <o:hashParam name="foo" value="#{bean.foo}" render="fooResult" /> <o:hashParam name="bar" value="#{bean.bar}" /> </f:metadata> ... <h:body> ... <h:panelGroup id="fooResult"> ... </h:panelGroup> ... </h:body>
You can use the default
attribute to declare a non-null value which should be interpreted as the default
value. In other words, when the current model value matches the default value, then the hash parameter will be
removed.
<f:metadata> <o:hashParam name="foo" value="#{bean.foo}" /> <o:hashParam name="bar" value="#{bean.bar}" default="kaz" /> </f:metadata>
When #{bean.foo}
is "baz"
and #{bean.bar}
is "kaz"
or empty,
then the reflected hash query string will become https://example.com/page.xhtml#foo=baz
.
If #{bean.bar}
is any other value, then it will appear in the hash query string.
Info | Value |
---|---|
Component Type | org.omnifaces.component.input.HashParam |
Handler Class | None |
Renderer Type | None |
Description | None |
Name | Required | Type | Description |
---|---|---|---|
name | true | jakarta.el.ValueExpression
(must evaluate to java.lang.String )
| The name of the hash parameter from which the value for this component is retrieved on an initial request or to override the stored value on a postback. |
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 )
| A ValueExpression enabled attribute that, if present, will be used as the text of the converter message, replacing any message that comes from the converter. |
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. |
required | false | jakarta.el.ValueExpression
(must evaluate to boolean )
| Flag indicating that the user is required to provide a submitted value for this input component. This component extends the behavior of this by only making this required for a non-faces request. |
requiredMessage | false | jakarta.el.ValueExpression
(must evaluate to java.lang.String )
| A ValueExpression enabled attribute that, if present, will be used as the text of the validation message for the "required" facility, if the "required" facility is used. |
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 )
| A ValueExpression enabled attribute that, if present, will be used as the text of the validator message, replacing any message that comes from the validator. |
value | false | jakarta.el.ValueExpression
(must evaluate to java.lang.Object )
| A ValueExpression to which the value of the hash parameter, as determined by the name attribute, is bound. The resolved value of this expression is used when encoding the view parameter into a bookmarkable link or redirect URL with view parameter encoding enabled. If this attribute is omitted, the value of the request parameter will instead be the local value of the UIViewParameter. |
default | false | jakarta.el.ValueExpression
(must evaluate to java.lang.String )
| The default value of the hash parameter. When the model value matches the default value, then the hash parameter will be hidden. |
render | false | jakarta.el.ValueExpression
(must evaluate to java.lang.String )
| A space separated string of client IDs to update after the hash param has been set in bean on page load. |
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. In the latter case, the method has no way of easily
knowing what the new value is, but this can be useful in cases
where a notification is needed that "this value
changed".
|
maxlength | false | jakarta.el.ValueExpression
(must evaluate to int )
| The maximum number of characters that may be entered in this field. |
binding | false | jakarta.el.ValueExpression
(must evaluate to jakarta.faces.component.UIComponent )
| The ValueExpression linking this component to a property in a backing bean |
Output generated by Vdldoc View Declaration Language Documentation Generator.