Class InputHidden
- java.lang.Object
-
- jakarta.faces.component.UIComponent
-
- jakarta.faces.component.UIComponentBase
-
- jakarta.faces.component.UIOutput
-
- jakarta.faces.component.UIInput
-
- jakarta.faces.component.html.HtmlInputHidden
-
- org.omnifaces.component.input.InputHidden
-
- All Implemented Interfaces:
EditableValueHolder
,PartialStateHolder
,StateHolder
,TransientStateHolder
,ValueHolder
,ComponentSystemEventListener
,FacesListener
,SystemEventListenerHolder
,EventListener
public class InputHidden extends HtmlInputHidden
The
<o:inputHidden>
is a component that extends the standard<h:inputHidden>
and changes the behavior to immediately convert, validate and update during apply request values phase, regardless of any conversion/validation errors on otherUIInput
components within the same form. The standard<h:inputHidden>
follows the same lifecycle as otherUIInput
components which is in the end unintuive as hidden input fields are usually under control of the developer.Use case 1: Imagine a form with a
<h:inputHidden>
and a<h:inputText>
. The hidden input holds some prepopulated value of a request scoped bean which is intended to be passed through to the request scoped bean instance of the next request. However, when conversion/validation fails on the text input, then the hidden input won't update the bean property and then becomes empty. I.e. the original value gets permanently lost. This can be bypassed by using ajax to update only specific fields, but this will fail when the update of the hidden input is actually needed (e.g. because the value can possibly be adjusted in action/listener method).Use case 2: Imagine a form with an
UIInput
orUICommand
component whoserendered
attribute relies on a request scoped bean property which is retained for the next request through a<h:inputHidden>
. However, when Faces needs to decode theUIInput
orUICommand
component during the postback, therendered
attribute has defaulted back tofalse
because the<h:inputHidden>
hasn't yet updated the request scoped bean property yet.This behavior cannot be achieved by using
immediate="true"
on<h:inputHidden>
. It would only move the conversion/validation into the apply request values phase. The model still won't be updated on time.Usage
You can use it the same way as
<h:inputHidden>
, you only need to changeh:
intoo:
to get the "immediate v2.0" behavior.<h:form> <o:inputHidden value="#{bean.hidden}" /> ... </h:form>
When using ajax, don't forget to make sure that the component is also covered by the
execute
attribute.- Since:
- 3.7
- Author:
- Bauke Scholtz
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class jakarta.faces.component.html.HtmlInputHidden
HtmlInputHidden.PropertyKeys
-
-
Field Summary
Fields Modifier and Type Field Description static String
COMPONENT_TYPE
The component type, which is "org.omnifaces.component.input.InputHidden".-
Fields inherited from class jakarta.faces.component.UIInput
ALWAYS_PERFORM_VALIDATION_WHEN_REQUIRED_IS_TRUE, COMPONENT_FAMILY, CONVERSION_MESSAGE_ID, EMPTY_STRING_AS_NULL_PARAM_NAME, REQUIRED_MESSAGE_ID, UPDATE_MESSAGE_ID, VALIDATE_EMPTY_FIELDS_PARAM_NAME
-
Fields inherited from class jakarta.faces.component.UIComponent
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
-
-
Constructor Summary
Constructors Constructor Description InputHidden()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
decode(FacesContext context)
This override performs decode, validate and update at once.void
processUpdates(FacesContext context)
This override which does effectively nothing prevents Faces from performing update for second time.void
processValidators(FacesContext context)
This override which does effectively nothing prevents Faces from performing validation for second time.-
Methods inherited from class jakarta.faces.component.UIInput
addValidator, addValueChangeListener, clearInitialState, compareValues, getConvertedValue, getConverterMessage, getFamily, getRequiredMessage, getSubmittedValue, getValidator, getValidatorMessage, getValidators, getValue, getValueChangeListener, getValueChangeListeners, isEmpty, isImmediate, isLocalValueSet, isRequired, isValid, markInitialState, processDecodes, removeValidator, removeValueChangeListener, resetValue, restoreState, saveState, setConverterMessage, setImmediate, setLocalValueSet, setRequired, setRequiredMessage, setSubmittedValue, setValid, setValidator, setValidatorMessage, setValue, setValueChangeListener, updateModel, validate, validateValue
-
Methods inherited from class jakarta.faces.component.UIOutput
getConverter, getLocalValue, setConverter
-
Methods inherited from class jakarta.faces.component.UIComponentBase
addClientBehavior, addFacesListener, broadcast, encodeBegin, encodeChildren, encodeEnd, findComponent, getAttributes, getChildCount, getChildren, getClientBehaviors, getClientId, getDefaultEventName, getEventNames, getFacesContext, getFacesListeners, getFacet, getFacetCount, getFacets, getFacetsAndChildren, getId, getListenersForEventClass, getParent, getPassThroughAttributes, getRenderer, getRendererType, getRendersChildren, getValueBinding, invokeOnComponent, isRendered, isTransient, processRestoreState, processSaveState, queueEvent, removeFacesListener, restoreAttachedState, saveAttachedState, setId, setParent, setRendered, setRendererType, setTransient, setValueBinding, subscribeToEvent, unsubscribeFromEvent
-
Methods inherited from class jakarta.faces.component.UIComponent
encodeAll, getClientId, getCompositeComponentParent, getContainerClientId, getCurrentComponent, getCurrentCompositeComponent, getNamingContainer, getPassThroughAttributes, getResourceBundleMap, getStateHelper, getStateHelper, getTransientStateHelper, getTransientStateHelper, getValueExpression, initialStateMarked, isCompositeComponent, isInView, isVisitable, popComponentFromEL, processEvent, pushComponentToEL, restoreTransientState, saveTransientState, setInView, setValueExpression, visitTree
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jakarta.faces.component.ValueHolder
getConverter, getLocalValue, setConverter
-
-
-
-
Field Detail
-
COMPONENT_TYPE
public static final String COMPONENT_TYPE
The component type, which is "org.omnifaces.component.input.InputHidden".- See Also:
- Constant Field Values
-
-
Method Detail
-
decode
public void decode(FacesContext context)
This override performs decode, validate and update at once.
-
processValidators
public void processValidators(FacesContext context)
This override which does effectively nothing prevents Faces from performing validation for second time.- Overrides:
processValidators
in classUIInput
-
processUpdates
public void processUpdates(FacesContext context)
This override which does effectively nothing prevents Faces from performing update for second time.- Overrides:
processUpdates
in classUIInput
-
-