java.lang.Object
org.apache.hivemind.impl.BaseLocatable
org.apache.tapestry.AbstractComponent
org.apache.tapestry.form.Form
- All Implemented Interfaces:
- org.apache.tapestry.IAction, org.apache.tapestry.IComponent, org.apache.tapestry.IDirect, org.apache.tapestry.IForm, org.apache.tapestry.IRender, org.apache.hivemind.Locatable, org.apache.hivemind.LocationHolder
- public abstract class Form
- extends org.apache.tapestry.AbstractComponent
- implements org.apache.tapestry.IForm, org.apache.tapestry.IDirect
Component which contains form element components. Forms use the
action or direct services to handle the form submission. A Form will wrap
other components and static HTML, including
form components such as TextArea, TextField, Checkbox, etc.
[Component Reference]
When a form is submitted, it continues through the rewind cycle until
after all of its wrapped elements have renderred. As the form
component render (in the rewind cycle), they will be updating
properties of the containing page and notifying thier listeners. Again:
each form component is responsible not only for rendering HTML (to present the
form), but for handling it's share of the form submission.
Only after all that is done will the Form notify its listener.
Starting in release 1.0.2, a Form can use either the direct service or
the action service. The default is the direct service, even though
in earlier releases, only the action service was available.
| Fields inherited from class org.apache.hivemind.impl.BaseLocatable |
|
|
Constructor Summary |
Form()
|
|
Method Summary |
void |
addEventHandler(FormEventType type,
java.lang.String functionName)
Adds an additional event handler. |
void |
addHiddenValue(java.lang.String name,
java.lang.String value)
Adds a hidden field value to be stored in the form. |
void |
addHiddenValue(java.lang.String name,
java.lang.String id,
java.lang.String value)
Adds a hidden field value to be stored in the form. |
protected java.lang.String |
buildAllocatedIdList()
Converts the allocateIds property into a string, a comma-separated list of ids. |
protected void |
cleanupAfterRender(org.apache.tapestry.IRequestCycle cycle)
Invoked by AbstractComponent.render(IMarkupWriter, IRequestCycle)>AbstractComponent.render(IMarkupWriter, IRequestCycle) 55 after the component renders, to
clear any parameters back to null (or 0, or false, or whatever the correct default is). |
protected void |
emitEventHandlers(org.apache.tapestry.IMarkupWriter writer,
org.apache.tapestry.IRequestCycle cycle)
|
protected void |
finishLoad()
Invoked, as a convienience, from
AbstractComponent.finishLoad(IRequestCycle, IPageLoader, IComponentSpecification)>AbstractComponent.finishLoad(IRequestCycle, IPageLoader, IComponentSpecification) 55 . |
static org.apache.tapestry.IForm |
get(org.apache.tapestry.IRequestCycle cycle)
Returns the currently active org.apache.tapestry.IForm, or null if no form is
active. |
abstract org.apache.tapestry.valid.IValidationDelegate |
getDelegate()
Returns the validation delegate for the form. |
protected java.lang.String |
getDisplayName()
Returns the name of the element. |
java.lang.String |
getElementId(IFormComponent component)
Constructs a unique identifier (within the Form). |
java.lang.String |
getElementId(IFormComponent component,
java.lang.String baseId)
Constructs a unique identifier from the base id. |
private org.apache.tapestry.engine.ILink |
getLink(org.apache.tapestry.IRequestCycle cycle,
java.lang.String actionId)
Builds the EngineServiceLink for the form, using either the direct or
action service. |
abstract org.apache.tapestry.IActionListener |
getListener()
|
abstract java.lang.String |
getMethod()
|
java.lang.String |
getName()
Returns the name generated for the form. |
boolean |
getRequiresSession()
Returns true if the stateful parameter is bound to
a true value. |
abstract org.apache.tapestry.IBinding |
getStatefulBinding()
|
protected java.lang.String |
getTag()
Returns the tag of the form. |
abstract boolean |
isDirect()
Returns true if this Form is configured to use the direct
service. |
boolean |
isRewinding()
Indicates to any wrapped form components that they should respond to the form
submission. |
boolean |
isStateful()
Invoked when not rendering, so it uses the stateful binding. |
protected void |
prepareForRender(org.apache.tapestry.IRequestCycle cycle)
Invoked by AbstractComponent.render(IMarkupWriter, IRequestCycle)>AbstractComponent.render(IMarkupWriter, IRequestCycle) 55 to prepare the component to render. |
protected void |
reconstructAllocatedIds(java.lang.String storedIdList)
Converts a string passed as a parameter (and containing a comma
separated list of ids) back into the allocateIds property. |
protected void |
renderComponent(org.apache.tapestry.IMarkupWriter writer,
org.apache.tapestry.IRequestCycle cycle)
Invoked by AbstractComponent.render(IMarkupWriter, IRequestCycle)>AbstractComponent.render(IMarkupWriter, IRequestCycle) 55 to actually render the component
(with any parameter values already set). |
void |
rewind(org.apache.tapestry.IMarkupWriter writer,
org.apache.tapestry.IRequestCycle cycle)
Simply invokes AbstractComponent.render(IMarkupWriter, IRequestCycle)>AbstractComponent.render(IMarkupWriter, IRequestCycle) 55 . |
abstract void |
setDelegate(org.apache.tapestry.valid.IValidationDelegate delegate)
|
abstract void |
setDirect(boolean direct)
|
void |
setEncodingType(java.lang.String encodingType)
May be invoked by a component to force the encoding type of the
form to a particular value. |
void |
trigger(org.apache.tapestry.IRequestCycle cycle)
Method invoked by the direct service. |
protected void |
writeAttributes(org.apache.tapestry.IMarkupWriter writer,
org.apache.tapestry.engine.ILink link)
|
protected void |
writeHiddenField(org.apache.tapestry.IMarkupWriter writer,
java.lang.String name,
java.lang.String value)
|
protected void |
writeHiddenField(org.apache.tapestry.IMarkupWriter writer,
java.lang.String name,
java.lang.String id,
java.lang.String value)
|
private void |
writeHiddenFieldsForParameter(org.apache.tapestry.IMarkupWriter writer,
org.apache.tapestry.engine.ILink link,
java.lang.String parameterName)
|
protected void |
writeHiddenValues(org.apache.tapestry.IMarkupWriter writer)
Writes hidden values accumulated during the render
(by components invoking addHiddenValue(String, String) 55 . |
private void |
writeLinkParameters(org.apache.tapestry.IMarkupWriter writer,
org.apache.tapestry.engine.ILink link,
boolean reserveOnly)
|
| Methods inherited from class org.apache.tapestry.AbstractComponent |
addAsset, addBody, addComponent, finishLoad, format, format, format, format, formatString, formatString, formatString, formatString, getAsset, getAssets, getBeans, getBinding, getBindingNames, getBindings, getBody, getBodyCount, getChangeObserver, getComponent, getComponents, getContainer, getExtendedId, getId, getIdPath, getListeners, getMessage, getMessages, getNamespace, getPage, getProperty, getSpecification, getString, pageEndRender, render, renderBody, renderInformalParameters, setBinding, setContainer, setId, setNamespace, setPage, setProperty, setSpecification, toString |
| Methods inherited from interface org.apache.tapestry.IComponent |
addAsset, addBody, addComponent, finishLoad, getAsset, getAssets, getBinding, getBindingNames, getBindings, getComponent, getComponents, getContainer, getExtendedId, getId, getIdPath, getMessage, getMessages, getNamespace, getPage, getProperty, getSpecification, getString, renderBody, setBinding, setContainer, setId, setNamespace, setPage, setProperty, setSpecification |
| Methods inherited from interface org.apache.tapestry.IRender |
render |
__CLOVER_130_0
public static com.cortexeb.tools.clover.d __CLOVER_130_0
_rewinding
private boolean _rewinding
_rendering
private boolean _rendering
_name
private java.lang.String _name
_allocatedIdIndex
private int _allocatedIdIndex
- Used when rewinding the form to figure to match allocated ids (allocated during
the rewind) against expected ids (allocated in the previous request cycle, when
the form was rendered).
- Since:
- 3.0
_allocatedIds
private java.util.List _allocatedIds
- The list of allocated ids for form elements within this form. This list
is constructed when a form renders, and is validated against when the
form is rewound.
- Since:
- 3.0
_events
private java.util.Map _events
- java.util.Map, keyed on FormEventType. Values are either a String (the name
of a single event), or a java.util.List of Strings.
- Since:
- 1.0.2
EVENT_MAP_SIZE
private static final int EVENT_MAP_SIZE
- See Also:
- Constant Field Values
_elementIdAllocator
private org.apache.tapestry.util.IdAllocator _elementIdAllocator
_encodingType
private java.lang.String _encodingType
_hiddenValues
private java.util.List _hiddenValues
Form
public Form()
get
public static org.apache.tapestry.IForm get(org.apache.tapestry.IRequestCycle cycle)
- Returns the currently active org.apache.tapestry.IForm, or null if no form is
active. This is a convienience method, the result will be
null, or an instance of org.apache.tapestry.IForm, but not necessarily a
Form.
isRewinding
public boolean isRewinding()
- Indicates to any wrapped form components that they should respond to the form
submission.
- Specified by:
isRewinding in interface org.apache.tapestry.IForm
isDirect
public abstract boolean isDirect()
- Returns true if this Form is configured to use the direct
service.
This is derived from the direct parameter, and defaults
to true if not bound.
- Since:
- 1.0.2
getRequiresSession
public boolean getRequiresSession()
- Returns true if the stateful parameter is bound to
a true value. If stateful is not bound, also returns
the default, true.
- Specified by:
getRequiresSession in interface org.apache.tapestry.IAction
- Since:
- 1.0.1
getElementId
public java.lang.String getElementId(IFormComponent component)
- Constructs a unique identifier (within the Form). The identifier
consists of the component's id, with an index number added to
ensure uniqueness.
Simply invokes getElementId(org.apache.tapestry.form.IFormComponent, java.lang.String) 55
with the component's id.
- Specified by:
getElementId in interface org.apache.tapestry.IForm
- Since:
- 1.0.2
getElementId
public java.lang.String getElementId(IFormComponent component,
java.lang.String baseId)
- Constructs a unique identifier from the base id. If possible, the
id is used as-is. Otherwise, a unique identifier is appended
to the id.
This method is provided simply so that some components
(ImageSubmit) have more specific control over
their names.
- Specified by:
getElementId in interface org.apache.tapestry.IForm
- Since:
- 1.0.3
getName
public java.lang.String getName()
- Returns the name generated for the form. This is used to faciliate
components that write JavaScript and need to access the form or
its contents.
This value is generated when the form renders, and is not cleared.
If the Form is inside a org.apache.tapestry.components.Foreach,
this will be the most recently
generated name for the Form.
This property is exposed so that sophisticated applications can write
JavaScript handlers for the form and components within the form.
- Specified by:
getName in interface org.apache.tapestry.IForm
prepareForRender
protected void prepareForRender(org.apache.tapestry.IRequestCycle cycle)
- Description copied from class:
org.apache.tapestry.AbstractComponent
- Invoked by AbstractComponent.render(IMarkupWriter, IRequestCycle)>
AbstractComponent.render(IMarkupWriter, IRequestCycle) 55 to prepare the component to render.
This implementation sets JavaBeans properties from matching bound parameters. Subclasses that
override this method must invoke this implementation as well.
- Since:
- 3.0
cleanupAfterRender
protected void cleanupAfterRender(org.apache.tapestry.IRequestCycle cycle)
- Description copied from class:
org.apache.tapestry.AbstractComponent
- Invoked by AbstractComponent.render(IMarkupWriter, IRequestCycle)>
AbstractComponent.render(IMarkupWriter, IRequestCycle) 55 after the component renders, to
clear any parameters back to null (or 0, or false, or whatever the correct default is).
Primarily, this is used to ensure that the component doesn't hold onto any objects that could
otherwise be garbage collected.
Subclasses may override this implementation, but must also invoke it.
writeAttributes
protected void writeAttributes(org.apache.tapestry.IMarkupWriter writer,
org.apache.tapestry.engine.ILink link)
renderComponent
protected void renderComponent(org.apache.tapestry.IMarkupWriter writer,
org.apache.tapestry.IRequestCycle cycle)
- Description copied from class:
org.apache.tapestry.AbstractComponent
- Invoked by AbstractComponent.render(IMarkupWriter, IRequestCycle)>
AbstractComponent.render(IMarkupWriter, IRequestCycle) 55 to actually render the component
(with any parameter values already set). This is the method that subclasses must implement.
addEventHandler
public void addEventHandler(FormEventType type,
java.lang.String functionName)
- Adds an additional event handler.
- Specified by:
addEventHandler in interface org.apache.tapestry.IForm
- Since:
- 1.0.2
emitEventHandlers
protected void emitEventHandlers(org.apache.tapestry.IMarkupWriter writer,
org.apache.tapestry.IRequestCycle cycle)
rewind
public void rewind(org.apache.tapestry.IMarkupWriter writer,
org.apache.tapestry.IRequestCycle cycle)
- Simply invokes AbstractComponent.render(IMarkupWriter, IRequestCycle)>
AbstractComponent.render(IMarkupWriter, IRequestCycle) 55 .
- Specified by:
rewind in interface org.apache.tapestry.IForm
- Since:
- 1.0.2
trigger
public void trigger(org.apache.tapestry.IRequestCycle cycle)
- Method invoked by the direct service.
- Specified by:
trigger in interface org.apache.tapestry.IDirect
- Since:
- 1.0.2
getLink
private org.apache.tapestry.engine.ILink getLink(org.apache.tapestry.IRequestCycle cycle,
java.lang.String actionId)
- Builds the EngineServiceLink for the form, using either the direct or
action service.
- Since:
- 1.0.3
writeLinkParameters
private void writeLinkParameters(org.apache.tapestry.IMarkupWriter writer,
org.apache.tapestry.engine.ILink link,
boolean reserveOnly)
writeHiddenField
protected void writeHiddenField(org.apache.tapestry.IMarkupWriter writer,
java.lang.String name,
java.lang.String value)
- Since:
- 3.0
writeHiddenField
protected void writeHiddenField(org.apache.tapestry.IMarkupWriter writer,
java.lang.String name,
java.lang.String id,
java.lang.String value)
writeHiddenFieldsForParameter
private void writeHiddenFieldsForParameter(org.apache.tapestry.IMarkupWriter writer,
org.apache.tapestry.engine.ILink link,
java.lang.String parameterName)
- Since:
- 2.2
buildAllocatedIdList
protected java.lang.String buildAllocatedIdList()
- Converts the allocateIds property into a string, a comma-separated list of ids.
This is included as a hidden field in the form and is used to identify
discrepencies when the form is submitted.
- Since:
- 3.0
reconstructAllocatedIds
protected void reconstructAllocatedIds(java.lang.String storedIdList)
- Converts a string passed as a parameter (and containing a comma
separated list of ids) back into the allocateIds property.
- Since:
- 3.0
getDelegate
public abstract org.apache.tapestry.valid.IValidationDelegate getDelegate()
- Description copied from interface:
org.apache.tapestry.IForm
- Returns the validation delegate for the form.
Returns null if the form does not have a delegate.
- Specified by:
getDelegate in interface org.apache.tapestry.IForm
setDelegate
public abstract void setDelegate(org.apache.tapestry.valid.IValidationDelegate delegate)
setDirect
public abstract void setDirect(boolean direct)
getListener
public abstract org.apache.tapestry.IActionListener getListener()
getMethod
public abstract java.lang.String getMethod()
isStateful
public boolean isStateful()
- Invoked when not rendering, so it uses the stateful binding.
If not bound, returns true.
- Specified by:
isStateful in interface org.apache.tapestry.IDirect
getStatefulBinding
public abstract org.apache.tapestry.IBinding getStatefulBinding()
finishLoad
protected void finishLoad()
- Description copied from class:
org.apache.tapestry.AbstractComponent
- Invoked, as a convienience, from
AbstractComponent.finishLoad(IRequestCycle, IPageLoader, IComponentSpecification)>
AbstractComponent.finishLoad(IRequestCycle, IPageLoader, IComponentSpecification) 55 . This implemenation
does nothing. Subclasses may override without invoking this implementation.
setEncodingType
public void setEncodingType(java.lang.String encodingType)
- Description copied from interface:
org.apache.tapestry.IForm
- May be invoked by a component to force the encoding type of the
form to a particular value.
- Specified by:
setEncodingType in interface org.apache.tapestry.IForm
getTag
protected java.lang.String getTag()
- Returns the tag of the form.
- Since:
- 3.0
getDisplayName
protected java.lang.String getDisplayName()
- Returns the name of the element.
- Since:
- 3.0
addHiddenValue
public void addHiddenValue(java.lang.String name,
java.lang.String value)
- Description copied from interface:
org.apache.tapestry.IForm
- Adds a hidden field value to be stored in the form. This ensures that all
of the <input type="hidden"> (or equivalent) are grouped together,
which ensures that the output HTML is valid (ie. doesn't
have <input> improperly nested with <tr>, etc.).
It is acceptible to add multiple hidden fields with the same name.
They will be written in the order they are received.
- Specified by:
addHiddenValue in interface org.apache.tapestry.IForm
- Since:
- 3.0
addHiddenValue
public void addHiddenValue(java.lang.String name,
java.lang.String id,
java.lang.String value)
- Description copied from interface:
org.apache.tapestry.IForm
- Adds a hidden field value to be stored in the form. This ensures that all
of the <input type="hidden"> (or equivalent) are grouped together,
which ensures that the output HTML is valid (ie. doesn't
have <input> improperly nested with <tr>, etc.).
It is acceptible to add multiple hidden fields with the same name.
They will be written in the order they are received.
- Specified by:
addHiddenValue in interface org.apache.tapestry.IForm
- Since:
- 3.0
writeHiddenValues
protected void writeHiddenValues(org.apache.tapestry.IMarkupWriter writer)
- Writes hidden values accumulated during the render
(by components invoking
addHiddenValue(String, String) 55 .
- Since:
- 3.0