net.jot.web.forms
Class JOTGeneratedForm

java.lang.Object
  extended by net.jot.web.view.JOTViewBlock
      extended by net.jot.web.view.JOTViewTag
          extended by net.jot.web.forms.JOTForm
              extended by net.jot.web.forms.JOTGeneratedForm
Direct Known Subclasses:
JOTDBForm, JOTPropertiesForm

public abstract class JOTGeneratedForm
extends JOTForm

This is a generic object you can implement/subclass to have a simple HTML form generated from data. You can subclass it as-is or reimplement/copy methods to modify the generated Html Or implement one of the subclasses such as JOTDBForm You will want to add the needed css classes to your css file. see bellow getCss()

Author:
thibautc

Field Summary
static java.lang.String HAD_SUCCESS
           
 
Fields inherited from class net.jot.web.forms.JOTForm
REQUEST_ID
 
Fields inherited from class net.jot.web.view.JOTViewBlock
content, visible
 
Constructor Summary
JOTGeneratedForm()
           
 
Method Summary
 void addCategory(JOTFormCategory cat)
          Adds a form category (form section sperator with title)
 void addFormField(JOTFormField field)
          Adds a form field
 void addSubmitButton(JOTFormSubmitButton button)
          The form submit button
protected  java.lang.String getCss()
          Ovveride this to change the form CSS It's probably best to have this css into your template and have this return an empty string.
protected  java.lang.String getDescription(JOTFormField field, int spanCpt)
          Ovveride this to change the look of the description (a.k.a form field help CSS popup)
 java.lang.String getFormAction()
           
protected  java.lang.String getFormBowells(JOTFlowRequest request)
          Generates HTMl for the inside of the form, ovveride for cutom html
 java.lang.String getHtml(JOTFlowRequest request)
          Ovveride this to change the look.
 java.util.Vector getItems()
          Returns all the items (fields,categories,buttons etc..) composing this form.
protected  java.lang.String getJavascript()
          Ovveride this if you want custom javascript
 void init(JOTFlowRequest request)
          You can use this method to set initial form values (Called the first time the form is created) Ex: defineField("name", JOTFormConst.TEXTAREA); get("fname").setValue("toto");
abstract  void layoutForm(JOTFlowRequest request)
           
 void refreshData(JOTFlowRequest request)
           
 void setFormAction(java.lang.String action)
          Sets where the form should go to "action" Ex: setFormAction("submitform.do");
 void setFormTitle(java.lang.String title)
          Mai title for the form, that appears at the top of the form
 java.util.Hashtable validate(JOTFlowRequest request)
          You need to define this method to you want to validate your form.
abstract  java.util.Hashtable validateForm(JOTFlowRequest request)
          Implement this to validate the form Return a hashtable of errors, or null/empty hashtable if no errors
 
Methods inherited from class net.jot.web.forms.JOTForm
defineField, get, getAll, getErrors, getResult, hasValidated, preValidate, reparseForm, save, setErrors, setHasValidated, setResult, validatePermissions
 
Methods inherited from class net.jot.web.view.JOTViewTag
getFlags, getTagProperties, removeFlag, setFlag, setTagProperty, unsetTagProperty
 
Methods inherited from class net.jot.web.view.JOTViewBlock
getContent, isVisible, setContent, setVisible
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HAD_SUCCESS

public static final java.lang.String HAD_SUCCESS
See Also:
Constant Field Values
Constructor Detail

JOTGeneratedForm

public JOTGeneratedForm()
Method Detail

layoutForm

public abstract void layoutForm(JOTFlowRequest request)
Parameters:
request -

getHtml

public java.lang.String getHtml(JOTFlowRequest request)
                         throws java.lang.Exception
Ovveride this to change the look. if you don't like the default.

Throws:
java.lang.Exception

getJavascript

protected java.lang.String getJavascript()
Ovveride this if you want custom javascript


getCss

protected java.lang.String getCss()
Ovveride this to change the form CSS It's probably best to have this css into your template and have this return an empty string. This here are just default that would work independently of the template.


getDescription

protected java.lang.String getDescription(JOTFormField field,
                                          int spanCpt)
Ovveride this to change the look of the description (a.k.a form field help CSS popup)

Parameters:
field -
spanCpt -
Returns:

getFormBowells

protected java.lang.String getFormBowells(JOTFlowRequest request)
                                   throws java.lang.Exception
Generates HTMl for the inside of the form, ovveride for cutom html

Throws:
java.lang.Exception

addFormField

public void addFormField(JOTFormField field)
Adds a form field

Parameters:
field -

addCategory

public void addCategory(JOTFormCategory cat)
Adds a form category (form section sperator with title)

Parameters:
cat -

addSubmitButton

public void addSubmitButton(JOTFormSubmitButton button)
The form submit button

Parameters:
button -

setFormTitle

public void setFormTitle(java.lang.String title)
Mai title for the form, that appears at the top of the form

Parameters:
title -

init

public void init(JOTFlowRequest request)
          throws java.lang.Exception
Description copied from class: JOTForm
You can use this method to set initial form values (Called the first time the form is created) Ex: defineField("name", JOTFormConst.TEXTAREA); get("fname").setValue("toto");

Specified by:
init in class JOTForm
Throws:
java.lang.Exception

refreshData

public void refreshData(JOTFlowRequest request)
                 throws java.lang.Exception
Throws:
java.lang.Exception

getFormAction

public java.lang.String getFormAction()

setFormAction

public void setFormAction(java.lang.String action)
Sets where the form should go to "action" Ex: setFormAction("submitform.do");

Parameters:
action -

validateForm

public abstract java.util.Hashtable validateForm(JOTFlowRequest request)
                                          throws java.lang.Exception
Implement this to validate the form Return a hashtable of errors, or null/empty hashtable if no errors

Returns:
Throws:
java.lang.Exception

validate

public final java.util.Hashtable validate(JOTFlowRequest request)
                                   throws java.lang.Exception
Description copied from class: JOTForm
You need to define this method to you want to validate your form. The returned a hashtable or error messages (String error_id, String error_text) The hashtable should be empty/null if no errors occured. Ex: Hashtable h=new Hashtable(); h.put("error1","Password invalid");

Specified by:
validate in class JOTForm
Throws:
java.lang.Exception

getItems

public java.util.Vector getItems()
Returns all the items (fields,categories,buttons etc..) composing this form.

Returns: