You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by aw...@apache.org on 2007/08/22 07:29:39 UTC
svn commit: r568425 - in /myfaces/trinidad/trunk/trinidad: src/site/site.xml
src/site/xdoc/devguide/ppr.xml src/site/xdoc/release-notes.xml
trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Page.js
Author: awiner
Date: Tue Aug 21 22:29:38 2007
New Revision: 568425
URL: http://svn.apache.org/viewvc?rev=568425&view=rev
Log:
TRINIDAD-129: AJAX hook for detecting DOM replacement
- Add addDomReplaceListener() hook and doc it
Modified:
myfaces/trinidad/trunk/trinidad/src/site/site.xml
myfaces/trinidad/trunk/trinidad/src/site/xdoc/devguide/ppr.xml
myfaces/trinidad/trunk/trinidad/src/site/xdoc/release-notes.xml
myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Page.js
Modified: myfaces/trinidad/trunk/trinidad/src/site/site.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad/src/site/site.xml?rev=568425&r1=568424&r2=568425&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad/src/site/site.xml (original)
+++ myfaces/trinidad/trunk/trinidad/src/site/site.xml Tue Aug 21 22:29:38 2007
@@ -29,8 +29,7 @@
<menu name="">
<item name="Download" href="download.html"/>
- <item name="Overview" href="release.html"/>
- <item name="Release Notes" href="release.html#Release Notes" />
+ <item name="Release Notes" href="release-notes.html" />
<item name="Javadoc" href="trinidad-api/apidocs/index.html" />
<item name="Tag Documentation" href="trinidad-api/tagdoc.html" />
<item name="Developer Guide" href="devguide/index.html" />
Modified: myfaces/trinidad/trunk/trinidad/src/site/xdoc/devguide/ppr.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad/src/site/xdoc/devguide/ppr.xml?rev=568425&r1=568424&r2=568425&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad/src/site/xdoc/devguide/ppr.xml (original)
+++ myfaces/trinidad/trunk/trinidad/src/site/xdoc/devguide/ppr.xml Tue Aug 21 22:29:38 2007
@@ -441,17 +441,33 @@
TrRequestQueue.STATE_READY or TrRequestQueue.STATE_BUSY, depending
on the current state of the request queue. The statusIndicator
component uses exactly this mechanism to know when to start
-and stop spinning its indicator.
+and stop spinning its indicator. You can optionally pass a
+second parameter to addStateChangeListener() for the "this"
+you want active when your callback is notified.
+</p>
+<p>
+Trinidad also lets you get notified when DOM is replaced
+after an AJAX response by adding a "DOM replace listener"
+on the page:
+<source>
+ function myCallback(oldDom, newDom) { ... }
+
+ TrPage.getInstance().addDomReplaceListener(myCallback);
+</source>
+The callback is passed two parameters: the old DOM element
+and the new DOM element that is replacing it. This callback
+is invoked after the replacement has happened.
+As with addStateChangeListener(), a second argument can be
+passed if you need a "this" to be active when your callback
+is notified.
</p>
</subsection>
</section>
<section name="Coming Features">
<p>
-The following features are planned enhancements, all high priority:
+The following features are planned enhancements:
<ul>
-<li>Notification when a DOM tree is being replaced by PPR
-(<a href="http://issues.apache.org/jira/browse/TRINIDAD-129">TRINIDAD-129</a>)</li>
<li>Optimized postback lifecycle (at least in JSF 1.2)</li>
<li>Support for explicitly requesting PPR of component from client</li>
</ul>
Modified: myfaces/trinidad/trunk/trinidad/src/site/xdoc/release-notes.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad/src/site/xdoc/release-notes.xml?rev=568425&r1=568424&r2=568425&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad/src/site/xdoc/release-notes.xml (original)
+++ myfaces/trinidad/trunk/trinidad/src/site/xdoc/release-notes.xml Tue Aug 21 22:29:38 2007
@@ -24,7 +24,7 @@
</properties>
<body>
- <section name="Apache MyFaces Trinidad 1.0.2 Release Notes">
+ <section name="Apache MyFaces Trinidad 1.0.3 Release Notes">
<p>
<ul>
<li>
@@ -41,40 +41,19 @@
</section>
<section name="Overview">
- <p>This is the first release of Apache MyFaces Trinidad since
-leaving the incubator. The highlight of this release is greatly
-improved client-side validation, now using inline DHTML instead of
-Javascript alerts, as provided by Danny Robinson. Many bugs
-have been fixed. See below for the full list.
+ <p>
</p>
</section>
<section name="Release Notes">
<subsection name="Features">
<ul>
-<li>Client-side validation no longer shows Javascript alerts. Instead,
-error messages are shown inline on the components. This can
-be overridden (to use alerts or disable altogether) using a
-new <client-validation> element in trinidad-config.xml.
-Thanks to Danny Robinson for this feature.
-</li>
-
-<li>A new "autoSubmit" attribute on table and treeTable will send
-PPR submissions to the server any time a row is selected.</li>
-
-<li>"autoSubmit" now works inside of a subform.</li>
-
-<li>.css skinning files can now be edited live without rebooting the server.</li>
-
-<li>The labelAndAccessKey and textAndAccessKey attribute are supported in Facelets</li>
</ul>
</subsection>
<subsection name="Changes from previous release">
<ul>
- <li>The skin selector names for tr:messages have been slightly modified for consistency, and added flexibility.
- Refer to the <a href="skin-selectors.html">Skinning Guide</a> for more information</li>
</ul>
</subsection>
@@ -86,11 +65,18 @@
<subsection name="Improvements">
<ul>
+<li>Partial-page rendering should now be much more efficient, as
+many portions of the page that are not being rerendered can be
+skipped entirely.
+</li>
</ul>
</subsection>
<subsection name="New Features">
<ul>
+<li>A new addDomReplaceListener() method on the page Javascript
+object lets a developer receive notification when DOM is
+replaced by PPR.</li>
</ul>
</subsection>
Modified: myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Page.js
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Page.js?rev=568425&r1=568424&r2=568425&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Page.js (original)
+++ myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Page.js Tue Aug 21 22:29:38 2007
@@ -337,6 +337,20 @@
{
// replace the target node with the new source node
targetNode.parentNode.replaceChild(sourceNode, targetNode);
+ // Call all the DOM replace listeners
+ var listeners = this._domReplaceListeners;
+ if (listeners)
+ {
+ for (var i = 0; i < listeners.length; i+=2)
+ {
+ var currListener = listeners[i];
+ var currInstance = listeners[i+1];
+ if (currInstance != null)
+ currListener.call(currInstance, targetNode, sourceNode);
+ else
+ currListener(targetNode, sourceNode);
+ }
+ }
}
// TODO: handle nodes that don't have ID, but do take the focus?
@@ -553,6 +567,57 @@
return loadedLibraries;
}
+/**
+ * Adds a listener for DOM replacement notification.
+ * @param {function} listener listener function to add
+ * @param {object} instance to pass as "this" when calling function (optional)
+ */
+TrPage.prototype.addDomReplaceListener = function(listener, instance)
+{
+ var domReplaceListeners = this._domReplaceListeners;
+ if (!domReplaceListeners)
+ {
+ domReplaceListeners = new Array();
+ this._domReplaceListeners = domReplaceListeners;
+ }
+
+ domReplaceListeners.push(listener);
+ domReplaceListeners.push(instance);
+}
+
+/**
+* Removes a listener for DOM replace notifications.
+* @param {function} listener listener function to remove
+* @param {object} instance to pass as this when calling function
+*/
+TrPage.prototype.removeDomReplaceListener = function(listener, instance)
+{
+ // remove the listener/instance combination
+ var domReplaceListeners = this._domReplaceListeners;
+ var length = domReplaceListeners.length;
+
+ for (var i = 0; i < length; i++)
+ {
+ var currListener = domReplaceListeners[i];
+ i++;
+
+ if (currListener == listener)
+ {
+ var currInstance = domReplaceListeners[i];
+ if (currInstance === instance)
+ {
+ domReplaceListeners.splice(i - 1, 2);
+ break;
+ }
+ }
+ }
+
+ // remove array, if empty
+ if (domReplaceListeners.length == 0)
+ {
+ this._domReplaceListeners = null;
+ }
+}
/**
* Adds the styleClassMap entries to the existing internal