org.norther.tammi.spray.template.tool
Class FormTool

java.lang.Object
  extended by org.norther.tammi.core.rt.Introspector
      extended by org.norther.tammi.spray.engine.tool.BeanTool
          extended by org.norther.tammi.spray.template.tool.FormTool
All Implemented Interfaces:
Serializable, EventListener, Poolable, Recyclable, ContextBindingListener

public class FormTool
extends BeanTool

A request context tool for rendering forms.

Author:
Ilkka Priha
See Also:
Serialized Form

Constructor Summary
FormTool()
          Constructs a new form.
 
Method Summary
 boolean checkPermission(String actions)
          Checks access permission for the current form.
 boolean checkPermission(Variable variable, String actions)
          Checks access permission for the specified variable.
 void clearFormParameters()
          Clears the request parameters of the current form.
 boolean contains(String name)
          Checks whether the current form variable contains the named attribute.
protected  Variable createVariable(String type)
          Creates a variable MBean instance.
 void dispose()
          Disposes the object after use.
 String getAttributes(String name, MBeanAttributeInfo attribute)
          Resolves a named form property of the specified form attribute.
 Comparator getComparator()
          Gets the comparator of the current form attribute.
 String getDescription()
          Gets the current form attribute description.
 String getDescription(MBeanAttributeInfo attribute)
          Gets the specified form attribute description.
 String getDetail()
          Gets the current form attribute detail.
 String getDetail(MBeanAttributeInfo attribute)
          Gets the specified form attribute detail.
 EnumeratedList getEnumeration()
          Gets the current form attribute value enumeration as a list of localized enumeration entries.
 EnumeratedList getEnumeration(MBeanAttributeInfo attribute)
          Gets the specified form attribute value enumeration as a list of localized enumeration attributes.
 String getForm()
          Gets the form theme of this request.
protected  FormFilter getFormFilter()
          Gets the form filter from the filter stack.
 Map getFormParameters()
          Gets request parameters of the current form.
 String getGroup()
          Gets the current form attribute group.
 String getGroup(MBeanAttributeInfo attribute)
          Gets the specified form attribute group.
 String getId()
          Gets the id of the current form, if any.
 String getIdName()
          Gets the name of the form id field.
 String getIndexName()
          Gets the name of the form index field.
 MBeanAttributeInfo getInfo()
          Gets the attribute info of the current form attribute.
 MBeanAttributeInfo getInfo(String name)
          Gets the named attribute info of the current form variable.
 MBeanAttributeInfo getInfo(String name, boolean unlocked)
          Gets the named and optionally unlocked attribute info of the current form variable.
 String getInvalidation()
          Gets the current form attribute invalidation message.
 String getInvalidation(MBeanAttributeInfo attribute)
          Gets the specified form attribute invalidation message.
 Object getKeyValue()
          Gets the current form key attribute value.
 Object getKeyValue(MBeanAttributeInfo attribute)
          Gets the specified form key attribute value.
 Object getKeyValue(String name)
          Gets the named key attribute value of the current form variable.
 List getList()
          Gets the attribute info list of the current form variable.
 List getList(boolean unlocked)
          Gets the optionally unlocked attribute info list of the current form variable.
 Number getMax()
          Gets the maximum value of the current form attribute.
 Number getMin()
          Gets the minimum value of the current form attribute.
 String getName()
          Gets the current form attribute name with the form prefix.
 String getName(MBeanAttributeInfo attribute)
          Gets the specified form attribute name with the form prefix.
 String getName(String name)
          Gets the named form attribute with the form prefix.
protected  PageFilter getPageFilter()
          Gets the page filter from the filter stack.
 String getParameter()
          Gets the request parameter of the current form attribute.
 String getParameter(MBeanAttributeInfo attribute)
          Gets the request parameter of the specified form attribute.
 String getParameter(String name)
          Gets a named request parameter.
 String getParameter(String name, String def)
          Gets a named request parameter with a default value.
 String[] getParameters()
          Gets the request parameters of the current form attribute.
 String[] getParameters(MBeanAttributeInfo attribute)
          Gets the request parameters of the specified form attribute.
 String[] getParameters(String name)
          Gets named request parameters.
 String getPattern()
          Gets the pattern of the current form attribute.
 String getPrefix()
          Gets the current form prefix, if any.
