Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.clra.web
Class NameSelectorTag  view NameSelectorTag download NameSelectorTag.java

java.lang.Object
  extended byjavax.servlet.jsp.tagext.TagSupport
      extended bycom.clra.web.NameSelectorTag
All Implemented Interfaces:
javax.servlet.jsp.tagext.IterationTag, javax.servlet.jsp.tagext.JspTag, java.io.Serializable, javax.servlet.jsp.tagext.Tag

public class NameSelectorTag
extends javax.servlet.jsp.tagext.TagSupport

Allows the user to choose a group of items, selected by the first letter of their name.

Selection is case-insensitive and limited to 8 predefined groups, like the buttons on a telephone:

  1. ABC - names less than 'D'
  2. DEF - names greater than 'D' and less than 'G'
  3. GHI - names greater than 'G' and less than 'J'
  4. JKL - names greater than 'J' and less than 'M'
  5. MNO - names greater than 'M' and less than 'P'
  6. PQRS - names greater than 'P' and less than 'T'
  7. TUV - names greater than 'T' and less than 'W'
  8. WXYZ - names greater than or equal to 'W'
Note that the first group, ABC, may contain names like "3Com", whereas the last group, WXYZ, may contain names like "Ėtvos". Also note that the group is indexed from '2', not '0'.

Version:
$Revision: 1.4 $ $Date: 2003/02/26 03:38:46 $

Field Summary
private static java.util.Map _groups
          The cached value of the groups used by this selector
private static java.lang.String base
           
private  java.lang.Integer currentGroup
          The currently selected group (2 - 9)
protected static org.apache.struts.util.MessageResources messages
          The message resources for this package
protected  java.lang.String page
          The context-relative URI
private static org.apache.log4j.Category theLog
           
 
Fields inherited from class javax.servlet.jsp.tagext.TagSupport
id, pageContext
 
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
NameSelectorTag()
           
 
Method Summary
protected  java.lang.String createLink(int group, javax.servlet.http.HttpServletRequest request)
          Creates a link from the currentGroup request
protected  java.lang.String createLink(int group, java.lang.String contextPath, java.lang.String page)
          Create a link from the specified page
protected  java.lang.String createQueryString(int group, java.util.Hashtable queryParams)
          Form a query string from current parameter and the specified group
protected  void doEndLink()
           
 int doEndTag()
          Render the end of the selector
protected  void doGroupLeadingSeparationText(int unused)
          Writes the text that separates group links
protected  void doGroupLink(int group)
          Write a group link
protected  void doGroupLinks()
          Writes an alphabet's worth of group links
protected  void doGroupText(int group)
          Writes a Integer-based group (2 - 9) as user-friendly text
protected  void doGroupTrailingSeparationText(int unused)
          Writes the text that separates group links
protected  void doStartLink(int group)
           
 int doStartTag()
          Render the beginning of the selector
 java.lang.Integer getCurrentGroup()
          Return the currently selected group (2 - 9, or null)
 java.lang.String getPage()
          Return the context-relative URI
static java.lang.Integer groupFromContext(javax.servlet.jsp.PageContext context)
          A utility which determines what group should be currently selected based on the page context.
protected static java.util.Map groups()
          The groups used by this selector
 void release()
          Release any acquired resources.
static void resetGroupInContexts(javax.servlet.jsp.PageContext context, java.lang.Integer group)
          A utility which resets request and session attributes so that only the session attribute AN_GROUP holds the currently selected name.
 void setCurrentGroup(java.lang.Integer currentGroup)
          Set the currently selected group (2 - 9, or null)
 void setPage(java.lang.String page)
          Set the context-relative URI
 
Methods inherited from class javax.servlet.jsp.tagext.TagSupport
doAfterBody, 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
 

Field Detail

base

private static final java.lang.String base

theLog

private static final org.apache.log4j.Category theLog

messages

protected static org.apache.struts.util.MessageResources messages
The message resources for this package


_groups

private static java.util.Map _groups
The cached value of the groups used by this selector


page

protected java.lang.String page
The context-relative URI


currentGroup

private java.lang.Integer currentGroup
The currently selected group (2 - 9)

Constructor Detail

NameSelectorTag

public NameSelectorTag()
Method Detail

groups

protected static java.util.Map groups()
The groups used by this selector


getPage

public java.lang.String getPage()
Return the context-relative URI


setPage

public void setPage(java.lang.String page)
Set the context-relative URI


getCurrentGroup

public java.lang.Integer getCurrentGroup()
Return the currently selected group (2 - 9, or null)


setCurrentGroup

public void setCurrentGroup(java.lang.Integer currentGroup)
                     throws javax.servlet.jsp.JspException
Set the currently selected group (2 - 9, or null)


groupFromContext

public static java.lang.Integer groupFromContext(javax.servlet.jsp.PageContext context)
A utility which determines what group should be currently selected based on the page context. The algorithm is:
  1. Check for a request parameter named INameList.AN_GROUP. If found, and it is a valid Integer in the range 2 - 9, use it.
  2. Check for a request attribute named INameList.AN_GROUP. If found, and it is valid, use it.
  3. Check for a session attribute named INameList.AN_GROUP. If found, and it is valid, use it.
  4. If a valid group hasn't been determined yet, return the index of the first group, ABC (index 2).


resetGroupInContexts

public static void resetGroupInContexts(javax.servlet.jsp.PageContext context,
                                        java.lang.Integer group)
A utility which resets request and session attributes so that only the session attribute AN_GROUP holds the currently selected name. The algorithm is:
  1. Check for a request attribute named INameList.AN_GROUP. If found, remove it.
  2. Check for a session attribute named INameList.AN_GROUP. If found, reset to the specified value; otherwise create and set it.
If the specified name is invalid (not between 2 - 9, inclusive), no action is taken and an error is logged.


createQueryString

protected java.lang.String createQueryString(int group,
                                             java.util.Hashtable queryParams)
Form a query string from current parameter and the specified group


createLink

protected java.lang.String createLink(int group,
                                      java.lang.String contextPath,
                                      java.lang.String page)
                               throws javax.servlet.jsp.JspException
Create a link from the specified page


createLink

protected java.lang.String createLink(int group,
                                      javax.servlet.http.HttpServletRequest request)
Creates a link from the currentGroup request


doStartLink

protected void doStartLink(int group)
                    throws javax.servlet.jsp.JspException

doEndLink

protected void doEndLink()
                  throws javax.servlet.jsp.JspException

doGroupText

protected void doGroupText(int group)
                    throws javax.servlet.jsp.JspException
Writes a Integer-based group (2 - 9) as user-friendly text


doGroupLeadingSeparationText

protected void doGroupLeadingSeparationText(int unused)
                                     throws javax.servlet.jsp.JspException
Writes the text that separates group links


doGroupTrailingSeparationText

protected void doGroupTrailingSeparationText(int unused)
                                      throws javax.servlet.jsp.JspException
Writes the text that separates group links


doGroupLink

protected void doGroupLink(int group)
                    throws javax.servlet.jsp.JspException
Write a group link


doGroupLinks

protected void doGroupLinks()
                     throws javax.servlet.jsp.JspException
Writes an alphabet's worth of group links


doStartTag

public int doStartTag()
               throws javax.servlet.jsp.JspException
Render the beginning of the selector


doEndTag

public int doEndTag()
             throws javax.servlet.jsp.JspException
Render the end of the selector


release

public void release()
Release any acquired resources.