|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.hivemind.impl.BaseLocatable
org.apache.tapestry.AbstractComponent
org.apache.tapestry.form.Form
public abstract class Form
Component which contains form element components. 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.
Release 4.0 adds two new listeners, getCancel()
and getRefresh()
and
corresponding client-side behavior to force a form to refresh (update, bypassing input field
validation) or cancel (update immediately).
Field Summary |
---|
Fields inherited from class org.apache.tapestry.AbstractComponent |
---|
_body, _bodyCount |
Constructor Summary | |
---|---|
Form()
|
Method Summary | |
---|---|
void |
addDeferredRunnable(Runnable runnable)
Adds a deferred runnable, an object to be executed either before the </form> tag is rendered (when rendering), or before the form's listener is invoked (when rewinding). |
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 void |
cleanupAfterRender(IRequestCycle cycle)
Invoked by AbstractComponent.render(IMarkupWriter, IRequestCycle) after the component renders. |
abstract IActionListener |
getCancel()
cancel parameter, may be null. |
abstract IValidationDelegate |
getDelegate()
delegate parameter, which has a default (starting in release 4.0). |
abstract IEngineService |
getDirectService()
Injected. |
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 JavascriptManager |
getJavascriptManager()
Injected JavascriptManager which will be used by
form to render javascript contributions. |
abstract IActionListener |
getListener()
listener parameter, may be null. |
abstract ListenerInvoker |
getListenerInvoker()
Injected. |
abstract String |
getMethod()
method parameter. |
String |
getName()
Returns the name generated for the form. |
abstract Integer |
getPort()
port , may be null. |
JSONObject |
getProfile()
The javascript object profile being built by this context to validate/translate form values. |
abstract IActionListener |
getRefresh()
refresh parameter, may be null. |
boolean |
getRequiresSession()
Returns true if the stateful parameter is bound to a true value. |
abstract WebResponse |
getResponse()
Injected. |
abstract String |
getScheme()
scheme parameter, may be null. |
abstract IActionListener |
getSuccess()
success parameter, may be null. |
boolean |
isFormFieldUpdating()
Checks to see if a form field has been updated. |
boolean |
isRewinding()
Indicates to any wrapped form components that they should respond to the form submission. |
abstract boolean |
isStateful()
stateful parameter. |
protected FormSupport |
newFormSupport(IMarkupWriter writer,
IRequestCycle cycle)
Returns a new instance of FormSupportImpl . |
String |
peekClientId(IFormComponent component)
Used internally to "peek" at what the next generated client id will be for the given component when it renders. |
protected void |
prepareForRender(IRequestCycle cycle)
Invoked by AbstractComponent.render(IMarkupWriter, IRequestCycle) to prepare the component to render. |
void |
prerenderField(IMarkupWriter writer,
IComponent field,
org.apache.hivemind.Location location)
Pre-renders the specified field, buffering the result for later use by FormBehavior.wasPrerendered(IMarkupWriter, IComponent) . |
void |
registerForFocus(IFormComponent field,
int priority)
Registers a field for automatic focus. |
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) . |
void |
setEncodingType(String encodingType)
May be invoked by a component to force the encoding type of the form to a particular value. |
void |
setFormFieldUpdating(boolean value)
Sets a flag denoting whether or not an IFormComponent field has been
updated according to the logic defined in
ResponseBuilder.updateComponent(String) . |
void |
trigger(IRequestCycle cycle)
Method invoked by the direct service. |
boolean |
wasPrerendered(IComponent field)
Invoked to check if a particular component has been pre-rendered. |
boolean |
wasPrerendered(IMarkupWriter writer,
IComponent field)
Invoked by a form control component (a field) that may have been pre-rendered. |
Methods inherited from class org.apache.hivemind.impl.BaseLocatable |
---|
getLocation, setLocation |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.apache.tapestry.IForm |
---|
getFocus, isClientValidationEnabled |
Methods inherited from interface org.apache.tapestry.IComponent |
---|
addAsset, addBody, addComponent, enterActiveState, finishLoad, getAsset, getAssets, getBeans, getBinding, getBindingNames, getBindings, getClientId, getComponent, getComponents, getContainedComponent, getContainer, getEventInvoker, getExtendedId, getId, getIdPath, getListeners, getMessages, getNamespace, getPage, getSpecification, getSpecifiedId, getTemplateTagName, isRendering, peekClientId, renderBody, setBinding, setClientId, setContainedComponent, setContainer, setId, setNamespace, setPage, setTemplateTagName |
Methods inherited from interface org.apache.tapestry.IRender |
---|
render |
Methods inherited from interface org.apache.hivemind.LocationHolder |
---|
setLocation |
Methods inherited from interface org.apache.hivemind.Locatable |
---|
getLocation |
Methods inherited from interface org.apache.tapestry.IDynamicInvoker |
---|
getUpdateComponents, isAsync, isJson |
Constructor Detail |
---|
public Form()
Method Detail |
---|
public boolean isRewinding()
isRewinding
in interface FormBehavior
org.apache.hivemind.ApplicationRuntimeException
- if not rendering.public abstract IEngineService getDirectService()
public boolean getRequiresSession()
public String getElementId(IFormComponent component)
Simply invokes
getElementId(org.apache.tapestry.form.IFormComponent, java.lang.String)
with the
component's id.
getElementId
in interface FormBehavior
component
- The component to get the unique id of.
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 FormBehavior
component
- The component to generate an element id for.baseId
- The basic id of the component.
public String peekClientId(IFormComponent component)
IRequestCycle.peekUniqueId(String)
.
peekClientId
in interface FormBehavior
component
- The component to determine the next client id for.
public String getName()
This value is generated when the form renders, and is not cleared. If the Form is inside a
ForBean
, 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. The default
implementation of this method is empty.
prepareForRender
in class AbstractComponent
protected void cleanupAfterRender(IRequestCycle cycle)
AbstractComponent
AbstractComponent.render(IMarkupWriter, IRequestCycle)
after the component renders.
cleanupAfterRender
in class AbstractComponent
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
protected FormSupport newFormSupport(IMarkupWriter writer, IRequestCycle cycle)
FormSupportImpl
.
public void addEventHandler(FormEventType type, String functionName)
addEventHandler
in interface FormBehavior
type
- Type of event to add.functionName
- Name of the javascript function being added.public void rewind(IMarkupWriter writer, IRequestCycle cycle)
AbstractComponent.render(IMarkupWriter, IRequestCycle)
.
rewind
in interface IForm
public void trigger(IRequestCycle cycle)
trigger
in interface IDirect
cycle
- The current request.public abstract WebResponse getResponse()
public abstract IValidationDelegate getDelegate()
getDelegate
in interface IForm
public abstract IActionListener getListener()
public abstract IActionListener getSuccess()
public abstract IActionListener getCancel()
public abstract IActionListener getRefresh()
public abstract String getMethod()
public abstract boolean isStateful()
isStateful
in interface IDirect
isStateful
in interface IDirectEvent
isStateful
in class AbstractComponent
public abstract String getScheme()
public abstract Integer getPort()
public void setEncodingType(String encodingType)
FormBehavior
setEncodingType
in interface FormBehavior
encodingType
- The encoding type to set.Upload
public void addHiddenValue(String name, String value)
FormBehavior
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 FormBehavior
name
- The name of the hidden input.value
- The value to store in the hidden field.public void addHiddenValue(String name, String id, String value)
FormBehavior
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 FormBehavior
name
- The name of the hidden input.id
- The id of the hidden input - should almost always be the same as the name.value
- The value to store in the hidden field.public void prerenderField(IMarkupWriter writer, IComponent field, org.apache.hivemind.Location location)
FormBehavior
FormBehavior.wasPrerendered(IMarkupWriter, IComponent)
. Typically, it is a
FieldLabel
component that pre-renders an associated
field. This little dance is necessary to properly support field labels inside loops, and to
handle the portlet action/render request cycle.
prerenderField
in interface FormBehavior
writer
- the markup writer (from which a nested markup writer is obtained)field
- the field to pre-render. The field is responsible for invoking
FormBehavior.wasPrerendered(IMarkupWriter, IComponent)
.location
- an optional location (of the FieldLabel component) used when reporting errors.public boolean wasPrerendered(IMarkupWriter writer, IComponent field)
FormBehavior
wasPrerendered
in interface FormBehavior
writer
- The markup writer to render with. (may be ignored during dynamic requests)field
- The component to check for pre-rendering.
public boolean wasPrerendered(IComponent field)
FormBehavior
wasPrerendered
in interface FormBehavior
field
- The component to check for pre-rendering. (Such as is done by FieldLabel
.
public void addDeferredRunnable(Runnable runnable)
FormBehavior
addDeferredRunnable
in interface FormBehavior
runnable
- the object to execute (which may not be null)public abstract ListenerInvoker getListenerInvoker()
public void registerForFocus(IFormComponent field, int priority)
FormBehavior
registerForFocus
in interface FormBehavior
field
- the field requesting focuspriority
- a priority level used to determine whether the registered field becomes the focus
field. Constants for this purpose are defined in ValidationConstants
.public JSONObject getProfile()
getProfile
in interface FormBehavior
JSONObject
profile.public boolean isFormFieldUpdating()
isFormFieldUpdating
in interface FormBehavior
FormBehavior.setFormFieldUpdating(boolean)
public void setFormFieldUpdating(boolean value)
IFormComponent
field has been
updated according to the logic defined in
ResponseBuilder.updateComponent(String)
.
Currently this flag is used during ajax/json responses so that cooperating
ResponseBuilder
s can be worked with to ensure form state is properly
updated on the client. Specifically, that the hidden form input fields and
any associated validation profiles are updated.
setFormFieldUpdating
in interface FormBehavior
value
- The value to set.public abstract JavascriptManager getJavascriptManager()
JavascriptManager
which will be used by
form to render javascript contributions.
JavascriptManager
for this request.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |