Author: abelevich
Date: 2010-09-01 06:57:22 -0400 (Wed, 01 Sep 2010)
New Revision: 19065
Modified:
trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractDataScroller.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/ControlsState.java
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/DataScrollerBaseRenderer.java
trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/datascroller.js
trunk/ui/iteration/ui/src/main/templates/datascroller.template.xml
Log:
https://jira.jboss.org/browse/RF-8703, refactor template, fix fastStep
Modified:
trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractDataScroller.java
===================================================================
---
trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractDataScroller.java 2010-09-01
10:26:09 UTC (rev 19064)
+++
trunk/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractDataScroller.java 2010-09-01
10:57:22 UTC (rev 19065)
@@ -68,6 +68,10 @@
public static final String LAST_FACET_NAME = "last";
+ public static final String NEXT_FACET_NAME = "next";
+
+ public static final String PREVIOUS_FACET_NAME = "previous";
+
public static final String FAST_FORWARD_FACET_NAME = "fastforward";
public static final String FAST_REWIND_FACET_NAME = "fastrewind";
@@ -82,16 +86,9 @@
private Integer page;
- protected enum PropertyKeys {
- boundaryControls, fastControls, fastStep, forComponent, inactiveStyle,
selectStyle, inactiveStyleClass, selectStyleClass, scrollerListener, lastPageMode,
maxPages, pageIndexVar, pagesVar, renderIfSinglePage, style, styleClass, stepControls
- }
-
@Attribute
public abstract String getLastPageMode();
- @Attribute(defaultValue="0")
- public abstract int getFastStep();
-
@Attribute
public abstract String getForComponent();
@@ -104,6 +101,12 @@
@Attribute(defaultValue="show")
public abstract String getFastControls();
+ @Attribute(defaultValue="show")
+ public abstract String getStepControls();
+
+ @Attribute(defaultValue="1")
+ public abstract int getFastStep();
+
public void addScrollerListener(DataScrollerListener listener) {
addFacesListener(listener);
}
@@ -163,10 +166,6 @@
return DataScrollerUtils.findDataTable(this);
}
- private int getFastStepOrDefault() {
- return (Integer) getStateHelper().eval(PropertyKeys.fastStep, 1);
- }
-
public int getPageForFacet(String facetName) {
if (facetName == null) {
throw new NullPointerException();
@@ -179,10 +178,14 @@
newPage = 1;
} else if (LAST_FACET_NAME.equals(facetName)) {
newPage = pageCount > 0 ? pageCount : 1;
+ } else if (PREVIOUS_FACET_NAME.equals(facetName)) {
+ newPage = getPage() - 1;
+ } else if (NEXT_FACET_NAME.equals(facetName)) {
+ newPage = getPage() + 1;
} else if (FAST_FORWARD_FACET_NAME.equals(facetName)) {
- newPage = getPage() + getFastStepOrDefault();
+ newPage = getPage() + getFastStep();
} else if (FAST_REWIND_FACET_NAME.equals(facetName)) {
- newPage = getPage() - getFastStepOrDefault();
+ newPage = getPage() - getFastStep();
} else {
try {
newPage = Integer.parseInt(facetName.toString());
@@ -234,7 +237,15 @@
public UIComponent getLast() {
return getFacetByKey(LAST_FACET_NAME);
}
+
+ public UIComponent getNext() {
+ return getFacetByKey(NEXT_FACET_NAME);
+ }
+ public UIComponent getPrevious() {
+ return getFacetByKey(PREVIOUS_FACET_NAME);
+ }
+
public UIComponent getFastForward() {
return getFacetByKey(FAST_FORWARD_FACET_NAME);
}
Modified: trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/ControlsState.java
===================================================================
---
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/ControlsState.java 2010-09-01
10:26:09 UTC (rev 19064)
+++
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/ControlsState.java 2010-09-01
10:57:22 UTC (rev 19065)
@@ -35,7 +35,15 @@
private boolean lastRendered = true;
private boolean lastEnabled = true;
+
+ private boolean nextRendered = true;
+
+ private boolean nextEnabled = true;
+ private boolean previousRendered = true;
+
+ private boolean previousEnabled = true;
+
private boolean fastRewindRendered = true;
private boolean fastRewindEnabled = true;
@@ -109,8 +117,40 @@
public void setFastForwardEnabled(boolean fastForwardEnabled) {
this.fastForwardEnabled = fastForwardEnabled;
}
+
+ public boolean getNextRendered() {
+ return nextRendered;
+ }
- public boolean isControlsSeparatorRendered() {
+ public void setNextRendered(boolean nextRendered) {
+ this.nextRendered = nextRendered;
+ }
+
+ public boolean getNextEnabled() {
+ return nextEnabled;
+ }
+
+ public void setNextEnabled(boolean nextEnabled) {
+ this.nextEnabled = nextEnabled;
+ }
+
+ public boolean getPreviousRendered() {
+ return previousRendered;
+ }
+
+ public void setPreviousRendered(boolean previousRendered) {
+ this.previousRendered = previousRendered;
+ }
+
+ public boolean getPreviousEnabled() {
+ return previousEnabled;
+ }
+
+ public void setPreviousEnabled(boolean previousEnabled) {
+ this.previousEnabled = previousEnabled;
+ }
+
+ public boolean getControlsSeparatorRendered() {
return controlsSeparatorRendered;
}
Modified:
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/DataScrollerBaseRenderer.java
===================================================================
---
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/DataScrollerBaseRenderer.java 2010-09-01
10:26:09 UTC (rev 19064)
+++
trunk/ui/iteration/ui/src/main/java/org/richfaces/renderkit/DataScrollerBaseRenderer.java 2010-09-01
10:57:22 UTC (rev 19065)
@@ -87,10 +87,10 @@
boolean useFirst = true;
boolean useLast = true;
-
+
boolean useBackFast = true;
boolean useForwFast = true;
-
+
ControlsState controlsState = new ControlsState();
if (pageIndex <= minPageIdx) {
@@ -110,6 +110,7 @@
}
String boundaryControls = (String)
component.getAttributes().get("boundaryControls");
+ String stepControls = (String)
component.getAttributes().get("stepControls");
String fastControls = (String)
component.getAttributes().get("fastControls");
boolean isAuto = "auto".equals(boundaryControls);
@@ -125,7 +126,21 @@
controlsState.setFirstRendered(false);
controlsState.setLastRendered(false);
}
+
+ isAuto = "auto".equals(stepControls);
+ if (isAuto || "show".equals(stepControls)) {
+ if (isAuto) {
+ controlsState.setPreviousRendered(useFirst);
+ controlsState.setNextRendered(useLast);
+ }
+ controlsState.setPreviousEnabled(useFirst);
+ controlsState.setNextEnabled(useLast);
+ } else {
+ controlsState.setPreviousRendered(false);
+ controlsState.setNextRendered(false);
+ }
+
isAuto = "auto".equals(fastControls);
if (isAuto || "show".equals(fastControls)) {
if (isAuto) {
@@ -253,9 +268,17 @@
left.put(clientId + "_ds_fr",
AbstractDataScroller.FAST_REWIND_FACET_NAME);
}
+ if (controlsState.getPreviousRendered() &&
controlsState.getPreviousEnabled()) {
+ left.put(clientId + "_ds_prev",
AbstractDataScroller.PREVIOUS_FACET_NAME);
+ }
+
if (controlsState.getFastForwardRendered() &&
controlsState.getFastForwardEnabled()) {
right.put(clientId + "_ds_ff",
AbstractDataScroller.FAST_FORWARD_FACET_NAME);
}
+
+ if (controlsState.getNextRendered() && controlsState.getNextEnabled()) {
+ right.put(clientId + "_ds_next",
AbstractDataScroller.NEXT_FACET_NAME);
+ }
if (controlsState.getLastRendered() && controlsState.getLastEnabled()) {
right.put(clientId + "_ds_l",
AbstractDataScroller.LAST_FACET_NAME);
@@ -306,6 +329,10 @@
definition.addToBody(buffer);
return definition;
}
+
+ public void encodeFacet(FacesContext context, UIComponent component) throws
IOException {
+ component.encodeAll(context);
+ }
public boolean getRendersChildren() {
return true;
Modified:
trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/datascroller.js
===================================================================
---
trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/datascroller.js 2010-09-01
10:26:09 UTC (rev 19064)
+++
trunk/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/datascroller.js 2010-09-01
10:57:22 UTC (rev 19065)
@@ -132,13 +132,21 @@
RichFaces.Event.fireById(this.id, this.getScrollEventName(), {'page' :
page});
}
},
-
+
+ fastForward: function() {
+ this.switchToPage("fastforward");
+ },
+
+ fastRewind: function() {
+ this.switchToPage("fastrewind");
+ },
+
next: function() {
- this.switchToPage("fastforward");
+ this.switchToPage("next");
},
previous: function() {
- this.switchToPage("fastrewind");
+ this.switchToPage("previous");
},
first: function() {
Modified: trunk/ui/iteration/ui/src/main/templates/datascroller.template.xml
===================================================================
--- trunk/ui/iteration/ui/src/main/templates/datascroller.template.xml 2010-09-01 10:26:09
UTC (rev 19064)
+++ trunk/ui/iteration/ui/src/main/templates/datascroller.template.xml 2010-09-01 10:57:22
UTC (rev 19065)
@@ -1,8 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
+<!--
+JBoss, Home of Professional Open Source
+Copyright ${year}, Red Hat, Inc. and individual contributors
+by the @authors tag. See the copyright.txt in the distribution for a
+full listing of individual contributors.
+
+This is free software; you can redistribute it and/or modify it
+under the terms of the GNU Lesser General Public License as
+published by the Free Software Foundation; either version 2.1 of
+the License, or (at your option) any later version.
+
+
+This software 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 software; if not, write to the Free
+Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+-->
+
<cdk:root
xmlns="http://jboss.org/schema/richfaces/cdk/xhtml-el"
xmlns:cdk="http://jboss.org/schema/richfaces/cdk/core"
xmlns:c="http://jboss.org/schema/richfaces/cdk/jstl/core"
xmlns:cc="http://jboss.org/schema/richfaces/cdk/jsf/composite"
-
xmlns:javaee="http://java.sun.com/xml/ns/javaee">
+
xmlns:javaee="http://java.sun.com/xml/ns/javaee"
xmlns:xi="http://www.w3.org/2001/XInclude">
<cc:interface>
<cdk:class>org.richfaces.renderkit.html.DataScrollerRenderer</cdk:class>
@@ -12,81 +36,79 @@
</cc:interface>
<cc:implementation>
-
<cdk:object type="org.richfaces.renderkit.ControlsState"
name="controlsState"
value="#{getControlsState(facesContext,component)}" />
<span id="#{clientId}" class="rf-ds"><!-- Now decor is
disabled !!! -->
+
<c:if test="#{controlsState.firstRendered}">
- <c:choose>
- <c:when test="#{controlsState.firstEnabled}">
- <a id="#{clientId}_ds_f" class="rf-ds-btn rf-ds-l"
href="javascript:void(0)" >
- ««
- </a>
- </c:when>
- <c:otherwise>
- <span id="#{clientId}_ds_f" class="rf-ds-btn rf-ds-l
rf-ds-dis">
- ««
- </span>
- </c:otherwise>
- </c:choose>
+ <cdk:object type="boolean" name="isEnabled"
value="#{controlsState.firstEnabled}"/>
+ <cdk:object type="UIComponent" name="facet"
value="#{component.getFacet('first')}"/>
+ <cdk:object type="String" name="enabledStyles"
value="rf-ds-btn rf-ds-l"/>
+ <cdk:object type="String" name="disabledStyles"
value="rf-ds-btn rf-ds-l rf-ds-dis"/>
+ <cdk:object type="String" name="id"
value="#{clientId}_ds_f"/>
+ <cdk:object type="String" name="defaultText"
value="««««"/>
+ <xi:include xpointer="xpointer(/*)"
href="buttons.template.include" />
</c:if>
-
<c:if test="#{controlsState.fastRewindRendered}">
- <c:choose>
- <c:when test="#{controlsState.fastRewindEnabled}">
- <a id="#{clientId}_ds_fr" class="rf-ds-btn rf-ds-l"
href="javascript:void(0)">
- «
- </a>
- </c:when>
- <c:otherwise>
- <span id="#{clientId}_ds_fr" class="rf-ds-btn rf-ds-l
rf-ds-dis">
- «
- </span>
- </c:otherwise>
- </c:choose>
+ <cdk:object type="boolean" name="isEnabled"
value="#{controlsState.fastRewindEnabled}"/>
+ <cdk:object type="UIComponent" name="facet"
value="#{component.getFacet('fastRewind')}"/>
+ <cdk:object type="java.lang.String" name="enabledStyles"
value="rf-ds-btn rf-ds-l"/>
+ <cdk:object type="java.lang.String" name="disabledStyles"
value="rf-ds-btn rf-ds-l rf-ds-dis"/>
+ <cdk:object type="java.lang.String" name="id"
value="#{clientId}_ds_fr"/>
+ <cdk:object type="java.lang.String" name="defaultText"
value="««"/>
+ <xi:include xpointer="xpointer(/*)"
href="buttons.template.include" />
</c:if>
+
+ <c:if test="#{controlsState.previousRendered}">
+ <cdk:object name="isEnabled"
value="#{controlsState.previousEnabled}"/>
+ <cdk:object name="facet"
value="#{component.getFacet('previous')}"/>
+ <cdk:object type="java.lang.String" name="enabledStyles"
value="rf-ds-btn rf-ds-l"/>
+ <cdk:object type="java.lang.String" name="disabledStyles"
value="rf-ds-btn rf-ds-l rf-ds-dis"/>
+ <cdk:object name="id" value="#{clientId}_ds_prev"/>
+ <cdk:object name="defaultText" value="«"/>
+ <xi:include xpointer="xpointer(/*)"
href="buttons.template.include" />
+ </c:if>
- <cdk:object type="java.util.Map" name="digitals"
value="#{renderPager(responseWriter, facesContext, component)}" />
-
- <c:if test="#{controlsState.fastForwardRendered}">
- <c:choose>
- <c:when test="#{controlsState.fastForwardEnabled}">
- <a id="#{clientId}_ds_ff" class="rf-ds-btn rf-ds-r"
href="javascript:void(0);">
- »
- </a>
- </c:when>
- <c:otherwise>
- <span id="#{clientId}_ds_ff" class="rf-ds-btn rf-ds-r
rf-ds-dis">
- »
- </span>
- </c:otherwise>
- </c:choose>
+ <cdk:object type="java.util.Map" name="digitals"
value="#{renderPager(responseWriter, facesContext, component)}" />
+
+ <c:if test="#{controlsState.nextRendered}">
+ <cdk:object name="isEnabled"
value="#{controlsState.nextEnabled}"/>
+ <cdk:object name="facet"
value="#{component.getFacet('next')}"/>
+ <cdk:object type="java.lang.String" name="enabledStyles"
value="rf-ds-btn rf-ds-r"/>
+ <cdk:object type="java.lang.String" name="disabledStyles"
value="rf-ds-btn rf-ds-r rf-ds-dis"/>
+ <cdk:object name="id" value="#{clientId}_ds_next"/>
+ <cdk:object name="defaultText" value="»"/>
+ <xi:include xpointer="xpointer(/*)"
href="buttons.template.include" />
</c:if>
+ <c:if test="#{controlsState.fastForwardRendered}">
+ <cdk:object name="isEnabled"
value="#{controlsState.fastForwardEnabled}"/>
+ <cdk:object name="facet"
value="#{component.getFacet('fastForward')}"/>
+ <cdk:object type="java.lang.String" name="enabledStyles"
value="rf-ds-btn rf-ds-r"/>
+ <cdk:object type="java.lang.String" name="disabledStyles"
value="rf-ds-btn rf-ds-r rf-ds-dis"/>
+ <cdk:object name="id" value="#{clientId}_ds_ff"/>
+ <cdk:object name="defaultText"
value="»»"/>
+ <xi:include xpointer="xpointer(/*)"
href="buttons.template.include" />
+ </c:if>
+
<c:if test="#{controlsState.lastRendered}">
- <c:choose>
- <c:when test="#{controlsState.lastEnabled}">
- <a id="#{clientId}_ds_l" class="rf-ds-btn rf-ds-r"
href="javascript:void(0);">
- »»
- </a>
- </c:when>
- <c:otherwise>
- <span id="#{clientId}_ds_l" class="rf-ds-btn rf-ds-r
rf-ds-dis">
- »»
- </span>
- </c:otherwise>
- </c:choose>
- </c:if>
-
+ <cdk:object name="isEnabled"
value="#{controlsState.lastEnabled}"/>
+ <cdk:object name="facet"
value="#{component.getFacet('last')}"/>
+ <cdk:object type="java.lang.String" name="enabledStyles"
value="rf-ds-btn rf-ds-r"/>
+ <cdk:object type="java.lang.String" name="disabledStyles"
value="rf-ds-btn rf-ds-r rf-ds-dis"/>
+ <cdk:object name="id" value="#{clientId}_ds_l"/>
+ <cdk:object name="defaultText"
value="»»»»"/>
+ <xi:include xpointer="xpointer(/*)"
href="buttons.template.include" />
+ </c:if>
+
<cdk:object type="java.util.Map" name="buttons"
value="#{getControls(facesContext, component, controlsState)}" />
<script type="text/javascript">
<cdk:call expression="buildScript(responseWriter, facesContext, component,
buttons, digitals);"/>
</script>
</span>
-
-
+
</cc:implementation>
</cdk:root>
\ No newline at end of file