|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.tapestry.spec.BaseLocatable org.apache.tapestry.AbstractComponent org.apache.tapestry.form.Form
public abstract class Form
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.
Field Summary |
---|
Fields inherited from interface org.apache.tapestry.IForm |
---|
ATTRIBUTE_NAME |
Constructor Summary | |
---|---|
Form()
|
Method Summary | |
---|---|
void |
addEventHandler(FormEventType type,
String functionName)
Adds an additional event handler. |
void |
addHiddenValue(String name,
String value)
Adds a hidden field value to be stored in the form. |
void |
addHiddenValue(String name,
String id,
String value)
Adds a hidden field value to be stored in the form. |
protected String |
buildAllocatedIdList()
Converts the allocateIds property into a string, a comma-separated list of ids. |
protected void |
cleanupAfterRender(IRequestCycle cycle)
Invoked by AbstractComponent.render(IMarkupWriter, IRequestCycle)
after the component renders, to clear any parameters back to
null (or 0, or false, or whatever the correct default is). |
protected void |
emitEventHandlers(IMarkupWriter writer,
IRequestCycle cycle)
|
protected void |
finishLoad()
Invoked, as a convienience, from AbstractComponent.finishLoad(IRequestCycle, IPageLoader, IComponentSpecification) . |
static IForm |
get(IRequestCycle cycle)
Returns the currently active IForm , or null if no form is
active. |
abstract IValidationDelegate |
getDelegate()
Returns the validation delegate for the form. |
protected String |
getDisplayName()
Returns the name of the element. |
String |
getElementId(IFormComponent component)
Constructs a unique identifier (within the Form). |
String |
getElementId(IFormComponent component,
String baseId)
Constructs a unique identifier from the base id. |
abstract IActionListener |
getListener()
|
abstract String |
getMethod()
|
String |
getName()
Returns the name generated for the form. |
boolean |
getRequiresSession()
Returns true if the stateful parameter is bound to a true value. |
abstract IBinding |
getStatefulBinding()
|
protected 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(IRequestCycle cycle)
Invoked by AbstractComponent.render(IMarkupWriter, IRequestCycle)
to prepare the component to render. |
protected void |
reconstructAllocatedIds(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(IMarkupWriter writer,
IRequestCycle cycle)
Invoked by AbstractComponent.render(IMarkupWriter, IRequestCycle)
to actually render the component (with any parameter values
already set). |
void |
rewind(IMarkupWriter writer,
IRequestCycle cycle)
Simply invokes AbstractComponent.render(IMarkupWriter, IRequestCycle) . |
abstract void |
setDelegate(IValidationDelegate delegate)
|
abstract void |
setDirect(boolean direct)
|
void |
setEncodingType(String encodingType)
May be invoked by a component to force the encoding type of the form to a particular value. |
void |
trigger(IRequestCycle cycle)
Method invoked by the direct service. |
protected void |
writeAttributes(IMarkupWriter writer,
ILink link)
|
protected void |
writeHiddenField(IMarkupWriter writer,
String name,
String value)
|
protected void |
writeHiddenField(IMarkupWriter writer,
String name,
String id,
String value)
|
protected void |
writeHiddenValues(IMarkupWriter writer)
Writes hidden values accumulated during the render (by components invoking addHiddenValue(String, String) . |
Methods inherited from class org.apache.tapestry.spec.BaseLocatable |
---|
getLocation, setLocation |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
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 |
Methods inherited from interface org.apache.tapestry.ILocationHolder |
---|
setLocation |
Methods inherited from interface org.apache.tapestry.ILocatable |
---|
getLocation |
Constructor Detail |
---|
public Form()
Method Detail |
---|
public static IForm get(IRequestCycle cycle)
IForm
, or null if no form is
active. This is a convienience method, the result will be
null, or an instance of IForm
, but not necessarily a
Form
.
public boolean isRewinding()
isRewinding
in interface IForm
ApplicationRuntimeException
- if not rendering.public abstract boolean isDirect()
This is derived from the direct parameter, and defaults to true if not bound.
public boolean getRequiresSession()
getRequiresSession
in interface IAction
public String getElementId(IFormComponent component)
Simply invokes getElementId(org.apache.tapestry.form.IFormComponent, java.lang.String)
with the component's id.
getElementId
in interface IForm
public String getElementId(IFormComponent component, String baseId)
This method is provided simply so that some components
(ImageSubmit
) have more specific control over
their names.
getElementId
in interface IForm
public String getName()
This value is generated when the form renders, and is not cleared.
If the Form is inside a 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.
getName
in interface IForm
AbstractFormComponent.getName()
protected void prepareForRender(IRequestCycle cycle)
AbstractComponent
AbstractComponent.render(IMarkupWriter, IRequestCycle)
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.
prepareForRender
in class AbstractComponent
protected void cleanupAfterRender(IRequestCycle cycle)
AbstractComponent
AbstractComponent.render(IMarkupWriter, IRequestCycle)
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.
cleanupAfterRender
in class AbstractComponent
protected void writeAttributes(IMarkupWriter writer, ILink link)
protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
AbstractComponent
AbstractComponent.render(IMarkupWriter, IRequestCycle)
to actually render the component (with any parameter values
already set). This is the method that subclasses must implement.
renderComponent
in class AbstractComponent
public void addEventHandler(FormEventType type, String functionName)
addEventHandler
in interface IForm
protected void emitEventHandlers(IMarkupWriter writer, IRequestCycle cycle)
public void rewind(IMarkupWriter writer, IRequestCycle cycle)
AbstractComponent.render(IMarkupWriter, IRequestCycle)
.
rewind
in interface IForm
public void trigger(IRequestCycle cycle)
trigger
in interface IDirect
protected void writeHiddenField(IMarkupWriter writer, String name, String value)
protected void writeHiddenField(IMarkupWriter writer, String name, String id, String value)
protected String buildAllocatedIdList()
protected void reconstructAllocatedIds(String storedIdList)
buildAllocatedIdList()
public abstract IValidationDelegate getDelegate()
IForm
getDelegate
in interface IForm
public abstract void setDelegate(IValidationDelegate delegate)
public abstract void setDirect(boolean direct)
public abstract IActionListener getListener()
public abstract String getMethod()
public boolean isStateful()
isStateful
in interface IDirect
public abstract IBinding getStatefulBinding()
protected void finishLoad()
AbstractComponent
AbstractComponent.finishLoad(IRequestCycle, IPageLoader, IComponentSpecification)
.
This implemenation does nothing. Subclasses may override without invoking
this implementation.
finishLoad
in class AbstractComponent
public void setEncodingType(String encodingType)
IForm
setEncodingType
in interface IForm
Upload
protected String getTag()
protected String getDisplayName()
public void addHiddenValue(String name, String value)
IForm
It is acceptible to add multiple hidden fields with the same name. They will be written in the order they are received.
addHiddenValue
in interface IForm
public void addHiddenValue(String name, String id, String value)
IForm
It is acceptible to add multiple hidden fields with the same name. They will be written in the order they are received.
addHiddenValue
in interface IForm
protected void writeHiddenValues(IMarkupWriter writer)
addHiddenValue(String, String)
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |