Manual with JSP Only

Introduction

This section describes how integrate quickly FormView with JSP Only (Without Struts) with basic configuration of FormView. To configurate FormView (form-view.xml; displayer-config.xml), you must define the FormviewServlet in your web.xml. So after you can use FormView like Struts.

FormviewServlet

To configurate FormviewServlet servlet, you must do like this :

  ....
  <!-- Servlet FormView which load config of FormView -->
  <servlet>
    <servlet-name>action</servlet-name>
      <servlet-class>net.sourceforge.formview.servlet.FormViewServlet</servlet-class>
      <!-- FormView Config files (Required) -->
      <init-param>
        <param-name>formViewConfig</param-name>
        <param-value>/WEB-INF/form-view.xml</param-value>
      </init-param>
      <!-- Displayer Config files (Not required) -->
      <init-param>
        <param-name>displayerConfig</param-name>
        <param-value>/WEB-INF/displayers-config.xml</param-value>
      </init-param>                     
      <load-on-startup>1</load-on-startup>
  </servlet>
  ....

This Servlet initialize :

  • formViewConfig which contains form-view.xml to use. If you have several configuration files, you can declare it sperated by , character, like this :
      ....
      <init-param>
        <param-name>formViewConfig</param-name>
        <param-value>/WEB-INF/form-view.xml,/WEB-INF/form-view.xml</param-value>
      </init-param>
      ....
  • displayerConfig, if you want configure your displayer config.

Using FormView in your JSP

Once FormView configurate, you can use FormView with request variable and application variable :

  // Set state to READ
  WEBFormViewUtil.saveState(request, application, FormViewConstants.STATE_READ);
  // Save Formview 
  WEBFormViewUtil.saveFormView(request, application, "/project");
  

Manage date, required and maxlength property.

If you use FormView, without Struts, you have not validation XML configuration for merging date, required and maxlength property with field. But you can manage it (to add automaticly (*) if field is required, calendar.gif if field is date, by configuring formview-config.xml like this :

  <form name="/project" >
    <field property="name" required="true" />
    <field property="date" date="true" />
    <field property="managerId" required="true" />
  </form>
  

This configuration will add (*) to name and managerId input HTML and will add a calendar.gif to date input HTML.