net.mlw.vlh.web.tag
Class DefaultPagingTag

java.lang.Object
  extended byjavax.servlet.jsp.tagext.TagSupport
      extended byjavax.servlet.jsp.tagext.BodyTagSupport
          extended bynet.mlw.vlh.web.tag.ConfigurableTag
              extended bynet.mlw.vlh.web.tag.DefaultPagingTag
All Implemented Interfaces:
Attributeable, javax.servlet.jsp.tagext.BodyTag, javax.servlet.jsp.tagext.IterationTag, Serializable, javax.servlet.jsp.tagext.Tag

public class DefaultPagingTag
extends ConfigurableTag

Generate buttons to navigate through pages of data using i18n (internationalization). The following keys are required to be define in message sources.

If you like to, you can add your properties file in your locale and add this lines of code in your language:

Summary info:
  1. paging.text.totalRow={0} Total
  2. paging.text.pageFromTotal= {0} of {1} page(s)
Paging info:
  1. paging.first(off), paging.first(on)
  2. paging.previous(off), paging.previous(on)
  3. paging.forward(off), paging.forward(on)
  4. paging.last(off), paging.last(on)
  5. paging.delim
  6. paging.text.totalRow
  7. paging.text.pageFromTotal
Focus info:
  1. paging.focus(on), paging.focus(off), paging.focus(disabled), paging.focus(error)
Items per page info:
  1. paging.itemsPerPage.label = Items Per Page:
  2. paging.itemsPerPage.title = Number of items per page.
  3. paging.itemsPerPage.button = Set

Version:
$Revision: 1.38 $ $Date: 2005/11/23 15:02:16 $
Author:
Matthew L. Wilson, Andrej Zachar
See Also:
Serialized Form

Field Summary
 
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
DefaultPagingTag()
           
 
Method Summary
 int doAfterBody()
           
 int doEndTag()
           
 int doStartTag()
           
protected  ValueListConfigBean getConfig()
           
protected  Locale getLocale()
           
protected  String getMessage(String code, Object[] args, Locale locale)
          Try to resolve the message.
protected  String getMessage(String code, Object[] args, String defaultMessage, Locale locale)
          Try to resolve the message.
 int getPages()
           
protected  TableInfo getTableInfo()
           
protected  ValueList getValueList()
           
protected  ValueListInfo getValueListInfo()
           
protected  void init(javax.servlet.http.HttpServletRequest request)
           
 boolean isGenerateItemsPerPageForm()
           
 boolean isShowItemsPerPage()
           
 boolean isShowSummary()
           
 void release()
          Called on a Tag handler to release state.
protected  void renderFocusControl(StringBuffer sb)
           
protected  void renderItemsPerPage(StringBuffer sb, HashMap itemsPerPageParameters)
           
protected  void renderPagingLink(StringBuffer sb, Map parameters, String value)
          Renders <a> tag for control buttons.
protected  void renderPerPageInputBox(StringBuffer sb, Map attributes)
          Render input box for items per page.
protected  void renderPerPageLabel(StringBuffer sb, Map attributes, String text)
          Render label for items per page input box.
protected  void renderPerPageSubmitButton(StringBuffer sb, Map attributes)
          Render submit button for items per page input box.
protected  void renderSumary(StringBuffer sb)
           
 void setGenerateItemsPerPageForm(boolean nestedForm)
           
 void setPages(int pages)
           
 void setShowItemsPerPage(boolean showItemsPerPage)
          Enable or disable generating form for number of items per page.
 void setShowSummary(boolean showSummary)
           
 
Methods inherited from class net.mlw.vlh.web.tag.ConfigurableTag
appendClassCellAttribute, getAttributes, getCellAttributes, resetAttributes, setAttributes, setCellAttribute
 
Methods inherited from class javax.servlet.jsp.tagext.BodyTagSupport
doInitBody, getBodyContent, getPreviousOut, 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
 

Constructor Detail

DefaultPagingTag

public DefaultPagingTag()
Method Detail

getConfig

protected ValueListConfigBean getConfig()

getValueList

protected ValueList getValueList()

getValueListInfo

protected ValueListInfo getValueListInfo()

getTableInfo

protected TableInfo getTableInfo()

getLocale

protected Locale getLocale()

init

protected void init(javax.servlet.http.HttpServletRequest request)
             throws javax.servlet.jsp.JspException
Throws:
javax.servlet.jsp.JspException

doStartTag

public int doStartTag()
               throws javax.servlet.jsp.JspException
Throws:
javax.servlet.jsp.JspException
See Also:
TagSupport.doStartTag()

getMessage

protected String getMessage(String code,
                            Object[] args,
                            Locale locale)
                     throws org.springframework.context.NoSuchMessageException,
                            javax.servlet.jsp.JspException
Try to resolve the message. Treat as an error if the message can't be found.

