You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by sk...@apache.org on 2005/11/28 23:17:55 UTC
svn commit: r349525 - in
/myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/datascroller:
HtmlDataScroller.java HtmlDataScrollerRenderer.java HtmlDataScrollerTag.java
Author: skitching
Date: Mon Nov 28 14:17:20 2005
New Revision: 349525
URL: http://svn.apache.org/viewcvs?rev=349525&view=rev
Log:
Replace tabs with spaces
Modified:
myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/datascroller/HtmlDataScroller.java
myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/datascroller/HtmlDataScrollerRenderer.java
myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/datascroller/HtmlDataScrollerTag.java
Modified: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/datascroller/HtmlDataScroller.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/datascroller/HtmlDataScroller.java?rev=349525&r1=349524&r2=349525&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/datascroller/HtmlDataScroller.java (original)
+++ myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/datascroller/HtmlDataScroller.java Mon Nov 28 14:17:20 2005
@@ -42,21 +42,21 @@
*/
public class HtmlDataScroller extends HtmlPanelGroup implements ActionSource
{
- private static final Log log = LogFactory.getLog(HtmlDataScroller.class);
+ private static final Log log = LogFactory.getLog(HtmlDataScroller.class);
- private static final String FIRST_FACET_NAME = "first";
- private static final String LAST_FACET_NAME = "last";
- private static final String NEXT_FACET_NAME = "next";
- private static final String PREVIOUS_FACET_NAME = "previous";
- private static final String FAST_FORWARD_FACET_NAME = "fastforward";
- private static final String FAST_REWIND_FACET_NAME = "fastrewind";
+ private static final String FIRST_FACET_NAME = "first";
+ private static final String LAST_FACET_NAME = "last";
+ private static final String NEXT_FACET_NAME = "next";
+ private static final String PREVIOUS_FACET_NAME = "previous";
+ private static final String FAST_FORWARD_FACET_NAME = "fastforward";
+ private static final String FAST_REWIND_FACET_NAME = "fastrewind";
- // just for caching the associated uidata
- private transient UIData _UIData;
+ // just for caching the associated uidata
+ private transient UIData _UIData;
private MethodBinding _actionListener;
- /**
+ /**
* Catch any attempts to queue events for this component, and ensure
* the event's phase is set appropriately. Events are expected to be
* queued by this component's renderer.
@@ -65,24 +65,24 @@
* be marked to fire in the "apply request values" phase. When this
* component is not immediate the event will fire during the
* "invoke application" phase instead.
- */
- public void queueEvent(FacesEvent event)
- {
- if (event != null && event instanceof ActionEvent)
- {
- if (isImmediate())
- {
- event.setPhaseId(PhaseId.APPLY_REQUEST_VALUES);
- }
- else
- {
- event.setPhaseId(PhaseId.INVOKE_APPLICATION);
- }
- }
- super.queueEvent(event);
- }
+ */
+ public void queueEvent(FacesEvent event)
+ {
+ if (event != null && event instanceof ActionEvent)
+ {
+ if (isImmediate())
+ {
+ event.setPhaseId(PhaseId.APPLY_REQUEST_VALUES);
+ }
+ else
+ {
+ event.setPhaseId(PhaseId.INVOKE_APPLICATION);
+ }
+ }
+ super.queueEvent(event);
+ }
- /**
+ /**
* Invoke any action listeners attached to this class.
* <p>
* After listener invocation, the associated UIData's properties get
@@ -97,98 +97,98 @@
* by uiData.getRows() * fastStep.
* <li>next, fast-forward and last options have the obvious effect.
* </ul>
- */
- public void broadcast(FacesEvent event) throws AbortProcessingException
- {
- super.broadcast(event);
+ */
+ public void broadcast(FacesEvent event) throws AbortProcessingException
+ {
+ super.broadcast(event);
if (event instanceof ScrollerActionEvent)
- {
+ {
ScrollerActionEvent scrollerEvent = (ScrollerActionEvent) event;
broadcastToActionListener(scrollerEvent);
// huh? getUIData never returns null.
- UIData uiData = getUIData();
- if (uiData == null)
- {
- return;
- }
-
- int pageindex = scrollerEvent.getPageIndex();
- if (pageindex == -1)
- {
- String facet = scrollerEvent.getScrollerfacet();
- if (FACET_FIRST.equals(facet))
- {
- uiData.setFirst(0);
- }
- else if (FACET_PREVIOUS.equals(facet))
- {
- int previous = uiData.getFirst() - uiData.getRows();
- if (previous >= 0)
- uiData.setFirst(previous);
- }
- else if (FACET_NEXT.equals(facet))
- {
- int next = uiData.getFirst() + uiData.getRows();
- if (next < uiData.getRowCount())
- uiData.setFirst(next);
- }
- else if (FACET_FAST_FORWARD.equals(facet))
- {
- int fastStep = getFastStep();
- if (fastStep <= 0)
- fastStep = 1;
- int next = uiData.getFirst() + uiData.getRows() * fastStep;
- int rowcount = uiData.getRowCount();
- if (next > rowcount)
- next = (rowcount - 1) - ((rowcount - 1) % uiData.getRows());
- uiData.setFirst(next);
- }
- else if (FACET_FAST_REWIND.equals(facet))
- {
- int fastStep = getFastStep();
- if (fastStep <= 0)
- fastStep = 1;
- int previous = uiData.getFirst() - uiData.getRows() * fastStep;
- if (previous < 0)
- previous = 0;
- uiData.setFirst(previous);
- }
- else if (FACET_LAST.equals(facet))
- {
- int rowcount = uiData.getRowCount();
- int rows = uiData.getRows();
- int delta = rowcount % rows;
- int first = delta > 0 && delta < rows ? rowcount - delta : rowcount - rows;
- if (first >= 0)
- {
- uiData.setFirst(first);
- }
- else
- {
- uiData.setFirst(0);
- }
- }
- }
- else
- {
- int pageCount = getPageCount();
- if (pageindex > pageCount)
- {
- pageindex = pageCount;
- }
- else if (pageindex <= 0)
- {
- pageindex = 1;
- }
- uiData.setFirst(uiData.getRows() * (pageindex - 1));
- }
- }
- }
+ UIData uiData = getUIData();
+ if (uiData == null)
+ {
+ return;
+ }
+
+ int pageindex = scrollerEvent.getPageIndex();
+ if (pageindex == -1)
+ {
+ String facet = scrollerEvent.getScrollerfacet();
+ if (FACET_FIRST.equals(facet))
+ {
+ uiData.setFirst(0);
+ }
+ else if (FACET_PREVIOUS.equals(facet))
+ {
+ int previous = uiData.getFirst() - uiData.getRows();
+ if (previous >= 0)
+ uiData.setFirst(previous);
+ }
+ else if (FACET_NEXT.equals(facet))
+ {
+ int next = uiData.getFirst() + uiData.getRows();
+ if (next < uiData.getRowCount())
+ uiData.setFirst(next);
+ }
+ else if (FACET_FAST_FORWARD.equals(facet))
+ {
+ int fastStep = getFastStep();
+ if (fastStep <= 0)
+ fastStep = 1;
+ int next = uiData.getFirst() + uiData.getRows() * fastStep;
+ int rowcount = uiData.getRowCount();
+ if (next > rowcount)
+ next = (rowcount - 1) - ((rowcount - 1) % uiData.getRows());
+ uiData.setFirst(next);
+ }
+ else if (FACET_FAST_REWIND.equals(facet))
+ {
+ int fastStep = getFastStep();
+ if (fastStep <= 0)
+ fastStep = 1;
+ int previous = uiData.getFirst() - uiData.getRows() * fastStep;
+ if (previous < 0)
+ previous = 0;
+ uiData.setFirst(previous);
+ }
+ else if (FACET_LAST.equals(facet))
+ {
+ int rowcount = uiData.getRowCount();
+ int rows = uiData.getRows();
+ int delta = rowcount % rows;
+ int first = delta > 0 && delta < rows ? rowcount - delta : rowcount - rows;
+ if (first >= 0)
+ {
+ uiData.setFirst(first);
+ }
+ else
+ {
+ uiData.setFirst(0);
+ }
+ }
+ }
+ else
+ {
+ int pageCount = getPageCount();
+ if (pageindex > pageCount)
+ {
+ pageindex = pageCount;
+ }
+ else if (pageindex <= 0)
+ {
+ pageindex = 1;
+ }
+ uiData.setFirst(uiData.getRows() * (pageindex - 1));
+ }
+ }
+ }
- /**
+ /**
* @param event
*/
protected void broadcastToActionListener(ScrollerActionEvent event)
@@ -215,89 +215,89 @@
}
/**
- * @return int
- */
- public UIData getUIData()
- {
- if (_UIData == null)
- {
- _UIData = findUIData();
- }
- return _UIData;
- }
-
- /**
- * @return the page index of the uidata
- */
- public int getPageIndex()
- {
- UIData uiData = getUIData();
- int rows = uiData.getRows();
- int pageIndex;
- if (rows > 0)
- {
- pageIndex = uiData.getFirst() / rows + 1;
- }
- else
- {
- log.warn("DataTable " + uiData.getClientId(FacesContext.getCurrentInstance())
- + " has invalid rows attribute.");
- pageIndex = 0;
- }
- if (uiData.getFirst() % rows > 0)
- {
- pageIndex++;
- }
- return pageIndex;
- }
-
- /**
- * @return the page count of the uidata
- */
- public int getPageCount()
- {
- UIData uiData = getUIData();
- int rows = uiData.getRows();
- int pageCount;
- if (rows > 0)
- {
- pageCount = rows <= 0 ? 1 : uiData.getRowCount() / rows;
- if (uiData.getRowCount() % rows > 0)
- {
- pageCount++;
- }
- }
- else
- {
- rows = 1;
- pageCount = 1;
- }
- return pageCount;
- }
-
- /**
- * @return int
- */
- public int getRowCount()
- {
- return getUIData().getRowCount();
- }
-
- /**
- * @return int
- */
- public int getRows()
- {
- return getUIData().getRows();
- }
-
- /**
- * @return int
- */
- public int getFirstRow()
- {
- return getUIData().getFirst();
- }
+ * @return int
+ */
+ public UIData getUIData()
+ {
+ if (_UIData == null)
+ {
+ _UIData = findUIData();
+ }
+ return _UIData;
+ }
+
+ /**
+ * @return the page index of the uidata
+ */
+ public int getPageIndex()
+ {
+ UIData uiData = getUIData();
+ int rows = uiData.getRows();
+ int pageIndex;
+ if (rows > 0)
+ {
+ pageIndex = uiData.getFirst() / rows + 1;
+ }
+ else
+ {
+ log.warn("DataTable " + uiData.getClientId(FacesContext.getCurrentInstance())
+ + " has invalid rows attribute.");
+ pageIndex = 0;
+ }
+ if (uiData.getFirst() % rows > 0)
+ {
+ pageIndex++;
+ }
+ return pageIndex;
+ }
+
+ /**
+ * @return the page count of the uidata
+ */
+ public int getPageCount()
+ {
+ UIData uiData = getUIData();
+ int rows = uiData.getRows();
+ int pageCount;
+ if (rows > 0)
+ {
+ pageCount = rows <= 0 ? 1 : uiData.getRowCount() / rows;
+ if (uiData.getRowCount() % rows > 0)
+ {
+ pageCount++;
+ }
+ }
+ else
+ {
+ rows = 1;
+ pageCount = 1;
+ }
+ return pageCount;
+ }
+
+ /**
+ * @return int
+ */
+ public int getRowCount()
+ {
+ return getUIData().getRowCount();
+ }
+
+ /**
+ * @return int
+ */
+ public int getRows()
+ {
+ return getUIData().getRows();
+ }
+
+ /**
+ * @return int
+ */
+ public int getFirstRow()
+ {
+ return getUIData().getFirst();
+ }
/**
* Find the UIData component associated with this scroller.
@@ -312,116 +312,117 @@
* @throws IllegalArgumentException if an associated UIData component
* cannot be found.
*/
- protected UIData findUIData()
- {
- String forStr = getFor();
- UIComponent forComp;
- if (forStr == null)
- {
- // DataScroller may be a child of uiData
- forComp = getParent();
- }
- else
- {
- forComp = findComponent(forStr);
- }
- if (forComp == null)
- {
- throw new IllegalArgumentException(
- "could not find UIData referenced by attribute dataScroller@for = '"
- + forStr + "'");
- }
- else if (!(forComp instanceof UIData))
- {
- throw new IllegalArgumentException(
- "uiComponent referenced by attribute dataScroller@for = '" + forStr + "' must be of type "
- + UIData.class.getName() + ", not type " + forComp.getClass().getName());
- }
- return (UIData) forComp;
- }
-
- public void setFirst(UIComponent first)
- {
- getFacets().put(FIRST_FACET_NAME, first);
- }
-
- public UIComponent getFirst()
- {
- return (UIComponent) getFacets().get(FIRST_FACET_NAME);
- }
-
- public void setLast(UIComponent last)
- {
- getFacets().put(LAST_FACET_NAME, last);
- }
-
- public UIComponent getLast()
- {
- return (UIComponent) getFacets().get(LAST_FACET_NAME);
- }
-
- public void setNext(UIComponent next)
- {
- getFacets().put(NEXT_FACET_NAME, next);
- }
-
- public UIComponent getNext()
- {
- return (UIComponent) getFacets().get(NEXT_FACET_NAME);
- }
-
- public void setFastForward(UIComponent previous)
- {
- getFacets().put(FAST_FORWARD_FACET_NAME, previous);
- }
-
- public UIComponent getFastForward()
- {
- return (UIComponent) getFacets().get(FAST_FORWARD_FACET_NAME);
- }
-
- public void setFastRewind(UIComponent previous)
- {
- getFacets().put(FAST_REWIND_FACET_NAME, previous);
- }
-
- public UIComponent getFastRewind()
- {
- return (UIComponent) getFacets().get(FAST_REWIND_FACET_NAME);
- }
-
- public void setPrevious(UIComponent previous)
- {
- getFacets().put(PREVIOUS_FACET_NAME, previous);
- }
-
- public UIComponent getPrevious()
- {
- return (UIComponent) getFacets().get(PREVIOUS_FACET_NAME);
- }
-
- public boolean getRendersChildren()
- {
- return true;
- }
-
- /**
- * @see javax.faces.component.ActionSource#getAction()
- */
- public MethodBinding getAction()
- {
- // not used
- return null;
- }
-
- /**
- * @see javax.faces.component.ActionSource#setAction(javax.faces.el.MethodBinding)
- */
- public void setAction(MethodBinding action)
- {
- throw new UnsupportedOperationException(
- "defining an action is not supported. use an actionlistener");
- }
+ protected UIData findUIData()
+ {
+ String forStr = getFor();
+ UIComponent forComp;
+ if (forStr == null)
+ {
+ // DataScroller may be a child of uiData
+ forComp = getParent();
+ }
+ else
+ {
+ forComp = findComponent(forStr);
+ }
+ if (forComp == null)
+ {
+ throw new IllegalArgumentException(
+ "could not find UIData referenced by attribute dataScroller@for = '"
+ + forStr + "'");
+ }
+ else if (!(forComp instanceof UIData))
+ {
+ throw new IllegalArgumentException(
+ "uiComponent referenced by attribute dataScroller@for = '"
+ + forStr + "' must be of type " + UIData.class.getName()
+ + ", not type " + forComp.getClass().getName());
+ }
+ return (UIData) forComp;
+ }
+
+ public void setFirst(UIComponent first)
+ {
+ getFacets().put(FIRST_FACET_NAME, first);
+ }
+
+ public UIComponent getFirst()
+ {
+ return (UIComponent) getFacets().get(FIRST_FACET_NAME);
+ }
+
+ public void setLast(UIComponent last)
+ {
+ getFacets().put(LAST_FACET_NAME, last);
+ }
+
+ public UIComponent getLast()
+ {
+ return (UIComponent) getFacets().get(LAST_FACET_NAME);
+ }
+
+ public void setNext(UIComponent next)
+ {
+ getFacets().put(NEXT_FACET_NAME, next);
+ }
+
+ public UIComponent getNext()
+ {
+ return (UIComponent) getFacets().get(NEXT_FACET_NAME);
+ }
+
+ public void setFastForward(UIComponent previous)
+ {
+ getFacets().put(FAST_FORWARD_FACET_NAME, previous);
+ }
+
+ public UIComponent getFastForward()
+ {
+ return (UIComponent) getFacets().get(FAST_FORWARD_FACET_NAME);
+ }
+
+ public void setFastRewind(UIComponent previous)
+ {
+ getFacets().put(FAST_REWIND_FACET_NAME, previous);
+ }
+
+ public UIComponent getFastRewind()
+ {
+ return (UIComponent) getFacets().get(FAST_REWIND_FACET_NAME);
+ }
+
+ public void setPrevious(UIComponent previous)
+ {
+ getFacets().put(PREVIOUS_FACET_NAME, previous);
+ }
+
+ public UIComponent getPrevious()
+ {
+ return (UIComponent) getFacets().get(PREVIOUS_FACET_NAME);
+ }
+
+ public boolean getRendersChildren()
+ {
+ return true;
+ }
+
+ /**
+ * @see javax.faces.component.ActionSource#getAction()
+ */
+ public MethodBinding getAction()
+ {
+ // not used
+ return null;
+ }
+
+ /**
+ * @see javax.faces.component.ActionSource#setAction(javax.faces.el.MethodBinding)
+ */
+ public void setAction(MethodBinding action)
+ {
+ throw new UnsupportedOperationException(
+ "defining an action is not supported. use an actionlistener");
+ }
/**
* @see javax.faces.component.ActionSource#setActionListener(javax.faces.el.MethodBinding)
@@ -439,397 +440,397 @@
return _actionListener;
}
- /**
- * @see javax.faces.component.ActionSource#addActionListener(javax.faces.event.ActionListener)
- */
- public void addActionListener(ActionListener listener)
- {
- addFacesListener(listener);
- }
-
- /**
- * @see javax.faces.component.ActionSource#getActionListeners()
- */
- public ActionListener[] getActionListeners()
- {
- return (ActionListener[]) getFacesListeners(ActionListener.class);
- }
-
- /**
- * @see javax.faces.component.ActionSource#removeActionListener(javax.faces.event.ActionListener)
- */
- public void removeActionListener(ActionListener listener)
- {
- removeFacesListener(listener);
- }
-
- //------------------ GENERATED CODE BEGIN (do not modify!) --------------------
-
- public static final String COMPONENT_TYPE = "org.apache.myfaces.HtmlDataScroller";
- public static final String COMPONENT_FAMILY = "javax.faces.Panel";
- private static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.DataScroller";
- private static final boolean DEFAULT_IMMEDIATE = false;
-
- private String _for = null;
- private Integer _fastStep = null;
- private String _pageIndexVar = null;
- private String _pageCountVar = null;
- private String _rowsCountVar = null;
- private String _displayedRowsCountVar = null;
- private String _firstRowIndexVar = null;
- private String _lastRowIndexVar = null;
- private String _style = null;
- private String _styleClass = null;
- private String _columnClasses = null;
- private Boolean _paginator = null;
- private Integer _paginatorMaxPages = null;
- private String _paginatorTableClass = null;
- private String _paginatorTableStyle = null;
- private String _paginatorColumnClass = null;
- private String _paginatorColumnStyle = null;
- private String _paginatorActiveColumnClass = null;
- private String _paginatorActiveColumnStyle = null;
- private Boolean _renderFacetsIfSinglePage = null;
- private Boolean _immediate;
-
- public static final String FACET_FIRST = "first".intern();
- public static final String FACET_PREVIOUS = "previous".intern();
- public static final String FACET_NEXT = "next".intern();
- public static final String FACET_LAST = "last".intern();
- public static final String FACET_FAST_FORWARD = "fastf".intern();
- public static final String FACET_FAST_REWIND = "fastr".intern();
-
- public HtmlDataScroller()
- {
- setRendererType(DEFAULT_RENDERER_TYPE);
- }
-
- public String getFamily()
- {
- return COMPONENT_FAMILY;
- }
-
- public void setFor(String forValue)
- {
- _for = forValue;
- }
-
- public String getFor()
- {
- if (_for != null)
- return _for;
- ValueBinding vb = getValueBinding("for");
- return vb != null ? (String) vb.getValue(getFacesContext()) : null;
- }
-
- public void setFastStep(int fastStep)
- {
- _fastStep = new Integer(fastStep);
- }
-
- public int getFastStep()
- {
- if (_fastStep != null)
- return _fastStep.intValue();
- ValueBinding vb = getValueBinding("fastStep");
- Integer v = vb != null ? (Integer) vb.getValue(getFacesContext()) : null;
- return v != null ? v.intValue() : Integer.MIN_VALUE;
- }
-
- public void setPageIndexVar(String pageIndexVar)
- {
- _pageIndexVar = pageIndexVar;
- }
-
- public String getPageIndexVar()
- {
- if (_pageIndexVar != null)
- return _pageIndexVar;
- ValueBinding vb = getValueBinding("pageIndexVar");
- return vb != null ? (String) vb.getValue(getFacesContext()) : null;
- }
-
- public void setPageCountVar(String pageCountVar)
- {
- _pageCountVar = pageCountVar;
- }
-
- public String getPageCountVar()
- {
- if (_pageCountVar != null)
- return _pageCountVar;
- ValueBinding vb = getValueBinding("pageCountVar");
- return vb != null ? (String) vb.getValue(getFacesContext()) : null;
- }
-
- public void setRowsCountVar(String rowsCountVar)
- {
- _rowsCountVar = rowsCountVar;
- }
-
- public String getRowsCountVar()
- {
- if (_rowsCountVar != null)
- return _rowsCountVar;
- ValueBinding vb = getValueBinding("rowsCountVar");
- return vb != null ? (String) vb.getValue(getFacesContext()) : null;
- }
-
- public void setDisplayedRowsCountVar(String displayedRowsCountVar)
- {
- _displayedRowsCountVar = displayedRowsCountVar;
- }
-
- public String getDisplayedRowsCountVar()
- {
- if (_displayedRowsCountVar != null)
- return _displayedRowsCountVar;
- ValueBinding vb = getValueBinding("displayedRowsCountVar");
- return vb != null ? (String) vb.getValue(getFacesContext()) : null;
- }
-
- public void setFirstRowIndexVar(String firstRowIndexVar)
- {
- _firstRowIndexVar = firstRowIndexVar;
- }
-
- public String getFirstRowIndexVar()
- {
- if (_firstRowIndexVar != null)
- return _firstRowIndexVar;
- ValueBinding vb = getValueBinding("firstRowIndexVar");
- return vb != null ? (String) vb.getValue(getFacesContext()) : null;
- }
-
- public void setLastRowIndexVar(String lastRowIndexVar)
- {
- _lastRowIndexVar = lastRowIndexVar;
- }
-
- public String getLastRowIndexVar()
- {
- if (_lastRowIndexVar != null)
- return _lastRowIndexVar;
- ValueBinding vb = getValueBinding("lastRowIndexVar");
- return vb != null ? (String) vb.getValue(getFacesContext()) : null;
- }
-
- public void setStyle(String style)
- {
- _style = style;
- }
-
- public String getStyle()
- {
- if (_style != null)
- return _style;
- ValueBinding vb = getValueBinding("style");
- return vb != null ? (String) vb.getValue(getFacesContext()) : null;
- }
-
- public void setStyleClass(String styleClass)
- {
- _styleClass = styleClass;
- }
-
- public String getStyleClass()
- {
- if (_styleClass != null)
- return _styleClass;
- ValueBinding vb = getValueBinding("styleClass");
- return vb != null ? (String) vb.getValue(getFacesContext()) : null;
- }
-
- public void setPaginator(boolean paginator)
- {
- _paginator = Boolean.valueOf(paginator);
- }
-
- public boolean isPaginator()
- {
- if (_paginator != null)
- return _paginator.booleanValue();
- ValueBinding vb = getValueBinding("paginator");
- Boolean v = vb != null ? (Boolean) vb.getValue(getFacesContext()) : null;
- return v != null ? v.booleanValue() : false;
- }
-
- public void setPaginatorMaxPages(int paginatorMaxPages)
- {
- _paginatorMaxPages = new Integer(paginatorMaxPages);
- }
-
- public int getPaginatorMaxPages()
- {
- if (_paginatorMaxPages != null)
- return _paginatorMaxPages.intValue();
- ValueBinding vb = getValueBinding("paginatorMaxPages");
- Integer v = vb != null ? (Integer) vb.getValue(getFacesContext()) : null;
- return v != null ? v.intValue() : Integer.MIN_VALUE;
- }
-
- public void setPaginatorTableClass(String paginatorTableClass)
- {
- _paginatorTableClass = paginatorTableClass;
- }
-
- public String getPaginatorTableClass()
- {
- if (_paginatorTableClass != null)
- return _paginatorTableClass;
- ValueBinding vb = getValueBinding("paginatorTableClass");
- return vb != null ? (String) vb.getValue(getFacesContext()) : null;
- }
-
- public void setPaginatorTableStyle(String paginatorTableStyle)
- {
- _paginatorTableStyle = paginatorTableStyle;
- }
-
- public String getPaginatorTableStyle()
- {
- if (_paginatorTableStyle != null)
- return _paginatorTableStyle;
- ValueBinding vb = getValueBinding("paginatorTableStyle");
- return vb != null ? (String) vb.getValue(getFacesContext()) : null;
- }
-
- public void setPaginatorColumnClass(String paginatorColumnClass)
- {
- _paginatorColumnClass = paginatorColumnClass;
- }
-
- public String getPaginatorColumnClass()
- {
- if (_paginatorColumnClass != null)
- return _paginatorColumnClass;
- ValueBinding vb = getValueBinding("paginatorColumnClass");
- return vb != null ? (String) vb.getValue(getFacesContext()) : null;
- }
-
- public void setPaginatorColumnStyle(String paginatorColumnStyle)
- {
- _paginatorColumnStyle = paginatorColumnStyle;
- }
-
- public String getPaginatorColumnStyle()
- {
- if (_paginatorColumnStyle != null)
- return _paginatorColumnStyle;
- ValueBinding vb = getValueBinding("paginatorColumnStyle");
- return vb != null ? (String) vb.getValue(getFacesContext()) : null;
- }
-
- public void setPaginatorActiveColumnClass(String paginatorActiveColumnClass)
- {
- _paginatorActiveColumnClass = paginatorActiveColumnClass;
- }
-
- public String getPaginatorActiveColumnClass()
- {
- if (_paginatorActiveColumnClass != null)
- return _paginatorActiveColumnClass;
- ValueBinding vb = getValueBinding("paginatorActiveColumnClass");
- return vb != null ? (String) vb.getValue(getFacesContext()) : null;
- }
-
- public void setPaginatorActiveColumnStyle(String paginatorActiveColumnStyle)
- {
- _paginatorActiveColumnStyle = paginatorActiveColumnStyle;
- }
-
- public String getPaginatorActiveColumnStyle()
- {
- if (_paginatorActiveColumnStyle != null)
- return _paginatorActiveColumnStyle;
- ValueBinding vb = getValueBinding("paginatorActiveColumnStyle");
- return vb != null ? (String) vb.getValue(getFacesContext()) : null;
- }
-
- public void setRenderFacetsIfSinglePage(boolean renderFacetsIfSinglePage)
- {
- _renderFacetsIfSinglePage = Boolean.valueOf(renderFacetsIfSinglePage);
- }
-
- public boolean isRenderFacetsIfSinglePage()
- {
- if (_renderFacetsIfSinglePage != null)
- return _renderFacetsIfSinglePage.booleanValue();
- ValueBinding vb = getValueBinding("renderFacetsIfSinglePage");
- Boolean v = vb != null ? (Boolean) vb.getValue(getFacesContext()) : null;
- return v != null ? v.booleanValue() : true;
- }
-
- public void setImmediate(boolean immediate)
- {
- _immediate = Boolean.valueOf(immediate);
- }
-
- public boolean isImmediate()
- {
- if (_immediate != null)
- return _immediate.booleanValue();
- ValueBinding vb = getValueBinding("immediate");
- Boolean v = vb != null ? (Boolean) vb.getValue(getFacesContext()) : null;
- return v != null ? v.booleanValue() : DEFAULT_IMMEDIATE;
- }
-
- public Object saveState(FacesContext context)
- {
- Object values[] = new Object[23];
- values[0] = super.saveState(context);
- values[1] = _for;
- values[2] = _fastStep;
- values[3] = _pageIndexVar;
- values[4] = _pageCountVar;
- values[5] = _rowsCountVar;
- values[6] = _displayedRowsCountVar;
- values[7] = _firstRowIndexVar;
- values[8] = _lastRowIndexVar;
- values[9] = _style;
- values[10] = _styleClass;
- values[11] = _columnClasses;
- values[12] = _paginator;
- values[13] = _paginatorMaxPages;
- values[14] = _paginatorTableClass;
- values[15] = _paginatorTableStyle;
- values[16] = _paginatorColumnClass;
- values[17] = _paginatorColumnStyle;
- values[18] = _paginatorActiveColumnClass;
- values[19] = _paginatorActiveColumnStyle;
- values[20] = _renderFacetsIfSinglePage;
- values[21] = _immediate;
+ /**
+ * @see javax.faces.component.ActionSource#addActionListener(javax.faces.event.ActionListener)
+ */
+ public void addActionListener(ActionListener listener)
+ {
+ addFacesListener(listener);
+ }
+
+ /**
+ * @see javax.faces.component.ActionSource#getActionListeners()
+ */
+ public ActionListener[] getActionListeners()
+ {
+ return (ActionListener[]) getFacesListeners(ActionListener.class);
+ }
+
+ /**
+ * @see javax.faces.component.ActionSource#removeActionListener(javax.faces.event.ActionListener)
+ */
+ public void removeActionListener(ActionListener listener)
+ {
+ removeFacesListener(listener);
+ }
+
+ //------------------ GENERATED CODE BEGIN (do not modify!) --------------------
+
+ public static final String COMPONENT_TYPE = "org.apache.myfaces.HtmlDataScroller";
+ public static final String COMPONENT_FAMILY = "javax.faces.Panel";
+ private static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.DataScroller";
+ private static final boolean DEFAULT_IMMEDIATE = false;
+
+ private String _for = null;
+ private Integer _fastStep = null;
+ private String _pageIndexVar = null;
+ private String _pageCountVar = null;
+ private String _rowsCountVar = null;
+ private String _displayedRowsCountVar = null;
+ private String _firstRowIndexVar = null;
+ private String _lastRowIndexVar = null;
+ private String _style = null;
+ private String _styleClass = null;
+ private String _columnClasses = null;
+ private Boolean _paginator = null;
+ private Integer _paginatorMaxPages = null;
+ private String _paginatorTableClass = null;
+ private String _paginatorTableStyle = null;
+ private String _paginatorColumnClass = null;
+ private String _paginatorColumnStyle = null;
+ private String _paginatorActiveColumnClass = null;
+ private String _paginatorActiveColumnStyle = null;
+ private Boolean _renderFacetsIfSinglePage = null;
+ private Boolean _immediate;
+
+ public static final String FACET_FIRST = "first".intern();
+ public static final String FACET_PREVIOUS = "previous".intern();
+ public static final String FACET_NEXT = "next".intern();
+ public static final String FACET_LAST = "last".intern();
+ public static final String FACET_FAST_FORWARD = "fastf".intern();
+ public static final String FACET_FAST_REWIND = "fastr".intern();
+
+ public HtmlDataScroller()
+ {
+ setRendererType(DEFAULT_RENDERER_TYPE);
+ }
+
+ public String getFamily()
+ {
+ return COMPONENT_FAMILY;
+ }
+
+ public void setFor(String forValue)
+ {
+ _for = forValue;
+ }
+
+ public String getFor()
+ {
+ if (_for != null)
+ return _for;
+ ValueBinding vb = getValueBinding("for");
+ return vb != null ? (String) vb.getValue(getFacesContext()) : null;
+ }
+
+ public void setFastStep(int fastStep)
+ {
+ _fastStep = new Integer(fastStep);
+ }
+
+ public int getFastStep()
+ {
+ if (_fastStep != null)
+ return _fastStep.intValue();
+ ValueBinding vb = getValueBinding("fastStep");
+ Integer v = vb != null ? (Integer) vb.getValue(getFacesContext()) : null;
+ return v != null ? v.intValue() : Integer.MIN_VALUE;
+ }
+
+ public void setPageIndexVar(String pageIndexVar)
+ {
+ _pageIndexVar = pageIndexVar;
+ }
+
+ public String getPageIndexVar()
+ {
+ if (_pageIndexVar != null)
+ return _pageIndexVar;
+ ValueBinding vb = getValueBinding("pageIndexVar");
+ return vb != null ? (String) vb.getValue(getFacesContext()) : null;
+ }
+
+ public void setPageCountVar(String pageCountVar)
+ {
+ _pageCountVar = pageCountVar;
+ }
+
+ public String getPageCountVar()
+ {
+ if (_pageCountVar != null)
+ return _pageCountVar;
+ ValueBinding vb = getValueBinding("pageCountVar");
+ return vb != null ? (String) vb.getValue(getFacesContext()) : null;
+ }
+
+ public void setRowsCountVar(String rowsCountVar)
+ {
+ _rowsCountVar = rowsCountVar;
+ }
+
+ public String getRowsCountVar()
+ {
+ if (_rowsCountVar != null)
+ return _rowsCountVar;
+ ValueBinding vb = getValueBinding("rowsCountVar");
+ return vb != null ? (String) vb.getValue(getFacesContext()) : null;
+ }
+
+ public void setDisplayedRowsCountVar(String displayedRowsCountVar)
+ {
+ _displayedRowsCountVar = displayedRowsCountVar;
+ }
+
+ public String getDisplayedRowsCountVar()
+ {
+ if (_displayedRowsCountVar != null)
+ return _displayedRowsCountVar;
+ ValueBinding vb = getValueBinding("displayedRowsCountVar");
+ return vb != null ? (String) vb.getValue(getFacesContext()) : null;
+ }
+
+ public void setFirstRowIndexVar(String firstRowIndexVar)
+ {
+ _firstRowIndexVar = firstRowIndexVar;
+ }
+
+ public String getFirstRowIndexVar()
+ {
+ if (_firstRowIndexVar != null)
+ return _firstRowIndexVar;
+ ValueBinding vb = getValueBinding("firstRowIndexVar");
+ return vb != null ? (String) vb.getValue(getFacesContext()) : null;
+ }
+
+ public void setLastRowIndexVar(String lastRowIndexVar)
+ {
+ _lastRowIndexVar = lastRowIndexVar;
+ }
+
+ public String getLastRowIndexVar()
+ {
+ if (_lastRowIndexVar != null)
+ return _lastRowIndexVar;
+ ValueBinding vb = getValueBinding("lastRowIndexVar");
+ return vb != null ? (String) vb.getValue(getFacesContext()) : null;
+ }
+
+ public void setStyle(String style)
+ {
+ _style = style;
+ }
+
+ public String getStyle()
+ {
+ if (_style != null)
+ return _style;
+ ValueBinding vb = getValueBinding("style");
+ return vb != null ? (String) vb.getValue(getFacesContext()) : null;
+ }
+
+ public void setStyleClass(String styleClass)
+ {
+ _styleClass = styleClass;
+ }
+
+ public String getStyleClass()
+ {
+ if (_styleClass != null)
+ return _styleClass;
+ ValueBinding vb = getValueBinding("styleClass");
+ return vb != null ? (String) vb.getValue(getFacesContext()) : null;
+ }
+
+ public void setPaginator(boolean paginator)
+ {
+ _paginator = Boolean.valueOf(paginator);
+ }
+
+ public boolean isPaginator()
+ {
+ if (_paginator != null)
+ return _paginator.booleanValue();
+ ValueBinding vb = getValueBinding("paginator");
+ Boolean v = vb != null ? (Boolean) vb.getValue(getFacesContext()) : null;
+ return v != null ? v.booleanValue() : false;
+ }
+
+ public void setPaginatorMaxPages(int paginatorMaxPages)
+ {
+ _paginatorMaxPages = new Integer(paginatorMaxPages);
+ }
+
+ public int getPaginatorMaxPages()
+ {
+ if (_paginatorMaxPages != null)
+ return _paginatorMaxPages.intValue();
+ ValueBinding vb = getValueBinding("paginatorMaxPages");
+ Integer v = vb != null ? (Integer) vb.getValue(getFacesContext()) : null;
+ return v != null ? v.intValue() : Integer.MIN_VALUE;
+ }
+
+ public void setPaginatorTableClass(String paginatorTableClass)
+ {
+ _paginatorTableClass = paginatorTableClass;
+ }
+
+ public String getPaginatorTableClass()
+ {
+ if (_paginatorTableClass != null)
+ return _paginatorTableClass;
+ ValueBinding vb = getValueBinding("paginatorTableClass");
+ return vb != null ? (String) vb.getValue(getFacesContext()) : null;
+ }
+
+ public void setPaginatorTableStyle(String paginatorTableStyle)
+ {
+ _paginatorTableStyle = paginatorTableStyle;
+ }
+
+ public String getPaginatorTableStyle()
+ {
+ if (_paginatorTableStyle != null)
+ return _paginatorTableStyle;
+ ValueBinding vb = getValueBinding("paginatorTableStyle");
+ return vb != null ? (String) vb.getValue(getFacesContext()) : null;
+ }
+
+ public void setPaginatorColumnClass(String paginatorColumnClass)
+ {
+ _paginatorColumnClass = paginatorColumnClass;
+ }
+
+ public String getPaginatorColumnClass()
+ {
+ if (_paginatorColumnClass != null)
+ return _paginatorColumnClass;
+ ValueBinding vb = getValueBinding("paginatorColumnClass");
+ return vb != null ? (String) vb.getValue(getFacesContext()) : null;
+ }
+
+ public void setPaginatorColumnStyle(String paginatorColumnStyle)
+ {
+ _paginatorColumnStyle = paginatorColumnStyle;
+ }
+
+ public String getPaginatorColumnStyle()
+ {
+ if (_paginatorColumnStyle != null)
+ return _paginatorColumnStyle;
+ ValueBinding vb = getValueBinding("paginatorColumnStyle");
+ return vb != null ? (String) vb.getValue(getFacesContext()) : null;
+ }
+
+ public void setPaginatorActiveColumnClass(String paginatorActiveColumnClass)
+ {
+ _paginatorActiveColumnClass = paginatorActiveColumnClass;
+ }
+
+ public String getPaginatorActiveColumnClass()
+ {
+ if (_paginatorActiveColumnClass != null)
+ return _paginatorActiveColumnClass;
+ ValueBinding vb = getValueBinding("paginatorActiveColumnClass");
+ return vb != null ? (String) vb.getValue(getFacesContext()) : null;
+ }
+
+ public void setPaginatorActiveColumnStyle(String paginatorActiveColumnStyle)
+ {
+ _paginatorActiveColumnStyle = paginatorActiveColumnStyle;
+ }
+
+ public String getPaginatorActiveColumnStyle()
+ {
+ if (_paginatorActiveColumnStyle != null)
+ return _paginatorActiveColumnStyle;
+ ValueBinding vb = getValueBinding("paginatorActiveColumnStyle");
+ return vb != null ? (String) vb.getValue(getFacesContext()) : null;
+ }
+
+ public void setRenderFacetsIfSinglePage(boolean renderFacetsIfSinglePage)
+ {
+ _renderFacetsIfSinglePage = Boolean.valueOf(renderFacetsIfSinglePage);
+ }
+
+ public boolean isRenderFacetsIfSinglePage()
+ {
+ if (_renderFacetsIfSinglePage != null)
+ return _renderFacetsIfSinglePage.booleanValue();
+ ValueBinding vb = getValueBinding("renderFacetsIfSinglePage");
+ Boolean v = vb != null ? (Boolean) vb.getValue(getFacesContext()) : null;
+ return v != null ? v.booleanValue() : true;
+ }
+
+ public void setImmediate(boolean immediate)
+ {
+ _immediate = Boolean.valueOf(immediate);
+ }
+
+ public boolean isImmediate()
+ {
+ if (_immediate != null)
+ return _immediate.booleanValue();
+ ValueBinding vb = getValueBinding("immediate");
+ Boolean v = vb != null ? (Boolean) vb.getValue(getFacesContext()) : null;
+ return v != null ? v.booleanValue() : DEFAULT_IMMEDIATE;
+ }
+
+ public Object saveState(FacesContext context)
+ {
+ Object values[] = new Object[23];
+ values[0] = super.saveState(context);
+ values[1] = _for;
+ values[2] = _fastStep;
+ values[3] = _pageIndexVar;
+ values[4] = _pageCountVar;
+ values[5] = _rowsCountVar;
+ values[6] = _displayedRowsCountVar;
+ values[7] = _firstRowIndexVar;
+ values[8] = _lastRowIndexVar;
+ values[9] = _style;
+ values[10] = _styleClass;
+ values[11] = _columnClasses;
+ values[12] = _paginator;
+ values[13] = _paginatorMaxPages;
+ values[14] = _paginatorTableClass;
+ values[15] = _paginatorTableStyle;
+ values[16] = _paginatorColumnClass;
+ values[17] = _paginatorColumnStyle;
+ values[18] = _paginatorActiveColumnClass;
+ values[19] = _paginatorActiveColumnStyle;
+ values[20] = _renderFacetsIfSinglePage;
+ values[21] = _immediate;
values[22] = saveAttachedState(context, _actionListener);
- return values;
- }
+ return values;
+ }
- public void restoreState(FacesContext context, Object state)
- {
- Object values[] = (Object[]) state;
- super.restoreState(context, values[0]);
- _for = (String) values[1];
- _fastStep = (Integer) values[2];
- _pageIndexVar = (String) values[3];
- _pageCountVar = (String) values[4];
- _rowsCountVar = (String) values[5];
- _displayedRowsCountVar = (String) values[6];
- _firstRowIndexVar = (String) values[7];
- _lastRowIndexVar = (String) values[8];
- _style = (String) values[9];
- _styleClass = (String) values[10];
- _columnClasses = (String) values[11];
- _paginator = (Boolean) values[12];
- _paginatorMaxPages = (Integer) values[13];
- _paginatorTableClass = (String) values[14];
- _paginatorTableStyle = (String) values[15];
- _paginatorColumnClass = (String) values[16];
- _paginatorColumnStyle = (String) values[17];
- _paginatorActiveColumnClass = (String) values[18];
- _paginatorActiveColumnStyle = (String) values[19];
- _renderFacetsIfSinglePage = (Boolean) values[20];
- _immediate = (Boolean) values[21];
+ public void restoreState(FacesContext context, Object state)
+ {
+ Object values[] = (Object[]) state;
+ super.restoreState(context, values[0]);
+ _for = (String) values[1];
+ _fastStep = (Integer) values[2];
+ _pageIndexVar = (String) values[3];
+ _pageCountVar = (String) values[4];
+ _rowsCountVar = (String) values[5];
+ _displayedRowsCountVar = (String) values[6];
+ _firstRowIndexVar = (String) values[7];
+ _lastRowIndexVar = (String) values[8];
+ _style = (String) values[9];
+ _styleClass = (String) values[10];
+ _columnClasses = (String) values[11];
+ _paginator = (Boolean) values[12];
+ _paginatorMaxPages = (Integer) values[13];
+ _paginatorTableClass = (String) values[14];
+ _paginatorTableStyle = (String) values[15];
+ _paginatorColumnClass = (String) values[16];
+ _paginatorColumnStyle = (String) values[17];
+ _paginatorActiveColumnClass = (String) values[18];
+ _paginatorActiveColumnStyle = (String) values[19];
+ _renderFacetsIfSinglePage = (Boolean) values[20];
+ _immediate = (Boolean) values[21];
_actionListener = (MethodBinding)restoreAttachedState(context, values[22]);
- }
+ }
- //------------------ GENERATED CODE END ---------------------------------------
+ //------------------ GENERATED CODE END ---------------------------------------
}
Modified: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/datascroller/HtmlDataScrollerRenderer.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/datascroller/HtmlDataScrollerRenderer.java?rev=349525&r1=349524&r2=349525&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/datascroller/HtmlDataScrollerRenderer.java (original)
+++ myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/datascroller/HtmlDataScrollerRenderer.java Mon Nov 28 14:17:20 2005
@@ -40,176 +40,176 @@
*/
public class HtmlDataScrollerRenderer extends HtmlRenderer
{
- private static final Log log = LogFactory.getLog(HtmlDataScrollerRenderer.class);
+ private static final Log log = LogFactory.getLog(HtmlDataScrollerRenderer.class);
- public static final String RENDERER_TYPE = "org.apache.myfaces.DataScroller";
+ public static final String RENDERER_TYPE = "org.apache.myfaces.DataScroller";
- protected static final String PAGE_NAVIGATION = "idx".intern();
+ protected static final String PAGE_NAVIGATION = "idx".intern();
- public boolean getRendersChildren()
- {
- return true;
- }
+ public boolean getRendersChildren()
+ {
+ return true;
+ }
/**
* Determine which datascroller navigation option the user chose (if any),
* and if they did then queue the appropriate ScrollerActionEvent for
* later execution.
*/
- public void decode(FacesContext context, UIComponent component)
- {
- RendererUtils.checkParamValidity(context, component, HtmlDataScroller.class);
-
- Map parameter = context.getExternalContext().getRequestParameterMap();
- String param = (String) parameter.get(component.getClientId(context));
- if (param != null && param.length() > 0)
- {
- if (param.startsWith(PAGE_NAVIGATION))
- {
+ public void decode(FacesContext context, UIComponent component)
+ {
+ RendererUtils.checkParamValidity(context, component, HtmlDataScroller.class);
+
+ Map parameter = context.getExternalContext().getRequestParameterMap();
+ String param = (String) parameter.get(component.getClientId(context));
+ if (param != null && param.length() > 0)
+ {
+ if (param.startsWith(PAGE_NAVIGATION))
+ {
// the user chose a specific page# to jump to
- component.queueEvent(new ScrollerActionEvent(component, Integer.parseInt(param
- .substring(PAGE_NAVIGATION.length(), param.length()))));
- }
- else
- {
+ component.queueEvent(new ScrollerActionEvent(component, Integer.parseInt(param
+ .substring(PAGE_NAVIGATION.length(), param.length()))));
+ }
+ else
+ {
// the user chose first/last/prev/next/fastrewind/fastforward
- component.queueEvent(new ScrollerActionEvent(component, param));
- }
- }
- }
+ component.queueEvent(new ScrollerActionEvent(component, param));
+ }
+ }
+ }
/**
* Expose much of the internal state of this component so that UIComponents
* nested within this component can very flexibly display the component state
* to the user.
*/
- protected void setVariables(FacesContext facescontext, HtmlDataScroller scroller)
- throws IOException
- {
- Map requestMap = facescontext.getExternalContext().getRequestMap();
-
- String pageCountVar = scroller.getPageCountVar();
- if (pageCountVar != null)
- {
- int pageCount = scroller.getPageCount();
- requestMap.put(pageCountVar, new Integer(pageCount));
- }
- String pageIndexVar = scroller.getPageIndexVar();
- if (pageIndexVar != null)
- {
- int pageIndex = (scroller.getRowCount() > 0)? scroller.getPageIndex() : 0;
- requestMap.put(pageIndexVar, new Integer(pageIndex));
- }
- String rowsCountVar = scroller.getRowsCountVar();
- if (rowsCountVar != null)
- {
- int rowsCount = scroller.getRowCount();
- requestMap.put(rowsCountVar, new Integer(rowsCount));
- }
- String displayedRowsCountVar = scroller.getDisplayedRowsCountVar();
- if (displayedRowsCountVar != null)
- {
- int displayedRowsCount = scroller.getRows();
- int max = scroller.getRowCount() - scroller.getFirstRow();
- if (displayedRowsCount > max)
- displayedRowsCount = max;
- requestMap.put(displayedRowsCountVar, new Integer(displayedRowsCount));
- }
- String firstRowIndexVar = scroller.getFirstRowIndexVar();
- if (firstRowIndexVar != null)
- {
+ protected void setVariables(FacesContext facescontext, HtmlDataScroller scroller)
+ throws IOException
+ {
+ Map requestMap = facescontext.getExternalContext().getRequestMap();
+
+ String pageCountVar = scroller.getPageCountVar();
+ if (pageCountVar != null)
+ {
+ int pageCount = scroller.getPageCount();
+ requestMap.put(pageCountVar, new Integer(pageCount));
+ }
+ String pageIndexVar = scroller.getPageIndexVar();
+ if (pageIndexVar != null)
+ {
+ int pageIndex = (scroller.getRowCount() > 0)? scroller.getPageIndex() : 0;
+ requestMap.put(pageIndexVar, new Integer(pageIndex));
+ }
+ String rowsCountVar = scroller.getRowsCountVar();
+ if (rowsCountVar != null)
+ {
+ int rowsCount = scroller.getRowCount();
+ requestMap.put(rowsCountVar, new Integer(rowsCount));
+ }
+ String displayedRowsCountVar = scroller.getDisplayedRowsCountVar();
+ if (displayedRowsCountVar != null)
+ {
+ int displayedRowsCount = scroller.getRows();
+ int max = scroller.getRowCount() - scroller.getFirstRow();
+ if (displayedRowsCount > max)
+ displayedRowsCount = max;
+ requestMap.put(displayedRowsCountVar, new Integer(displayedRowsCount));
+ }
+ String firstRowIndexVar = scroller.getFirstRowIndexVar();
+ if (firstRowIndexVar != null)
+ {
int firstRowIndex = (scroller.getRowCount() > 0)? scroller.getFirstRow() + 1 : 0;
- requestMap.put(firstRowIndexVar, new Integer(firstRowIndex));
- }
- String lastRowIndexVar = scroller.getLastRowIndexVar();
- if (lastRowIndexVar != null)
- {
- int lastRowIndex = scroller.getFirstRow() + scroller.getRows();
- int count = scroller.getRowCount();
- if (lastRowIndex > count)
- lastRowIndex = count;
- requestMap.put(lastRowIndexVar, new Integer(lastRowIndex));
- }
- }
-
- public void removeVariables(FacesContext facescontext, HtmlDataScroller scroller)
- throws IOException
- {
- Map requestMap = facescontext.getExternalContext().getRequestMap();
-
- String pageCountVar = scroller.getPageCountVar();
- if (pageCountVar != null)
- {
- requestMap.remove(pageCountVar);
- }
- String pageIndexVar = scroller.getPageIndexVar();
- if (pageIndexVar != null)
- {
- requestMap.remove(pageIndexVar);
- }
- String rowsCountVar = scroller.getRowsCountVar();
- if (rowsCountVar != null)
- {
- requestMap.remove(rowsCountVar);
- }
- String displayedRowsCountVar = scroller.getDisplayedRowsCountVar();
- if (displayedRowsCountVar != null)
- {
- requestMap.remove(displayedRowsCountVar);
- }
- String firstRowIndexVar = scroller.getFirstRowIndexVar();
- if (firstRowIndexVar != null)
- {
- requestMap.remove(firstRowIndexVar);
- }
- String lastRowIndexVar = scroller.getLastRowIndexVar();
- if (lastRowIndexVar != null)
- {
- requestMap.remove(lastRowIndexVar);
- }
- }
-
- public void encodeBegin(FacesContext facesContext, UIComponent uiComponent) throws IOException
- {
- super.encodeBegin(facesContext, uiComponent);
-
- RendererUtils.checkParamValidity(facesContext, uiComponent, HtmlDataScroller.class);
-
- HtmlDataScroller scroller = (HtmlDataScroller) uiComponent;
-
- setVariables(facesContext, scroller);
- }
-
- public void encodeChildren(FacesContext facescontext, UIComponent uicomponent)
- throws IOException
- {
- RendererUtils.checkParamValidity(facescontext, uicomponent, HtmlDataScroller.class);
-
- RendererUtils.renderChildren(facescontext, uicomponent);
- }
-
- public void encodeEnd(FacesContext facesContext, UIComponent uiComponent) throws IOException
- {
- RendererUtils.checkParamValidity(facesContext, uiComponent, HtmlDataScroller.class);
-
- HtmlDataScroller scroller = (HtmlDataScroller) uiComponent;
-
- if (scroller.getUIData() == null)
- {
- return;
- }
-
- renderScroller(facesContext, scroller);
- removeVariables(facesContext, scroller);
- }
-
- protected void renderScroller(FacesContext facesContext, HtmlDataScroller scroller)
- throws IOException
- {
- ResponseWriter writer = facesContext.getResponseWriter();
+ requestMap.put(firstRowIndexVar, new Integer(firstRowIndex));
+ }
+ String lastRowIndexVar = scroller.getLastRowIndexVar();
+ if (lastRowIndexVar != null)
+ {
+ int lastRowIndex = scroller.getFirstRow() + scroller.getRows();
+ int count = scroller.getRowCount();
+ if (lastRowIndex > count)
+ lastRowIndex = count;
+ requestMap.put(lastRowIndexVar, new Integer(lastRowIndex));
+ }
+ }
+
+ public void removeVariables(FacesContext facescontext, HtmlDataScroller scroller)
+ throws IOException
+ {
+ Map requestMap = facescontext.getExternalContext().getRequestMap();
+
+ String pageCountVar = scroller.getPageCountVar();
+ if (pageCountVar != null)
+ {
+ requestMap.remove(pageCountVar);
+ }
+ String pageIndexVar = scroller.getPageIndexVar();
+ if (pageIndexVar != null)
+ {
+ requestMap.remove(pageIndexVar);
+ }
+ String rowsCountVar = scroller.getRowsCountVar();
+ if (rowsCountVar != null)
+ {
+ requestMap.remove(rowsCountVar);
+ }
+ String displayedRowsCountVar = scroller.getDisplayedRowsCountVar();
+ if (displayedRowsCountVar != null)
+ {
+ requestMap.remove(displayedRowsCountVar);
+ }
+ String firstRowIndexVar = scroller.getFirstRowIndexVar();
+ if (firstRowIndexVar != null)
+ {
+ requestMap.remove(firstRowIndexVar);
+ }
+ String lastRowIndexVar = scroller.getLastRowIndexVar();
+ if (lastRowIndexVar != null)
+ {
+ requestMap.remove(lastRowIndexVar);
+ }
+ }
+
+ public void encodeBegin(FacesContext facesContext, UIComponent uiComponent) throws IOException
+ {
+ super.encodeBegin(facesContext, uiComponent);
+
+ RendererUtils.checkParamValidity(facesContext, uiComponent, HtmlDataScroller.class);
+
+ HtmlDataScroller scroller = (HtmlDataScroller) uiComponent;
+
+ setVariables(facesContext, scroller);
+ }
+
+ public void encodeChildren(FacesContext facescontext, UIComponent uicomponent)
+ throws IOException
+ {
+ RendererUtils.checkParamValidity(facescontext, uicomponent, HtmlDataScroller.class);
+
+ RendererUtils.renderChildren(facescontext, uicomponent);
+ }
+
+ public void encodeEnd(FacesContext facesContext, UIComponent uiComponent) throws IOException
+ {
+ RendererUtils.checkParamValidity(facesContext, uiComponent, HtmlDataScroller.class);
- if (!scroller.isRenderFacetsIfSinglePage() && scroller.getPageCount() <= 1)
- return;
+ HtmlDataScroller scroller = (HtmlDataScroller) uiComponent;
+
+ if (scroller.getUIData() == null)
+ {
+ return;
+ }
+
+ renderScroller(facesContext, scroller);
+ removeVariables(facesContext, scroller);
+ }
+
+ protected void renderScroller(FacesContext facesContext, HtmlDataScroller scroller)
+ throws IOException
+ {
+ ResponseWriter writer = facesContext.getResponseWriter();
+
+ if (!scroller.isRenderFacetsIfSinglePage() && scroller.getPageCount() <= 1)
+ return;
if (scroller.getFirst() == null && scroller.getFastRewind() == null
&& scroller.getPrevious() == null && !scroller.isPaginator()
@@ -217,223 +217,223 @@
&& scroller.getLast() == null)
return;
- writer.startElement("table", scroller);
- String styleClass = scroller.getStyleClass();
- if (styleClass != null)
- {
- writer.writeAttribute("class", styleClass, null);
- }
- String style = scroller.getStyle();
- if (style != null)
- {
- writer.writeAttribute("style", style, null);
- }
- writer.startElement("tr", scroller);
-
- UIComponent facetComp = scroller.getFirst();
- if (facetComp != null)
- {
- writer.startElement("td", scroller);
- renderFacet(facesContext, scroller, facetComp, HtmlDataScroller.FACET_FIRST);
- writer.endElement("td");
- }
- facetComp = scroller.getFastRewind();
- if (facetComp != null)
- {
- writer.startElement("td", scroller);
- renderFacet(facesContext, scroller, facetComp, HtmlDataScroller.FACET_FAST_REWIND);
- writer.endElement("td");
- }
- facetComp = scroller.getPrevious();
- if (facetComp != null)
- {
- writer.startElement("td", scroller);
- renderFacet(facesContext, scroller, facetComp, HtmlDataScroller.FACET_PREVIOUS);
- writer.endElement("td");
- }
- if (scroller.isPaginator())
- {
- writer.startElement("td", scroller);
- renderPaginator(facesContext, scroller);
- writer.endElement("td");
- }
- facetComp = scroller.getNext();
- if (facetComp != null)
- {
- writer.startElement("td", scroller);
- renderFacet(facesContext, scroller, facetComp, HtmlDataScroller.FACET_NEXT);
- writer.endElement("td");
- }
- facetComp = scroller.getFastForward();
- if (facetComp != null)
- {
- writer.startElement("td", scroller);
- renderFacet(facesContext, scroller, facetComp, HtmlDataScroller.FACET_FAST_FORWARD);
- writer.endElement("td");
- }
- facetComp = scroller.getLast();
- if (facetComp != null)
- {
- writer.startElement("td", scroller);
- renderFacet(facesContext, scroller, facetComp, HtmlDataScroller.FACET_LAST);
- writer.endElement("td");
- }
-
- writer.endElement("tr");
- writer.endElement("table");
- }
-
- protected void renderFacet(FacesContext facesContext, HtmlDataScroller scroller,
- UIComponent facetComp, String facetName) throws IOException
- {
- UIComponent link = getLink(facesContext, scroller, facetName);
- link.encodeBegin(facesContext);
- facetComp.encodeBegin(facesContext);
- if (facetComp.getRendersChildren())
- facetComp.encodeChildren(facesContext);
- facetComp.encodeEnd(facesContext);
- link.encodeEnd(facesContext);
- }
+ writer.startElement("table", scroller);
+ String styleClass = scroller.getStyleClass();
+ if (styleClass != null)
+ {
+ writer.writeAttribute("class", styleClass, null);
+ }
+ String style = scroller.getStyle();
+ if (style != null)
+ {
+ writer.writeAttribute("style", style, null);
+ }
+ writer.startElement("tr", scroller);
+
+ UIComponent facetComp = scroller.getFirst();
+ if (facetComp != null)
+ {
+ writer.startElement("td", scroller);
+ renderFacet(facesContext, scroller, facetComp, HtmlDataScroller.FACET_FIRST);
+ writer.endElement("td");
+ }
+ facetComp = scroller.getFastRewind();
+ if (facetComp != null)
+ {
+ writer.startElement("td", scroller);
+ renderFacet(facesContext, scroller, facetComp, HtmlDataScroller.FACET_FAST_REWIND);
+ writer.endElement("td");
+ }
+ facetComp = scroller.getPrevious();
+ if (facetComp != null)
+ {
+ writer.startElement("td", scroller);
+ renderFacet(facesContext, scroller, facetComp, HtmlDataScroller.FACET_PREVIOUS);
+ writer.endElement("td");
+ }
+ if (scroller.isPaginator())
+ {
+ writer.startElement("td", scroller);
+ renderPaginator(facesContext, scroller);
+ writer.endElement("td");
+ }
+ facetComp = scroller.getNext();
+ if (facetComp != null)
+ {
+ writer.startElement("td", scroller);
+ renderFacet(facesContext, scroller, facetComp, HtmlDataScroller.FACET_NEXT);
+ writer.endElement("td");
+ }
+ facetComp = scroller.getFastForward();
+ if (facetComp != null)
+ {
+ writer.startElement("td", scroller);
+ renderFacet(facesContext, scroller, facetComp, HtmlDataScroller.FACET_FAST_FORWARD);
+ writer.endElement("td");
+ }
+ facetComp = scroller.getLast();
+ if (facetComp != null)
+ {
+ writer.startElement("td", scroller);
+ renderFacet(facesContext, scroller, facetComp, HtmlDataScroller.FACET_LAST);
+ writer.endElement("td");
+ }
+
+ writer.endElement("tr");
+ writer.endElement("table");
+ }
+
+ protected void renderFacet(FacesContext facesContext, HtmlDataScroller scroller,
+ UIComponent facetComp, String facetName) throws IOException
+ {
+ UIComponent link = getLink(facesContext, scroller, facetName);
+ link.encodeBegin(facesContext);
+ facetComp.encodeBegin(facesContext);
+ if (facetComp.getRendersChildren())
+ facetComp.encodeChildren(facesContext);
+ facetComp.encodeEnd(facesContext);
+ link.encodeEnd(facesContext);
+ }
/**
* The "paginator" is a sequence of page numbers which the user can click
* on to leap directly to a specific page of data.
*/
- protected void renderPaginator(FacesContext facesContext, HtmlDataScroller scroller)
- throws IOException
- {
- ResponseWriter writer = facesContext.getResponseWriter();
-
- int maxPages = scroller.getPaginatorMaxPages();
- if (maxPages <= 1)
- {
- maxPages = 2;
- }
- int pageCount = scroller.getPageCount();
- if (pageCount <= 1)
- {
- return;
- }
- int pageIndex = scroller.getPageIndex();
- int delta = maxPages / 2;
-
- int pages;
- int start;
- if (pageCount > maxPages && pageIndex > delta)
- {
- pages = maxPages;
- start = pageIndex - pages / 2 - 1;
- if (start + pages > pageCount)
- {
- start = pageCount - pages;
- }
- }
- else
- {
- pages = pageCount < maxPages ? pageCount : maxPages;
- start = 0;
- }
-
- writer.startElement("table", scroller);
-
- String styleClass = scroller.getPaginatorTableClass();
- if (styleClass != null)
- {
- writer.writeAttribute("class", styleClass, null);
- }
- String style = scroller.getPaginatorTableStyle();
- if (style != null)
- {
- writer.writeAttribute("style", style, null);
- }
-
- writer.startElement("tr", scroller);
-
- for (int i = start, size = start + pages; i < size; i++)
- {
- int idx = i + 1;
- writer.startElement("td", scroller);
- String cStyleClass;
- String cStyle;
- if (idx == pageIndex)
- {
- cStyleClass = scroller.getPaginatorActiveColumnClass();
- cStyle = scroller.getPaginatorActiveColumnStyle();
- }
- else
- {
- cStyleClass = scroller.getPaginatorColumnClass();
- cStyle = scroller.getPaginatorColumnStyle();
- }
- if (cStyleClass != null)
- {
- writer.writeAttribute("class", cStyleClass, null);
- }
- if (cStyle != null)
- {
- writer.writeAttribute("style", cStyle, null);
- }
-
- HtmlCommandLink link = getLink(facesContext, scroller, Integer.toString(idx), idx);
- link.encodeBegin(facesContext);
- link.encodeChildren(facesContext);
- link.encodeEnd(facesContext);
-
- writer.endElement("td");
- }
-
- writer.endElement("tr");
- writer.endElement("table");
- }
-
- protected HtmlCommandLink getLink(FacesContext facesContext, HtmlDataScroller scroller,
- String text, int pageIndex)
- {
- String id = HtmlDataScrollerRenderer.PAGE_NAVIGATION + Integer.toString(pageIndex);
- Application application = facesContext.getApplication();
-
- HtmlCommandLink link = (HtmlCommandLink) application
- .createComponent(HtmlCommandLink.COMPONENT_TYPE);
- link.setId(scroller.getId() + id);
- link.setTransient(true);
- UIParameter parameter = (UIParameter) application
- .createComponent(UIParameter.COMPONENT_TYPE);
- parameter.setId(scroller.getId() + id + "_param");
- parameter.setTransient(true);
- parameter.setName(scroller.getClientId(facesContext));
- parameter.setValue(id);
- List children = link.getChildren();
- children.add(parameter);
- if (text != null)
- {
- HtmlOutputText uiText = (HtmlOutputText) application
- .createComponent(HtmlOutputText.COMPONENT_TYPE);
- uiText.setTransient(true);
- uiText.setValue(text);
- children.add(uiText);
- }
- scroller.getChildren().add(link);
- return link;
- }
-
- protected HtmlCommandLink getLink(FacesContext facesContext, HtmlDataScroller scroller,
- String facetName)
- {
- Application application = facesContext.getApplication();
-
- HtmlCommandLink link = (HtmlCommandLink) application
- .createComponent(HtmlCommandLink.COMPONENT_TYPE);
- link.setId(scroller.getId() + facetName);
- link.setTransient(true);
- UIParameter parameter = (UIParameter) application
- .createComponent(UIParameter.COMPONENT_TYPE);
- parameter.setId(scroller.getId() + facetName + "_param");
- parameter.setTransient(true);
- parameter.setName(scroller.getClientId(facesContext));
- parameter.setValue(facetName);
- List children = link.getChildren();
- children.add(parameter);
- scroller.getChildren().add(link);
- return link;
- }
+ protected void renderPaginator(FacesContext facesContext, HtmlDataScroller scroller)
+ throws IOException
+ {
+ ResponseWriter writer = facesContext.getResponseWriter();
+
+ int maxPages = scroller.getPaginatorMaxPages();
+ if (maxPages <= 1)
+ {
+ maxPages = 2;
+ }
+ int pageCount = scroller.getPageCount();
+ if (pageCount <= 1)
+ {
+ return;
+ }
+ int pageIndex = scroller.getPageIndex();
+ int delta = maxPages / 2;
+
+ int pages;
+ int start;
+ if (pageCount > maxPages && pageIndex > delta)
+ {
+ pages = maxPages;
+ start = pageIndex - pages / 2 - 1;
+ if (start + pages > pageCount)
+ {
+ start = pageCount - pages;
+ }
+ }
+ else
+ {
+ pages = pageCount < maxPages ? pageCount : maxPages;
+ start = 0;
+ }
+
+ writer.startElement("table", scroller);
+
+ String styleClass = scroller.getPaginatorTableClass();
+ if (styleClass != null)
+ {
+ writer.writeAttribute("class", styleClass, null);
+ }
+ String style = scroller.getPaginatorTableStyle();
+ if (style != null)
+ {
+ writer.writeAttribute("style", style, null);
+ }
+
+ writer.startElement("tr", scroller);
+
+ for (int i = start, size = start + pages; i < size; i++)
+ {
+ int idx = i + 1;
+ writer.startElement("td", scroller);
+ String cStyleClass;
+ String cStyle;
+ if (idx == pageIndex)
+ {
+ cStyleClass = scroller.getPaginatorActiveColumnClass();
+ cStyle = scroller.getPaginatorActiveColumnStyle();
+ }
+ else
+ {
+ cStyleClass = scroller.getPaginatorColumnClass();
+ cStyle = scroller.getPaginatorColumnStyle();
+ }
+ if (cStyleClass != null)
+ {
+ writer.writeAttribute("class", cStyleClass, null);
+ }
+ if (cStyle != null)
+ {
+ writer.writeAttribute("style", cStyle, null);
+ }
+
+ HtmlCommandLink link = getLink(facesContext, scroller, Integer.toString(idx), idx);
+ link.encodeBegin(facesContext);
+ link.encodeChildren(facesContext);
+ link.encodeEnd(facesContext);
+
+ writer.endElement("td");
+ }
+
+ writer.endElement("tr");
+ writer.endElement("table");
+ }
+
+ protected HtmlCommandLink getLink(FacesContext facesContext, HtmlDataScroller scroller,
+ String text, int pageIndex)
+ {
+ String id = HtmlDataScrollerRenderer.PAGE_NAVIGATION + Integer.toString(pageIndex);
+ Application application = facesContext.getApplication();
+
+ HtmlCommandLink link = (HtmlCommandLink) application
+ .createComponent(HtmlCommandLink.COMPONENT_TYPE);
+ link.setId(scroller.getId() + id);
+ link.setTransient(true);
+ UIParameter parameter = (UIParameter) application
+ .createComponent(UIParameter.COMPONENT_TYPE);
+ parameter.setId(scroller.getId() + id + "_param");
+ parameter.setTransient(true);
+ parameter.setName(scroller.getClientId(facesContext));
+ parameter.setValue(id);
+ List children = link.getChildren();
+ children.add(parameter);
+ if (text != null)
+ {
+ HtmlOutputText uiText = (HtmlOutputText) application
+ .createComponent(HtmlOutputText.COMPONENT_TYPE);
+ uiText.setTransient(true);
+ uiText.setValue(text);
+ children.add(uiText);
+ }
+ scroller.getChildren().add(link);
+ return link;
+ }
+
+ protected HtmlCommandLink getLink(FacesContext facesContext, HtmlDataScroller scroller,
+ String facetName)
+ {
+ Application application = facesContext.getApplication();
+
+ HtmlCommandLink link = (HtmlCommandLink) application
+ .createComponent(HtmlCommandLink.COMPONENT_TYPE);
+ link.setId(scroller.getId() + facetName);
+ link.setTransient(true);
+ UIParameter parameter = (UIParameter) application
+ .createComponent(UIParameter.COMPONENT_TYPE);
+ parameter.setId(scroller.getId() + facetName + "_param");
+ parameter.setTransient(true);
+ parameter.setName(scroller.getClientId(facesContext));
+ parameter.setValue(facetName);
+ List children = link.getChildren();
+ children.add(parameter);
+ scroller.getChildren().add(link);
+ return link;
+ }
}
Modified: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/datascroller/HtmlDataScrollerTag.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/datascroller/HtmlDataScrollerTag.java?rev=349525&r1=349524&r2=349525&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/datascroller/HtmlDataScrollerTag.java (original)
+++ myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/datascroller/HtmlDataScrollerTag.java Mon Nov 28 14:17:20 2005
@@ -50,7 +50,7 @@
private static final String PAGINATOR_COL_STYLE_ATTR = "paginatorColumnStyle";
private static final String PAGINATOR_ACTCOL_CLASS_ATTR = "paginatorActiveColumnClass";
private static final String PAGINATOR_ACTCOL_STYLE_ATTR = "paginatorActiveColumnStyle";
- private static final String RENDER_FACETS_IF_SINGLE_PAGE_ATTR = "renderFacetsIfSinglePage";
+ private static final String RENDER_FACETS_IF_SINGLE_PAGE_ATTR = "renderFacetsIfSinglePage";
private String _for;
private String _fastStep;
@@ -70,8 +70,8 @@
private String _paginatorColumnStyle;
private String _paginatorActiveColumnClass;
private String _paginatorActiveColumnStyle;
- private String _renderFacetsIfSinglePage;
-
+ private String _renderFacetsIfSinglePage;
+
private String _immediate;
private String _actionListener;
@@ -99,7 +99,7 @@
_paginatorColumnStyle=null;
_paginatorActiveColumnClass=null;
_paginatorActiveColumnStyle=null;
- _renderFacetsIfSinglePage=null;
+ _renderFacetsIfSinglePage=null;
_enabledOnUserRole=null;
_visibleOnUserRole=null;
_immediate=null;
@@ -138,8 +138,8 @@
setStringProperty(component, PAGINATOR_COL_STYLE_ATTR, _paginatorColumnStyle);
setStringProperty(component, PAGINATOR_ACTCOL_CLASS_ATTR, _paginatorActiveColumnClass);
setStringProperty(component, PAGINATOR_ACTCOL_STYLE_ATTR, _paginatorActiveColumnStyle);
- setBooleanProperty(component, RENDER_FACETS_IF_SINGLE_PAGE_ATTR, _renderFacetsIfSinglePage);
-
+ setBooleanProperty(component, RENDER_FACETS_IF_SINGLE_PAGE_ATTR, _renderFacetsIfSinglePage);
+
setBooleanProperty(component, JSFAttr.IMMEDIATE_ATTR, _immediate);
setActionListenerProperty(component, _actionListener);
@@ -240,7 +240,7 @@
public void setRenderFacetsIfSinglePage(String renderFacetsIfSinglePage)
{
- _renderFacetsIfSinglePage = renderFacetsIfSinglePage;
+ _renderFacetsIfSinglePage = renderFacetsIfSinglePage;
}
public void setImmediate(String immediate)