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.
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 :
.... <init-param> <param-name>formViewConfig</param-name> <param-value>/WEB-INF/form-view.xml,/WEB-INF/form-view.xml</param-value> </init-param> ....
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");
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.