org.ztemplates.web.request.impl
Class ZFormServiceImpl

java.lang.Object
  extended by org.ztemplates.web.request.impl.ZFormServiceImpl
All Implemented Interfaces:
ZIFormService

public class ZFormServiceImpl
extends Object
implements ZIFormService


Field Summary
 
Fields inherited from interface org.ztemplates.web.ZIFormService
SPRING_NAME
 
Constructor Summary
ZFormServiceImpl(ZIServletService servletService, ZIActionApplicationContext actionContext)
           
 
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.
 Set<ZProperty> getPropertiesByName(ZIForm form, Set<String> propNames)
           
 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
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ZFormServiceImpl

public ZFormServiceImpl(ZIServletService servletService,
                        ZIActionApplicationContext actionContext)
Method Detail

setWriteable

public void setWriteable(ZIForm form,
                         boolean b)
                  throws Exception
Description copied from interface: ZIFormService
sets all Properties in a form to writeable b

Specified by:
setWriteable in interface ZIFormService
Throws:
Exception

setReadable

public void setReadable(ZIForm form,
                        boolean b)
                 throws Exception
Description copied from interface: ZIFormService
sets all Properties in the form to readable b

Specified by:
setReadable in interface ZIFormService
Throws:
Exception

setRequired

public void setRequired(ZIForm form,
                        boolean b)
                 throws Exception
Description copied from interface: ZIFormService
sets all Properties in a form to required b

Specified by:
setRequired in interface ZIFormService
Throws:
Exception

getJavaScriptDependency

public ZScriptDependency getJavaScriptDependency(ZIForm form)
                                          throws Exception
Description copied from interface: ZIFormService
returns the JavaScript needed by the form, typically by StringValidators in Properties.

Specified by:
getJavaScriptDependency in interface ZIFormService
Returns:
Throws:
Exception

copyValuesToForm

public void copyValuesToForm(ZFormValues values,
                             ZIForm form)
                      throws Exception
Description copied from interface: ZIFormService
writes the form values back into the form.

Specified by:
copyValuesToForm in interface ZIFormService
Throws:
Exception

copyFormToValues

public void copyFormToValues(ZIForm form,
                             ZFormValues values)
                      throws Exception
Description copied from interface: ZIFormService
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.

Specified by:
copyFormToValues in interface ZIFormService
Throws:
Exception

getPropertiesByName

public Set<ZProperty> getPropertiesByName(ZIForm form,
                                          Set<String> propNames)
                                   throws Exception
Throws:
Exception

initPropertyNames

public void initPropertyNames(ZIForm form)
                       throws Exception
Description copied from interface: ZIFormService
initialized the property names if the form has not been processed by a action, but created manually.

Specified by:
initPropertyNames in interface ZIFormService
Throws:
Exception

initPropertyNames

public void initPropertyNames(ZIForm form,
                              String formId)
                       throws Exception
Description copied from interface: ZIFormService
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

Specified by:
initPropertyNames in interface ZIFormService
formId - the formId, is prepended to each propertyName
Throws:
Exception

computeJson

public org.json.JSONObject computeJson(ZIForm form)
                                throws Exception
Description copied from interface: ZIFormService
computes a JSON representation of a form, used typically in AJAX - Call - Handlers

Specified by:
computeJson in interface ZIFormService
Returns:
Throws:
Exception

serialize

public String serialize(Serializable obj)
                 throws Exception
Description copied from interface: ZIFormService
serializes a object to a string that can be put into a hidden form parameter

Specified by:
serialize in interface ZIFormService
Returns:
Throws:
Exception

deserialize

public Object deserialize(String s)
                   throws Exception
Description copied from interface: ZIFormService
deserializes a object serialized to a string with serialize()

Specified by:
deserialize in interface ZIFormService
Returns:
Throws:
Exception

copyFormToSession

public void copyFormToSession(ZIForm form)
                       throws Exception
Description copied from interface: ZIFormService
same as copyFormToSession(form.getClass().getName(), form); stores the form values into the servlet session under the form class name

Specified by:
copyFormToSession in interface ZIFormService
Throws:
Exception

copyFormToSession

public void copyFormToSession(String name,
                              ZIForm form)
                       throws Exception
Description copied from interface: ZIFormService
stores the form values into the servlet session under the given name

Specified by:
copyFormToSession in interface ZIFormService
Throws:
Exception

copySessionToForm

public void copySessionToForm(ZIForm form)
                       throws Exception
Description copied from interface: ZIFormService
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.

Specified by:
copySessionToForm in interface ZIFormService
Throws:
Exception

copySessionToForm

public void copySessionToForm(String name,
                              ZIForm form)
                       throws Exception
Description copied from interface: ZIFormService
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.

Specified by:
copySessionToForm in interface ZIFormService
Throws:
Exception


Copyright © 2011. All Rights Reserved.