Class UIViewParameter

All Implemented Interfaces:
EditableValueHolder, PartialStateHolder, StateHolder, TransientStateHolder, ValueHolder, ComponentSystemEventListener, FacesListener, SystemEventListenerHolder, EventListener

public class UIViewParameter extends UIInput

UIViewParameter represents a binding between a request parameter and a model property or UIViewRoot property. This is a bi-directional binding.

The ViewDeclarationLanguage implementation must cause an instance of this component to appear in the view for each occurrence of an <f:viewParam /> element placed inside of an <f:metadata /> element. The user must place this facet within the UIViewRoot.

Because this class extends UIInput any actions that one would normally take on a UIInput instance are valid for instances of this class. Instances of this class participate in the regular Jakarta Server Faces lifecycle, including on Ajax requests.

Since:
2.0
  • Field Details

    • COMPONENT_TYPE

      public static final String COMPONENT_TYPE

      The standard component type for this component.

      See Also:
    • COMPONENT_FAMILY

      public static final String COMPONENT_FAMILY

      The standard component family for this component.

      See Also:
  • Constructor Details

    • UIViewParameter

      public UIViewParameter()

      Create a new UIViewParameter instance with default property values.

  • Method Details

    • getFamily

      public String getFamily()
      Description copied from class: UIComponent

      Return the identifier of the component family to which this component belongs. This identifier, in conjunction with the value of the rendererType property, may be used to select the appropriate Renderer for this component instance. Note this method should NOT return null

      Overrides:
      getFamily in class UIInput
      Returns:
      the component family (not null).
    • getName

      public String getName()

      Return the request parameter name from which the value is retrieved.

      Returns:
      the name.
      Since:
      2.0
    • setName

      public void setName(String name)

      Set the request parameter name from which the value is retrieved.

      Parameters:
      name - The new request parameter name.
      Since:
      2.0
    • isImmediate

      public boolean isImmediate()

      Return false. The immediate setting is not relevant for view parameters and must be assumed to be false.

      Specified by:
      isImmediate in interface EditableValueHolder
      Overrides:
      isImmediate in class UIInput
      Returns:
      true if immediate, false otherwise.
      Since:
      2.0
    • getSubmittedValue

      public Object getSubmittedValue()

      Assume that the submitted value is always a string, but the return type from this method is Object..

      Specified by:
      getSubmittedValue in interface EditableValueHolder
      Overrides:
      getSubmittedValue in class UIInput
      Returns:
      the submitted value.
      Since:
      2.0
    • setSubmittedValue

      public void setSubmittedValue(Object submittedValue)
      PENDING (docs) Interesting that submitted value isn't saved by the parent
      Specified by:
      setSubmittedValue in interface EditableValueHolder
      Overrides:
      setSubmittedValue in class UIInput
      Parameters:
      submittedValue - The new submitted value
    • decode

      public void decode(FacesContext context)

      Override behavior from superclass to pull a value from the incoming request parameter map under the name given by getName() and store it with a call to UIInput.setSubmittedValue(Object).

      Overrides:
      decode in class UIInput
      Parameters:
      context - FacesContext for the request we are processing
      Since:
      2.0
    • processValidators

      public void processValidators(FacesContext context)

      Specialize superclass behavior to treat null differently. In this class, a null value along with the "required" flag being set to true will cause a validation failure. Otherwise, If the UIInput.EMPTY_STRING_AS_NULL_PARAM_NAME context parameter is true and the value is null, call UIInput.setSubmittedValue(Object) passing the empty string as the argument. This will cause the normal validation processing to happen, including bean validation.

      Overrides:
      processValidators in class UIInput
      Parameters:
      context - the Faces context.
      Since:
      2.0
      See Also:
    • updateModel

      public void updateModel(FacesContext context)

      Call through to superclass UIInput.updateModel(FacesContext) then take the additional action of pushing the value into request scope if and only if the value is not a value expression, is valid, and the local value was set on this lifecycle execution.

      Overrides:
      updateModel in class UIInput
      Parameters:
      context - FacesContext for the request we are processing
      Since:
      2.0
    • encodeAll

      public void encodeAll(FacesContext context) throws IOException

      Called specially by UIViewRoot.encodeEnd(FacesContext), this method simply sets the submitted value to be the return from getStringValue(FacesContext).

      Overrides:
      encodeAll in class UIComponent
      Parameters:
      context - the Faces context.
      Throws:
      IOException - when an I/O error occurs.
      Since:
      2.0
    • getStringValue

      public String getStringValue(FacesContext context)

      If the value of this parameter comes from a ValueExpression return the value of the expression, otherwise, return the local value.

      Parameters:
      context - the Faces context.
      Returns:
      the string value.
      Since:
      2.0
    • getStringValueFromModel

      public String getStringValueFromModel(FacesContext context) throws ConverterException

      Manually perform standard conversion steps to get a string value from the value expression.

      Parameters:
      context - the Faces context.
      Returns:
      the string value from the model.
      Throws:
      ConverterException
      Since:
      2.0
    • getConvertedValue

      protected Object getConvertedValue(FacesContext context, Object submittedValue) throws ConverterException

      Because this class has no Renderer, leverage the one from the standard HTML_BASIC RenderKit with component-family: jakarta.faces.Input and renderer-type: jakarta.faces.Text and call its Renderer.getConvertedValue(FacesContext, T, Object) method.

      Overrides:
      getConvertedValue in class UIInput
      Parameters:
      context - the Faces context.
      submittedValue - the submitted value.
      Returns:
      the converted value.
      Throws:
      ConverterException
      Since:
      2.0