net.jot.web.forms
Class JOTDBForm

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
                  extended by net.jot.web.forms.JOTDBForm

public abstract class JOTDBForm
extends JOTGeneratedForm

This form helps into automatically generating/parsing an HTMl form to/From a Database entry(DB Model) It allows for simple CRUD actions on a db object. This is an extension of JOTGeneratedForm, see that for extra documentation. TODO: maybe sublass this for fully automated form this would use a text file description of the form and be fully automatic (stored in db)

Author:
thibautc

Field Summary
static java.lang.String JOT_GENERATED_FORM_ID
          ID for JOT form
static java.lang.String JOT_GENERATED_FORM_MODEL_CLASS
          stores the form/model java class
static java.lang.String JOT_GENERATED_FORM_TOKEN
          The token is here for security reasons, so that somebody can't fake the form request and change a different DB entry than the one he is suppose to be editing
protected  JOTModel model
          You should set this value in your implementatio in upatemodel()
 
Fields inherited from class net.jot.web.forms.JOTGeneratedForm
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
JOTDBForm()
           
 
Method Summary
 void addFormField(JOTFormField field)
          Adds a field to the form
protected  java.lang.String getFormBowells(JOTFlowRequest request)
          Generate the html for the "inside" of the form, using the DB object(model) to set the values etc...
 JOTModel getModel()
           
 void refreshData(JOTFlowRequest request)
          Needs to be called whenever you want the form data to be re-fetched from the data source/db Need to be called at least once after the form is created.
 void save(JOTFlowRequest request)
          Saves the form value into the DB object.
abstract  void updateModel(JOTFlowRequest request)
          This should be implemented so that it: - retrieves/update the "model" object(ie: does the db query to find/update the DB/Model object).
 
Methods inherited from class net.jot.web.forms.JOTGeneratedForm
addCategory, addSubmitButton, getCss, getDescription, getFormAction, getHtml, getItems, getJavascript, init, layoutForm, setFormAction, setFormTitle, validate, validateForm
 
Methods inherited from class net.jot.web.forms.JOTForm
defineField, get, getAll, getErrors, getResult, hasValidated, preValidate, reparseForm, 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

JOT_GENERATED_FORM_ID

public static final java.lang.String JOT_GENERATED_FORM_ID
ID for JOT form

See Also:
Constant Field Values

JOT_GENERATED_FORM_TOKEN

public static final java.lang.String JOT_GENERATED_FORM_TOKEN
The token is here for security reasons, so that somebody can't fake the form request and change a different DB entry than the one he is suppose to be editing

See Also:
Constant Field Values

JOT_GENERATED_FORM_MODEL_CLASS

public static final java.lang.String JOT_GENERATED_FORM_MODEL_CLASS
stores the form/model java class

See Also:
Constant Field Values

model

protected JOTModel model
You should set this value in your implementatio in upatemodel()

Constructor Detail

JOTDBForm

public JOTDBForm()
Method Detail

getFormBowells

protected java.lang.String getFormBowells(JOTFlowRequest request)
                                   throws java.lang.Exception
Generate the html for the "inside" of the form, using the DB object(model) to set the values etc...

Overrides:
getFormBowells in class JOTGeneratedForm
Parameters:
request -
Returns:
Throws:
java.lang.Exception

addFormField

public void addFormField(JOTFormField field)
Adds a field to the form

Overrides:
addFormField in class JOTGeneratedForm

refreshData

public void refreshData(JOTFlowRequest request)
                 throws java.lang.Exception
Needs to be called whenever you want the form data to be re-fetched from the data source/db Need to be called at least once after the form is created.

Overrides:
refreshData in class JOTGeneratedForm
Throws:
java.lang.Exception

save

public void save(JOTFlowRequest request)
          throws java.lang.Exception
Saves the form value into the DB object.

Specified by:
save in class JOTForm
Parameters:
request -
Throws:
java.lang.Exception

updateModel

public abstract void updateModel(JOTFlowRequest request)
                          throws java.lang.Exception
This should be implemented so that it: - retrieves/update the "model" object(ie: does the db query to find/update the DB/Model object). ex: .... JOTSQLQueryParams params=new JOTSQLQueryParams(); params.addCondition(new JOTSQLCondition("id",JOTSQLCondition.IS_EQUAL,request.getParameter("userId"))); model=JOTQueryManager.findOrCreateOne(MyModelImpl.class, params); ....

Throws:
java.lang.Exception

getModel

public JOTModel getModel()