net.sourceforge.jstags.tags.forms
Class FormRules

java.lang.Object
  extended by javax.servlet.jsp.tagext.TagSupport
      extended by javax.servlet.jsp.tagext.BodyTagSupport
          extended by net.sourceforge.jstags.tags.JSTagsBodyTagSupport
              extended by net.sourceforge.jstags.tags.forms.FormRules
All Implemented Interfaces:
java.io.Serializable, javax.servlet.jsp.tagext.BodyTag, javax.servlet.jsp.tagext.IterationTag, javax.servlet.jsp.tagext.JspTag, javax.servlet.jsp.tagext.Tag

public class FormRules
extends JSTagsBodyTagSupport

It allows the configuration of a form(HTML form) so that, the input fields can be shown and hidden depending on the values of other fields in the form This effect depends on the javascript library Mochikit

Since:
1.0
Author:
sschz@users.sourceforge.net
See Also:
Serialized Form

Field Summary
private  java.lang.String displayAlways
           
private  java.lang.String formName
           
private static org.apache.log4j.Logger logger
          Logger for this class
private  net.sf.json.JSONArray rules
           
private static long serialVersionUID
           
 
Fields inherited from class javax.servlet.jsp.tagext.BodyTagSupport
bodyContent
 
Fields inherited from class javax.servlet.jsp.tagext.TagSupport
id, pageContext
 
Fields inherited from interface javax.servlet.jsp.tagext.BodyTag
EVAL_BODY_BUFFERED, EVAL_BODY_TAG
 
Fields inherited from interface javax.servlet.jsp.tagext.IterationTag
EVAL_BODY_AGAIN
 
Fields inherited from interface javax.servlet.jsp.tagext.Tag
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
 
Constructor Summary
FormRules()
           
 
Method Summary
 void addRule(java.lang.String field, net.sf.json.JSONObject pairs)
           
 int doStartTag()
           
 java.lang.String getDisplayAlways()
           
 java.lang.String getFormName()
           
 net.sf.json.JSONArray getRules()
           
protected  java.lang.String getTemplateName()
           
protected  java.util.Map<java.lang.String,java.lang.String> getTemplateNameValuePairs()
           
 void setDisplayAlways(java.lang.String displayAlways)
           
 void setFormName(java.lang.String formName)
           
 
Methods inherited from class net.sourceforge.jstags.tags.JSTagsBodyTagSupport
doEndTag, getOutput
 
Methods inherited from class javax.servlet.jsp.tagext.BodyTagSupport
doAfterBody, doInitBody, getBodyContent, getPreviousOut, release, setBodyContent
 
Methods inherited from class javax.servlet.jsp.tagext.TagSupport
findAncestorWithClass, getId, getParent, getValue, getValues, removeValue, setId, setPageContext, setParent, setValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.servlet.jsp.tagext.Tag
getParent, setPageContext, setParent
 

Field Detail

logger

private static final org.apache.log4j.Logger logger
Logger for this class


serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

formName

private java.lang.String formName

displayAlways

private java.lang.String displayAlways

rules

private net.sf.json.JSONArray rules
Constructor Detail

FormRules

public FormRules()
Method Detail

doStartTag

public int doStartTag()
               throws javax.servlet.jsp.JspException
Specified by:
doStartTag in interface javax.servlet.jsp.tagext.Tag
Overrides:
doStartTag in class javax.servlet.jsp.tagext.BodyTagSupport
Throws:
javax.servlet.jsp.JspException

getTemplateName

protected java.lang.String getTemplateName()
                                    throws javax.servlet.jsp.JspException
Specified by:
getTemplateName in class JSTagsBodyTagSupport
Returns:
name of the .JS template used to create the JavaScript code used by this tag
Throws:
javax.servlet.jsp.JspException

getTemplateNameValuePairs

protected java.util.Map<java.lang.String,java.lang.String> getTemplateNameValuePairs()
Specified by:
getTemplateNameValuePairs in class JSTagsBodyTagSupport
Returns:
Map of [name, value] pairs representing all the name-value pairs used to create the JavaScript code. Such pairs will be used to replace data inside the .js template in order to adapt the JavaScript code to a certain effect.

getDisplayAlways

public java.lang.String getDisplayAlways()
Returns:
the fields to be displayed when the page is loaded and at any other time. It is a String in the form ['fieldId1', 'fieldId2', ...] where fieldIdX represents the id of a form field to be displayed

setDisplayAlways

public void setDisplayAlways(java.lang.String displayAlways)

addRule

public void addRule(java.lang.String field,
                    net.sf.json.JSONObject pairs)
Parameters:
field - id of the form field
pairs - JSONObject with the information on what fields are to be displayed when field has a certain value. This object, has the form {"fieldValue1": "[fieldToShow1, fieldToShow2]", "fieldValue2": "[fieldToShow3, fieldToShow4]"} where:
  • fieldValueX: represents a possible value of the field that, when set, will make other form fields to be shown or hidden(the ones in []).
  • fieldToShowX: represents a field that will be shown when the field value is equals to fieldValueY. If fieldToShowX is '*', all the fields in the form will be displayed when that rule is applied.

getFormName

public java.lang.String getFormName()
Returns:
the name of the form that is being configured

setFormName

public void setFormName(java.lang.String formName)
Parameters:
formName - the name of the form that is being configured

getRules

public net.sf.json.JSONArray getRules()
Returns:
all the rules used to configure the form. Every rule is set by means of a FormRule tag


Copyright © 2007. All Rights Reserved.