Class Form


public class Form extends ClosingUIBean

Renders HTML an input form.

The remote form allows the form to be submitted without the page being refreshed. The results from the form can be inserted into any HTML element on the page.

NOTE:
The order / logic in determining the posting url of the generated HTML form is as follows:

  1. If the action attribute is not specified, then the current request will be used to determine the posting url
  2. If the action is given, Struts will try to obtain an ActionConfig. This will be successful if the action attribute is a valid action alias defined struts.xml.
  3. If the action is given and is not an action alias defined in struts.xml, Struts will used the action attribute as if it is the posting url, separting the namespace from it and using UrlHelper to generate the final url.

The client-side JS validate attribute is deprecated since 7.4.0 — use the html5 theme's constraint attributes instead. Removed in 8.0.0.

Examples

 

 <s:form ... />

 
 
  • Field Details

  • Constructor Details

    • Form

      public Form(ValueStack stack, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response)
  • Method Details

    • evaluateNameValue

      protected boolean evaluateNameValue()
      Overrides:
      evaluateNameValue in class UIBean
    • getDefaultOpenTemplate

      public String getDefaultOpenTemplate()
      Specified by:
      getDefaultOpenTemplate in class ClosingUIBean
    • getDefaultTemplate

      protected String getDefaultTemplate()
      Description copied from class: UIBean
      A contract that requires each concrete UI Tag to specify which template should be used as a default. For example, the CheckboxTab might return "checkbox.vm" while the RadioTag might return "radio.vm". This value not begin with a '/' unless you intend to make the path absolute rather than relative to the current theme.
      Specified by:
      getDefaultTemplate in class UIBean
      Returns:
      The name of the template to be used as the default.
    • setConfiguration

      public void setConfiguration(Configuration configuration)
    • setObjectFactory

      public void setObjectFactory(ObjectFactory objectFactory)
    • setUrlRenderer

      public void setUrlRenderer(UrlRenderer urlRenderer)
    • setActionValidatorManager

      public void setActionValidatorManager(ActionValidatorManager mgr)
    • setTextProviderFactory

      public void setTextProviderFactory(TextProviderFactory textProviderFactory)
    • evaluateExtraParams

      protected void evaluateExtraParams()
      Overrides:
      evaluateExtraParams in class UIBean
    • populateComponentHtmlId

      protected void populateComponentHtmlId(Form form)
      Form component determine the its HTML element id as follows:-
      1. if an 'id' attribute is specified.
      2. if an 'action' attribute is specified, it will be used as the id.
      Overrides:
      populateComponentHtmlId in class UIBean
      Parameters:
      form - enclosing form tag
    • evaluateClientSideJsEnablement

      @Deprecated(since="7.4.0", forRemoval=true) protected void evaluateClientSideJsEnablement(String actionName, String namespace, String actionMethod)
      Deprecated, for removal: This API element is subject to removal in a future version.
      since 7.4.0, for removal in 8.0.0. The generated client-side validator only ever covered fields rendered by a nested Struts tag (WW-2975). Use the html5 theme with struts.ui.html5.constraints=true, which derives native HTML5 constraint attributes per field instead.
      Evaluate client side JavaScript Enablement.
      Parameters:
      actionName - the actioName to check for
      namespace - the namespace to check for
      actionMethod - the method to ckeck for
    • getValidators

      @Deprecated(since="7.4.0", forRemoval=true) public List getValidators(String name)
      Deprecated, for removal: This API element is subject to removal in a future version.
      since 7.4.0, for removal in 8.0.0. Use getFieldValidators(String), which is generically typed and resolves the action's validators once per form rather than per field.
      Looks up the validators for a field, for the deprecated client-side JavaScript validator.
      Parameters:
      name - the field name to look up
      Returns:
      the validators applying to the field, never null
    • getFieldValidators

      public List<Validator> getFieldValidators(String name)
      Returns the validators declared for a single field, resolving the action's validator list at most once per form render.
      Since:
      7.4.0
    • getValidatedObject

      public Object getValidatedObject(String name)
      The object a field's validators run against: the visited object for a field reached through a visitor validator, otherwise null — the caller then uses the action, as validation does. Resolved by getFieldValidators(String), which must run first.
      Since:
      7.4.0
    • getVisitorReturnType

      protected Class getVisitorReturnType(Class actionClass, String visitorFieldName)
      Return type of visited object.
      Parameters:
      actionClass - action class
      visitorFieldName - field name
      Returns:
      type of visited object
    • getSequence

      protected int getSequence()
      Get a incrementing sequence unique to this Form component. It is used by Form component's child that might need a sequence to make them unique.
      Returns:
      int
    • setOnsubmit

      public void setOnsubmit(String onsubmit)
    • setOnreset

      public void setOnreset(String onreset)
    • setAction

      public void setAction(String action)
    • setTarget

      public void setTarget(String target)
    • setEnctype

      public void setEnctype(String enctype)
    • setMethod

      public void setMethod(String method)
    • setNamespace

      public void setNamespace(String namespace)
    • setValidate

      @Deprecated(since="7.4.0", forRemoval=true) public void setValidate(String validate)
      Deprecated, for removal: This API element is subject to removal in a future version.
      since 7.4.0, for removal in 8.0.0. The generated client-side validator only ever covered fields rendered by a nested Struts tag (WW-2975). Use the html5 theme with struts.ui.html5.constraints=true instead.
    • setPortletMode

      public void setPortletMode(String portletMode)
    • setWindowState

      public void setWindowState(String windowState)
    • setAcceptcharset

      public void setAcceptcharset(String acceptcharset)
    • setFocusElement

      public void setFocusElement(String focusElement)
    • setIncludeContext

      public void setIncludeContext(boolean includeContext)