org.apache.struts2.components
Class Form

java.lang.Object
  extended by org.apache.struts2.components.Component
      extended by org.apache.struts2.components.UIBean
          extended by org.apache.struts2.components.ClosingUIBean
              extended by org.apache.struts2.components.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 successfull 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.

Examples

 
 

<s:form ... />


Field Summary
protected  java.lang.String acceptcharset
           
protected  java.lang.String action
           
protected  java.lang.String enctype
           
protected  java.lang.String method
           
protected  java.lang.String namespace
           
protected  java.lang.String onsubmit
           
static java.lang.String OPEN_TEMPLATE
           
protected  java.lang.String portletMode
           
protected  java.lang.String target
           
static java.lang.String TEMPLATE
           
protected  java.lang.String validate
           
protected  java.lang.String windowState
           
 
Fields inherited from class org.apache.struts2.components.UIBean
accesskey, cssClass, cssStyle, disabled, label, labelPosition, name, onblur, onchange, onclick, ondblclick, onfocus, onkeydown, onkeypress, onkeyup, onmousedown, onmousemove, onmouseout, onmouseover, onmouseup, onselect, request, required, requiredposition, response, tabindex, template, templateDir, templateSuffix, theme, title, tooltip, tooltipConfig, value
 
Fields inherited from class org.apache.struts2.components.Component
COMPONENT_STACK, id, parameters, stack
 
Constructor Summary
Form(com.opensymphony.xwork2.util.ValueStack stack, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
           
 
Method Summary
protected  void evaluateExtraParams()
           
protected  boolean evaluateNameValue()
           
 java.lang.String getDefaultOpenTemplate()
           
protected  java.lang.String getDefaultTemplate()
          A contract that requires each concrete UI Tag to specify which template should be used as a default.
protected  int getSequence()
          Get a incrementing sequence unique to this Form component.
 java.util.List getValidators(java.lang.String name)
           
protected  void populateComponentHtmlId(Form form)
          Form component determine the its HTML element id as follows:- if an 'id' attribute is specified. if an 'action' attribute is specified, it will be used as the id.
 void setAcceptcharset(java.lang.String acceptcharset)
          The accepted charsets for this form.
 void setAction(java.lang.String action)
          Set action nane to submit to, without .action suffix
 void setEnctype(java.lang.String enctype)
          HTML form enctype attribute
 void setMethod(java.lang.String method)
          HTML form method attribute
 void setNamespace(java.lang.String namespace)
          namespace for action to submit to
 void setOnsubmit(java.lang.String onsubmit)
          HTML onsubmit attribute
 void setPortletMode(java.lang.String portletMode)
          The portlet mode to display after the form submit
 void setTarget(java.lang.String target)
          HTML form target attribute
 void setValidate(java.lang.String validate)
          Whether client side/remote validation should be performed.
 void setWindowState(java.lang.String windowState)
          The window state to display after the form submit
 
Methods inherited from class org.apache.struts2.components.ClosingUIBean
setOpenTemplate, start
 
Methods inherited from class org.apache.struts2.components.UIBean
addFormParameter, buildTemplateName, enableAncestorFormCustomOnsubmit, end, escape, evaluateParams, getTemplate, getTemplateDir, getTheme, getTooltipConfig, getValueClassType, mergeTemplate, setAccesskey, setCssClass, setCssStyle, setDisabled, setLabel, setLabelposition, setName, setOnblur, setOnchange, setOnclick, setOndblclick, setOnfocus, setOnkeydown, setOnkeypress, setOnkeyup, setOnmousedown, setOnmousemove, setOnmouseout, setOnmouseover, setOnmouseup, setOnselect, setRequired, setRequiredposition, setTabindex, setTemplate, setTemplateDir, setTheme, setTitle, setTooltip, setTooltipConfig, setValue
 
Methods inherited from class org.apache.struts2.components.Component
addAllParameters, addParameter, altSyntax, copyParams, determineActionURL, determineNamespace, end, fieldError, findAncestor, findString, findString, findValue, findValue, findValue, getComponentStack, getId, getParameters, getStack, popComponentStack, setId, toString, usesBody
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OPEN_TEMPLATE

public static final java.lang.String OPEN_TEMPLATE
See Also:
Constant Field Values

TEMPLATE

public static final java.lang.String TEMPLATE
See Also:
Constant Field Values

onsubmit

protected java.lang.String onsubmit

action

protected java.lang.String action

target

protected java.lang.String target

enctype

protected java.lang.String enctype

method

protected java.lang.String method

namespace

protected java.lang.String namespace

validate

protected java.lang.String validate

portletMode

protected java.lang.String portletMode

windowState

protected java.lang.String windowState

acceptcharset

protected java.lang.String acceptcharset
Constructor Detail

Form

public Form(com.opensymphony.xwork2.util.ValueStack stack,
            javax.servlet.http.HttpServletRequest request,
            javax.servlet.http.HttpServletResponse response)
Method Detail

evaluateNameValue

protected boolean evaluateNameValue()
Overrides:
evaluateNameValue in class UIBean

getDefaultOpenTemplate

public java.lang.String getDefaultOpenTemplate()
Specified by:
getDefaultOpenTemplate in class ClosingUIBean

getDefaultTemplate

protected java.lang.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.

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

getValidators

public java.util.List getValidators(java.lang.String name)

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(java.lang.String onsubmit)
HTML onsubmit attribute


setAction

public void setAction(java.lang.String action)
Set action nane to submit to, without .action suffix


setTarget

public void setTarget(java.lang.String target)
HTML form target attribute


setEnctype

public void setEnctype(java.lang.String enctype)
HTML form enctype attribute


setMethod

public void setMethod(java.lang.String method)
HTML form method attribute


setNamespace

public void setNamespace(java.lang.String namespace)
namespace for action to submit to


setValidate

public void setValidate(java.lang.String validate)
Whether client side/remote validation should be performed. Only useful with theme xhtml/ajax


setPortletMode

public void setPortletMode(java.lang.String portletMode)
The portlet mode to display after the form submit


setWindowState

public void setWindowState(java.lang.String windowState)
The window state to display after the form submit


setAcceptcharset

public void setAcceptcharset(java.lang.String acceptcharset)
The accepted charsets for this form. The values may be comma or blank delimited.



Copyright © 2000-2006 Apache Software Foundation. All Rights Reserved.