protected  String getPrefix(int index)
          Gets the indexed prefix.
 int getSelectedEnum()
          Gets the index of the selected enumeration of the current form attribute.
 int getSelectedEnum(MBeanAttributeInfo attribute)
          Gets the index of the selected enumeration of the specified form attribute.
 Set getSelectedEnums()
          Gets the indeces of the selected enumerations of the current form attribute.
 Set getSelectedEnums(MBeanAttributeInfo attribute)
          Gets the indeces of the selected enumerations of the specified form attribute.
 Object getSelectedValue()
          Gets the current form attribute value selected by the user.
 Object getSelectedValue(MBeanAttributeInfo attribute)
          Gets the specified form attribute value selected by the user.
 Object[] getSelectedValues()
          Gets the current form attribute values selected by the user.
 Object[] getSelectedValues(MBeanAttributeInfo attribute)
          Gets the specified form attribute values selected by the user.
 String getType()
          Gets the current form attribute type.
 String getType(MBeanAttributeInfo attribute)
          Gets the specified form attribute type.
 Map getValidation()
          Gets validation exceptions of the current form variable.
 Map getValidation(Variable variable)
          Gets validation exceptions of the specified form variable.
 Map getValidation(Variable variable, int index)
          Gets validation exceptions of the indexed form variable.
 Object getValue()
          Gets the current form attribute value without string conversion or localization.
 Object getValue(MBeanAttributeInfo attribute)
          Gets the specified form attribute value without string conversion or localization.
 Object getValue(String name)
          Gets the named attribute value of the current form variable.
 Variable getVariable()
          Gets the current form variable MBean.
 boolean hasConverter()
          Checks the converter of the current form attribute type.
 boolean isAllVisible()
          Checks whether all attributes of the current form variable are visible.
 boolean isAllVisible(Variable variable)
          Checks whether all attributes of the specified form variable are visible.
 boolean isAnyVisible()
          Checks whether any attribute of the current form variable is visible.
 boolean isAnyVisible(Variable variable)
          Checks whether any attribute of the specified form variable is visible.
 boolean isArray()
          Checks if the current form attribute is an array.
 boolean isBlankAccepted()
          Checks if the current form attribute acceopts blank strings.
 boolean isCloneable()
          Checks if the current form attribute is loneable.
 boolean isCorrelative()
          Checks if the current form attribute is correlative.
 boolean isDisabled()
          Checks if the current form attribute is disabled.
 boolean isEmptyAccepted()
          Checks if the current form attribute is accepts empty arrays.
 boolean isEnumerated()
          Checks if the current form attribute is an enumerated.
 boolean isEqualGroup(MBeanAttributeInfo attribute)
          Checks whether the specified group equals with the current one.
 boolean isInteractive()
          Checks if the current form attribute is interactive.
 boolean isLocal()
          Checks if the current form attribute is local.
 boolean isLocalized()
          Checks if the current form attribute is localized.
 boolean isLocalizedVariables()
          Checks whether variables are localized.
 boolean isMandatory()
          Checks if the current form attribute is mandatory.
 boolean isOrdered()
          Checks if the current form attribute is ordered.
 boolean isReadable()
          Checks if the current form attribute is readable.
 boolean isReadOnly()
          Checks whether the current form is read-only.
 boolean isSameGroup(MBeanAttributeInfo attribute)
          Checks whether the current group should be applied to the specified attribute.
 boolean isSerialized()
          Checks if the current form attribute is serialized.
 boolean isSorted()
          Checks if the current form attribute is sorted.
 boolean isTraceable()
          Checks if the current form attribute is traced.
 boolean isTransient()
          Checks if the current form attribute is transient.
 boolean isTrimmed()
          Checks if the current form attribute is trimmed.
 boolean isValidated()
          Checks whether the current form variable is validated.
 boolean isValidated(Variable variable)
          Checks whether the specified form variable is validated.
 boolean isValidated(Variable variable, int index)
          Checks whether the indexed form variable is validated.
 boolean isVisible()
          Checks if the current form attribute is visible.
 boolean isWritable()
          Checks if the current form attribute is writable.
 int length()
          Returns the length of the current form array attribute.
 int length(MBeanAttributeInfo attribute)
          Returns the length of the specified form array attribute.
 void remove()
          Removes the current form variable MBean.
 void remove(Variable variable)
          Removes the specified form variable MBean.
 void remove(Variable variable, int index)
          Removes the indexed form variable MBean.
 void render()
          Renders the current form variable.
 void render(boolean readonly)
          Renders the current form variable with a read-only option.
 void render(MBeanAttributeInfo attribute)
          Renders a form attribute and marks it as the current one.
 void render(MBeanAttributeInfo attribute, boolean readonly)
          Renders a form attribute with a read-only option and marks it as the current one.
 void render(String template)
          Renders the current form variable with a template.
 void render(String template, boolean readonly)
          Renders the current form variable with a template and read-only option.
 void render(String template, MBeanAttributeInfo attribute)
          Renders a form attribute with a specified template and marks it as the current one.
 void render(String template, MBeanAttributeInfo attribute, boolean readonly)
          Renders a form attribute with a specified template and read-only option and marks it as the current one.
 void render(String template, Variable variable)
          Renders the specified form variable with a template and marks it as the current one.
 void render(String template, Variable variable, boolean readonly)
          Renders the specified form variable with a template and read-only option and marks it as the current one.
 void render(String template, Variable variable, int index)
          Renders the indexed form variable with a template and marks it as the current one.
 void render(String template, Variable variable, int index, boolean readonly)
          Renders the indexed form variable with a template and read-only option and marks it as the current one.
 void render(Variable variable)
          Renders the specified form variable and marks it as the current one.
 void render(Variable variable, boolean readonly)
          Renders the specified form variable with a read-only option and marks it as the current one.
 void render(Variable variable, int index)
          Renders the indexed form variable and marks it as the current one.
 void render(Variable variable, int index, boolean readonly)
          Renders the indexed form variable and read-only option and marks it as the current one.
 void resetForm()
          Resets the form theme of this request and session.
 void resetFormParameters()
          Resets the request parameters of the current form.
 ConcurrentMap resolve()
          Resolves form properties of the current form attribute.
 ConcurrentMap resolve(MBeanAttributeInfo attribute)
          Resolves form properties of the specified form attribute.
 String resolve(String name)
          Resolves a named form property of the current form attribute.
 String resolve(String name, Variable variable, MBeanAttributeInfo attribute)
          Resolves a named form property of the specified form variable and attribute.
 ConcurrentMap resolve(Variable variable, MBeanAttributeInfo attribute)
          Resolves form properties of the specified form variable and attribute.
 Variable restore(String type)
          Restores a saved form variable MBean or creates a new one.
 Variable restore(String type, boolean create)
          Restores a saved form variable MBean.
 Variable restore(String type, int index)
          Restores a saved indexed form variable MBean or creates a new one.
 Variable restore(String type, int index, boolean create)
          Restores a saved indexed form variable MBean.
 void save()
          Saves the current form variable MBean.
 void save(Variable variable)
          Saves the specified form variable MBean.
 void save(Variable variable, int index)
          Saves the indexed form variable MBean.
 void setAllVisible(boolean flag)
          Sets whether all attributes of the current form variable are visible.
 void setAllVisible(Variable variable, boolean flag)
          Sets whether all attributes of the specified form variable are visible.
 void setForm(String name)
          Sets the form theme of this request.
 void setForm(String name, boolean perm)
          Sets the form theme of this request and optionally of this session.
 void setId(String id)
          Sets the id of the current form and resets the index.
 void setInfo(MBeanAttributeInfo attribute)
          Sets the attribute info of the current form attribute.
 void setInfo(String name)
          Sets the named attribute info of the current form attribute.
 void setReadOnly(boolean readonly)
          Sets whether the current form is read-only.
 void setValue(MBeanAttributeInfo attribute, Object value)
          Sets the specified form attribute value without localization.
 void setValue(MBeanAttributeInfo attribute, Object value, boolean forced)
          Sets the specified form attribute value without localization and optionally by-passing attribute's current writable and mandatory settings.
 void setValue(Object value)
          Sets the current form attribute value without localization.
 void setValue(Object value, boolean forced)
          Sets the current form attribute value without localization and optionally by-passing attribute's current writable and mandatory settings.
 void setValue(String name, Object value)
          Sets the named attribute value of the current form variable.
 void setValue(String name, Object value, boolean forced)
          Sets the named attribute value of the current form variable optionally by-passing attribute's current writable and mandatory settings.
 void setVariable(Variable variable)
          Sets the current form variable MBean.
 void setVariable(Variable variable, boolean readonly)
          Sets the current form variable MBean with a read-only option.
 void setVariable(Variable variable, int index)
          Sets the current indexed form variable MBean.
 void setVariable(Variable variable, int index, boolean readonly)
          Sets the current indexed form variable MBean with a read-only option.
 String toString()
          Returns the current form attribute value as a localized string.
 String toString(MBeanAttributeInfo attribute)
          Returns the specified form attribute value as a localized string.
 String toString(String name)
          Returns the named form attribute value as a localized string.
 String[] toStrings()
          Returns the current form attribute values as a localized string array.
 String[] toStrings(MBeanAttributeInfo attribute)
          Returns the specified form attribute values as a localized string array.
 String[] toStrings(String name)
          Returns the named form attribute values as a localized string array.
 boolean update()
          Updates the current form variable with request parameters.
 boolean update(ObjectName name)
          Updates the current form variable with request parameters and exports the result to the specified MBean, if the update was successful.
 boolean update(ObjectName name, AttributeFilter filter)
          Updates the current form variable with request parameters and exports the result to the specified MBean by applying a filter, if the update was successful.
 boolean update(Variable variable)
          Updates the specified form variable with request parameters and marks it as the current one.
 boolean update(Variable variable, int index)
          Updates the indexed form variable with request parameters and marks it as the current one.
 boolean validate()
          Validates request parameters of the current form variable.
 boolean validate(Variable variable)
          Validates request parameters of the specified form variable and marks it as the current one.
 boolean validate(Variable variable, int index)
          Validates request parameters of the indexed form variable and marks it as the current one.
 
