org.apache.tapestry.form
Class MultipleFormSupport

java.lang.Object
  extended by org.apache.tapestry.form.FormSupportImpl
      extended by org.apache.tapestry.form.MultipleFormSupport
All Implemented Interfaces:
FormSupport, FormBehavior

public class MultipleFormSupport
extends FormSupportImpl

A FormSupport implementation that can work when a form is included multiple times in a given page ( due to it being in a loop or in a component that's included many times in the page).

This is achieved by prefixing the ids of all form elements with the form's id.

Since:
4.1.1

Field Summary
 
Fields inherited from class org.apache.tapestry.form.FormSupportImpl
_cycle, _elementIdAllocator, FIELD_FOCUS_ATTRIBUTE, FORM_IDS, RESERVED_FORM_IDS, SUBMIT_MODE
 
Constructor Summary
MultipleFormSupport(IMarkupWriter writer, IRequestCycle cycle, IForm form)
           
 
Method Summary
 String getElementId(IFormComponent component, String baseId)
          Constructs a unique identifier (within the page).
 String peekClientId(IFormComponent comp)
          Used internally to "peek" at what the next generated client id will be for the given component when it renders.
protected  String peekClientId(IFormComponent comp, String baseId)
           
 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.
 
Methods inherited from class org.apache.tapestry.form.FormSupportImpl
addDeferredRunnable, addEventHandler, addHiddenValue, addHiddenValue, emitEventManagerInitialization, getElementId, getForm, getHiddenFieldWriter, getProfile, isFormFieldUpdating, isRewinding, prerenderField, registerForFocus, render, setEncodingType, setFormFieldUpdating, wasPrerendered, wasPrerendered, writeHiddenField, writeHiddenFieldList, writeHiddenFields, writeTag
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultipleFormSupport

public MultipleFormSupport(IMarkupWriter writer,
                           IRequestCycle cycle,
                           IForm form)
Method Detail

getElementId

public String getElementId(IFormComponent component,
                           String baseId)
Constructs a unique identifier (within the page). The identifier consists of the component's id, with an index number added to ensure uniqueness.

Specified by:
getElementId in interface FormBehavior
Overrides:
getElementId in class FormSupportImpl
Parameters:
component - The component to generate an element id for.
baseId - The basic id of the component.
Returns:
The form specific unique identifier for the given element. May be the same as the baseId if this is the first render of that specific component.

peekClientId

public String peekClientId(IFormComponent comp)
Description copied from interface: FormBehavior
Used internally to "peek" at what the next generated client id will be for the given component when it renders. Similar to the logic found in IRequestCycle.peekUniqueId(String).

Specified by:
peekClientId in interface FormBehavior
Overrides:
peekClientId in class FormSupportImpl
Parameters:
comp - The component to determine the next client id for.
Returns:
The next possible client ID for the component.

peekClientId

protected String peekClientId(IFormComponent comp,
                              String baseId)

rewind

public String rewind()
Description copied from interface: FormSupport
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. This should only be invoked by the Form component.

Specified by:
rewind in interface FormSupport
Overrides:
rewind in class FormSupportImpl
Returns:
a code indicating why the form was submitted: FormConstants.SUBMIT_NORMAL, FormConstants.SUBMIT_CANCEL or FormConstants.SUBMIT_REFRESH.


Copyright © 2006-2007 Apache Software Foundation. All Rights Reserved.