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

Quick Search    Search Deep

jreceiver.util.taglibs
Class PageNavigationTag  view PageNavigationTag download PageNavigationTag.java

java.lang.Object
  extended byjavax.servlet.jsp.tagext.TagSupport
      extended byjreceiver.util.taglibs.PageNavigationTag
All Implemented Interfaces:
javax.servlet.jsp.tagext.IterationTag, javax.servlet.jsp.tagext.JspTag, java.io.Serializable, javax.servlet.jsp.tagext.Tag

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

JSP Tag pageNavigation, used to display an array of page numbers to traverse a large set of data.

Required attributes are total_pages and page_no. url_pattern is optional and defaults to page{0}.html which produces page1.html, page2.html, etc. It uses a MessageFormat pattern where {0} is replaced by the page number (pageNo) and {1} is replaced by the page count (totalPages).

Example of default output for page numbers 1 through 16:

 <<- 1 2 3 4 .. 16 ->>
 <<- 1 2 3 4 5 .. 16 ->>
 <<- 1 2 3 4 5 6 .. 16 ->>
 <<- 1 2 3 4 5 6 7 .. 16 ->>
 <<- 1 2 3 4 5 6 7 8 .. 16 ->>
 <<- 1 2 3 4 5 6 7 8 9 .. 16 ->>
 <<- 1 .. 4 5 6 7 8 9 10 .. 16 ->>
 <<- 1 .. 5 6 7 8 9 10 11 .. 16 ->>
 <<- 1 .. 6 7 8 9 10 11 12 .. 16 ->>
 <<- 1 .. 7 8 9 10 11 12 13 .. 16 ->>
 <<- 1 .. 8 9 10 11 12 13 14 15 16 ->>
 <<- 1 .. 9 10 11 12 13 14 15 16 ->>
 <<- 1 .. 10 11 12 13 14 15 16 ->>
 <<- 1 .. 11 12 13 14 15 16 ->>
 <<- 1 .. 12 13 14 15 16 ->>
 <<- 1 .. 13 14 15 16 ->>
 

Example usage:

 
 

Version:
$Revision: 1.5 $ $Date: 2002/07/31 11:29:43 $

Field Summary
private  int block_size
          The size of the floating block of numbers, with (block_size/2) number on either side of the current page no.
private static int DEFAULT_BLOCK_SIZE
           
private static java.lang.String DEFAULT_NEXT
           
private static java.lang.String DEFAULT_PREV
           
private  java.lang.String default_text
          The default text if the tag or number given is invalid/null
private static int DEFAULT_THRESHOLD
           
private static java.lang.String DEFAULT_URL_PATTERN
           
protected static org.apache.commons.logging.Log log
          logging sink
private  java.lang.String next
          The string (or image) to represent the right arrow
private  int page_no
          The current page number, 1-indexed
private  java.lang.String prev
          The string (or image) to represent the left arrow
private  int threshold
          The point at which diresis (sp?) will begin to show up on either side of the list of numbers as the floating block moves away from the edge.
private  int total_pages
          The number of pages we provide navigation over
private  java.text.MessageFormat url_format
          The template used to generate links for each page number we display
 
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
PageNavigationTag()
           
 
Method Summary
 int doEndTag()
          Method called at end of Tag
 int doStartTag()
          Method called at start of tag -- extract attributes
private  java.lang.String getHref(int page_no, java.lang.Object displayed)
          Do a MessageFormat of the url_pattern with the following optional parameters:
 void setBlockSize(int block_size)
          Assign the block size
 void setDefault(java.lang.String default_text)
          Set the default text if an invalid number or no tag body is given
 void setNext(java.lang.String next)
          Set the right arrow text or image
 void setPageNo(int page_no)
          Assign the current page number
 void setPrev(java.lang.String prev)
          Set the left arrow text or image
 void setThreshold(int threshold)
          Assign the threshold
 void setTotalPages(int total_pages)
          Assign the total pages
 void setUrlPattern(java.lang.String url_pattern)
          Set the url template
 
Methods inherited from class javax.servlet.jsp.tagext.TagSupport
doAfterBody, findAncestorWithClass, getId, getParent, getValue, getValues, release, 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

DEFAULT_BLOCK_SIZE

private static final int DEFAULT_BLOCK_SIZE
See Also:
Constant Field Values

DEFAULT_THRESHOLD

private static final int DEFAULT_THRESHOLD
See Also:
Constant Field Values

DEFAULT_PREV

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

DEFAULT_NEXT

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

DEFAULT_URL_PATTERN

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

page_no

private int page_no
The current page number, 1-indexed


block_size

private int block_size
The size of the floating block of numbers, with (block_size/2) number on either side of the current page no.

Must be an odd number, three or greater.


threshold

private int threshold
The point at which diresis (sp?) will begin to show up on either side of the list of numbers as the floating block moves away from the edge.

Must be greater than 3.


prev

private java.lang.String prev
The string (or image) to represent the left arrow


next

private java.lang.String next
The string (or image) to represent the right arrow


total_pages

private int total_pages
The number of pages we provide navigation over


url_format

private java.text.MessageFormat url_format
The template used to generate links for each page number we display


default_text

private java.lang.String default_text
The default text if the tag or number given is invalid/null


log

protected static org.apache.commons.logging.Log log
logging sink

Constructor Detail

PageNavigationTag

public PageNavigationTag()
Method Detail

doStartTag

public final int doStartTag()
                     throws javax.servlet.jsp.JspException
Method called at start of tag -- extract attributes


doEndTag

public final int doEndTag()
                   throws javax.servlet.jsp.JspException
Method called at end of Tag


getHref

private java.lang.String getHref(int page_no,
                                 java.lang.Object displayed)
Do a MessageFormat of the url_pattern with the following optional parameters:

   {0} the page number
   {1} total pages
 


setThreshold

public final void setThreshold(int threshold)
                        throws javax.servlet.jsp.JspException
Assign the threshold


setBlockSize

public final void setBlockSize(int block_size)
                        throws javax.servlet.jsp.JspException
Assign the block size


setPrev

public final void setPrev(java.lang.String prev)
Set the left arrow text or image


setNext

public final void setNext(java.lang.String next)
Set the right arrow text or image


setPageNo

public final void setPageNo(int page_no)
                     throws javax.servlet.jsp.JspException
Assign the current page number


setTotalPages

public final void setTotalPages(int total_pages)
                         throws javax.servlet.jsp.JspException
Assign the total pages


setUrlPattern

public final void setUrlPattern(java.lang.String url_pattern)
Set the url template


setDefault

public final void setDefault(java.lang.String default_text)
Set the default text if an invalid number or no tag body is given