com.silverpeas.form
Class AbstractForm

java.lang.Object
  extended by com.silverpeas.form.AbstractForm
All Implemented Interfaces:
Form
Direct Known Subclasses:
HtmlForm, XmlForm, XmlSearchForm

public abstract class AbstractForm
extends Object
implements Form

This abstract class implements the form interface and provides for all concretes classes a default implementation of some displaying methods.


Field Summary
static String CONTEXT_FORM_FILE
           
static String CONTEXT_FORM_IMAGE
           
static String REPEATED_FIELD_CSS_HIDE
           
static String REPEATED_FIELD_CSS_SHOW
           
static String REPEATED_FIELD_SEPARATOR
           
 
Constructor Summary
AbstractForm(RecordTemplate template)
          Creates a new form from the specified template of records.
 
Method Summary
 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()
           
 List<FieldTemplate> getFieldTemplates()
          Gets the template of all of the fields that made this form.
 String getFormName()
           
 String getName()
           
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 fields
 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).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.silverpeas.form.Form
toString
 

Field Detail

CONTEXT_FORM_FILE

public static final String CONTEXT_FORM_FILE
See Also:
Constant Field Values

CONTEXT_FORM_IMAGE

public static final String CONTEXT_FORM_IMAGE
See Also:
Constant Field Values

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 interface Form

getFormName

public String getFormName()

getFieldTemplates

public List<FieldTemplate> getFieldTemplates()
Gets the template of all of the fields that made this form.

Returns:

getTitle

public String getTitle()
Gets the title of this form.

Specified by:
getTitle in interface Form
Returns:
the title of this form or an empty string if it isn't set.

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 silvertrace and writes an empty string when :

Specified by:
displayScripts in interface Form
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.

Specified by:
display in interface Form
Parameters:
out - the JSP writer.
pagesContext - the JSP page context.
record - the record the data records embbed 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.

Specified by:
display in interface Form
Parameters:
out - the JSP writer.
pagesContext - the JSP page context.

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.

Specified by:
update in interface Form
Parameters:
items - the item of a form in which is embbeded multipart data.
record - the record of data.
pagesContext - the page context.

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.

Specified by:
update in interface Form
Parameters:
items - the item of a form in which is embbeded multipart data.
record - the record of data.
pagesContext - the page context.
updateWysiwyg - flag indicating if all of WYSIWYG data can be updated.

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 interface Form
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).

Specified by:
isEmpty in interface Form
Parameters:
items - the items embbeding multipart data in the form.
record - the record of data.
pagesContext - the page context.
Returns:
true if one of the form field has no data.

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)
Specified by:
setData in interface Form

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 interface Form
Parameters:
viewForm - true if this form is a 'view' form

isViewForm

public boolean isViewForm()


Copyright © 2016 Silverpeas. All Rights Reserved.