public class Form extends HtmlForm
The <o:form>
is a component that extends the standard <h:form>
and provides a
way to keep view or request parameters in the request URL after a post-back and offers in combination with the
<o:ignoreValidationFailed>
tag on an UICommand
component the possibility to ignore
validation failures so that the invoke action phase will be executed anyway. This component also supports adding
query string parameters to the action URL via nested <f:param>
and <o:param>
.
You can use it the same way as <h:form>
, you only need to change h:
to
o:
.
The standard UIForm
doesn't put the original view parameters in the action URL that's used for the post-back.
Instead, it relies on those view parameters to be stored in the state associated with the standard
UIViewParameter
. Via this state those parameters are invisibly re-applied after every post-back.
The disadvantage of this invisible retention of view parameters is that the user doesn't see them anymore in the address bar of the browser that is used to interact with the faces application. Copy-pasting the URL from the address bar or refreshing the page by hitting enter inside the address bar will therefore not always yield the expected results.
To solve this, this component offers an attribute includeViewParams="true"
that will optionally include
all view parameters, in exactly the same way that this can be done for <h:link>
and
<h:button>
.
<o:form includeViewParams="true">
This setting is ignored when includeRequestParams="true"
or useRequestURI="true"
is used.
As an alternative to includeViewParams
, you can use includeRequestParams="true"
to
optionally include the current GET request query string.
<o:form includeRequestParams="true">
This setting overrides the includeViewParams
.
This setting is ignored when useRequestURI="true"
is used.
As an alternative to includeViewParams
and includeRequestParams
, you can use
useRequestURI="true"
to use the current request URI, including with the GET request query string, if
any. This is particularly useful if you're using FacesViews or forwarding everything to 1 page. Otherwise, by default
the current view ID will be used.
<o:form useRequestURI="true">
This setting overrides the includeViewParams
and includeRequestParams
.
The standard UIForm
doesn't support adding query string parameters to the action URL. This component offers
this possibility via nested <f:param>
and <o:param>
.
<o:form> <f:param name="somename" value="somevalue" /> ... </o:form>
This can be used in combination with useRequestURI
, includeViewParams
and
includeRequestParams
. The <f|o:param>
will override any included view or request
parameters on the same name. To conditionally add or override, use the disabled
attribute of
<f|o:param>
.
The support was added in OmniFaces 2.2.
In order to properly use the <o:ignoreValidationFailed>
tag on an UICommand
component, its
parent <h:form>
component has to be replaced by this <o:form>
component.
See also IgnoreValidationFailed
.
Modifier and Type | Field and Description |
---|---|
static String |
COMPONENT_TYPE |
COMPONENT_FAMILY
ATTRS_WITH_DECLARED_DEFAULT_VALUES, BEANINFO_KEY, bindings, COMPOSITE_COMPONENT_TYPE_KEY, COMPOSITE_FACET_NAME, CURRENT_COMPONENT, CURRENT_COMPOSITE_COMPONENT, FACETS_KEY, HONOR_CURRENT_COMPONENT_ATTRIBUTES_PARAM_NAME, VIEW_LOCATION_KEY
SEPARATOR_CHAR
Constructor and Description |
---|
Form() |
Modifier and Type | Method and Description |
---|---|
void |
encodeBegin(FacesContext context) |
boolean |
isIgnoreValidationFailed()
Returns whether or not the form should ignore validation fail (and thus proceed to update model/invoke action).
|
boolean |
isIncludeRequestParams()
Returns whether or not the request parameters should be encoded into the form's action URL.
|
boolean |
isIncludeViewParams()
Returns whether or not the view parameters should be encoded into the form's action URL.
|
boolean |
isUseRequestURI()
Returns whether or not the request URI should be used as form's action URL.
|
void |
processUpdates(FacesContext context) |
void |
processValidators(FacesContext context) |
void |
setIgnoreValidationFailed(boolean ignoreValidationFailed)
Set whether or not the form should ignore validation fail.
|
void |
setIncludeRequestParams(boolean includeRequestParams)
Set whether or not the request parameters should be encoded into the form's action URL.
|
void |
setIncludeViewParams(boolean includeViewParams)
Set whether or not the view parameters should be encoded into the form's action URL.
|
void |
setUseRequestURI(boolean useRequestURI)
Set whether or not the request URI should be used as form's action URL.
|
getAccept, getAcceptcharset, getDefaultEventName, getDir, getEnctype, getEventNames, getLang, getOnclick, getOndblclick, getOnkeydown, getOnkeypress, getOnkeyup, getOnmousedown, getOnmousemove, getOnmouseout, getOnmouseover, getOnmouseup, getOnreset, getOnsubmit, getRole, getStyle, getStyleClass, getTarget, getTitle, setAccept, setAcceptcharset, setDir, setEnctype, setLang, setOnclick, setOndblclick, setOnkeydown, setOnkeypress, setOnkeyup, setOnmousedown, setOnmousemove, setOnmouseout, setOnmouseover, setOnmouseup, setOnreset, setOnsubmit, setRole, setStyle, setStyleClass, setTarget, setTitle
createUniqueId, getContainerClientId, getFamily, isPrependId, isSubmitted, processDecodes, setPrependId, setSubmitted, visitTree
addClientBehavior, addFacesListener, broadcast, clearInitialState, decode, encodeChildren, encodeEnd, findComponent, getAttributes, getChildCount, getChildren, getClientBehaviors, getClientId, getFacesContext, getFacesListeners, getFacet, getFacetCount, getFacets, getFacetsAndChildren, getId, getListenersForEventClass, getParent, getPassThroughAttributes, getRenderer, getRendererType, getRendersChildren, getValueBinding, invokeOnComponent, isRendered, isTransient, markInitialState, processRestoreState, processSaveState, queueEvent, removeFacesListener, restoreAttachedState, restoreState, saveAttachedState, saveState, setId, setParent, setRendered, setRendererType, setTransient, setValueBinding, subscribeToEvent, unsubscribeFromEvent
encodeAll, getClientId, getCompositeComponentParent, getCurrentComponent, getCurrentCompositeComponent, getNamingContainer, getPassThroughAttributes, getResourceBundleMap, getStateHelper, getStateHelper, getTransientStateHelper, getTransientStateHelper, getValueExpression, initialStateMarked, isCompositeComponent, isInView, isVisitable, popComponentFromEL, processEvent, pushComponentToEL, restoreTransientState, saveTransientState, setInView, setValueExpression
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addClientBehavior, getClientBehaviors
public static final String COMPONENT_TYPE
public void processValidators(FacesContext context)
processValidators
in class UIForm
public void processUpdates(FacesContext context)
processUpdates
in class UIForm
public void encodeBegin(FacesContext context) throws IOException
encodeBegin
in class UIComponentBase
IOException
public boolean isIncludeViewParams()
public void setIncludeViewParams(boolean includeViewParams)
includeViewParams
- The state of the switch for encoding view parameterspublic boolean isIncludeRequestParams()
public void setIncludeRequestParams(boolean includeRequestParams)
includeRequestParams
- The state of the switch for encoding request parameters.public boolean isUseRequestURI()
public void setUseRequestURI(boolean useRequestURI)
useRequestURI
- The state of the switch for using request URI.public boolean isIgnoreValidationFailed()
public void setIgnoreValidationFailed(boolean ignoreValidationFailed)
ignoreValidationFailed
- Whether or not the form should ignore validation fail.Copyright © 2012–2019 OmniFaces. All rights reserved.