|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.tapestry.form.FormSupportImpl
public class FormSupportImpl
Encapsulates most of the behavior of a Form component.
Field Summary | |
---|---|
protected IRequestCycle |
_cycle
|
static String |
FIELD_FOCUS_ATTRIBUTE
Attribute set to true when a field has been focused; used to prevent conflicting JavaScript for field focusing from being emitted. |
static String |
FORM_IDS
Name of query parameter storing the ids alloocated while rendering the form, as a comma seperated list. |
static String |
RESERVED_FORM_IDS
Names of additional ids that were pre-reserved, as a comma-sepereated list. |
static String |
SEED_IDS
DataSqueezer squeezed list of IRequestCycle id allocation state as it was just before this
form was rendered. |
static String |
SUBMIT_MODE
Indicates why the form was submitted: whether for normal ("submit"), refresh, or because the form was canceled. |
Constructor Summary | |
---|---|
FormSupportImpl(IMarkupWriter writer,
IRequestCycle cycle,
IForm form)
|
|
FormSupportImpl(IMarkupWriter writer,
IRequestCycle cycle,
IForm form,
JavascriptManager javascriptManager)
|
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 |
emitEventManagerInitialization(String formId)
Pre-renders the form, setting up some client-side form support. |
String |
getElementId(IFormComponent component)
Constructs a unique identifier (within the Form). |
String |
getElementId(IFormComponent component,
String baseId)
Constructs a unique identifier (within the Form). |
IForm |
getForm()
Gets a reference to the previously stored IForm . |
protected IMarkupWriter |
getHiddenFieldWriter()
Determines if a hidden field change has occurred, which would require that we write hidden form fields using the ResponseBuilder
writer. |
JSONObject |
getProfile()
The javascript object profile being built by this context to validate/translate form values. |
boolean |
isFormFieldUpdating()
Checks to see if a form field has been updated. |
boolean |
isRewinding()
Returns true if the form is rewinding (meaning, the form was the subject of the request cycle). |
String |
peekClientId(IFormComponent comp)
Used internally to "peek" at what the next generated client id will be for the given component when it renders. |
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. |
void |
render(String method,
IRender informalParametersRenderer,
ILink link,
String scheme,
Integer port)
Invoked when the form is rendering. |
String |
rewind()
Invoked to rewind the form, which renders the body of the form, allowing form element components to pull data from the request and update page properties. |
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) . |
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. |
protected void |
writeHiddenField(IMarkupWriter writer,
String name,
String id,
String value)
Overwridden by GoFormSupportImpl (WML). |
protected void |
writeHiddenFieldList(IMarkupWriter writer)
Writes out all hidden values previously added by addHiddenValue(String, String, String) , plus the allocated id list. |
protected void |
writeHiddenFields()
Writes out all hidden values previously added by addHiddenValue(String, String, String) . |
protected void |
writeTag(IMarkupWriter writer,
String method,
String url)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String FORM_IDS
public static final String RESERVED_FORM_IDS
public static final String SEED_IDS
DataSqueezer
squeezed list of IRequestCycle
id allocation state as it was just before this
form was rendered. Is used to ensure that all generated form ids are globally unique and consistent
between requests.
public static final String SUBMIT_MODE
public static final String FIELD_FOCUS_ATTRIBUTE
protected final IRequestCycle _cycle
Constructor Detail |
---|
public FormSupportImpl(IMarkupWriter writer, IRequestCycle cycle, IForm form)
public FormSupportImpl(IMarkupWriter writer, IRequestCycle cycle, IForm form, JavascriptManager javascriptManager)
Method Detail |
---|
public IForm getForm()
IForm
.
getForm
in interface FormSupport
public void addEventHandler(FormEventType type, String functionName)
FormEventType.SUBMIT
is most typical.
addEventHandler
in interface FormBehavior
type
- Type of event to add.functionName
- Name of the javascript function being added.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 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)
Simply invokes
getElementId(org.apache.tapestry.form.IFormComponent, java.lang.String)
with the
component's id.
getElementId
in interface FormBehavior
component
- The component to generate an element id for.baseId
- The basic id of the component.
public String peekClientId(IFormComponent comp)
FormBehavior
IRequestCycle.peekUniqueId(String)
.
peekClientId
in interface FormBehavior
comp
- The component to determine the next client id for.
public boolean isRewinding()
FormBehavior
isRewinding
in interface FormBehavior
public void render(String method, IRender informalParametersRenderer, ILink link, String scheme, Integer port)
FormSupport
Form
component.
render
in interface FormSupport
method
- the HTTP method ("get" or "post")informalParametersRenderer
- object that will render informal parameterslink
- The link to which the form will submit (encapsulating the URL and the query
parameters)scheme
- the desired scheme for the generated URL, typically "http" or "https". If
non-null, and the scheme does not match the current request's scheme, then an
absolute URL with the specified scheme will be generated, rather than a URI.port
- the desired port for the generated URL, typically "80", "443". If
non-null, and the port does not match the current request's port, then an
absolute URL with the specified port will be generated, rather than a URI.protected void emitEventManagerInitialization(String formId)
formId
- The client id of the form.public String rewind()
FormSupport
Form
component.
rewind
in interface FormSupport
FormConstants.SUBMIT_NORMAL
,
FormConstants.SUBMIT_CANCEL
or FormConstants.SUBMIT_REFRESH
.public void setEncodingType(String encodingType)
FormBehavior
setEncodingType
in interface FormBehavior
encodingType
- The encoding type to set.Upload
protected void writeHiddenField(IMarkupWriter writer, String name, String id, String value)
GoFormSupportImpl
(WML).
protected void writeHiddenFields()
addHiddenValue(String, String, String)
. Writes a <div> tag around
writeHiddenFieldList(IMarkupWriter)
. Overriden by
GoFormSupportImpl
.
protected void writeHiddenFieldList(IMarkupWriter writer)
addHiddenValue(String, String, String)
, plus the allocated id list.
protected IMarkupWriter getHiddenFieldWriter()
ResponseBuilder
writer.
IMarkupWriter
if not doing a managed ajax/json
response, else whatever is returned from ResponseBuilder
.protected void writeTag(IMarkupWriter writer, String method, String url)
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 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.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |