org.apache.shale.usecases.rolodex
Class WebPagerRenderer

java.lang.Object
  extended by javax.faces.render.Renderer
      extended by org.apache.shale.usecases.rolodex.WebPagerRenderer

public class WebPagerRenderer
extends javax.faces.render.Renderer


Constructor Summary
WebPagerRenderer()
           
 
Method Summary
 void decode(javax.faces.context.FacesContext context, javax.faces.component.UIComponent pager)
          This basic component doesn't use javascript for navigation.
 void encodeBegin(javax.faces.context.FacesContext context, javax.faces.component.UIComponent uicomponent)
          Delegates to the super implementation.
 void encodeEnd(javax.faces.context.FacesContext context, javax.faces.component.UIComponent pager)
          Locates a parent UIData component, decodes the selected page query parameter and advances the first row of the UIData component based on the selected page.
protected  javax.faces.component.UIData findDataComponent(javax.faces.component.UIComponent uicomponent)
          Looks for the first data component parent.
protected  String getActionStr(javax.faces.context.FacesContext context)
          Determines the base URL by calling on the view handler.
protected  int getCurrentPage(javax.faces.component.UIData uidata)
          Returns the current page based on the UIData component's state.
protected  int getPageEndIndex(javax.faces.context.FacesContext context, javax.faces.component.UIData data)
          Returns the ending row index displayed by the UIData component.
protected  int getPageEndIndex(int page, javax.faces.context.FacesContext context, javax.faces.component.UIData data)
          Returns the ending row index displayed by the UIData component.
protected  int getPageIndex(javax.faces.context.FacesContext context, javax.faces.component.UIData data)
          Returns the selected page index.
protected  int getPages(javax.faces.component.UIData data)
          Returns the total number of pages based on the size of the model's set and the total rows displayed.
protected  int getPageStartIndex(javax.faces.context.FacesContext context, javax.faces.component.UIData data)
          Returns the starting row within the UIData's model based on the selected page index, the total rows the model has and the rows per page.
protected  int getPageStartIndex(int page, javax.faces.context.FacesContext context, javax.faces.component.UIData data)
          Returns the starting row within the UIData's model based on the selected page index, the total rows the model has and the rows per page.
protected  String getPageTag(javax.faces.context.FacesContext context, javax.faces.component.UIData data)
          Returns the query parameter tag based on the parent UIData component.
protected  int getRowsOnPage(int page, javax.faces.context.FacesContext context, javax.faces.component.UIData data)
          Returns the total rows on the selected page.
protected  int getRowsPerPage(javax.faces.component.UIData data)
          Returns the rows per page of the UIData component.
protected  Iterator iterator(javax.faces.context.FacesContext context, javax.faces.component.UIData data)
          Returns a PageInfo Iterator used to render the individual page links.
protected  org.apache.shale.usecases.rolodex.WebPagerRenderer.PageInfo nextPage(javax.faces.context.FacesContext context, javax.faces.component.UIData data)
          Returns PageInfo that defines the next link.
protected  org.apache.shale.usecases.rolodex.WebPagerRenderer.PageInfo prevPage(javax.faces.context.FacesContext context, javax.faces.component.UIData data)
          Returns PageInfo used to render the previous page links.
protected  void writeNextPageLink(javax.faces.context.FacesContext context, javax.faces.component.UIData data, javax.faces.component.UIComponent pager)
          Generates the next page link.
protected  void writePageCaption(javax.faces.context.FacesContext context, javax.faces.component.UIData data, javax.faces.component.UIComponent pager)
          Writes a pager caption documenting the total model rows, current page and total pages.
protected  void writePageIndex(javax.faces.context.FacesContext context, javax.faces.component.UIData data, javax.faces.component.UIComponent pager)
          Renders a hidden input field that keeps track of the current page.
protected  void writePageLinks(javax.faces.context.FacesContext context, javax.faces.component.UIData data, javax.faces.component.UIComponent pager)
          The first ten pages are displayed as individual page links.
protected  void writePrevPageLink(javax.faces.context.FacesContext context, javax.faces.component.UIData data, javax.faces.component.UIComponent pager)
          Writes the previous page link.
 
Methods inherited from class javax.faces.render.Renderer
convertClientId, encodeChildren, getConvertedValue, getRendersChildren
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WebPagerRenderer

public WebPagerRenderer()
Method Detail

decode

public void decode(javax.faces.context.FacesContext context,
                   javax.faces.component.UIComponent pager)

This basic component doesn't use javascript for navigation. This means that the decode logic is in the encode/rendering phase.

Overrides:
decode in class javax.faces.render.Renderer

encodeEnd

public void encodeEnd(javax.faces.context.FacesContext context,
                      javax.faces.component.UIComponent pager)
               throws IOException

