Author: nbelaevski
Date: 2008-03-19 14:10:39 -0400 (Wed, 19 Mar 2008)
New Revision: 6974
Removed:
trunk/ui/datascroller/src/main/resources/org/richfaces/renderkit/html/scripts/
Modified:
trunk/ui/datascroller/src/main/config/component/datascroller.xml
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-2233
Modified: trunk/ui/datascroller/src/main/config/component/datascroller.xml
===================================================================
--- trunk/ui/datascroller/src/main/config/component/datascroller.xml 2008-03-19 18:10:23
UTC (rev 6973)
+++ trunk/ui/datascroller/src/main/config/component/datascroller.xml 2008-03-19 18:10:39
UTC (rev 6974)
@@ -263,6 +263,11 @@
<classname>java.lang.String</classname>
<description>Name of variable in request scope containing number of
pages</description>
</property>
+
+ <property>
+ <name>onpagechange</name>
+ <classname>java.lang.String</classname>
+ </property>
</component>
&listeners;
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-19
18:10:23 UTC (rev 6973)
+++
trunk/ui/datascroller/src/main/java/org/richfaces/renderkit/html/DataScrollerRenderer.java 2008-03-19
18:10:39 UTC (rev 6974)
@@ -35,7 +35,7 @@
import org.ajax4jsf.javascript.JSFunction;
import org.ajax4jsf.javascript.JSFunctionDefinition;
-import org.ajax4jsf.javascript.JSReference;
+import org.ajax4jsf.javascript.JSLiteral;
import org.ajax4jsf.renderkit.AjaxRendererUtils;
import org.ajax4jsf.renderkit.HeaderResourcesRendererBase;
import org.richfaces.component.UIDatascroller;
@@ -224,7 +224,7 @@
}
public Object getOnClick(String string) {
- return "RichFaces.Datascroller.switchToPage(this, event, '" + string +
"');";
+ return "Event.fire(this, 'rich:datascroller:onscroll', {'page':
'" + string + "'});";
}
public void renderPages(FacesContext context, UIComponent component, int pageIndex,
int count)
@@ -275,8 +275,7 @@
}
public String getSubmitFunction(FacesContext context, UIComponent component) {
-
- JSFunctionDefinition definition = new JSFunctionDefinition("event",
"value");
+ JSFunctionDefinition definition = new JSFunctionDefinition("event");
JSFunction function = AjaxRendererUtils.buildAjaxFunction(component,
context);
@@ -289,13 +288,28 @@
parameters.putAll(params);
}
- parameters.put(component.getClientId(context), new
JSReference("value"));
+ parameters.put(component.getClientId(context), new
JSLiteral("event.memo.page"));
function.addParameter(eventOptions);
StringBuffer buffer = new StringBuffer();
function.appendScript(buffer);
buffer.append("; return false;");
- definition.addToBody(buffer.toString());
+
+ String onPageChange = (String) component.getAttributes().get("onpagechange");
+ if (onPageChange != null && onPageChange.length() != 0) {
+ JSFunctionDefinition onPageChangeDef = new JSFunctionDefinition("event");
+ onPageChangeDef.addToBody(onPageChange);
+ onPageChangeDef.addToBody("; return true;");
+
+ definition.addToBody("if (");
+ definition.addToBody(onPageChangeDef.toScript());
+ definition.addToBody("(event)) {");
+ definition.addToBody(buffer.toString());
+ definition.addToBody("}");
+ } else {
+ definition.addToBody(buffer.toString());
+ }
+
return definition.toScript();
}
Modified: trunk/ui/datascroller/src/main/templates/org/richfaces/htmlDatascroller.jspx
===================================================================
---
trunk/ui/datascroller/src/main/templates/org/richfaces/htmlDatascroller.jspx 2008-03-19
18:10:23 UTC (rev 6973)
+++
trunk/ui/datascroller/src/main/templates/org/richfaces/htmlDatascroller.jspx 2008-03-19
18:10:39 UTC (rev 6974)
@@ -13,8 +13,7 @@
<h:scripts>
new org.ajax4jsf.javascript.PrototypeScript(),
- new org.ajax4jsf.javascript.AjaxScript(),
- /org/richfaces/renderkit/html/scripts/datascroller.js
+ new org.ajax4jsf.javascript.AjaxScript()
</h:scripts>
<f:clientid var="clientId"/>
@@ -351,7 +350,7 @@
]]>
</jsp:scriptlet>
<script type="text/javascript">
- RichFaces.Datascroller.initialize('#{clientId}',
#{this:getSubmitFunction(context,component)});
+ Event.observe('#{clientId}', 'rich:datascroller:onscroll',
#{this:getSubmitFunction(context,component)});
</script>
</div>
</f:root>
\ No newline at end of file