Class 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.
    • 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

      • getFieldTemplates

        public List<FieldTemplate> getFieldTemplates()
        Gets the template of all of the fields that made this form.
        Specified by:
        getFieldTemplates in interface Form
        Returns:
        a List of FieldTemplate
      • 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 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 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 embedded 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()
      • 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()
      • getJavascriptSnippet

        protected String getJavascriptSnippet()
      • getSkippableSnippet

        protected String getSkippableSnippet​(PagesContext pageContext)