[richfaces-svn-commits] JBoss Rich Faces SVN: r2414 - in trunk/framework/impl/src/main: javascript/ajaxjsf and 1 other directory.
richfaces-svn-commits at lists.jboss.org
richfaces-svn-commits at lists.jboss.org
Wed Aug 22 15:59:04 EDT 2007
Author: dbiatenia
Date: 2007-08-22 15:59:04 -0400 (Wed, 22 Aug 2007)
New Revision: 2414
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxRendererUtils.java
trunk/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js
Log:
new attribute 'beforeupdate' added, js-function will be invoked before updating DOM-tree on the page
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxRendererUtils.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxRendererUtils.java 2007-08-22 19:47:53 UTC (rev 2413)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxRendererUtils.java 2007-08-22 19:59:04 UTC (rev 2414)
@@ -77,10 +77,17 @@
public static final String STATUS_ATTR_NAME = "status";
/**
- * Attribute for keep JavaScript funtion name for call after complete
+ * Attribute for keep JavaScript function name for call after complete
* request.
*/
public static final String ONCOMPLETE_ATTR_NAME = "oncomplete";
+
+ /**
+ * Attribute for keep JavaScript function name for call before updating
+ * DOM tree.
+ */
+ public static final String BEFOREUPDATE_ATTR_NAME = "beforeupdate";
+
/**
* Attribute to keep
@@ -292,6 +299,19 @@
options.put("oncomplete", function);
}
+
+ String beforeupdate = getAjaxBeforeUpdate(uiComponent);
+ if (null != beforeupdate) {
+ JSFunctionDefinition function = new JSFunctionDefinition();
+ function.addParameter("request");
+ function.addParameter("event");
+ function.addParameter("data");
+ function.addToBody(beforeupdate);
+
+ options.put("beforeupdate", function);
+ }
+
+
String status = getAjaxStatus(uiComponent);
if (null != status) {
options.put("status", status);
@@ -561,6 +581,22 @@
}
/**
+ * Get function name for call before update DOM.
+ *
+ * @param component
+ * for wich calculate function name
+ * @return name of JavaScript function or <code>null</code>
+ */
+ public static String getAjaxBeforeUpdate(UIComponent component) {
+ if (component instanceof AjaxComponent) {
+ return ((AjaxComponent) component).getBeforeUpdate();
+
+ }
+ return (String) component.getAttributes().get(ONCOMPLETE_ATTR_NAME);
+ }
+
+
+ /**
* Calculate, must be component render only given areas, or all sended from
* server.
*
Modified: trunk/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js
===================================================================
--- trunk/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js 2007-08-22 19:47:53 UTC (rev 2413)
+++ trunk/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js 2007-08-22 19:59:04 UTC (rev 2414)
@@ -672,6 +672,13 @@
}
} else {
if(req.getParserStatus() == Sarissa.PARSED_OK){
+
+ // perform beforeupdate if exists
+ if(options.beforeupdate){
+ LOG.debug( "Call request beforeupdate function before replacing elemements" );
+ options.beforeupdate(req, req.domEvt, req.getJSON('_ajax:data'));
+ }
+
var idsFromResponse = req.getResponseHeader("Ajax-Update-Ids");
// 3 strategy for replace :
// if setted affected parameters - replace its
More information about the richfaces-svn-commits
mailing list