Class AbstractForm
- java.lang.Object
-
- org.silverpeas.core.contribution.content.form.AbstractForm
-
-
Field Summary
Fields Modifier and Type Field Description static String
REPEATED_FIELD_CSS_HIDE
static String
REPEATED_FIELD_CSS_SHOW
static String
REPEATED_FIELD_SEPARATOR
-
Constructor Summary
Constructors Constructor Description AbstractForm(RecordTemplate template)
Creates a new form from the specified template of records.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
display(javax.servlet.jsp.JspWriter out, PagesContext pagesContext)
Prints this form into the specified JSP writer according to the specified records of data that populate the form fields.abstract void
display(javax.servlet.jsp.JspWriter out, PagesContext pagesContext, DataRecord record)
Prints this form into the specified JSP writer according to the specified records of data that populate the form fields.void
displayScripts(javax.servlet.jsp.JspWriter jw, PagesContext pagesContext)
Prints the javascripts which will be used to control the new values given to the data record fields.DataRecord
getData()
protected <T extends Field>
FieldDisplayer<T>getFieldDisplayer(FieldTemplate fieldTemplate)
List<FieldTemplate>
getFieldTemplates()
Gets the template of all of the fields that made this form.String
getFormName()
protected String
getJavascriptSnippet()
String
getName()
protected String
getSkippableSnippet(PagesContext pageContext)
protected Field
getSureField(FieldTemplate fieldTemplate, DataRecord record, int occurrence)
String
getTitle()
Gets the title of this form.boolean
isEmpty(List<org.apache.commons.fileupload.FileItem> items, DataRecord record, PagesContext pagesContext)
Is the form is empty?boolean
isViewForm()
void
setData(DataRecord data)
void
setFormName(String name)
void
setName(String name)
void
setTitle(String title)
Sets the form title.void
setViewForm(boolean viewForm)
Defines if this form is a 'view' form (opposite to an 'update' form) A 'view' form may have some specific behaviors like to not display empty fieldsString
toString(PagesContext pageContext)
List<String>
update(List<org.apache.commons.fileupload.FileItem> items, DataRecord record, PagesContext pagesContext)
Updates the values of the dataRecord using the RecordTemplate to extra control information (readOnly or mandatory status).List<String>
update(List<org.apache.commons.fileupload.FileItem> items, DataRecord record, PagesContext pagesContext, boolean updateWysiwyg)
Updates the values of the dataRecord using the RecordTemplate to extra control information (readOnly or mandatory status).List<String>
updateWysiwyg(List<org.apache.commons.fileupload.FileItem> items, DataRecord record, PagesContext pagesContext)
Updates the values of the dataRecord using the RecordTemplate to extra control information (readOnly or mandatory status).
-
-
-
Field Detail
-
REPEATED_FIELD_CSS_SHOW
public static final String REPEATED_FIELD_CSS_SHOW
- See Also:
- Constant Field Values
-
REPEATED_FIELD_CSS_HIDE
public static final String REPEATED_FIELD_CSS_HIDE
- See Also:
- Constant Field Values
-
REPEATED_FIELD_SEPARATOR
public static final String REPEATED_FIELD_SEPARATOR
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AbstractForm
public AbstractForm(RecordTemplate template) throws FormException
Creates a new form from the specified template of records.- Parameters:
template
- the record template.- Throws:
FormException
- if an error occurs while setting up the form.
-
-
Method Detail
-
setFormName
public void setFormName(String name)
- Specified by:
setFormName
in interfaceForm
-
getFormName
public String getFormName()
- Specified by:
getFormName
in interfaceForm
-
getFieldTemplates
public List<FieldTemplate> getFieldTemplates()
Gets the template of all of the fields that made this form.- Specified by:
getFieldTemplates
in interfaceForm
- Returns:
- a List of FieldTemplate
-
getTitle
public String getTitle()
Gets the title of this form.
-
setTitle
public void setTitle(String title)
Sets the form title.- Parameters:
title
- the new title of the form.
-
displayScripts
public void displayScripts(javax.servlet.jsp.JspWriter jw, PagesContext pagesContext)
Prints the javascripts which will be used to control the new values given to the data record fields. The error messages may be adapted to a local language. The RecordTemplate gives the field type and constraints. The RecordTemplate gives the local label too. Never throws an Exception but log a a trace and writes an empty string when :- a field is unknown by the template.
- a field has not the required type.
- Specified by:
displayScripts
in interfaceForm
- Parameters:
jw
- the JSP writer into which the javascript is written.pagesContext
- the JSP page context.
-
display
public abstract void display(javax.servlet.jsp.JspWriter out, PagesContext pagesContext, DataRecord record)
Prints this form into the specified JSP writer according to the specified records of data that populate the form fields.
-
display
public void display(javax.servlet.jsp.JspWriter out, PagesContext pagesContext)
Prints this form into the specified JSP writer according to the specified records of data that populate the form fields.
-
update
public List<String> update(List<org.apache.commons.fileupload.FileItem> items, DataRecord record, PagesContext pagesContext)
Updates the values of the dataRecord using the RecordTemplate to extra control information (readOnly or mandatory status). The fieldName must be used to retrieve the HTTP parameter from the request.
-
update
public List<String> update(List<org.apache.commons.fileupload.FileItem> items, DataRecord record, PagesContext pagesContext, boolean updateWysiwyg)
Updates the values of the dataRecord using the RecordTemplate to extra control information (readOnly or mandatory status). The fieldName must be used to retrieve the HTTP parameter from the request.
-
updateWysiwyg
public List<String> updateWysiwyg(List<org.apache.commons.fileupload.FileItem> items, DataRecord record, PagesContext pagesContext)
Updates the values of the dataRecord using the RecordTemplate to extra control information (readOnly or mandatory status). The fieldName must be used to retrieve the HTTP parameter from the request.- Specified by:
updateWysiwyg
in interfaceForm
- Parameters:
items
- the item of a form in which is embbeded multipart data.record
- the record of data.pagesContext
- the page context.
-
isEmpty
public boolean isEmpty(List<org.apache.commons.fileupload.FileItem> items, DataRecord record, PagesContext pagesContext)
Is the form is empty? A form is empty if all of its fields aren't valued (no data associated with them).
-
setName
public void setName(String name)
-
getName
public String getName()
-
getSureField
protected Field getSureField(FieldTemplate fieldTemplate, DataRecord record, int occurrence)
-
getData
public DataRecord getData()
-
setData
public void setData(DataRecord data)
-
setViewForm
public void setViewForm(boolean viewForm)
Description copied from interface:Form
Defines if this form is a 'view' form (opposite to an 'update' form) A 'view' form may have some specific behaviors like to not display empty fields- Specified by:
setViewForm
in interfaceForm
- Parameters:
viewForm
- true if this form is a 'view' form
-
isViewForm
public boolean isViewForm()
-
getFieldDisplayer
protected <T extends Field> FieldDisplayer<T> getFieldDisplayer(FieldTemplate fieldTemplate)
-
getJavascriptSnippet
protected String getJavascriptSnippet()
-
toString
public String toString(PagesContext pageContext)
-
getSkippableSnippet
protected String getSkippableSnippet(PagesContext pageContext)
-
-