org.ztemplates.web
Interface ZIFormService

All Known Implementing Classes:
ZFormServiceImpl, ZFormServiceSpring

public interface ZIFormService

Methods useful when doing form processing.

Author:
www.gerdziegler.de

Field Summary
static String SPRING_NAME
           
 
Method Summary
 org.json.JSONObject computeJson(ZIForm form)
          computes a JSON representation of a form, used typically in AJAX - Call - Handlers
 void copyFormToSession(String name, ZIForm form)
          stores the form values into the servlet session under the given name
 void copyFormToSession(ZIForm form)
          same as copyFormToSession(form.getClass().getName(), form); stores the form values into the servlet session under the form class name
 void copyFormToValues(ZIForm form, ZFormValues values)
          writes the form's values into a ZFormValues object that can be kept in a servlet session.
 void copySessionToForm(String name, ZIForm form)
          restores the form values from the servlet session, the values must be stored before under the given name with copyFormToSession.
 void copySessionToForm(ZIForm form)
          same as copySessionToForm(form.getClass().getName(), form); restores the form values from the servlet session, the values must be stored before with copyFormToSession.
 void copyValuesToForm(ZFormValues values, ZIForm form)
          writes the form values back into the form.
 Object deserialize(String s)
          deserializes a object serialized to a string with serialize()
 ZScriptDependency getJavaScriptDependency(ZIForm form)
          returns the JavaScript needed by the form, typically by StringValidators in Properties.
 void initPropertyNames(ZIForm form)
          initialized the property names if the form has not been processed by a action, but created manually.
 void initPropertyNames(ZIForm form, String formId)
          initialized the property names if the form has not been processed by a action, but created manually and you have multiple forms on your page, to ensure the ids are unique
 String serialize(Serializable obj)
          serializes a object to a string that can be put into a hidden form parameter
 void setReadable(ZIForm form, boolean b)
          sets all Properties in the form to readable b
 void setRequired(ZIForm form, boolean b)
          sets all Properties in a form to required b
 void setWriteable(ZIForm form, boolean b)
          sets all Properties in a form to writeable b
 

Field Detail

SPRING_NAME

static final String SPRING_NAME
See Also:
Constant Field Values
Method Detail

setWriteable

void setWriteable(ZIForm form,
                  boolean b)
                  throws Exception
sets all Properties in a form to writeable b

Parameters:
form -
b -
Throws:
Exception

setRequired

void setRequired(ZIForm form,
                 boolean b)
                 throws Exception
sets all Properties in a form to required b

Parameters:
form -
b -
Throws:
Exception

setReadable

void setReadable(ZIForm form,
                 boolean b)
                 throws Exception
sets all Properties in the form to readable b

Parameters:
form -
b -
Throws:
Exception

computeJson

org.json.JSONObject computeJson(ZIForm form)
                                throws Exception
computes a JSON representation of a form, used typically in AJAX - Call - Handlers

Parameters:
form -
Returns:
Throws:
Exception

serialize

String serialize(Serializable obj)
                 throws Exception
serializes a object to a string that can be put into a hidden form parameter

Parameters:
obj -
Returns:
Throws:
Exception

deserialize

Object deserialize(String s)
                   throws Exception
deserializes a object serialized to a string with serialize()

Parameters:
s -
Returns:
Throws:
Exception

copyValuesToForm

void copyValuesToForm(ZFormValues values,
                      ZIForm form)
                      throws Exception
writes the form values back into the form.

Throws:
Exception

copyFormToValues

void copyFormToValues(ZIForm form,
                      ZFormValues values)
                      throws Exception
writes the form's values into a ZFormValues object that can be kept in a servlet session. Do not keep the ZIform itself in the session, only the values. This is to avoid keeping any unwanted objects around. Use this to get the values form a form, the values are intended to be stored in the servlet session, Use this to keep form state between requests, do not keep the form object itself in the servlet session.

Throws:
Exception

copyFormToSession

void copyFormToSession(String name,
                       ZIForm form)
                       throws Exception
stores the form values into the servlet session under the given name

Parameters:
form -
Throws:
Exception

copyFormToSession

void copyFormToSession(ZIForm form)
                       throws Exception
same as copyFormToSession(form.getClass().getName(), form); stores the form values into the servlet session under the form class name

Parameters:
form -
Throws:
Exception

copySessionToForm

void copySessionToForm(String name,
                       ZIForm form)
                       throws Exception
restores the form values from the servlet session, the values must be stored before under the given name with copyFormToSession. If no form values can be found under that name, nothing is done.

Parameters:
form -
Throws:
Exception

copySessionToForm

void copySessionToForm(ZIForm form)
                       throws Exception
same as copySessionToForm(form.getClass().getName(), form); restores the form values from the servlet session, the values must be stored before with copyFormToSession. If no form values can be found under that name, nothing is done.

Parameters:
form -
Throws:
Exception

getJavaScriptDependency

ZScriptDependency getJavaScriptDependency(ZIForm form)
                                          throws Exception
returns the JavaScript needed by the form, typically by StringValidators in Properties.

Parameters:
form -
Returns:
Throws:
Exception

initPropertyNames

void initPropertyNames(ZIForm form)
                       throws Exception
initialized the property names if the form has not been processed by a action, but created manually.

Parameters:
form -
Throws:
Exception

initPropertyNames

void initPropertyNames(ZIForm form,
                       String formId)
                       throws Exception
initialized the property names if the form has not been processed by a action, but created manually and you have multiple forms on your page, to ensure the ids are unique

Parameters:
form -
formId - the formId, is prepended to each propertyName
Throws:
Exception


Copyright © 2011. All Rights Reserved.