Locates a parent UIData component, decodes the selected page query parameter and advances the first row of the UIData component based on the selected page.

Overrides:
encodeEnd in class javax.faces.render.Renderer
Throws:
IOException

writePrevPageLink

protected void writePrevPageLink(javax.faces.context.FacesContext context,
                                 javax.faces.component.UIData data,
                                 javax.faces.component.UIComponent pager)
                          throws IOException

Writes the previous page link.

Throws:
IOException

writePageIndex

protected void writePageIndex(javax.faces.context.FacesContext context,
                              javax.faces.component.UIData data,
                              javax.faces.component.UIComponent pager)
                       throws IOException

Renders a hidden input field that keeps track of the current page.

Throws:
IOException

writePageCaption

protected void writePageCaption(javax.faces.context.FacesContext context,
                                javax.faces.component.UIData data,
                                javax.faces.component.UIComponent pager)
                         throws IOException

Writes a pager caption documenting the total model rows, current page and total pages.

Throws:
IOException

writePageLinks

protected void writePageLinks(javax.faces.context.FacesContext context,
                              javax.faces.component.UIData data,
                              javax.faces.component.UIComponent pager)
                       throws IOException

The first ten pages are displayed as individual page links. The remainder of page links are displayed in increments of ten.

Throws:
IOException

writeNextPageLink

protected void writeNextPageLink(javax.faces.context.FacesContext context,
                                 javax.faces.component.UIData data,
                                 javax.faces.component.UIComponent pager)
                          throws IOException

Generates the next page link.

Throws:
IOException

getActionStr

protected String getActionStr(javax.faces.context.FacesContext context)

Determines the base URL by calling on the view handler.


getPageTag

protected String getPageTag(javax.faces.context.FacesContext context,
                            javax.faces.component.UIData data)

Returns the query parameter tag based on the parent UIData component.


getPageIndex

protected int getPageIndex(javax.faces.context.FacesContext context,
                           javax.faces.component.UIData data)

Returns the selected page index. This would be done in the decode method if this control was not scriptless.


getCurrentPage

protected int getCurrentPage(javax.faces.component.UIData uidata)

Returns the current page based on the UIData component's state.


findDataComponent

protected javax.faces.component.UIData findDataComponent(javax.faces.component.UIComponent uicomponent)

Looks for the first data component parent.


getRowsPerPage

protected int getRowsPerPage(javax.faces.component.UIData data)

Returns the rows per page of the UIData component. The value must be five or more.


getPageStartIndex

protected int getPageStartIndex(javax.faces.context.FacesContext context,
                                javax.faces.component.UIData data)

Returns the starting row within the UIData's model based on the selected page index, the total rows the model has and the rows per page.


getPageStartIndex

protected int getPageStartIndex(int page,
                                javax.faces.context.FacesContext context,
                                javax.faces.component.UIData data)

Returns the starting row within the UIData's model based on the selected page index, the total rows the model has and the rows per page.


getPageEndIndex

protected int getPageEndIndex(javax.faces.context.FacesContext context,
                              javax.faces.component.UIData data)

Returns the ending row index displayed by the UIData component.


getPageEndIndex

protected int getPageEndIndex(int page,
                              javax.faces.context.FacesContext context,
                              javax.faces.component.UIData data)

Returns the ending row index displayed by the UIData component.


getRowsOnPage

protected int getRowsOnPage(int page,
                            javax.faces.context.FacesContext context,
                            javax.faces.component.UIData data)

Returns the total rows on the selected page.


getPages

protected int getPages(javax.faces.component.UIData data)

Returns the total number of pages based on the size of the model's set and the total rows displayed.


prevPage

protected org.apache.shale.usecases.rolodex.WebPagerRenderer.PageInfo prevPage(javax.faces.context.FacesContext context,
                                                                               javax.faces.component.UIData data)

Returns PageInfo used to render the previous page links.


iterator

protected Iterator iterator(javax.faces.context.FacesContext context,
                            javax.faces.component.UIData data)

Returns a PageInfo Iterator used to render the individual page links.


nextPage

protected org.apache.shale.usecases.rolodex.WebPagerRenderer.PageInfo nextPage(javax.faces.context.FacesContext context,
                                                                               javax.faces.component.UIData data)

Returns PageInfo that defines the next link.


encodeBegin

public void encodeBegin(javax.faces.context.FacesContext context,
                        javax.faces.component.UIComponent uicomponent)
                 throws IOException

Delegates to the super implementation.

Overrides:
encodeBegin in class javax.faces.render.Renderer
Throws:
IOException


Copyright © 2004-2007 Apache Software Foundation. All Rights Reserved.