public class CmsForm
extends java.lang.Object
It is also responsible for collecting and validating the values of the form fields.
限定符和类型 | 字段和说明 |
---|---|
protected java.util.Set<java.lang.String> |
m_editedFields
The set of fields which have been edited.
|
protected java.util.Map<java.lang.String,I_CmsFormField> |
m_fields
A map from field ids to the corresponding widgets.
|
protected I_CmsFormHandler |
m_formHandler
The form handler.
|
protected boolean |
m_pressedEnter
A flag which indicates whether the user has pressed enter in a widget.
|
构造器和说明 |
---|
CmsForm(A_CmsFormFieldPanel panel)
Creates a new form with an existing form widget container.
|
CmsForm(boolean initPanel)
Creates a new form and optionally sets the form widget container to a simple form field panel.
|
限定符和类型 | 方法和说明 |
---|---|
void |
addField(I_CmsFormField field,
java.lang.String initialValue)
Adds a form field.
|
void |
addField(java.lang.String fieldGroup,
I_CmsFormField formField)
Adds a form field to the form.
|
void |
addField(java.lang.String fieldGroup,
I_CmsFormField formField,
java.lang.String initialValue)
Adds a form field to the form and sets its initial value.
|
void |
addResetHandler(I_CmsFormResetHandler handler)
Adds a new form reset handler to the form.
|
java.util.Map<java.lang.String,java.lang.String> |
collectValues()
Collects all values from the form fields.
|
protected java.lang.String |
createValidatorConfig()
Returns the configuration string for the server side form validator.
|
protected void |
defaultHandleKeyPress(I_CmsFormField field,
int keyCode)
The default keypress event handling function for form fields.
|
protected void |
defaultHandleValueChange(I_CmsFormField field,
java.lang.String newValue,
boolean inhibitValidation)
Default handler for value change events of form fields.
|
java.util.Set<java.lang.String> |
getEditedFields()
Returns the set of names of fields which have been edited by the user in the current form.
|
I_CmsFormField |
getField(java.lang.String id)
Returns the form field with a given id.
|
java.util.Map<java.lang.String,I_CmsFormField> |
getFields()
Returns a map of this form's field, indexed by their field name.
|
protected java.util.Collection<I_CmsFormField> |
getFieldsByModelId(java.lang.String modelId)
Gets the fields with a given model id.
|
A_CmsFormFieldPanel |
getWidget()
Returns the form widget container.
|
void |
handleSubmit(I_CmsFormSubmitHandler handler)
Passes this form's data to a form submit handler.
|
boolean |
noFieldsInvalid()
Checks that no fields are invalid.
|
boolean |
noFieldsInvalid(java.util.Collection<I_CmsFormField> fields)
Returns true if none of the fields in a collection are marked as invalid.
|
void |
removeGroup(java.lang.String group)
Removes all fields for the given group.
|
void |
render()
Renders all fields.
|
void |
renderGroup(java.lang.String group)
Renders the fields of the given group.
|
void |
setFormHandler(I_CmsFormHandler handler)
Sets the form handler for this form.
|
void |
setValidatorClass(java.lang.String validatorClass)
Sets the server-side form validator class to use.
|
void |
setWidget(A_CmsFormFieldPanel widget)
Sets the form widget container.
|
protected void |
updateFieldValidationStatus(I_CmsFormField field,
CmsValidationResult result)
Updates the field validation status.
|
protected void |
updateFieldValidationStatus(java.lang.String fieldId,
CmsValidationResult result)
Applies a validation result to a form field.
|
protected void |
updateModelValidationStatus(java.lang.String modelId,
CmsValidationResult result)
Updates the model validation status.
|
void |
validateAllFields()
Performs an initial validation of all form fields.
|
void |
validateAndSubmit()
Validates the form fields and submits their values if the validation was successful.
|
void |
validateField(I_CmsFormField field)
Validates a single field.
|
protected java.util.Set<java.lang.String> m_editedFields
protected java.util.Map<java.lang.String,I_CmsFormField> m_fields
protected I_CmsFormHandler m_formHandler
protected boolean m_pressedEnter
public CmsForm(A_CmsFormFieldPanel panel)
panel
- the form widget containerpublic CmsForm(boolean initPanel)
initPanel
- if true, initializes the form widget containerpublic void addField(I_CmsFormField field, java.lang.String initialValue)
field
- the field to addinitialValue
- the initial field valuepublic void addField(java.lang.String fieldGroup, I_CmsFormField formField)
fieldGroup
- the form field group keyformField
- the form field which should be addedpublic void addField(java.lang.String fieldGroup, I_CmsFormField formField, java.lang.String initialValue)
fieldGroup
- the form field group keyformField
- the form field which should be addedinitialValue
- the initial value of the form field, or null if the field shouldn't have an initial valuepublic void addResetHandler(I_CmsFormResetHandler handler)
handler
- the new form reset handlerpublic java.util.Map<java.lang.String,java.lang.String> collectValues()
This method omits form fields whose values are null.
public java.util.Set<java.lang.String> getEditedFields()
public I_CmsFormField getField(java.lang.String id)
id
- the id of the form fieldpublic java.util.Map<java.lang.String,I_CmsFormField> getFields()
public A_CmsFormFieldPanel getWidget()
public void handleSubmit(I_CmsFormSubmitHandler handler)
handler
- the form submit handlerpublic boolean noFieldsInvalid()
public boolean noFieldsInvalid(java.util.Collection<I_CmsFormField> fields)
fields
- the form fieldspublic void removeGroup(java.lang.String group)
group
- the group for which the fields should be removedpublic void render()
public void renderGroup(java.lang.String group)
group
- the field grouppublic void setFormHandler(I_CmsFormHandler handler)
handler
- the form handlerpublic void setValidatorClass(java.lang.String validatorClass)
validatorClass
- the form validator class namepublic void setWidget(A_CmsFormFieldPanel widget)
widget
- the form widget containerpublic void validateAllFields()
public void validateAndSubmit()
public void validateField(I_CmsFormField field)
field
- the field to validateprotected java.lang.String createValidatorConfig()
protected void defaultHandleKeyPress(I_CmsFormField field, int keyCode)
field
- the form field for which the event has been firedkeyCode
- the key codeprotected void defaultHandleValueChange(I_CmsFormField field, java.lang.String newValue, boolean inhibitValidation)
field
- the form field for which the event has been firedinhibitValidation
- prevents validation of the edited fieldnewValue
- the new valueprotected java.util.Collection<I_CmsFormField> getFieldsByModelId(java.lang.String modelId)
modelId
- the model idprotected void updateFieldValidationStatus(I_CmsFormField field, CmsValidationResult result)
field
- the form fieldresult
- the validation resultprotected void updateFieldValidationStatus(java.lang.String fieldId, CmsValidationResult result)
fieldId
- the field id to which the validation result should be appliedresult
- the result of the validation operationprotected void updateModelValidationStatus(java.lang.String modelId, CmsValidationResult result)
modelId
- the model idresult
- the validation result