javawebparts.taglib.uiwidgets
Class SwapperTag

java.lang.Object
  |
  +--javax.servlet.jsp.tagext.TagSupport
        |
        +--javax.servlet.jsp.tagext.BodyTagSupport
              |
              +--javawebparts.taglib.uiwidgets.SwapperTag
All Implemented Interfaces:
javax.servlet.jsp.tagext.BodyTag, javax.servlet.jsp.tagext.IterationTag, java.io.Serializable, javax.servlet.jsp.tagext.Tag

public class SwapperTag
extends javax.servlet.jsp.tagext.BodyTagSupport

This class is a custom tag that renders the Swapper UI widget. A Swapper has two boxes separated by four buttons, one button to swap an element from the left box to the right, one to swap from right to left, one to swap all items from the left to the right and one to swap all from right to left. It also has two buttons next to the right box that allows items to be moved up or down in the list. The left box is considered the "source" box and it is meant for the user to construct a list on the right from the items on the left.

This tag renders all necessary HTML and Javascript for this widget, including the function JWP_UIWT_getList(), which can be called to retrieve the list on either side of the swapper. Pass it the ID that you set in the tag iteself, and optionally the constant JWP_UIWT_LEFT or JWP_UIWT_RIGHT to specify which side you want (if you don't pass a second parameter you will get the list on the right). This function returns an array of strings. Here is an example to simply display the list on the right:

alert(JWP_UIWT_getList("swapper1"));

The contents of the tag (i.e., between the opening and closing tag) is for you to fill out. It should be the HTML for the <option> elements of a <select> tag. These options will be populated in the left box of the swapper initially. You can use whatever techniques you like to generate this markup, or it can of course be static. See the usage example below for an illustration of how this all fits together (this is the same usage example demonstrated in the sample app).

This tag uses the following attributes:

Here is a usage example:

<uiwidgets:swapper id="swapper1" boxWidth="150" divStyle="border:2 solid #017fff;" boxStyle="color:#ff0000;">
  <option value="value1"> Value 1 Text</option>
  <option value="value2"> Value 2 Text</option>
  <option value="value3"> Value 3 Text</option>
  <option value="value4"> Value 4 Text</option>
  <option value="value5"> Value 5 Text</option>
</uiwidgets:swapper>

Author:
Frank W. Zammetti.
See Also:
Serialized Form

Field Summary
private  java.lang.String boxClass
          The stylesheet class of the boxes of the Swapper.
private  java.lang.String boxHeight
          The height, in number of items, of the two boxes of the Swapper.
private  java.lang.String boxStyle
          The style of the two boxes of the Swapper.
private  java.lang.String boxWidth
          The width, in pixels, of the two boxes of the Swapper.
private  java.lang.String buttonClass
          The stylesheet class of all the buttons of the Swapper.
private  java.lang.String buttonStyle
          The style of all the buttons of the Swapper.
private  java.lang.String divClass
          The stylesheet class of the
the Swapper belongs in.
private  java.lang.String divStyle
          The style of the
element the Swapper is in.
private static java.lang.String FUNCTIONS_DECLARED_ATTRIBUTE
           
private  java.lang.String id
          The ID of the
the Swapper is in.
private static org.apache.commons.logging.Log log
          Log instance.
 
Fields inherited from class javax.servlet.jsp.tagext.BodyTagSupport
bodyContent
 
Fields inherited from class javax.servlet.jsp.tagext.TagSupport
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
SwapperTag()
           
 
Method Summary
 int doEndTag()
          Render widget code.
 int doStartTag()
          Render widget code.
private  void outputFunctions(java.lang.StringBuffer out)
          Writes the <script> containing the JavaScript function to the passed in StringBuffer.
 void setBoxClass(java.lang.String inBoxClass)
          Mutator for boxClass field.
 void setBoxHeight(java.lang.String inBoxHeight)
          Mutator for boxHeight field.
 void setBoxStyle(java.lang.String inBoxStyle)
          Mutator for boxStyle field.
 void setBoxWidth(java.lang.String inBoxWidth)
          Mutator for boxWidth field.
 void setButtonClass(java.lang.String inButtonClass)
          Mutator for buttonClass field.
 void setButtonStyle(java.lang.String inButtonStyle)
          Mutator for buttonStyle field.
 void setDivClass(java.lang.String inDivClass)
          Mutator for divClass field.
 void setDivStyle(java.lang.String inDivStyle)
          Mutator for divStyle field.
 void setId(java.lang.String inID)
          Mutator for ID field.
 
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, 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

FUNCTIONS_DECLARED_ATTRIBUTE

private static final java.lang.String FUNCTIONS_DECLARED_ATTRIBUTE
See Also:
Constant Field Values

log

private static org.apache.commons.logging.Log log
Log instance.


id

private java.lang.String id
The ID of the
the Swapper is in.


boxWidth

private java.lang.String boxWidth
The width, in pixels, of the two boxes of the Swapper. This value should be set to a value large enough to ensure that any value you may add to the boxes will fit. This will default to 100 if not present.


boxHeight

private java.lang.String boxHeight
The height, in number of items, of the two boxes of the Swapper. This is the same thing as the size attribute of a