Methods inherited from class org.norther.tammi.spray.engine.tool.BeanTool
addValue, addValue, create, create, create, create, disposed, getContext, getContextToolFilter, getDefaultLocale, getDescription, getDetail, getEnumeration, getFilter, getFilterChain, getFilterKey, getGroup, getKeyValue, getMBeanServer, getPrincipal, getRequest, getResourceMap, getResponse, getValue, getValue, getVariableRegistry, isBound, isDisposed, isFilterChanged, length, recycle, recycled, removeValue, removeValue, setValue, setValue, setValue, toString, toStrings, valueBound, valueUnbound
 
Methods inherited from class org.norther.tammi.core.rt.Introspector
clearResourceCache, contains, exportTo, exportTo, getComparator, getConverter, getInfo, getInfo, getList, getList, getLocale, getMax, getMin, getPattern, getResource, getResourceBundle, getResourceBundle, getResourceBundleName, getResourceBundleName, hasConverter, importFrom, importFrom, isArray, isBlankAccepted, isCloneable, isCorrelative, isDisabled, isEmptyAccepted, isEnumerated, isInteractive, isLocal, isLocalized, isMandatory, isOrdered, isReadable, isSerialized, isSorted, isTraceable, isTransient, isTrimmed, isVisible, isWritable, setLocale
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FormTool

