Author: nbelaevski
Date: 2009-04-20 18:48:43 -0400 (Mon, 20 Apr 2009)
New Revision: 13712
Added:
trunk/ui/datascroller/src/main/resources/org/richfaces/renderkit/html/scripts/
trunk/ui/datascroller/src/main/resources/org/richfaces/renderkit/html/scripts/datascroller.js
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/templates/org/richfaces/htmlDatascroller.jspx
Log:
https://jira.jboss.org/jira/browse/RF-6879
Modified: trunk/samples/datascroller-sample/src/main/java/org/richfaces/TestBean.java
===================================================================
--- trunk/samples/datascroller-sample/src/main/java/org/richfaces/TestBean.java 2009-04-20
18:57:20 UTC (rev 13711)
+++ trunk/samples/datascroller-sample/src/main/java/org/richfaces/TestBean.java 2009-04-20
22:48:43 UTC (rev 13712)
@@ -36,6 +36,9 @@
private ArrayList data4;
private ArrayList data5;
private ArrayList data6;
+
+ private ArrayList jsAPIScrollerData;
+
public boolean renderIfSinglePage;
public int rows;
public int maxpage;
@@ -85,6 +88,10 @@
data6.add(new Entry(null, i));
}
+ jsAPIScrollerData = new ArrayList();
+ for (int i = 0; i < 50; i++) {
+ jsAPIScrollerData.add(i);
+ }
}
@@ -234,4 +241,8 @@
}
}
}
+
+ public ArrayList getJsAPIScrollerData() {
+ return jsAPIScrollerData;
+ }
}
\ 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 2009-04-20 18:57:20
UTC (rev 13711)
+++ trunk/samples/datascroller-sample/src/main/webapp/pages/index.jsp 2009-04-20 22:48:43
UTC (rev 13712)
@@ -97,6 +97,27 @@
</h:form>
+
+ <h:form id="form">
+ Datascroller controlled via JS API:
+
+ <h:dataTable id="jsAPIDt" rows="5" border="1"
value="#{testBean.jsAPIScrollerData}" var="data">
+ <h:column>
+ <h:outputText value="#{data}" />
+ </h:column>
+ </h:dataTable>
+
+ <ds:datascroller fastStep="2" for="jsAPIDt"
id="jsAPIDs"/>
+
+ <h:panelGrid columns="1">
+ <h:outputLink onclick="$('form:jsAPIDs').component.first();
return false;">first</h:outputLink>
+ <h:outputLink onclick="$('form:jsAPIDs').component.previous();
return false;">previous</h:outputLink>
+ <h:outputLink
onclick="$('form:jsAPIDs').component.switchToPage(2); return
false;">switchToPage(2)</h:outputLink>
+ <h:outputLink onclick="$('form:jsAPIDs').component.next();
return false;">next</h:outputLink>
+ <h:outputLink onclick="$('form:jsAPIDs').component.last();
return false;">last</h:outputLink>
+ </h:panelGrid>
+
+ </h:form>
</f:view>
</body>
</html>
Added:
trunk/ui/datascroller/src/main/resources/org/richfaces/renderkit/html/scripts/datascroller.js
===================================================================
---
trunk/ui/datascroller/src/main/resources/org/richfaces/renderkit/html/scripts/datascroller.js
(rev 0)
+++
trunk/ui/datascroller/src/main/resources/org/richfaces/renderkit/html/scripts/datascroller.js 2009-04-20
22:48:43 UTC (rev 13712)
@@ -0,0 +1,43 @@
+if (!window.Richfaces) {
+ window.Richfaces = {};
+}
+
+Richfaces.DatascrollerScrollEvent = "rich:datascroller:onscroll";
+
+Richfaces.Datascroller = Class.create({
+ initialize: function(clientId, submitFunction) {
+ this.element = $(clientId);
+ this.element.component = this;
+
+ this["rich:destructor"] = "destroy";
+
+ Event.observe(this.element, Richfaces.DatascrollerScrollEvent, submitFunction);
+ },
+
+ destroy: function() {
+ this.element.component = undefined;
+ this.element = undefined;
+ },
+
+ switchToPage: function(page) {
+ if (typeof page != 'undefined' && page != null) {
+ Event.fire(this.element, Richfaces.DatascrollerScrollEvent, {'page': page});
+ }
+ },
+
+ next: function() {
+ this.switchToPage("next");
+ },
+
+ previous: function() {
+ this.switchToPage("previous");
+ },
+
+ first: function() {
+ this.switchToPage("first");
+ },
+
+ last: function() {
+ this.switchToPage("last");
+ }
+});
\ No newline at end of file
Modified: trunk/ui/datascroller/src/main/templates/org/richfaces/htmlDatascroller.jspx
===================================================================
---
trunk/ui/datascroller/src/main/templates/org/richfaces/htmlDatascroller.jspx 2009-04-20
18:57:20 UTC (rev 13711)
+++
trunk/ui/datascroller/src/main/templates/org/richfaces/htmlDatascroller.jspx 2009-04-20
22:48:43 UTC (rev 13712)
@@ -13,7 +13,8 @@
<h:scripts>
new org.ajax4jsf.javascript.PrototypeScript(),
- new org.ajax4jsf.javascript.AjaxScript()
+ new org.ajax4jsf.javascript.AjaxScript(),
+ /org/richfaces/renderkit/html/scripts/datascroller.js
</h:scripts>
<f:clientid var="clientId"/>
@@ -357,7 +358,7 @@
]]>
</jsp:scriptlet>
<script type="text/javascript">
- Event.observe('#{clientId}', 'rich:datascroller:onscroll',
#{this:getSubmitFunction(context,component)});
+ new Richfaces.Datascroller('#{clientId}',
#{this:getSubmitFunction(context,component)});
</script>
</div>
</f:root>