|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.jalios.jcms.context.JcmsContext
com.jalios.jcms.handler.PagerHandler
public class PagerHandler
This form handler process pager properties. It provides methods to retrieve common URLs needed to navigate using the pager. Unless really needed, you should prefer the use of the PagerTag inside your jsp rather than directly use this class. We use a compute method in order to be able for the PagerTag to provide the handler first even when the size/itemsNbr is not known yet.
| Field Summary | |
|---|---|
static int |
DEFAULT_PAGE_SIZE
|
static java.lang.String |
DEFAULT_SORT
|
static java.lang.String |
FORCED_PARAM_PREFIX
Prefix of request attributes name to force values of : "pageSize", "sort", "reverse" (before pager creation) and "pagerAll", "start" (before computation). |
static java.lang.String |
HANDLER_ATTRIBUTE
Request attribute name to retrieve the PagerHandler instance in a pager template. |
static int[] |
PAGE_SIZES
|
static int |
PAGER_ALL_LIMIT
|
static java.lang.String |
REVISION
|
static java.lang.String |
TEMPLATE_NAME_ATTRIBUTE
Request attribute name to retrieve the name of the pager template being processed. |
| Fields inherited from class com.jalios.jcms.context.JcmsContext |
|---|
browser, caddy, channel, inFO, initDone, initWorkspace, isAdmin, isAjaxRequest, isDBMember, isDebug, isLogged, loggedMember, request, response, userLang, userLocale, workspace |
| Fields inherited from interface com.jalios.util.JaliosConstants |
|---|
CRLF, MILLIS_IN_ONE_DAY, MILLIS_IN_ONE_HOUR, MILLIS_IN_ONE_MINUTE, MILLIS_IN_ONE_MONTH, MILLIS_IN_ONE_SECOND, MILLIS_IN_ONE_WEEK, MILLIS_IN_ONE_YEAR |
| Constructor Summary | |
|---|---|
PagerHandler(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
java.lang.String pParamPrefix,
int pDefaultPageSize,
java.lang.String pDefaultSort,
boolean pDefaultReverse,
int[] pPageSizes,
int pPagerAllLimit,
java.util.Map<java.lang.String,java.lang.String> pParameterMap,
int[] pPagesDisplayed)
Build a new PagerHandler. |
|
| Method Summary | |
|---|---|
boolean |
canShowPagerAll()
Check if the pager all link can be displayed. |
void |
clearSessionParams()
Clear all session parameters of this pager, if the paramPrefix specified is a portlet action param (starts PortalManager.PORTAL_ACTION... |
void |
compute(int pItemsNbr)
Do the computation for this Pager Handler |
void |
display(javax.servlet.jsp.PageContext pageContext,
java.lang.String template)
Display the pager using the specified template. |
int |
getCurrentPage()
This method CANNOT be called as long as the computation is not done. |
java.lang.String |
getFirstLinkURL()
This method CANNOT be called as long as the computation is not done. |
int |
getItemsNbr()
Retrieves the number of items managed by this pager. |
java.lang.String |
getLastLinkURL()
This method CANNOT be called as long as the computation is not done. |
java.lang.String |
getLinkCss()
Sets the css to use in links (default is empty). |
java.lang.String |
getNextLinkURL()
This method CANNOT be called as long as the computation is not done. |
java.lang.String |
getPageLinkURL(int pageIdx)
This method CANNOT be called as long as the computation is not done. |
java.lang.String |
getPagerAllURL()
This method CANNOT be called as long as the computation is not done. |
int |
getPageSize()
This method CANNOT be called as long as the computation is not done. |
int[] |
getPageSizes()
Retrieves the page sizes to be displayed for this pager. |
int |
getPagesLinksEndNbr()
Retrieves the number of the last page link to be displayed. |
int[] |
getPagesLinksNbrs()
Retrieves the page link numbers to be displayed. |
int |
getPagesLinksStartNbr()
Retrieves the number of the first page link to be displayed. |
int |
getPagesNbr()
Retrieves the total number of pages of this pager . |
java.lang.String |
getPreviousLinkURL()
This method CANNOT be called as long as the computation is not done. |
boolean |
getShowFirstLink()
|
boolean |
getShowLastLink()
|
java.lang.String |
getShowPagerURL()
This method CANNOT be called as long as the computation is not done. |
java.lang.String |
getShowPageSizeURL(int pPageSize)
This method CANNOT be called as long as the computation is not done. |
java.lang.String |
getSort()
This method can be called when the computation has not yet been done. |
java.lang.String |
getSortURL(java.lang.String pSort)
Return an URL to sort with given sort order. |
java.lang.String |
getSortURL(java.lang.String pSort,
boolean pReverse)
This method CANNOT be called as long as the computation is not done. |
int |
getStart()
Retrieves the start item idx of the pager. |
boolean |
isComputed()
|
boolean |
isFirstPage()
This method CANNOT be called as long as the computation is not done. |
boolean |
isLastPage()
This method CANNOT be called as long as the computation is not done. |
boolean |
isPagerAll()
Checks if this pager is in pager all mode. |
boolean |
isReverse()
This method can be called when the computation has not yet been done. |
void |
printAllPager(javax.servlet.jsp.JspWriter out)
Print a complete pager to the given output. |
void |
printFirstLink(javax.servlet.jsp.JspWriter out)
Print on the given JspWriter a link to show the First page. |
void |
printLastLink(javax.servlet.jsp.JspWriter out)
Print a link to navigate to the Last Page. |
void |
printNextLink(javax.servlet.jsp.JspWriter out)
Print a link to navigate to the next page. |
void |
printPagerAllLink(javax.servlet.jsp.JspWriter out)
Print a "Pager All" link to the given output (only if items nbr is allowed by property pager.show-all-limit). |
void |
printPagesLinks(javax.servlet.jsp.JspWriter out)
Print a list of links for current accessible pages to the given output. |
void |
printPreviousLink(javax.servlet.jsp.JspWriter out)
Print a link to navigate to the previous page. |
void |
printShowPagerLink(javax.servlet.jsp.JspWriter out)
Print a "Show Pager" link to the given output. |
boolean |
printShowPageSizesLink(javax.servlet.jsp.JspWriter out)
Print a list of links for changing the current page size (must be a valid page size as specified in property pager.page-sizes). |
void |
printSortLink(javax.servlet.jsp.JspWriter out,
java.lang.String pSort,
java.lang.String pTitleProp)
Print a link to sort with given sort order. |
void |
setLinkCss(java.lang.String css)
Sets the css to use in links (default is empty). |
void |
setResourcePath(java.lang.String resourcePath)
Sets the resourcePath to use in the url instead of using the current request resource path (default is null). |
void |
setShowFirstLink(boolean showFirstLink)
|
void |
setShowLastLink(boolean showLastLink)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String REVISION
public static final int[] PAGE_SIZES
public static final int PAGER_ALL_LIMIT
public static final int DEFAULT_PAGE_SIZE
public static final java.lang.String DEFAULT_SORT
public static final java.lang.String FORCED_PARAM_PREFIX
request.setAttribute(FORCED_PARAM_PREFIX + myPagerParamPrefix + "start", String.valueOf(myItemIdx));
public static final java.lang.String HANDLER_ATTRIBUTE
PagerHandler handler = (PagerHandler) request.getAttribute(PagerHandler.HANDLER_ATTRIBUTE);
public static final java.lang.String TEMPLATE_NAME_ATTRIBUTE
String template = (String) request.getAttribute(PagerHandler.TEMPLATE_NAME_ATTRIBUTE);
| Constructor Detail |
|---|
public PagerHandler(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
java.lang.String pParamPrefix,
int pDefaultPageSize,
java.lang.String pDefaultSort,
boolean pDefaultReverse,
int[] pPageSizes,
int pPagerAllLimit,
java.util.Map<java.lang.String,java.lang.String> pParameterMap,
int[] pPagesDisplayed)
request - the HttpServletRequest as needed by super class JcmsContextresponse - the HttpServletResponse as needed by super class JcmsContextpParamPrefix - an optionnal prefix to use for all pager parameterspDefaultPageSize - the default page size to use for this pager.
Leave below 0 to use default value specified in "pager.default-page-size", 10.pDefaultSort - the default sort order to use, possible values are usually defined
by the possible parameters value of the methods
Data.getComparator(String, boolean) and
Publication.getComparator(String, boolean).
Leave empty 0 to use default value specified in "pager.default-sort", "".pDefaultReverse - whether to reverse the sort (true) order or not (false).pPageSizes - the page sizes allowed for this pager, if null, the values specified
in the property "pager.page-sizes" are used, {10, 20, 50}.
If the default page size is not one of those, it is automatically
added to possible page size.pPagerAllLimit - the maximum number of items above which the pager all link
won't be displayed.
Leave below 0 to use default value specified in "pager.pager-all-limit", 500.pParameterMap - an optionnal Map of parameters
(String name/ String value) to be added/modified/removed
to every URLs generated by this pager.
For example, { "openTab" ==> "2", "highlight" ==> "hello world"}.pPagesDisplayed - maximum number of page links to display :| Method Detail |
|---|
public void compute(int pItemsNbr)
pItemsNbr - the number of items in the pagerpublic boolean isComputed()
compute(int)public void setResourcePath(java.lang.String resourcePath)
resourcePath - the resource path that will be used in all url,
can be empty, but if null, the resourcePath of current request will be used.
java.lang.IllegalStateException - if this method is called AFTER all parameters have been setpublic void setLinkCss(java.lang.String css)
css - a string of classnames to be used in pager links, e.g. "ajax-refresh pager-link"public java.lang.String getLinkCss()
"ajax-refresh pager-link"public java.lang.String getSortURL(java.lang.String pSort)
pSort - the sort order to use (usually a valid params for the method Data.getComparator(String, boolean)
java.lang.IllegalStateException - if this method is called before all parameters have been set
public java.lang.String getSortURL(java.lang.String pSort,
boolean pReverse)
pSort - the sort order to use (usually a valid params for the method Data.getComparator(String, boolean)pReverse - whether the sort order should be ascending or descending
java.lang.IllegalStateException - if this method is called before all parameters have been set
public void printSortLink(javax.servlet.jsp.JspWriter out,
java.lang.String pSort,
java.lang.String pTitleProp)
throws java.io.IOException
out - the JspWriter to use for printing, must not be null.pSort - the sort order to use, must not be empty (usually a valid params for the method Data.getComparator(String, boolean)pTitleProp - an optionnal I18N string to be used in the generated A tag (<a>{glp(pTitleProp)}</a>)
java.io.IOException - if an error occured when printing to specified JspWriter
java.lang.IllegalArgumentException - if pSort is null or empty
java.lang.IllegalStateException - if this method is called before all parameters have been setpublic java.lang.String getFirstLinkURL()
java.lang.IllegalStateException - if this method is called before all parameters have been set
public void printFirstLink(javax.servlet.jsp.JspWriter out)
throws java.io.IOException
out - the JspWriter to use for printing, must not be null.
java.io.IOException - if an error occured when printing to specified JspWriter
java.lang.IllegalStateException - if this method is called before all parameters have been setpublic java.lang.String getPreviousLinkURL()
java.lang.IllegalStateException - if this method is called before all parameters have been set
public void printPreviousLink(javax.servlet.jsp.JspWriter out)
throws java.io.IOException
out - the JspWriter to use for printing, must not be null.
java.io.IOException - if an error occured when printing to specified JspWriter
java.lang.IllegalStateException - if this method is called before all parameters have been setpublic java.lang.String getPageLinkURL(int pageIdx)
pageIdx - a new page index to navigate to, with 1 <= pageIdx <= pagesNbr
java.lang.IllegalArgumentException - if pageIdx does not match the requirements 1 <= pageIdx <= pagesNbr
java.lang.IllegalStateException - if this method is called before all parameters have been set
public void printPagesLinks(javax.servlet.jsp.JspWriter out)
throws java.io.IOException
out - the JspWriter to use for printing, must not be null.
java.io.IOException - if an error occured when printing to specified JspWriter
java.lang.IllegalStateException - if this method is called before all parameters have been setpublic java.lang.String getNextLinkURL()
java.lang.IllegalStateException - if this method is called before all parameters have been set
public void printNextLink(javax.servlet.jsp.JspWriter out)
throws java.io.IOException
out - the JspWriter to use for printing, must not be null.
java.io.IOException - if an error occured when printing to specified JspWriter
java.lang.IllegalStateException - if this method is called before all parameters have been setpublic java.lang.String getLastLinkURL()
java.lang.IllegalStateException - if this method is called before all parameters have been set
public void printLastLink(javax.servlet.jsp.JspWriter out)
throws java.io.IOException
out - the JspWriter to use for printing, must not be null.
java.io.IOException - if an error occured when printing to specified JspWriter
java.lang.IllegalStateException - if this method is called before all parameters have been setpublic java.lang.String getShowPageSizeURL(int pPageSize)
pPageSize - a new valid page size to use for the link
java.lang.IllegalArgumentException - if pPageSize is not a valide page size for this pager
java.lang.IllegalStateException - if this method is called before all parameters have been set
public boolean printShowPageSizesLink(javax.servlet.jsp.JspWriter out)
throws java.io.IOException
out - the JspWriter to use for printing, must not be null.
java.io.IOException - if an error occured when printing to specified JspWriter
java.lang.IllegalStateException - if this method is called before all parameters have been setpublic java.lang.String getPagerAllURL()
java.lang.IllegalStateException - if this method is called before all parameters have been set
public void printPagerAllLink(javax.servlet.jsp.JspWriter out)
throws java.io.IOException
out - the JspWriter to use for printing, must not be null.
java.io.IOException - if an error occured when printing to specified JspWriter
java.lang.IllegalStateException - if this method is called before all parameters have been setpublic java.lang.String getShowPagerURL()
java.lang.IllegalStateException - if this method is called before all parameters have been set
public void printShowPagerLink(javax.servlet.jsp.JspWriter out)
throws java.io.IOException
out - the JspWriter to use for printing, must not be null.
java.io.IOException - if an error occured when printing to specified JspWriter
java.lang.IllegalStateException - if this method is called before all parameters have been set
public void printAllPager(javax.servlet.jsp.JspWriter out)
throws java.io.IOException
out - the JspWriter to use for printing, must not be null.
java.io.IOException - if an error occured when printing to specified JspWriter
java.lang.IllegalStateException - if this method is called before all parameters have been set
public void display(javax.servlet.jsp.PageContext pageContext,
java.lang.String template)
throws javax.servlet.ServletException,
java.io.IOException
pageContext - the Jsp PageContext for which the page is being displayedtemplate - the template name (retrieved using property pager.template.{templateName}: /path/to.jsp
javax.servlet.ServletException
java.io.IOException
java.lang.IllegalArgumentException - if the specified template does not existspublic java.lang.String getSort()
public boolean isReverse()
public int getPageSize()
java.lang.IllegalStateException - if this method is called before all parameters have been setpublic int[] getPageSizes()
java.lang.IllegalStateException - if this method is called before all parameters have been setpublic boolean canShowPagerAll()
java.lang.IllegalStateException - if this method is called before all parameters have been setpublic boolean isPagerAll()
java.lang.IllegalStateException - if this method is called before all parameters have been setpublic int getStart()
java.lang.IllegalStateException - if this method is called before all parameters have been setpublic int getItemsNbr()
java.lang.IllegalStateException - if this method is called before all parameters have been setpublic int getPagesNbr()
java.lang.IllegalStateException - if this method is called before all parameters have been setpublic int getCurrentPage()
java.lang.IllegalStateException - if this method is called before all parameters have been setpublic boolean isFirstPage()
java.lang.IllegalStateException - if this method is called before all parameters have been setpublic boolean isLastPage()
java.lang.IllegalStateException - if this method is called before all parameters have been setpublic int getPagesLinksStartNbr()
public int[] getPagesLinksNbrs()
public int getPagesLinksEndNbr()
public boolean getShowFirstLink()
public void setShowFirstLink(boolean showFirstLink)
public boolean getShowLastLink()
public void setShowLastLink(boolean showLastLink)
public void clearSessionParams()
PortalManager.PORTAL_ACTION...).
Invoking this method will therefore reset the parameters and next request
for the same pager (parameter prefix) will not have memorized the pager options
(sorting/paging).
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||