public FormTool()
Constructs a new form.

Method Detail

dispose

public void dispose()
Description copied from interface: Recyclable
Disposes the object after use. The method is called when the object is returned to its pool. The dispose method must call its super.

Specified by:
dispose in interface Recyclable
Overrides:
dispose in class BeanTool

restore

public Variable restore(String type)
Restores a saved form variable MBean or creates a new one. New ones are automatically saved into the session.

Parameters:
type - the variable type.
Returns:
the form variable MBean or null.

restore

public Variable restore(String type,
                        boolean create)
Restores a saved form variable MBean. If create is true, a new variable is automatically created and saved into the session when needed.

Parameters:
type - the variable type.
create - true to create a missing variable.
Returns:
the form variable MBean or null.

restore

public Variable restore(String type,
                        int index)
Restores a saved indexed form variable MBean or creates a new one. New ones are automatically saved into the session.

Parameters:
type - the variable type.
index - the form index.
Returns:
the form variable MBean or null.

restore

public Variable restore(String type,
                        int index,
                        boolean create)
Restores a saved indexed form variable MBean. If create is true, a new variable is automatically created and saved into the session when needed.

Parameters:
type - the variable type.
index - the form index.
create - true to create a missing variable.
Returns:
the form variable MBean or null.

save

public void save()
Saves the current form variable MBean.


save

public void save(Variable variable)
Saves the specified form variable MBean.

Parameters:
variable - the variable.

save

public void save(Variable variable,
                 int index)
Saves the indexed form variable MBean.

Parameters:
variable - the variable.
index - the form index.

remove

public void remove()
Removes the current form variable MBean.


remove

public void remove(Variable variable)
Removes the specified form variable MBean.

Parameters:
variable - the variable.

remove

public void remove(Variable variable,
                   int index)
Removes the indexed form variable MBean.

Parameters:
variable - the variable.
index - the form index.

getId

public String getId()
Gets the id of the current form, if any.

Returns:
the form id or null.

setId

public void setId(String id)
Sets the id of the current form and resets the index.

Parameters:
id - the form id.

getIdName

public String getIdName()
Gets the name of the form id field.

Returns:
the form id field name.

getIndexName

public String getIndexName()
Gets the name of the form index field.

Returns:
the form index field name.

getForm

public String getForm()
Gets the form theme of this request.

Returns:
the name of the form theme or null.

setForm

public void setForm(String name)
Sets the form theme of this request.

Parameters:
name - the name of the form theme.

setForm

public void setForm(String name,
                    boolean perm)
Sets the form theme of this request and optionally of this session.

Parameters:
name - the name of the form theme.
perm - set permanently if true.

resetForm

public void resetForm()
Resets the form theme of this request and session.


getPrefix

public String getPrefix()
Gets the current form prefix, if any.

Returns:
the form prefix or null.

getVariable

public Variable getVariable()
Gets the current form variable MBean.

Returns:
the form variable MBean or null.

setVariable

public void setVariable(Variable variable)
Sets the current form variable MBean.

Parameters:
variable - the form variabl