Parameters:
code - the code to lookup up, such as 'calculator.noRateSet'
args - Array of arguments that will be filled in for params within the message (params look like "{0}", "{1,date}", "{2,time}" within a message), or null if none.
locale - the Locale in which to do the lookup
Returns:
the resolved message
Throws:
org.springframework.context.NoSuchMessageException - if the message wasn't found
javax.servlet.jsp.JspException
See Also:
java.text.MessageFormat

getMessage

protected String getMessage(String code,
                            Object[] args,
                            String defaultMessage,
                            Locale locale)
                     throws org.springframework.context.NoSuchMessageException,
                            javax.servlet.jsp.JspException
Try to resolve the message. Return default message if no message was found.

Parameters:
code - the code to lookup up, such as 'calculator.noRateSet'. Users of this class are encouraged to base message names on the relevant fully qualified class name, thus avoiding conflict and ensuring maximum clarity.
args - array of arguments that will be filled in for params within the message (params look like "{0}", "{1,date}", "{2,time}" within a message), or null if none.
locale - the Locale in which to do the lookup
defaultMessage - String to return if the lookup fails
Returns:
the resolved message if the lookup was successful; otherwise the default message passed as a parameter
Throws:
org.springframework.context.NoSuchMessageException
javax.servlet.jsp.JspException
See Also:
java.text.MessageFormat

renderItemsPerPage

protected void renderItemsPerPage(StringBuffer sb,
                                  HashMap itemsPerPageParameters)
                           throws org.springframework.context.NoSuchMessageException,
                                  javax.servlet.jsp.JspException
Parameters:
sb -
itemsPerPageParameters -
Throws:
org.springframework.context.NoSuchMessageException
javax.servlet.jsp.JspException

renderPerPageLabel

protected void renderPerPageLabel(StringBuffer sb,
                                  Map attributes,
                                  String text)
Render label for items per page input box. Subclasses can overide or extend the method to provide different behaviour.

Parameters:
sb - StringBuffer to render into
attributes -
text -

renderPerPageInputBox

protected void renderPerPageInputBox(StringBuffer sb,
                                     Map attributes)
Render input box for items per page. Subclasses can overide or extend the method to provide different behaviour.

Parameters:
sb - StringBuffer to tender into
attributes - Attributes for rendering a tag

renderPerPageSubmitButton

protected void renderPerPageSubmitButton(StringBuffer sb,
                                         Map attributes)
Render submit button for items per page input box. Subclasses can overide or extend the method to provide different behaviour.

Parameters:
sb -
attributes -

renderSumary

protected void renderSumary(StringBuffer sb)
                     throws org.springframework.context.NoSuchMessageException,
                            javax.servlet.jsp.JspException
Parameters:
sb -
Throws:
javax.servlet.jsp.JspException
org.springframework.context.NoSuchMessageException

renderFocusControl

protected void renderFocusControl(StringBuffer sb)
                           throws javax.servlet.jsp.JspException
Parameters:
sb -
Throws:
javax.servlet.jsp.JspException

doAfterBody

public int doAfterBody()
                throws javax.servlet.jsp.JspException
Throws:
javax.servlet.jsp.JspException
See Also:
IterationTag.doAfterBody()

doEndTag

public int doEndTag()
             throws javax.servlet.jsp.JspException
Specified by:
doEndTag in interface javax.servlet.jsp.tagext.Tag
Overrides:
doEndTag in class ConfigurableTag
Throws:
javax.servlet.jsp.JspException
See Also:
TagSupport.doEndTag()

renderPagingLink

protected void renderPagingLink(StringBuffer sb,
                                Map parameters,
                                String value)
Renders <a> tag for control buttons. Subclasses can overide or extend the method to provide different behaviour.

Parameters:
sb - StringBuffer to render into
parameters - Map of parameters
value - Label

getPages

public int getPages()
Returns:
Returns the pages.

setPages

public void setPages(int pages)
Parameters:
pages - The pages to set.

isShowSummary

public boolean isShowSummary()
Returns:
showSummary

setShowSummary

public void setShowSummary(boolean showSummary)
Parameters:
showSummary - The showSummary to set.

isShowItemsPerPage

public boolean isShowItemsPerPage()
Returns:
showItemsPerPage

setShowItemsPerPage

public void setShowItemsPerPage(boolean showItemsPerPage)
Enable or disable generating form for number of items per page.

Parameters:
showItemsPerPage -

isGenerateItemsPerPageForm

public boolean isGenerateItemsPerPageForm()
Returns:
Returns the generateItemsPerPageForm.

setGenerateItemsPerPageForm

public void setGenerateItemsPerPageForm(boolean nestedForm)
Parameters:
nestedForm -

release

public void release()
Called on a Tag handler to release state. The page compiler guarantees that JSP page implementation objects will invoke this method on all tag handlers, but there may be multiple invocations on doStartTag and doEndTag in between.

Specified by:
release in interface javax.servlet.jsp.tagext.Tag
Overrides:
release in class ConfigurableTag
See Also:
Tag.release()


Copyright © 2003-2006 mlavilson. All Rights Reserved.