CLRA 0.1.2

com.clra.web
Class YearViewSelectorTag

java.lang.Object
  |
  +--javax.servlet.jsp.tagext.TagSupport
        |
        +--com.clra.web.YearViewSelectorTag
All Implemented Interfaces:
Serializable, javax.servlet.jsp.tagext.Tag

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

Stuff.

Version:
$Revision: 1.2 $ $Date: 2002/02/18 18:07:33 $
Author:
Rick Hall
See Also:
Serialized Form

Field Summary
protected static org.apache.struts.util.MessageResources messages
          The message resources for this package
protected  String page
          The context-relative URI
 
Fields inherited from class javax.servlet.jsp.tagext.TagSupport
id, pageContext
 
Fields inherited from interface javax.servlet.jsp.tagext.Tag
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE
 
Constructor Summary
YearViewSelectorTag()
           
 
Method Summary
protected  String createLink(int year, javax.servlet.http.HttpServletRequest request)
          Creates a link from the currentYear request
protected  String createLink(int year, String contextPath, String page)
          Create a link from the specified page
protected  String createQueryString(int year, Hashtable queryParams)
          Form a query string from current parameter and the specified year
protected  void doEndLink()
           
 int doEndTag()
          Render the end of the selector
protected  void doStartLink(int year)
           
 int doStartTag()
          Render the beginning of the selector
protected  void doYearLeadingSeparationText(int unused)
          Writes the text that separates year links
protected  void doYearLink(int year)
          Write a year link
protected  void doYearLinks()
          Writes several year links
protected  void doYearText(int year)
          Writes a Calendar-based year (4 digits) as user-friendly text
protected  void doYearTrailingSeparationText(int unused)
          Writes the text that separates year links
 Integer getCurrentYear()
          Return the currently selected year (4 digits, or null)
 String getPage()
          Return the context-relative URI
static boolean hasFourDigits(int year)
          A slightly mis-named utility that checks if an int is positive and has four digits.
static boolean hasFourDigits(Integer year)
          A slightly mis-named utility that checks if an Integer is positive and has four digits.
 void release()
          Release any acquired resources.
static void resetYearInContexts(javax.servlet.jsp.PageContext context, Integer year)
          A utility which resets request and session attributes so that only the session attribute AN_YEAR holds the currently selected year.
 void setCurrentYear(Integer currentYear)
          Set the currently selected year (4 digits, or null)
 void setPage(String page)
          Set the context-relative URI
static Integer yearFromContext(javax.servlet.jsp.PageContext context)
          A utility which determines what year should be currently selected based on the page context.
 
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
 

Field Detail

messages

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

page

protected String page
The context-relative URI
Constructor Detail

YearViewSelectorTag

public YearViewSelectorTag()
Method Detail

getPage

public String getPage()
Return the context-relative URI

setPage

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

getCurrentYear

public Integer getCurrentYear()
Return the currently selected year (4 digits, or null)

setCurrentYear

public void setCurrentYear(Integer currentYear)
                    throws javax.servlet.jsp.JspException
Set the currently selected year (4 digits, or null)

hasFourDigits

public static boolean hasFourDigits(Integer year)
A slightly mis-named utility that checks if an Integer is positive and has four digits.

hasFourDigits

public static boolean hasFourDigits(int year)
A slightly mis-named utility that checks if an int is positive and has four digits.

yearFromContext

public static Integer yearFromContext(javax.servlet.jsp.PageContext context)
A utility which determines what year should be currently selected based on the page context. The algorithm is:
  1. Check for a request parameter named IEventList.AN_YEAR. If found, and it is a valid Integer (4 digits), use it.
  2. Check for a request attribute named IEventList.AN_YEAR. If found, and it is valid, use it.
  3. Check for a session attribute named IEventList.AN_YEAR. If found, and it is valid, use it.
  4. If a valid year hasn't been determined yet, return the current calendar year

resetYearInContexts

public static void resetYearInContexts(javax.servlet.jsp.PageContext context,
                                       Integer year)
A utility which resets request and session attributes so that only the session attribute AN_YEAR holds the currently selected year. The algorithm is:
  1. Check for a request attribute named IEventList.AN_YEAR. If found, remove it.
  2. Check for a session attribute named IEventList.AN_YEAR. If found, reset to the specified value; otherwise create and set it.
If the specified year is invalid (not 4 digits), no action is taken and an error is logged.

createQueryString

protected String createQueryString(int year,
                                   Hashtable queryParams)
Form a query string from current parameter and the specified year

createLink

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

createLink

protected String createLink(int year,
                            javax.servlet.http.HttpServletRequest request)
Creates a link from the currentYear request

doStartLink

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

doEndLink

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

doYearText

protected void doYearText(int year)
                   throws javax.servlet.jsp.JspException
Writes a Calendar-based year (4 digits) as user-friendly text

doYearLeadingSeparationText

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

doYearTrailingSeparationText

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

doYearLink

protected void doYearLink(int year)
                   throws javax.servlet.jsp.JspException
Write a year link

doYearLinks

protected void doYearLinks()
                    throws javax.servlet.jsp.JspException
Writes several year links

doStartTag

public int doStartTag()
               throws javax.servlet.jsp.JspException
Render the beginning of the selector
Overrides:
doStartTag in class javax.servlet.jsp.tagext.TagSupport

doEndTag

public int doEndTag()
             throws javax.servlet.jsp.JspException
Render the end of the selector
Overrides:
doEndTag in class javax.servlet.jsp.tagext.TagSupport

release

public void release()
Release any acquired resources.
Overrides:
release in class javax.servlet.jsp.tagext.TagSupport

CLRA 0.1.2