Author: alexsmirnov
Date: 2007-05-23 19:46:35 -0400 (Wed, 23 May 2007)
New Revision: 213
Modified:
trunk/framework/src/main/config/component/push.xml
trunk/framework/src/main/java/org/ajax4jsf/renderkit/html/AjaxPollRenderer.java
trunk/framework/src/main/java/org/ajax4jsf/renderkit/html/AjaxSupportRenderer.java
trunk/framework/src/main/javascript/ajaxjsf/JSFAJAX.js
Log:
Fix AJSF-42 issue ( process onsubmit function before send poll request )
Modified: trunk/framework/src/main/config/component/push.xml
===================================================================
--- trunk/framework/src/main/config/component/push.xml 2007-05-23 22:53:03 UTC (rev 212)
+++ trunk/framework/src/main/config/component/push.xml 2007-05-23 23:46:35 UTC (rev 213)
@@ -62,7 +62,8 @@
<name>actionExpression</name>
<classname>java.lang.String</classname>
<description>The action method binding expression.</description>
- </property>
+ </property>
+ <!--
<property>
<name>onsubmit</name>
<classname>java.lang.String</classname>
@@ -70,7 +71,8 @@
JavaScript code for call before submission of ajax
event
</description>
- </property>
+ </property>
+ -->
<property>
<name>interval</name>
<classname>int</classname>
Modified: trunk/framework/src/main/java/org/ajax4jsf/renderkit/html/AjaxPollRenderer.java
===================================================================
---
trunk/framework/src/main/java/org/ajax4jsf/renderkit/html/AjaxPollRenderer.java 2007-05-23
22:53:03 UTC (rev 212)
+++
trunk/framework/src/main/java/org/ajax4jsf/renderkit/html/AjaxPollRenderer.java 2007-05-23
23:46:35 UTC (rev 213)
@@ -32,6 +32,7 @@
import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
import org.ajax4jsf.framework.renderer.RendererUtils.HTML;
import org.ajax4jsf.framework.util.javascript.JSFunction;
+import org.ajax4jsf.framework.util.javascript.JSFunctionDefinition;
import org.ajax4jsf.renderkit.AjaxCommandRendererBase;
/**
@@ -62,6 +63,13 @@
Integer interval = new Integer(poll.getInterval());
options.put("pollinterval", interval);
options.put("pollId", component.getClientId(context));
+ Object onsubmit = component.getAttributes().get("onsubmit");
+ if (null != onsubmit) {
+ JSFunctionDefinition onsubmitFunction = new JSFunctionDefinition();
+ onsubmitFunction.addToBody(onsubmit);
+ options.put("onsubmit", onsubmitFunction);
+ }
+
// options.put("timeout", interval);
function.addParameter(options);
function.appendScript(script);
Modified:
trunk/framework/src/main/java/org/ajax4jsf/renderkit/html/AjaxSupportRenderer.java
===================================================================
---
trunk/framework/src/main/java/org/ajax4jsf/renderkit/html/AjaxSupportRenderer.java 2007-05-23
22:53:03 UTC (rev 212)
+++
trunk/framework/src/main/java/org/ajax4jsf/renderkit/html/AjaxSupportRenderer.java 2007-05-23
23:46:35 UTC (rev 213)
@@ -21,9 +21,6 @@
package org.ajax4jsf.renderkit.html;
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.framework.renderer.compiler.PreparedTemplate;
import org.ajax4jsf.renderkit.AjaxCommandRendererBase;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -57,8 +54,4 @@
return org.ajax4jsf.ajax.UIAjaxSupport.class;
}
- protected PreparedTemplate getTemplate(FacesContext context) {
- return null;
- }
-
}
Modified: trunk/framework/src/main/javascript/ajaxjsf/JSFAJAX.js
===================================================================
--- trunk/framework/src/main/javascript/ajaxjsf/JSFAJAX.js 2007-05-23 22:53:03 UTC (rev
212)
+++ trunk/framework/src/main/javascript/ajaxjsf/JSFAJAX.js 2007-05-23 23:46:35 UTC (rev
213)
@@ -401,7 +401,12 @@
};
A4J.AJAX._pollers[options.pollId] = window.setTimeout(function(){
A4J.AJAX._pollers[options.pollId]=undefined;
- A4J.AJAX.SubmitRequest(containerId,form,null,options);
+ if((typeof(options.onsubmit) == 'function') && (!options.onsubmit())){
+ // Onsubmit disable current poll, start next interval.
+ A4J.AJAX.Poll(containerId,form,options);
+ } else {
+ A4J.AJAX.SubmitRequest(containerId,form,null,options);
+ }
},options.pollinterval);
};