Author: nbelaevski
Date: 2008-03-09 17:37:04 -0400 (Sun, 09 Mar 2008)
New Revision: 6631
Added:
trunk/ui/datascroller/src/main/config/faces/
trunk/ui/datascroller/src/main/config/faces/faces-config.xml
trunk/ui/datascroller/src/main/java/org/richfaces/component/DataScrollerPhaseListener.java
trunk/ui/datascroller/src/main/java/org/richfaces/component/DataScrollerViewPhaseListener.java
Modified:
trunk/samples/datascroller-sample/src/main/java/org/richfaces/TestBean.java
trunk/samples/datascroller-sample/src/main/webapp/pages/index.jsp
trunk/ui/datascroller/src/main/config/component/datascroller.xml
trunk/ui/datascroller/src/main/java/org/richfaces/component/UIDatascroller.java
trunk/ui/datascroller/src/main/java/org/richfaces/renderkit/html/DataScrollerRenderer.java
trunk/ui/datascroller/src/main/templates/org/richfaces/htmlDatascroller.jspx
Log:
http://jira.jboss.com/jira/browse/RF-1133
Modified: trunk/samples/datascroller-sample/src/main/java/org/richfaces/TestBean.java
===================================================================
--- trunk/samples/datascroller-sample/src/main/java/org/richfaces/TestBean.java 2008-03-09
18:08:21 UTC (rev 6630)
+++ trunk/samples/datascroller-sample/src/main/java/org/richfaces/TestBean.java 2008-03-09
21:37:04 UTC (rev 6631)
@@ -220,4 +220,18 @@
public void setEventCount(int eventCount) {
this.eventCount = eventCount;
}
-}
+
+ public void addEntries() {
+ for (int i = 0; i < 5; i++) {
+ data.add(new Entry(null, data.size()));
+ }
+ }
+
+ public void removeEntries() {
+ if (data.size() >= 5) {
+ for (int i = 0; i < 5; i++) {
+ data.remove(data.size() - 1);
+ }
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/samples/datascroller-sample/src/main/webapp/pages/index.jsp
===================================================================
--- trunk/samples/datascroller-sample/src/main/webapp/pages/index.jsp 2008-03-09 18:08:21
UTC (rev 6630)
+++ trunk/samples/datascroller-sample/src/main/webapp/pages/index.jsp 2008-03-09 21:37:04
UTC (rev 6631)
@@ -87,9 +87,13 @@
</h:panelGrid>
<h:commandLink value="apply" />
+ <br />
+ <h:commandLink value="Add Entries"
action="#{testBean.addEntries}" />
+ <br />
+ <h:commandLink value="Remove Entries"
action="#{testBean.removeEntries}" />
+ <br />
-
</h:form>
</f:view>
</body>
Modified: trunk/ui/datascroller/src/main/config/component/datascroller.xml
===================================================================
--- trunk/ui/datascroller/src/main/config/component/datascroller.xml 2008-03-09 18:08:21
UTC (rev 6630)
+++ trunk/ui/datascroller/src/main/config/component/datascroller.xml 2008-03-09 21:37:04
UTC (rev 6631)
@@ -75,7 +75,7 @@
<classname>boolean</classname>
<description>If "false", this component is not
rendered</description>
</property>
- <property>
+ <property el="false">
<name>for</name>
<classname>java.lang.String</classname>
<description>ID of the table component whose data is scrollled
@@ -245,7 +245,6 @@
<name>actionExpression</name>
</property>
-
<property hidden="true">
<name>firstRow</name>
</property>
Added: trunk/ui/datascroller/src/main/config/faces/faces-config.xml
===================================================================
--- trunk/ui/datascroller/src/main/config/faces/faces-config.xml
(rev 0)
+++ trunk/ui/datascroller/src/main/config/faces/faces-config.xml 2008-03-09 21:37:04 UTC
(rev 6631)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<faces-config
xmlns="http://java.sun.com/xml/ns/javaee"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"
+ version="1.2">
+
+ <lifecycle>
+ <phase-listener>
+ org.richfaces.component.DataScrollerPhaseListener
+ </phase-listener>
+ </lifecycle>
+</faces-config>
Added:
trunk/ui/datascroller/src/main/java/org/richfaces/component/DataScrollerPhaseListener.java
===================================================================
---
trunk/ui/datascroller/src/main/java/org/richfaces/component/DataScrollerPhaseListener.java
(rev 0)
+++
trunk/ui/datascroller/src/main/java/org/richfaces/component/DataScrollerPhaseListener.java 2008-03-09
21:37:04 UTC (rev 6631)
@@ -0,0 +1,64 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.component;
+
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
+import javax.faces.event.PhaseEvent;
+import javax.faces.event.PhaseId;
+import javax.faces.event.PhaseListener;
+
+/**
+ * Created 08.03.2008
+ * @author Nick Belaevski
+ * @since 3.2
+ */
+
+public class DataScrollerPhaseListener implements PhaseListener {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -3614288642745891577L;
+
+ private static final String ATTRIBUTE_NAME = DataScrollerPhaseListener.class.getName();
+
+ private PhaseListener listener = new DataScrollerViewPhaseListener();
+
+ public void afterPhase(PhaseEvent event) {
+ }
+
+ public void beforePhase(PhaseEvent event) {
+ FacesContext facesContext = event.getFacesContext();
+ UIViewRoot viewRoot = facesContext.getViewRoot();
+ if (viewRoot != null && !Boolean.TRUE.equals(
+ viewRoot.getAttributes().get(ATTRIBUTE_NAME))) {
+ viewRoot.addPhaseListener(listener);
+ viewRoot.getAttributes().put(ATTRIBUTE_NAME, Boolean.TRUE);
+ }
+ }
+
+ public PhaseId getPhaseId() {
+ return PhaseId.RENDER_RESPONSE;
+ }
+
+}
Added:
trunk/ui/datascroller/src/main/java/org/richfaces/component/DataScrollerViewPhaseListener.java
===================================================================
---
trunk/ui/datascroller/src/main/java/org/richfaces/component/DataScrollerViewPhaseListener.java
(rev 0)
+++
trunk/ui/datascroller/src/main/java/org/richfaces/component/DataScrollerViewPhaseListener.java 2008-03-09
21:37:04 UTC (rev 6631)
@@ -0,0 +1,82 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.component;
+
+import java.util.Iterator;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIData;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
+import javax.faces.event.PhaseEvent;
+import javax.faces.event.PhaseId;
+import javax.faces.event.PhaseListener;
+
+
+/**
+ * Created 08.03.2008
+ * @author Nick Belaevski
+ * @since 3.2
+ */
+
+public class DataScrollerViewPhaseListener implements PhaseListener {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -3614288642745891577L;
+
+ public void afterPhase(PhaseEvent event) {
+ }
+
+ private void updateScrollers(UIComponent component) {
+ if (component.isRendered()) {
+ if (component instanceof UIDatascroller) {
+ UIDatascroller datascroller = (UIDatascroller) component;
+ datascroller.updateFirstRow();
+
+ UIData dataTable = datascroller.getDataTable();
+ if (dataTable.isRendered()) {
+ dataTable.setFirst(datascroller.getFirstRow());
+ }
+ }
+
+ Iterator<UIComponent> children = component.getFacetsAndChildren();
+ while(children.hasNext()) {
+ updateScrollers(children.next());
+ }
+ }
+ }
+
+ public void beforePhase(PhaseEvent event) {
+ FacesContext facesContext = event.getFacesContext();
+ UIViewRoot viewRoot = facesContext.getViewRoot();
+ if (viewRoot != null) {
+ updateScrollers(viewRoot);
+ }
+ }
+
+ public PhaseId getPhaseId() {
+ return PhaseId.RENDER_RESPONSE;
+ }
+
+}
Modified: trunk/ui/datascroller/src/main/java/org/richfaces/component/UIDatascroller.java
===================================================================
---
trunk/ui/datascroller/src/main/java/org/richfaces/component/UIDatascroller.java 2008-03-09
18:08:21 UTC (rev 6630)
+++
trunk/ui/datascroller/src/main/java/org/richfaces/component/UIDatascroller.java 2008-03-09
21:37:04 UTC (rev 6631)
@@ -21,11 +21,15 @@
package org.richfaces.component;
+import javax.el.ELException;
import javax.el.MethodExpression;
+import javax.el.ValueExpression;
import javax.faces.FacesException;
+import javax.faces.application.FacesMessage;
import javax.faces.component.ActionSource;
import javax.faces.component.UIComponent;
import javax.faces.component.UIData;
+import javax.faces.component.UIInput;
import javax.faces.context.FacesContext;
import javax.faces.event.AbortProcessingException;
import javax.faces.event.FacesEvent;
@@ -33,6 +37,7 @@
import org.ajax4jsf.component.AjaxActionComponent;
import org.ajax4jsf.renderkit.AjaxRendererUtils;
import org.ajax4jsf.renderkit.RendererUtils;
+import org.richfaces.component.util.MessageUtil;
import org.richfaces.event.DataScrollerEvent;
import org.richfaces.event.DataScrollerListener;
import org.richfaces.event.DataScrollerSource;
@@ -43,8 +48,10 @@
//create event listener & event classes to define PageSwitchEvent
//public abstract class UIDatascroller extends UIComponentBase implements
DataScrollerSource{
public abstract class UIDatascroller extends AjaxActionComponent
- implements DataScrollerSource, ActionSource {
+implements DataScrollerSource, ActionSource {
+ private Integer firstRow;
+
public static final String COMPONENT_TYPE = "org.richfaces.Datascroller";
public static final String COMPONENT_FAMILY =
"org.richfaces.Datascroller";
@@ -68,13 +75,13 @@
public static final String NEXT_DISABLED_FACET_NAME = "next_disabled";
public static final String PREVIOUS_DISABLED_FACET_NAME
- = "previous_disabled";
+ = "previous_disabled";
public static final String FAST_FORWARD_DISABLED_FACET_NAME
- = "fastforward_disabled";
+ = "fastforward_disabled";
public static final String FAST_REWIND_DISABLED_FACET_NAME
- = "fastrewind_disabled";
+ = "fastrewind_disabled";
public void addScrollerListener(DataScrollerListener listener) {
addFacesListener(listener);
@@ -93,14 +100,14 @@
super.broadcast(event);
if (event instanceof DataScrollerEvent) {
DataScrollerEvent dataScrollerEvent = (DataScrollerEvent) event;
- setPage(dataScrollerEvent.getNewScrolVal());
+ setPage(dataScrollerEvent.getNewScrolVal(), true);
FacesContext context = FacesContext.getCurrentInstance();
AjaxRendererUtils.addRegionByName(context, this, this.getId());
AjaxRendererUtils.addRegionByName(context, this, this.getFor());
setupReRender(context);
-
+
MethodExpression scrollerListener = getScrollerListener();
if (scrollerListener != null) {
scrollerListener.invoke(context.getELContext(), new Object[]{event});
@@ -206,7 +213,7 @@
}
if (forComp == null) {
throw new IllegalArgumentException("could not find dataTable with id
'"
- + forAttribute + "'");
+ + forAttribute + "'");
} else if (!(forComp instanceof UIData)) {
throw new IllegalArgumentException(
"component with id '" + forAttribute
@@ -222,20 +229,24 @@
int rows = getRows(uiData);
if (0 == rows) {
throw new FacesException("Missing 'rows' attribute on component
'"
- + uiData.getId() + "'");
+ + uiData.getId() + "'");
}
+ int firstRow = getFirstRow();
+
int pageIndex;
if (rows > 0) {
//xxxx nick -> alex - suppose this.getFirst() would be better here
- pageIndex = getFirstRow(uiData) / rows + 1;
+ pageIndex = firstRow / rows + 1;
} else {
//TODO nick -> nick - is it valid if under 0?
pageIndex = 0;
}
- if (getFirstRow(uiData) % rows > 0) {
+
+ if (firstRow % rows > 0) {
pageIndex++;
}
+
return pageIndex;
}
@@ -249,6 +260,69 @@
return getPageIndex(uiData);
}
+ private void setFirstRowValue(int row) {
+ FacesContext context = getFacesContext();
+ ValueExpression ve = getValueExpression("firstRow");
+ if (ve != null) {
+ try {
+ ve.setValue(context.getELContext(), row);
+ firstRow = null;
+ } catch (ELException e) {
+ String messageStr = e.getMessage();
+ Throwable result = e.getCause();
+ while (null != result &&
+ result.getClass().isAssignableFrom(ELException.class)) {
+ messageStr = result.getMessage();
+ result = result.getCause();
+ }
+ FacesMessage message;
+ if (null == messageStr) {
+ message =
+ MessageUtil.getMessage(context, UIInput.UPDATE_MESSAGE_ID,
+ new Object[] { MessageUtil.getLabel(
+ context, this) });
+ } else {
+ message = new FacesMessage(FacesMessage.SEVERITY_ERROR,
+ messageStr,
+ messageStr);
+ }
+ context.getExternalContext().log(message.getSummary(), result);
+ context.addMessage(getClientId(context), message);
+ context.renderResponse();
+ } catch (IllegalArgumentException e) {
+ FacesMessage message =
+ MessageUtil.getMessage(context, UIInput.UPDATE_MESSAGE_ID,
+ new Object[] { MessageUtil.getLabel(
+ context, this) });
+ context.getExternalContext().log(message.getSummary(), e);
+ context.addMessage(getClientId(context), message);
+ context.renderResponse();
+ } catch (Exception e) {
+ FacesMessage message =
+ MessageUtil.getMessage(context, UIInput.UPDATE_MESSAGE_ID,
+ new Object[] { MessageUtil.getLabel(
+ context, this) });
+ context.getExternalContext().log(message.getSummary(), e);
+ context.addMessage(getClientId(context), message);
+ context.renderResponse();
+ }
+ } else {
+ setFirstRow(row);
+ }
+ //TODO
+ }
+
+ private int getFirstRowForLastPage(int rowCount, int rows) {
+ int delta = rowCount % rows;
+ int newFirst = delta > 0 && delta < rows ? rowCount - delta :
rowCount
+ - rows;
+ if (newFirst >= 0) {
+ return newFirst;
+ } else {
+ return 0;
+ }
+ }
+
/**
* Sets the page number according to the parameter recived from the
* commandLink
@@ -257,92 +331,82 @@
* "fastforward", "fastrewind"
*/
public void setPage(String facetName) {
+ setPage(facetName, false);
+ }
- UIData dataTable = getDataTable();
-
+ public void setPage(String facetName, boolean updateModel) {
// check if facet is selected
if (FIRST_FACET_NAME.equals(facetName)) {
- setFirstRow(0);
- dataTable.setFirst(0);
- } else if (PREVIOUS_FACET_NAME.equals(facetName)) {
- int previous = dataTable.getFirst() - getRows(dataTable);
- if (previous >= 0) {
- setFirstRow(previous);
- }
- } else if (NEXT_FACET_NAME.equals(facetName)) {
+ setFirstRowValue(0);
+ } else {
+ UIData dataTable = getDataTable();
+
+ int first = getFirstRow();
int rows = getRows(dataTable);
- int next = dataTable.getFirst() + rows;
- if (next < getRowCount(dataTable)) {
- setFirstRow(next);
- }
- //if (rows>0){
- // if (((next+rows)/rows)>getMaxPages()){
- // next=getMaxPages()*rows-rows;;
- // }
- //}
- } else if (FAST_FORWARD_FACET_NAME.equals(facetName)) {
- int fastStep = getFastStep();
- int rows = getRows(dataTable);
- if (fastStep <= 0) {
- fastStep = 1;
- }
- int next = dataTable.getFirst() + rows * fastStep;
- int rowcount = getRowCount(dataTable);
- if (next >= rowcount) {
- next = (rowcount - 1) - ((rowcount - 1) % rows);
- }
- //if (rows>0){
- // if (((next+rows)/rows)>getMaxPages()){
- // next=getMaxPages()*rows-rows;;
- //}
- //}
- setFirstRow(next);
- } else if (FAST_REWIND_FACET_NAME.equals(facetName)) {
- int fastStep = getFastStep();
- if (fastStep <= 0) {
- fastStep = 1;
- }
- int previous = dataTable.getFirst() - getRows(dataTable) * fastStep;
- if (previous < 0) {
- previous = 0;
- }
- setFirstRow(previous);
- } else if (LAST_FACET_NAME.equals(facetName)) {
- int rowcount = getRowCount(dataTable);
- int rows = getRows(dataTable);
- int delta = rowcount % rows;
- int first = delta > 0 && delta < rows ? rowcount - delta :
rowcount
- - rows;
- if (first >= 0) {
+ int rowCount = getRowCount(dataTable);
+
+ if (PREVIOUS_FACET_NAME.equals(facetName)) {
+ int previous = first - rows;
+ if (previous >= 0) {
+ setFirstRowValue(previous);
+ }
+ } else if (NEXT_FACET_NAME.equals(facetName)) {
+ int next = first + rows;
+ if (next < rowCount) {
+ setFirstRowValue(next);
+ }
//if (rows>0){
- //if (((first+rows)/rows)>getMaxPages()){
- // first=getMaxPages()*rows-rows;
+ // if (((next+rows)/rows)>getMaxPages()){
+ // next=getMaxPages()*rows-rows;;
+ // }
//}
+ } else if (FAST_FORWARD_FACET_NAME.equals(facetName)) {
+ int fastStep = getFastStep();
+ if (fastStep <= 0) {
+ fastStep = 1;
+ }
+ int next = first + rows * fastStep;
+ if (next >= rowCount) {
+ next = (rowCount - 1) - ((rowCount - 1) % rows);
+ }
+ //if (rows>0){
+ // if (((next+rows)/rows)>getMaxPages()){
+ // next=getMaxPages()*rows-rows;;
//}
- setFirstRow(first);
- } else {
- setFirstRow(0);
+ //}
+ setFirstRowValue(next);
+ } else if (FAST_REWIND_FACET_NAME.equals(facetName)) {
+ int fastStep = getFastStep();
+ if (fastStep <= 0) {
+ fastStep = 1;
+ }
+ int previous = first - rows * fastStep;
+ if (previous < 0) {
+ previous = 0;
+ }
+ setFirstRowValue(previous);
+ } else if (LAST_FACET_NAME.equals(facetName)) {
+ setFirstRow(getFirstRowForLastPage(rowCount, rows));
}
- }
- // the paginator is selected
- else {
- int pageindex = Integer.parseInt(facetName);
- int pageCount = getPageCount(dataTable);
- if (pageindex > pageCount) {
- pageindex = pageCount;
- } else if (pageindex <= 0) {
- pageindex = 1;
+ // the paginator is selected
+ else {
+ int pageindex = Integer.parseInt(facetName);
+ int pageCount = getPageCount(rowCount, rows);
+ if (pageindex > pageCount) {
+ pageindex = pageCount;
+ } else if (pageindex <= 0) {
+ pageindex = 1;
+ }
+ setFirstRowValue(rows * (pageindex - 1));
}
- setFirstRow(getRows(dataTable) * (pageindex - 1));
+
}
}
- public int getPageCount(UIData data) {
- int rows = getRows(data);
+ public int getPageCount(int rowCount, int rows) {
int pageCount;
if (rows > 0) {
- int rowCount = getRowCount(data);
pageCount = rows <= 0 ? 1 : rowCount / rows;
if (rowCount % rows > 0) {
pageCount++;
@@ -357,6 +421,10 @@
return pageCount;
}
+ public int getPageCount(UIData data) {
+ return getPageCount(getRowCount(data), getRows(data));
+ }
+
/** @return the page count of the uidata */
public int getPageCount() {
return getPageCount(getDataTable());
@@ -417,15 +485,45 @@
return getFacet(PREVIOUS_FACET_NAME);
}
- public int getFirstRow(UIData data) {
- return data.getFirst();
+ public void updateFirstRow() {
+ UIData dataTable = getDataTable();
+ int rowCount = getRowCount(dataTable);
+ int firstRow = getFirstRow();
+
+ if (firstRow < 0) {
+ setFirstRow(0);
+ } else if (firstRow >= rowCount) {
+ setFirstRow(getFirstRowForLastPage(rowCount, getRows(dataTable)));
+ }
}
- public void setFirstRow(int rows) {
- getDataTable().setFirst(rows);
- //setControls();
+ public int getFirstRow() {
+ if (this.firstRow != null) {
+ return firstRow;
+ }
+
+ ValueExpression ve = getValueExpression("firstRow");
+ if (ve != null) {
+ try {
+ Integer firstRowObject = (Integer)
ve.getValue(getFacesContext().getELContext());
+
+ if (firstRowObject != null) {
+ return firstRowObject;
+ } else {
+ return 0;
+ }
+ } catch (ELException e) {
+ throw new FacesException(e);
+ }
+ } else {
+ return 0;
+ }
}
+ public void setFirstRow(int row) {
+ this.firstRow = row;
+ }
+
public String getFamily() {
return COMPONENT_FAMILY;
}
@@ -468,4 +566,20 @@
}
}
}
+
+ public Object saveState(FacesContext context) {
+ return new Object[] {
+ super.saveState(context),
+ firstRow,
+ };
+
+ }
+
+ public void restoreState(FacesContext context, Object object) {
+ Object[] state = (Object[]) object;
+
+ super.restoreState(context, state[0]);
+ firstRow = (Integer) state[1];
+ }
+
}
Modified:
trunk/ui/datascroller/src/main/java/org/richfaces/renderkit/html/DataScrollerRenderer.java
===================================================================
---
trunk/ui/datascroller/src/main/java/org/richfaces/renderkit/html/DataScrollerRenderer.java 2008-03-09
18:08:21 UTC (rev 6630)
+++
trunk/ui/datascroller/src/main/java/org/richfaces/renderkit/html/DataScrollerRenderer.java 2008-03-09
21:37:04 UTC (rev 6631)
@@ -34,7 +34,6 @@
import javax.faces.context.ResponseWriter;
import javax.faces.event.PhaseId;
-import org.ajax4jsf.Messages;
import org.ajax4jsf.javascript.JSFunction;
import org.ajax4jsf.renderkit.AjaxRendererUtils;
import org.ajax4jsf.renderkit.HeaderResourcesRendererBase;
@@ -48,15 +47,9 @@
return UIDatascroller.class;
}
- protected boolean isRenderedOnSinglePage(UIDatascroller scroller, UIData dataTable)
{
- return (scroller.getPageCount(dataTable) != 1 ||
scroller.isRenderIfSinglePage());
- }
-
public void doDecode(FacesContext context, UIComponent component) {
-
UIDatascroller scroller = (UIDatascroller) component;
-
- if (isRenderedOnSinglePage(scroller, scroller.getDataTable())) {
+ if (scroller.getPageCount() > 1) {
String param = (String) getParamMap(context).get(
component.getClientId(context));
if (param != null) {
Modified: trunk/ui/datascroller/src/main/templates/org/richfaces/htmlDatascroller.jspx
===================================================================
---
trunk/ui/datascroller/src/main/templates/org/richfaces/htmlDatascroller.jspx 2008-03-09
18:08:21 UTC (rev 6630)
+++
trunk/ui/datascroller/src/main/templates/org/richfaces/htmlDatascroller.jspx 2008-03-09
21:37:04 UTC (rev 6631)
@@ -26,9 +26,17 @@
<jsp:scriptlet>
<![CDATA[
javax.faces.component.UIData dataTable = component.getDataTable();
+
+ int maxPages = component.getMaxPages();
+ if (maxPages <= 1) {
+ maxPages = 1;
+ }
+
+ int pageCount = component.getPageCount(dataTable);
+
boolean singlePageRender = true;
- if (!isRenderedOnSinglePage(component, dataTable)) {
+ if (pageCount == 1 && !component.isRenderIfSinglePage()) {
singlePageRenderStyle = "; display: none";
singlePageRender = false;
}