You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by sc...@apache.org on 2005/07/06 19:34:12 UTC
svn commit: r209483 - in /myfaces/tomahawk/trunk:
src/java/org/apache/myfaces/custom/datascroller/ tld/
Author: schof
Date: Wed Jul 6 10:34:11 2005
New Revision: 209483
URL: http://svn.apache.org/viewcvs?rev=209483&view=rev
Log:
Mathias Broekelmann's patch for MYFACES-305
Added:
myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/datascroller/ScrollerActionEvent.java
Modified:
myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/datascroller/HtmlDataScroller.java
myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/datascroller/HtmlDataScroller.xml
myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/datascroller/HtmlDataScrollerRenderer.java
myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/datascroller/HtmlDataScrollerTag.java
myfaces/tomahawk/trunk/tld/myfaces_ext.tld
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=209483&r1=209482&r2=209483&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 Wed Jul 6 10:34:11 2005
@@ -15,415 +15,749 @@
*/
package org.apache.myfaces.custom.datascroller;
-import org.apache.myfaces.component.html.ext.HtmlPanelGroup;
-
+import javax.faces.component.ActionSource;
import javax.faces.component.UIComponent;
+import javax.faces.component.UIData;
import javax.faces.context.FacesContext;
+import javax.faces.el.MethodBinding;
import javax.faces.el.ValueBinding;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.ActionEvent;
+import javax.faces.event.ActionListener;
+import javax.faces.event.FacesEvent;
+import javax.faces.event.PhaseId;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.myfaces.component.html.ext.HtmlPanelGroup;
/**
* @author Thomas Spiegl (latest modification by $Author$)
* @version $Revision$ $Date$
*/
-public class HtmlDataScroller
- extends HtmlPanelGroup
+public class HtmlDataScroller extends HtmlPanelGroup implements ActionSource
{
- //private static final Log log = LogFactory.getLog(HtmlPanelTabbedPane.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";
-
- 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;
- }
-
-
- //------------------ 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 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 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;
+
+ /**
+ * @see javax.faces.component.UIComponentBase#queueEvent(javax.faces.event.FacesEvent)
+ */
+ 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);
+ }
+
+ /**
+ * @see javax.faces.component.UIComponentBase#broadcast(javax.faces.event.FacesEvent)
+ */
+ public void broadcast(FacesEvent event) throws AbortProcessingException
+ {
+ super.broadcast(event);
+
+ if (event instanceof ScrollerActionEvent)
+ {
+ ScrollerActionEvent scrollerEvent = (ScrollerActionEvent) event;
+ 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));
+ }
+ }
+ }
+
+ /**
+ * @return
+ */
+ 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
+ */
+ public int getRowCount()
+ {
+ return getUIData().getRowCount();
+ }
+
+ /**
+ * @return
+ */
+ public int getRows()
+ {
+ return getUIData().getRows();
+ }
+
+ /**
+ * @return
+ */
+ public int getFirstRow()
+ {
+ return getUIData().getFirst();
+ }
+
+ 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)
+ {
+ log.warn("could not find UIData referenced by attribute dataScroller@for = '"
+ + forStr + "'");
+ }
+ }
+ if (!(forComp instanceof UIData))
+ {
+ throw new IllegalArgumentException(
+ "uiComponent referenced by attribute dataScroller@for must be of type "
+ + UIData.class.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#getActionListener()
+ */
+ public MethodBinding getActionListener()
+ {
+ return null;
+ }
+
+ /**
+ * @see javax.faces.component.ActionSource#setActionListener(javax.faces.el.MethodBinding)
+ */
+ public void setActionListener(MethodBinding actionListener)
+ {
+ throw new UnsupportedOperationException(
+ "defining an action is not supported. use an 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 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;
- }
+ protected static final String FACET_FIRST = "first".intern();
+ protected static final String FACET_PREVIOUS = "previous".intern();
+ protected static final String FACET_NEXT = "next".intern();
+ protected static final String FACET_LAST = "last".intern();
+ protected static final String FACET_FAST_FORWARD = "fastf".intern();
+ protected 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)
- {
+ 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 Object saveState(FacesContext context)
- {
- Object values[] = new Object[21];
- 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;
+ }
+
+ 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[22];
+ 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;
- return values;
- }
+ values[21] = _immediate;
+ 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];
- }
- //------------------ GENERATED CODE END ---------------------------------------
+ //------------------ GENERATED CODE END ---------------------------------------
}
Modified: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/datascroller/HtmlDataScroller.xml
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/datascroller/HtmlDataScroller.xml?rev=209483&r1=209482&r2=209483&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/datascroller/HtmlDataScroller.xml (original)
+++ myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/datascroller/HtmlDataScroller.xml Wed Jul 6 10:34:11 2005
@@ -72,4 +72,9 @@
<name>renderFacetsIfSinglePage</name>
<type>boolean</type>
</field>
+ <field>
+ <name>immediate</name>
+ <type>boolean</type>
+ <default-value>false</default-value>
+ </field>
</component>
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=209483&r1=209482&r2=209483&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 Wed Jul 6 10:34:11 2005
@@ -15,11 +15,9 @@
*/
package org.apache.myfaces.custom.datascroller;
-import org.apache.myfaces.renderkit.RendererUtils;
-import org.apache.myfaces.renderkit.html.HtmlRenderer;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
import javax.faces.application.Application;
import javax.faces.component.UIComponent;
@@ -29,9 +27,11 @@
import javax.faces.component.html.HtmlOutputText;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
-import java.io.IOException;
-import java.util.List;
-import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.myfaces.renderkit.RendererUtils;
+import org.apache.myfaces.renderkit.html.HtmlRenderer;
/**
* @author Thomas Spiegl (latest modification by $Author$)
@@ -56,530 +56,383 @@
* Prevent division by zero in getPageIndex
*
*/
-public class HtmlDataScrollerRenderer
- extends HtmlRenderer
+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";
+
+ protected static final String PAGE_NAVIGATION = "idx".intern();
+
+ public boolean getRendersChildren()
+ {
+ return true;
+ }
+
+ 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)
+ {
+ if (param.startsWith(PAGE_NAVIGATION))
+ {
+ component.queueEvent(new ScrollerActionEvent(component, Integer.parseInt(param
+ .substring(PAGE_NAVIGATION.length(), param.length()))));
+ }
+ else
+ {
+ component.queueEvent(new ScrollerActionEvent(component, param));
+ }
+ }
+ }
- protected static final String FACET_FIRST = "first".intern();
- protected static final String FACET_PREVIOUS = "previous".intern();
- protected static final String FACET_NEXT = "next".intern();
- protected static final String FACET_LAST = "last".intern();
- protected static final String FACET_FAST_FORWARD = "fastf".intern();
- protected static final String FACET_FAST_REWIND = "fastr".intern();
- protected static final String PAGE_NAVIGATION = "idx".intern();
-
- public static final String RENDERER_TYPE = "org.apache.myfaces.DataScroller";
-
- public boolean getRendersChildren()
- {
- return true;
- }
-
- public void decode(FacesContext context, UIComponent component)
- {
- RendererUtils.checkParamValidity(context, component, HtmlDataScroller.class);
-
- HtmlDataScroller scroller = (HtmlDataScroller)component;
-
- UIData uiData = findUIData(scroller);
- if (uiData == null)
- {
- return;
- }
-
- Map parameter = context.getExternalContext().getRequestParameterMap();
- String param = (String)parameter.get(component.getClientId(context));
- if (param != null)
- {
- if (param.equals(FACET_FIRST))
- {
- uiData.setFirst(0);
- }
- else if (param.equals(FACET_PREVIOUS))
- {
- int previous = uiData.getFirst() - uiData.getRows();
- if (previous >= 0)
- uiData.setFirst(previous);
- }
- else if (param.equals(FACET_NEXT))
- {
- int next = uiData.getFirst() + uiData.getRows();
- if (next < uiData.getRowCount())
- uiData.setFirst(next);
- }
- else if (param.equals(FACET_FAST_FORWARD))
- {
- int fastStep = scroller.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 (param.equals(FACET_FAST_REWIND))
- {
- int fastStep = scroller.getFastStep();
- if (fastStep <= 0)
- fastStep = 1;
- int previous = uiData.getFirst() - uiData.getRows() * fastStep;
- if (previous < 0)
- previous = 0;
- uiData.setFirst(previous);
- }
- else if (param.equals(FACET_LAST))
- {
- 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 if (param.startsWith(PAGE_NAVIGATION))
- {
- int index = Integer.parseInt(param.substring(PAGE_NAVIGATION.length(), param.length()));
- int pageCount = getPageCount(uiData);
- if (index > pageCount)
- {
- index = pageCount;
- }
- else if (index <= 0)
- {
- index = 1;
- }
- uiData.setFirst(uiData.getRows() * (index - 1));
- }
- }
- }
-
- protected void setVariables(FacesContext facescontext, HtmlDataScroller scroller) throws IOException
- {
- UIData uiData = findUIData(scroller);
- if (uiData == null)
- {
- return;
- }
-
+ protected void setVariables(FacesContext facescontext, HtmlDataScroller scroller)
+ throws IOException
+ {
Map requestMap = facescontext.getExternalContext().getRequestMap();
-
- String pageCountVar = scroller.getPageCountVar();
- if (pageCountVar != null)
- {
- int pageCount = getPageCount(uiData);
- requestMap.put(pageCountVar, new Integer(pageCount));
- }
- String pageIndexVar = scroller.getPageIndexVar();
- if (pageIndexVar != null)
- {
- int pageIndex = getPageIndex(uiData);
- requestMap.put(pageIndexVar, new Integer(pageIndex));
- }
- String rowsCountVar = scroller.getRowsCountVar();
- if (rowsCountVar != null)
- {
- int rowsCount = uiData.getRowCount();
- requestMap.put(rowsCountVar, new Integer(rowsCount));
- }
- String displayedRowsCountVar = scroller.getDisplayedRowsCountVar();
- if (displayedRowsCountVar != null)
- {
- int displayedRowsCount = uiData.getRows();
- int max = uiData.getRowCount()-uiData.getFirst();
- if( displayedRowsCount > max )
- displayedRowsCount = max;
- requestMap.put(displayedRowsCountVar, new Integer(displayedRowsCount));
- }
- String firstRowIndexVar = scroller.getFirstRowIndexVar();
- if (firstRowIndexVar != null)
- {
- int firstRowIndex = uiData.getFirst()+1;
- requestMap.put(firstRowIndexVar, new Integer(firstRowIndex));
- }
- String lastRowIndexVar = scroller.getLastRowIndexVar();
- if (lastRowIndexVar != null)
- {
- int lastRowIndex = uiData.getFirst()+uiData.getRows();
- int count = uiData.getRowCount();
- if( lastRowIndex > count )
- lastRowIndex = count;
- requestMap.put(lastRowIndexVar, new Integer(lastRowIndex));
- }
- }
-
- public void removeVariables(FacesContext facescontext, HtmlDataScroller scroller) throws IOException
- {
+
+ 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.getPageIndex();
+ 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.getFirstRow() + 1;
+ 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);
- }
+ if (pageCountVar != null)
+ {
+ requestMap.remove(pageCountVar);
+ }
String pageIndexVar = scroller.getPageIndexVar();
- if (pageIndexVar != null)
- {
- requestMap.remove(pageIndexVar);
- }
+ if (pageIndexVar != null)
+ {
+ requestMap.remove(pageIndexVar);
+ }
String rowsCountVar = scroller.getRowsCountVar();
- if (rowsCountVar != null)
- {
- requestMap.remove(rowsCountVar);
- }
+ if (rowsCountVar != null)
+ {
+ requestMap.remove(rowsCountVar);
+ }
String displayedRowsCountVar = scroller.getDisplayedRowsCountVar();
- if (displayedRowsCountVar != null)
- {
- requestMap.remove(displayedRowsCountVar);
- }
+ if (displayedRowsCountVar != null)
+ {
+ requestMap.remove(displayedRowsCountVar);
+ }
String firstRowIndexVar = scroller.getFirstRowIndexVar();
- if (firstRowIndexVar != null)
- {
- requestMap.remove(firstRowIndexVar);
- }
+ if (firstRowIndexVar != null)
+ {
+ requestMap.remove(firstRowIndexVar);
+ }
String lastRowIndexVar = scroller.getLastRowIndexVar();
- if (lastRowIndexVar != null)
- {
- requestMap.remove(lastRowIndexVar);
- }
- }
+ if (lastRowIndexVar != null)
+ {
+ requestMap.remove(lastRowIndexVar);
+ }
+ }
- public void encodeBegin(FacesContext facesContext, UIComponent uiComponent) throws IOException {
+ public void encodeBegin(FacesContext facesContext, UIComponent uiComponent) throws IOException
+ {
super.encodeBegin(facesContext, uiComponent);
-
+
RendererUtils.checkParamValidity(facesContext, uiComponent, HtmlDataScroller.class);
-
- HtmlDataScroller scroller = (HtmlDataScroller)uiComponent;
-
+
+ HtmlDataScroller scroller = (HtmlDataScroller) uiComponent;
+
setVariables(facesContext, scroller);
}
- public void encodeChildren(FacesContext facescontext, UIComponent uicomponent) throws IOException
- {
- RendererUtils.checkParamValidity(facescontext, uicomponent, HtmlDataScroller.class);
+ public void encodeChildren(FacesContext facescontext, UIComponent uicomponent)
+ throws IOException
+ {
+ RendererUtils.checkParamValidity(facescontext, uicomponent, HtmlDataScroller.class);
- RendererUtils.renderChildren(facescontext, uicomponent);
- }
+ RendererUtils.renderChildren(facescontext, uicomponent);
+ }
- public void encodeEnd(FacesContext facesContext, UIComponent uiComponent) throws IOException{
+ public void encodeEnd(FacesContext facesContext, UIComponent uiComponent) throws IOException
+ {
RendererUtils.checkParamValidity(facesContext, uiComponent, HtmlDataScroller.class);
-
- HtmlDataScroller scroller = (HtmlDataScroller)uiComponent;
- UIData uiData = findUIData(scroller);
- if (uiData == null)
- {
- return;
- }
+ HtmlDataScroller scroller = (HtmlDataScroller) uiComponent;
+
+ if (scroller.getUIData() == null)
+ {
+ return;
+ }
- renderPaginator(uiData, facesContext, scroller);
+ renderScroller(facesContext, scroller);
removeVariables(facesContext, scroller);
- }
-
- public void renderPaginator(UIData uiData, FacesContext facesContext, HtmlDataScroller scroller) throws IOException
- {
+ }
+
+ public void renderScroller(FacesContext facesContext, HtmlDataScroller scroller)
+ throws IOException
+ {
ResponseWriter writer = facesContext.getResponseWriter();
- if (!scroller.isRenderFacetsIfSinglePage() && getPageCount(uiData)<=1)
+ if (!scroller.isRenderFacetsIfSinglePage() && scroller.getPageCount() <= 1)
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, FACET_FIRST);
- writer.endElement("td");
- }
- facetComp = scroller.getFastRewind();
- if (facetComp != null)
- {
- writer.startElement("td", scroller);
- renderFacet(facesContext, scroller, facetComp, FACET_FAST_REWIND);
- writer.endElement("td");
- }
- facetComp = scroller.getPrevious();
- if (facetComp != null)
- {
- writer.startElement("td", scroller);
- renderFacet(facesContext, scroller, facetComp, FACET_PREVIOUS);
- writer.endElement("td");
- }
- if (scroller.isPaginator())
- {
- writer.startElement("td", scroller);
- renderPaginator(facesContext, scroller, uiData);
- writer.endElement("td");
- }
- facetComp = scroller.getNext();
- if (facetComp != null)
- {
- writer.startElement("td", scroller);
- renderFacet(facesContext, scroller, facetComp, FACET_NEXT);
- writer.endElement("td");
- }
- facetComp = scroller.getFastForward();
- if (facetComp != null)
- {
- writer.startElement("td", scroller);
- renderFacet(facesContext, scroller, facetComp, FACET_FAST_FORWARD);
- writer.endElement("td");
- }
- facetComp = scroller.getLast();
- if (facetComp != null)
- {
- writer.startElement("td", scroller);
- renderFacet(facesContext, scroller, facetComp, FACET_LAST);
- writer.endElement("td");
- }
-
- writer.endElement("tr");
- writer.endElement("table");
- }
-
- private void renderFacet(FacesContext facesContext,
- HtmlDataScroller scroller,
- UIComponent facetComp,
- String facetName)
- throws IOException
- {
- UIComponent link = getLink(facesContext, scroller, facetComp, facetName);
- link.encodeBegin(facesContext);
- facetComp.encodeBegin(facesContext);
- if (facetComp.getRendersChildren())
- facetComp.encodeChildren(facesContext);
- facetComp.encodeEnd(facesContext);
- link.encodeEnd(facesContext);
- }
-
- protected void renderPaginator(FacesContext facesContext,
- HtmlDataScroller scroller,
- UIData uiData)
- throws IOException
- {
- ResponseWriter writer = facesContext.getResponseWriter();
-
- int maxPages = scroller.getPaginatorMaxPages();
- if (maxPages <= 1)
- {
- maxPages = 2;
- }
- int pageCount = getPageCount(uiData);
- if (pageCount <= 1)
- {
- return;
- }
- int pageIndex = getPageIndex(uiData);
- 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 = 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,
- UIComponent facetComp,
- 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);
- if (facetComp != null)
- children.add(facetComp);
- // dirty, cause facet-comp is now child from link & scroller!
- scroller.getChildren().add(link);
- return link;
- }
-
- protected int getPageIndex(UIData uiData)
- {
- 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;
- }
-
- protected int getPageCount(UIData uiData)
- {
- 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;
- }
-
- protected UIData findUIData(HtmlDataScroller scroller)
- {
- String forStr = scroller.getFor();
- UIComponent forComp;
- if (forStr == null)
- {
- // DataScroller may be a child of uiData
- forComp = scroller.getParent();
- }
- else
- {
- forComp = scroller.findComponent(scroller.getFor());
- if (forComp == null)
- {
- log.warn("could not find UIData referenced by attribute dataScroller@for = '" + scroller.getFor() + "'");
- }
- }
- if (!(forComp instanceof UIData))
- {
- throw new IllegalArgumentException("uiComponent referenced by attribute tableScroller@for must be of type " + UIData.class.getName());
- }
- return (UIData)forComp;
- }
+ 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");
+ }
+
+ private void renderFacet(FacesContext facesContext, HtmlDataScroller scroller,
+ UIComponent facetComp, String facetName) throws IOException
+ {
+ UIComponent link = getLink(facesContext, scroller, facetComp, facetName);
+ link.encodeBegin(facesContext);
+ facetComp.encodeBegin(facesContext);
+ if (facetComp.getRendersChildren())
+ facetComp.encodeChildren(facesContext);
+ facetComp.encodeEnd(facesContext);
+ link.encodeEnd(facesContext);
+ }
+
+ 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,
+ UIComponent facetComp, 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);
+ if (facetComp != null)
+ children.add(facetComp);
+ // dirty, cause facet-comp is now child from link & scroller!
+ 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=209483&r1=209482&r2=209483&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 Wed Jul 6 10:34:11 2005
@@ -16,6 +16,7 @@
package org.apache.myfaces.custom.datascroller;
import org.apache.myfaces.component.UserRoleAware;
+import org.apache.myfaces.renderkit.JSFAttr;
import org.apache.myfaces.taglib.UIComponentTagBase;
import javax.faces.component.UIComponent;
@@ -114,6 +115,8 @@
private String _paginatorActiveColumnClass;
private String _paginatorActiveColumnStyle;
private String _renderFacetsIfSinglePage;
+
+ private String _immediate;
// User Role support
private String _enabledOnUserRole;
@@ -142,6 +145,7 @@
_renderFacetsIfSinglePage=null;
_enabledOnUserRole=null;
_visibleOnUserRole=null;
+ _immediate=null;
}
public String getComponentType()
@@ -178,6 +182,8 @@
setStringProperty(component, PAGINATOR_ACTCOL_STYLE_ATTR, _paginatorActiveColumnStyle);
setBooleanProperty(component, RENDER_FACETS_IF_SINGLE_PAGE_ATTR, _renderFacetsIfSinglePage);
+ setBooleanProperty(component, JSFAttr.IMMEDIATE_ATTR, _immediate);
+
setStringProperty(component, UserRoleAware.ENABLED_ON_USER_ROLE_ATTR, _enabledOnUserRole);
setStringProperty(component, UserRoleAware.VISIBLE_ON_USER_ROLE_ATTR, _visibleOnUserRole);
}
@@ -276,6 +282,11 @@
public void setRenderFacetsIfSinglePage(String renderFacetsIfSinglePage)
{
_renderFacetsIfSinglePage = renderFacetsIfSinglePage;
+ }
+
+ public void setImmediate(String immediate)
+ {
+ _immediate = immediate;
}
// userrole attributes
Added: myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/datascroller/ScrollerActionEvent.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/datascroller/ScrollerActionEvent.java?rev=209483&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/datascroller/ScrollerActionEvent.java (added)
+++ myfaces/tomahawk/trunk/src/java/org/apache/myfaces/custom/datascroller/ScrollerActionEvent.java Wed Jul 6 10:34:11 2005
@@ -0,0 +1,59 @@
+package org.apache.myfaces.custom.datascroller;
+
+import javax.faces.component.UIComponent;
+import javax.faces.event.ActionEvent;
+import javax.faces.event.PhaseId;
+
+/**
+ * @author MBroekelmann
+ *
+ */
+public class ScrollerActionEvent extends ActionEvent
+{
+ private static final long serialVersionUID = -5692343289423906802L;
+
+ private final String mScrollerfacet;
+
+ private final int mPageIndex;
+
+ /**
+ * @param component
+ * @param scrollerfacet
+ */
+ public ScrollerActionEvent(UIComponent component, String scrollerfacet)
+ {
+ super(component);
+ mScrollerfacet = scrollerfacet;
+ mPageIndex = -1;
+ }
+
+ /**
+ *
+ */
+ public ScrollerActionEvent(UIComponent component, int pageIndex)
+ {
+ super(component);
+ if (pageIndex < 0)
+ {
+ throw new IllegalArgumentException("wrong pageindex");
+ }
+ mPageIndex = pageIndex;
+ mScrollerfacet = null;
+ }
+
+ /**
+ * @return Returns the scrollerfacet.
+ */
+ public String getScrollerfacet()
+ {
+ return mScrollerfacet;
+ }
+
+ /**
+ * @return
+ */
+ public int getPageIndex()
+ {
+ return mPageIndex;
+ }
+}
Modified: myfaces/tomahawk/trunk/tld/myfaces_ext.tld
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/tld/myfaces_ext.tld?rev=209483&r1=209482&r2=209483&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/tld/myfaces_ext.tld (original)
+++ myfaces/tomahawk/trunk/tld/myfaces_ext.tld Wed Jul 6 10:34:11 2005
@@ -1088,6 +1088,13 @@
Default is true.
</description>
</attribute>
+ <attribute>
+ <name>immediate</name>
+ <required>false</required>
+ <rtexprvalue>false</rtexprvalue>
+ <type>java.lang.String</type>
+ <description>True means, that the default ActionListener should be executed immediately (i.e. during Apply Request Values phase of the request processing lifecycle), rather than waiting until the Invoke Application phase.</description>
+ </attribute>
</tag>
<!-- inputDate -->