|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.arsdigita.bebop.Completable
com.arsdigita.bebop.SimpleComponent
com.arsdigita.bebop.FormSection
com.arsdigita.bebop.Form
Represents the visual structure of an HTML form. Forms can be constructed with a Container argument to specify the type of layout this form will adhere to. The default is a column panel.
As an example, a form that accepts a first and last name may be set up as follows:
public class MyForm extends Form implements FormProcessListener { private Text m_firstName; private Text m_lastName; public MyForm() { super("myform"); add(new Label("First Name:")); m_firstName = new Text("firstName"); m_firstName.setDefaultValue("John"); add(m_firstName); add(new Label("Last Name:")); m_lastName = new Text("lastName"); m_lastName.setDefaultValue("Doe"); m_lastName.addValidationListener(new NotNullValidationListener ("The last name")); add(m_lastName); add(new Submit("save", "Save")); addProcessListener(this); } public void process(FormSectionEvent e) { PageState s = e.getPageState(); System.out.println("You are " + m_firstName.getValue(s) + " " + m_lastName.getValue(s)); } }
This form automatically checks that the user supplied a last
name. Only then does it call the process
method, which
prints the user-supplied values.
Field Summary | |
static String |
GET
Constant for specifying a get submission method for this
form. |
static String |
POST
Constant for specifying a post submission method for this
form. |
static String |
versionId
|
Fields inherited from class com.arsdigita.bebop.FormSection |
m_formModel, m_panel |
Fields inherited from class com.arsdigita.bebop.SimpleComponent |
m_attr |
Fields inherited from interface com.arsdigita.bebop.util.BebopConstants |
BEBOP_BORDER, BEBOP_BOXPANEL, BEBOP_CELL, BEBOP_CHECKBOX, BEBOP_CHECKBOXGROUP, BEBOP_COLUMNPANEL, BEBOP_DATE, BEBOP_DATETIME, BEBOP_DHTMLEDITOR, BEBOP_FORMERRORS, BEBOP_FORMWIDGET, BEBOP_GRIDPANEL, BEBOP_LIST, BEBOP_MULTISELECT, BEBOP_OPTION, BEBOP_PAD, BEBOP_PADFRAME, BEBOP_PANELROW, BEBOP_PORTAL, BEBOP_PORTLET, BEBOP_RADIO, BEBOP_RADIOGROUP, BEBOP_SEG_BODY, BEBOP_SEG_HEADER, BEBOP_SEG_PANEL, BEBOP_SEGMENT, BEBOP_SELECT, BEBOP_TABLE, BEBOP_TABLEBODY, BEBOP_TABLEROW, BEBOP_TEXTAREA |
Fields inherited from interface com.arsdigita.bebop.Component |
BEBOP_XML_NS, CLASS, ID, ON_CLICK, STYLE |
Constructor Summary | |
Form(String name)
|
|
Form(String name,
Container panel)
Constructs a new form with the specified name and container. |
Method Summary | |
protected void |
addMagicTag()
Adds a Hidden Tag to this form so that our controller can determine if this is an initial request. |
void |
excludeParameterFromExport(ParameterModel model)
TODO |
protected void |
generateErrors(PageState ps,
Element parent)
|
void |
generateXML(PageState s,
Element parent)
Writes the output to a DOM to be used with the XSLT template to produce the appropriate output. |
protected Element |
generateXMLSansState(PageState s,
Element parent)
Generates the XML representing the form and its widgets, but not the state information from s . |
String |
getAction()
Returns the URL for the form's action attribute. |
FormData |
getFormData(PageState state)
Returns the form data constructed by the process method for the request described by
state . |
String |
getName()
Gets the name attribute for this form. |
protected boolean |
getProcessInvisible()
Returns true if form processing is turned on when the form is invisible. |
boolean |
isRedirecting()
Determine whether or not this Form will redirect after its process listeners are fired. |
FormData |
process(PageState state)
Processes this form, creating a FormData object. |
void |
register(Page p)
Adds this form to the page and traverses the components contained in this form, collecting parameterModels and Listeners into this form's FormModel. |
void |
respond(PageState state)
Responds to the request by processing this form with the HTTP request given in state . |
void |
setAction(String action)
Sets the URL for the form's action attribute. |
void |
setEncType(String encType)
Sets the enctype attribute used in the
form element. |
protected void |
setFormData(PageState state,
FormData data)
Protected access to set the formdata request local |
void |
setMethod(String method)
Sets the HTTP method used to submit the form. |
void |
setName(String name)
Sets the name attribute for the form. |
void |
setOnReset(String javascriptCode)
Sets the ONRESET attribute used in the
FORM element. |
void |
setOnSubmit(String javascriptCode)
Sets the onSubmit attribute used in the
form element. |
protected void |
setProcessInvisible(boolean processInvisible)
Turns form processing on/off when the form is invisible. |
void |
setRedirecting(boolean isRedirecting)
Setting the redirecting flag will cause the Form to clear the control event and redirect back to the current URL, after firing all process listeners. |
String |
toString()
Converts to a String. |
protected void |
traverse()
Traverses the components contained in this form, collecting parameterModels and Listeners into this form's FormModel. |
Methods inherited from class com.arsdigita.bebop.SimpleComponent |
clone, exportAttributes, getAttribute, getClassAttr, getIdAttr, getKey, getMetaDataAttribute, getStyleAttr, hasAttributes, isLocked, isVisible, setAttribute, setClassAttr, setIdAttr, setKey, setMetaDataAttribute, setStyleAttr, setVisible |
Methods inherited from class com.arsdigita.bebop.Completable |
addCompletionListener, fireCompletionEvent |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface com.arsdigita.bebop.Component |
getClassAttr, getIdAttr, getKey, getStyleAttr, isVisible, setClassAttr, setIdAttr, setKey, setStyleAttr, setVisible |
Methods inherited from interface com.arsdigita.util.Lockable |
isLocked |
Field Detail |
public static final String versionId
public static final String GET
get
submission method for this
form. See the W3C
HTML specification for a description of what this attribute
does.
public static final String POST
post
submission method for this
form. See the W3C HTML
specification for a description of what this attribute does.
Constructor Detail |
public Form(String name)
public Form(String name, Container panel)
name
- the name of the formpanel
- the implicit container that will hold the componentsMethod Detail |
public void generateXML(PageState s, Element parent)
Generates a DOM fragment:
<bebop:form action=%url; %bebopAttr;>
.. XML for panel ..
.. XML for page state ..
</bebop:form>
generateXML
in interface Component
generateXML
in class FormSection
s
- the page state used to determine the values of form
widgets and page state attributesparent
- the XML element to which the form adds its XML
representationPageState.generateXML(com.arsdigita.xml.Element)
protected Element generateXMLSansState(PageState s, Element parent)
s
.
s
- represents the curent request
protected void generateErrors(PageState ps, Element parent)
public boolean isRedirecting()
Determine whether or not this Form will redirect after its process listeners are fired.
public void setRedirecting(boolean isRedirecting)
Setting the redirecting flag will cause the Form to clear the control event and redirect back to the current URL, after firing all process listeners. Doing so means that a user reload will not cause the form to be resubmitted. The default value for this flag is false.
public void respond(PageState state) throws javax.servlet.ServletException
state
.
respond
in interface Component
respond
in class FormSection
state
- represents the current request
javax.servlet.ServletException
process(...)
public void setName(String name)
name
attribute for the form.
name
- the name for the formpublic String getName()
name
attribute for this form.
public void setEncType(String encType)
enctype
attribute used in the
form
element. No encoding type is specified by
default.
encType
- the encoding typepublic void setOnSubmit(String javascriptCode)
onSubmit
attribute used in the
form
element. No onsubmit handler is specified by
default.
javascriptCode
- the javascript code associated with this
attributepublic void setOnReset(String javascriptCode)
ONRESET
attribute used in the
FORM
element. No onreset handler is specified by
default.
javascriptCode
- the javascript code associated with this
attributepublic void setMethod(String method)
method
- either GET
or POST
protected boolean getProcessInvisible()
protected void setProcessInvisible(boolean processInvisible)
processInvisible
- true if the form listeners should be
processed even when the form is not visible on the pagepublic void setAction(String action)
action
attribute. This
is the URL to which submissions will be sent when the user
clicks a submit button on the form. By default, the action is
null
, instructing the form to set the action to
the URL of the page in which it is used. If the action is set
to a different URL, none of the listeners registered with this
form will be run.
action
- the URL to submit this form topublic final String getAction()
action
attribute.
setAction
public FormData process(PageState state) throws FormProcessException
FormData
object. Runs the
right set of init, validation, and process listeners, depending on
whether this is an initial request to the form and whether the form
submission was valid. Submission listeners are always run.
process
in class FormSection
state
- represents the current request
state
.
FormProcessException
getFormData(com.arsdigita.bebop.PageState)
public FormData getFormData(PageState state)
process
method for the request described by
state
. Processes the form if it has not already
been processed.
state
- describes the current request
state
, or null
if the form has not been
processed yet.protected void addMagicTag()
protected void traverse()
public void register(Page p)
register
in interface Component
register
in class SimpleComponent
p
- page in which to register this formpublic void excludeParameterFromExport(ParameterModel model)
public String toString()
this
.protected void setFormData(PageState state, FormData data)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |