FAQ
Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/xhr/XMLRequest.js
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/xhr/XMLRequest.js?rev=936035&r1=936034&r2=936035&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/xhr/XMLRequest.js (original)
+++ myfaces/trinidad/trunk/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/xhr/XMLRequest.js Tue Apr 20 19:19:36 2010
@@ -34,7 +34,6 @@ function TrXMLRequest()
this.xmlhttp = TrXMLRequest._createXmlHttpRequest();
}

-
/**
* Request state constants. See getCompletionState()
**/
@@ -206,4 +205,124 @@ TrXMLRequest.prototype.cleanup =function
delete this.xmlhttp;
}

+/**
+ * Wrapper for the JSF AJAX callback data that provides the same
+ * interface as TrXMLRequest to maintain a compatible API to ease
+ * the support of both the legacy code as well as code to integrate
+ * with JSF 2 AJAX
+ */
+function TrXMLJsfAjaxRequest(
+ event,
+ params)
+{
+ this.isSynchronous = false;
+ this.callback = null;
+ this._event = event;
+ this._params = params || new Object();
+ this._status = 0;
+ this._state = TrXMLRequest.UNINITIALIZED;
+}
+TrXMLJsfAjaxRequest.prototype.setCallback = function(value)
+{
+ this.callback = value;
+}
+TrXMLJsfAjaxRequest.prototype.getCompletionState = function()
+{
+ return this._state;
+}
+TrXMLJsfAjaxRequest.prototype.getStatus = function()
+{
+ return this._status;
+}
+TrXMLJsfAjaxRequest.prototype.getResponseXML = function()
+{
+ return this._responseXML;
+}
+TrXMLJsfAjaxRequest.prototype.getResponseText = function()
+{
+ return this._responseText;
+}
+TrXMLJsfAjaxRequest.prototype.cleanup = function()
+{
+ this.callback = null;
+}
+TrXMLJsfAjaxRequest.prototype._ajaxCallback = function(
+ data
+ )
+{
+ switch (data.status)
+ {
+ case "begin":
+ this._state = TrXMLRequest.LOADING;
+ break;
+ case "complete":
+ this._state = TrXMLRequest.LOADED;
+ break;
+ case "success":
+ default:
+ this._state = TrXMLRequest.COMPLETED;
+ break;
+ }
+
+ if (data.status != "begin")
+ {
+ this._status = data.responseCode;
+ this._responseXML = data.responseXML;
+ this._responseText = data.responseText;
+ }
+
+ if (this.callback)
+ {
+ this.callback(this);
+ }
+}
+TrXMLJsfAjaxRequest.prototype.__onerror = function(
+ data
+ )
+{
+ this._state = TrXMLRequest.COMPLETED;
+ this._status = data.responseCode;
+ this._responseXML = data.responseXML;
+ this._responseText = data.responseText;
+ if (this.callback)
+ {
+ this.callback(this);
+ }
+}
+TrXMLJsfAjaxRequest.prototype.send = function()
+{
+ var source = this._params.source ?
+ _getElementById(window.document, this._params.source) : null;
+
+ var ajaxCallback = TrUIUtils.createCallback(this, this._ajaxCallback);
+
+ var payload = {
+ "onevent": ajaxCallback,
+ "onerror": ajaxCallback,
+ "Tr-PPR-Message": true // Indicate that this a "legacy" PPR request sent over jsf.ajax
+ };
+
+ for (var p in this._params)
+ {
+ payload[p] = this._params[p];
+ }

+ jsf.ajax.request(
+ source,
+ this._event,
+ payload);
+
+ // No need for the event anymore, release the resource
+ delete this._event;
+}
+// No-op functions:
+TrXMLJsfAjaxRequest.prototype.setSynchronous =
+TrXMLJsfAjaxRequest.prototype.setRequestHeader = function() {}
+TrXMLJsfAjaxRequest.prototype.getAllResponseHeaders = function()
+{
+ return new Object();
+};
+TrXMLJsfAjaxRequest.prototype.getResponseHeader = function()
+{
+ return null;
+};
\ No newline at end of file

Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/xhr/XMLRequestEvent.js
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/xhr/XMLRequestEvent.js?rev=936035&r1=936034&r2=936035&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/xhr/XMLRequestEvent.js (original)
+++ myfaces/trinidad/trunk/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/xhr/XMLRequestEvent.js Tue Apr 20 19:19:36 2010
@@ -25,11 +25,15 @@
*/
function TrXMLRequestEvent(
status,
- request
+ request,
+ source,
+ formId
)
{
this._status = status;
this._request = request;
+ this._source = source;
+ this._formId = formId;
}

TrXMLRequestEvent.STATUS_QUEUED = 1;
@@ -37,11 +41,21 @@ TrXMLRequestEvent.STATUS_SEND_BEFORE = 2
TrXMLRequestEvent.STATUS_SEND_AFTER = 3;
TrXMLRequestEvent.STATUS_COMPLETE = 4;

+TrXMLRequestEvent.prototype.getFormId = function()
+{
+ return this._formId;
+}
+
TrXMLRequestEvent.prototype.getStatus = function()
{
return this._status;
}

+TrXMLRequestEvent.prototype.getSource = function()
+{
+ return this._source;
+}
+
/**
* Returns the response of the AJAX Request as an XML document
* NOTE: this method is valid only for TrXMLRequestEvent.STATUS_COMPLETE
@@ -147,4 +161,12 @@ TrXMLRequestEvent.prototype.isPprRespons
TrXMLRequestEvent.prototype.getResponseContentType = function()
{
this.getResponseHeader("Content-Type");
-}
\ No newline at end of file
+}
+
+/**
+ * Returns if the request was made by the built in JSF AJAX APIs
+ */
+TrXMLRequestEvent.prototype.isJsfAjaxRequest = function()
+{
+ return (this._request instanceof TrXMLJsfAjaxRequest);
+};
\ No newline at end of file

Search Discussions

  • Arobinson74 at Apr 20, 2010 at 7:20 pm
    Author: arobinson74
    Date: Tue Apr 20 19:19:36 2010
    New Revision: 936035

    URL: http://svn.apache.org/viewvc?rev=936035&view=rev
    Log:
    Merge the JSF2 AJAX branch onto the trunk

    Added:
    myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/components/editor.xhtml
    - copied unchanged from r936022, myfaces/trinidad/branches/jsf2_ajax.3/trinidad-examples/trinidad-demo/src/main/webapp/components/editor.xhtml
    myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/components/inputFile.xhtml
    - copied unchanged from r936022, myfaces/trinidad/branches/jsf2_ajax.3/trinidad-examples/trinidad-demo/src/main/webapp/components/inputFile.xhtml
    myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/demos/ajaxPPRDemos.xhtml
    - copied unchanged from r936022, myfaces/trinidad/branches/jsf2_ajax.3/trinidad-examples/trinidad-demo/src/main/webapp/demos/ajaxPPRDemos.xhtml
    myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/PartialViewContextFactoryImpl.java
    - copied unchanged from r936022, myfaces/trinidad/branches/jsf2_ajax.3/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/PartialViewContextFactoryImpl.java
    myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/PartialViewContextImpl.java
    - copied unchanged from r936022, myfaces/trinidad/branches/jsf2_ajax.3/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/PartialViewContextImpl.java
    Modified:
    myfaces/trinidad/trunk/ (props changed)
    myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/PartialDemoStatusBean.java
    myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/PartialDemoUtilBean.java
    myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/WEB-INF/trinidad-config.xml
    myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/WEB-INF/web.xml
    myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/components/inputFile.jspx
    myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/demos/clientBehaviorHolder.xhtml
    myfaces/trinidad/trunk/trinidad-impl/src/main/conf/META-INF/faces-config-base.xml
    myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/xmlHttp/XmlHttpConfigurator.java
    myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextImpl.java
    myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/CoreRenderKit.java
    myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/ppr/PPRResponseWriter.java
    myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/ppr/ScriptBufferingResponseWriter.java
    myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/BodyRenderer.java
    myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/CommandLinkRenderer.java
    myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/DocumentRenderer.java
    myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/FormRenderer.java
    myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/HeadRenderer.java
    myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/PartialPageUtils.java
    myfaces/trinidad/trunk/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Core.js
    myfaces/trinidad/trunk/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Page.js
    myfaces/trinidad/trunk/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/xhr/IFrameXMLRequestEvent.js
    myfaces/trinidad/trunk/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/xhr/RequestQueue.js
    myfaces/trinidad/trunk/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/xhr/XMLRequest.js
    myfaces/trinidad/trunk/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/xhr/XMLRequestEvent.js

    Propchange: myfaces/trinidad/trunk/
    ------------------------------------------------------------------------------
    --- svn:mergeinfo (original)
    +++ svn:mergeinfo Tue Apr 20 19:19:36 2010
    @@ -4,6 +4,7 @@
    /myfaces/trinidad/branches/TRINIDAD-1402:745675
    /myfaces/trinidad/branches/ar-1715:908782
    /myfaces/trinidad/branches/ar_clientBehaviors:881469-891464
    +/myfaces/trinidad/branches/jsf2_ajax.3:926625-936022
    /myfaces/trinidad/branches/jwaldman_StyleMap:754977-770778
    /myfaces/trinidad/branches/trinidad-1.2.x:923447,923460,929241
    /myfaces/trinidad/branches/trinidad-2.0.x:823098-895949

    Modified: myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/PartialDemoStatusBean.java
    URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/PartialDemoStatusBean.java?rev=936035&r1=936034&r2=936035&view=diff
    ==============================================================================
    --- myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/PartialDemoStatusBean.java (original)
    +++ myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/PartialDemoStatusBean.java Tue Apr 20 19:19:36 2010
    @@ -22,6 +22,9 @@ import java.text.SimpleDateFormat;

    import java.util.Date;

    +import org.apache.myfaces.trinidad.model.UploadedFile;
    +
    +
    public class PartialDemoStatusBean implements java.io.Serializable
    {
    public PartialDemoStatusBean()
    @@ -144,6 +147,24 @@ public class PartialDemoStatusBean imple
    _checkBoxUpdateCount++;
    }

    + public String getUploadFileState()
    + {
    + return this._uploadFileState;
    + }
    +
    + public void setUploadFile(UploadedFile file)
    + {
    + if (file == null)
    + {
    + this._uploadFileState = _DEFAULT_UPLOAD_FILE;
    + }
    + else
    + {
    + this._uploadFileState = String.format(
    + "Uploaded file %s (%d bytes)", file.getFilename(), file.getLength());
    + }
    + }
    +
    public void reset()
    {
    resetCheckBox();
    @@ -151,6 +172,7 @@ public class PartialDemoStatusBean imple
    _linkUpdate = _DEFAULT_LINK_UPDATE;
    _radioState = _DEFAULT_RADIO_STATE;
    _textValue = _DEFAULT_TEXT_VALUE;
    + _uploadFileState = _DEFAULT_UPLOAD_FILE;
    }

    private int _checkBoxUpdateCount;
    @@ -160,6 +182,7 @@ public class PartialDemoStatusBean imple
    private String _linkUpdate;
    private String _radioState;
    private String _textValue;
    + private String _uploadFileState;

    private static String _NOTHING = "nothing yet.";
    private static String _DEFAULT_CHECK_STATE = "updates this text.";
    @@ -170,4 +193,5 @@ public class PartialDemoStatusBean imple
    private static String _DEFAULT_RADIO_STATE = "no selection yet.";
    private static String _DEFAULT_TEXT_STATE = _NOTHING;
    private static String _DEFAULT_TEXT_VALUE = "Change this text";
    + private static String _DEFAULT_UPLOAD_FILE = "No file was uploaded";
    }

    Modified: myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/PartialDemoUtilBean.java
    URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/PartialDemoUtilBean.java?rev=936035&r1=936034&r2=936035&view=diff
    ==============================================================================
    --- myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/PartialDemoUtilBean.java (original)
    +++ myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/PartialDemoUtilBean.java Tue Apr 20 19:19:36 2010
    @@ -27,6 +27,8 @@ import javax.faces.event.ValueChangeEven

    import org.apache.myfaces.trinidad.component.UIXOutput;
    import org.apache.myfaces.trinidad.context.RequestContext;
    +import org.apache.myfaces.trinidad.model.UploadedFile;
    +

    public class PartialDemoUtilBean
    {
    @@ -121,6 +123,31 @@ public class PartialDemoUtilBean
    }
    }

    + public void setRenderInputFile(boolean renderInputFile)
    + {
    + this._renderInputFileTemp = renderInputFile;
    + }
    +
    + public boolean isRenderInputFile()
    + {
    + Boolean value = (Boolean)
    + FacesContext.getCurrentInstance().getViewRoot().getViewMap().get(
    + _RENDER_INPUT_FILE_KEY);
    + return value != null && value;
    + }
    +
    + public void fileUploaded(ValueChangeEvent event)
    + {
    + _status.setUploadFile((UploadedFile) event.getNewValue());
    + }
    +
    + public void updateRenderInputFileState(ActionEvent event)
    + {
    + FacesContext.getCurrentInstance().getViewRoot().getViewMap().put(
    + _RENDER_INPUT_FILE_KEY, _renderInputFileTemp);
    + _renderInputFileTemp = null;
    + }
    +
    private void _resetList()
    {
    _listUpdate.setValue("nothing yet.");
    @@ -135,4 +162,7 @@ public class PartialDemoUtilBean

    private PartialDemoStatusBean _status;
    private UIXOutput _listUpdate;
    + private Boolean _renderInputFileTemp;
    + private final static String _RENDER_INPUT_FILE_KEY = PartialDemoUtilBean.class.getName() +
    + ".renderInputFile";
    }

    Modified: myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/WEB-INF/trinidad-config.xml
    URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/WEB-INF/trinidad-config.xml?rev=936035&r1=936034&r2=936035&view=diff
    ==============================================================================
    --- myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/WEB-INF/trinidad-config.xml (original)
    +++ myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/WEB-INF/trinidad-config.xml Tue Apr 20 19:19:36 2010
    @@ -19,7 +19,7 @@

    -->
    <trinidad-config xmlns="http://myfaces.apache.org/trinidad/config">
    - <debug-output>true</debug-output>
    + <!--debug-output>true</debug-output-->
    <!-- Uncomment to switch back to ALERT style client-side validation,
    or set to DISABLED to disable it altogether
    <client-validation>ALERT</client-validation>

    Modified: myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/WEB-INF/web.xml
    URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/WEB-INF/web.xml?rev=936035&r1=936034&r2=936035&view=diff
    ==============================================================================
    --- myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/WEB-INF/web.xml (original)
    +++ myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/WEB-INF/web.xml Tue Apr 20 19:19:36 2010
    @@ -67,10 +67,10 @@

    <!-- Trinidad by default uses an optimized client-side state saving
    mechanism. To disable that, uncomment the following -->
    - <!--context-param>
    + <context-param>
    <param-name>org.apache.myfaces.trinidad.CLIENT_STATE_METHOD</param-name>
    - <param-value>all</param-value>
    - </context-param-->
    + <param-value>token</param-value>
    + </context-param>
    <!-- When token client-side state saving is enabled, MyFaces Trinidad can apply an additional
    optimization by caching an entire UIViewRoot tree with each token.
    (Note that this does not affect thread safety or session failover.)
    @@ -100,9 +100,8 @@

    <context-param>
    <param-name>javax.faces.FACELETS_VIEW_MAPPINGS</param-name>
    - <param-value>*.xhtml</param-value>
    <!-- to run facelets for jspx files comment the line above and uncomment line below-->
    - <!--param-value>*.xhtml;*.jspx</param-value-->
    + <param-value>*.xhtml</param-value>
    </context-param>

    <context-param>

    Modified: myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/components/inputFile.jspx
    URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/components/inputFile.jspx?rev=936035&r1=936034&r2=936035&view=diff
    ==============================================================================
    --- myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/components/inputFile.jspx (original)
    +++ myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/components/inputFile.jspx Tue Apr 20 19:19:36 2010
    @@ -30,7 +30,7 @@
    <f:facet name="separator">
    <tr:separator/>
    </f:facet>
    - <tr:panelGroupLayout layout="horizontal">
    + <tr:panelGroupLayout layout="horizontal" partialTriggers="cb1">
    <tr:commandLink immediate="true" text="Component Guide" action="guide"/>
    <tr:spacer width="10"/>
    <tr:goLink destination="http://myfaces.apache.org/trinidad/trinidad-api/tagdoc/tr_inputFile.html"

    Modified: myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/demos/clientBehaviorHolder.xhtml
    URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/demos/clientBehaviorHolder.xhtml?rev=936035&r1=936034&r2=936035&view=diff
    ==============================================================================
    --- myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/demos/clientBehaviorHolder.xhtml (original)
    +++ myfaces/trinidad/trunk/trinidad-examples/trinidad-demo/src/main/webapp/demos/clientBehaviorHolder.xhtml Tue Apr 20 19:19:36 2010
    @@ -69,7 +69,7 @@ function handleBlur(event)
    </tr:commandButton>
    <tr:commandButton id="cb2" text="Submit via JSF Ajax">
    <trd:invokeFunctionBehavior function="checkPrevent" />
    - <f:ajax render="it2" />
    + <f:ajax render="it2" execute="it1" />
    </tr:commandButton>
    </tr:panelFormLayout>
    </tr:panelHeader>

    Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/conf/META-INF/faces-config-base.xml
    URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/conf/META-INF/faces-config-base.xml?rev=936035&r1=936034&r2=936035&view=diff
    ==============================================================================
    --- myfaces/trinidad/trunk/trinidad-impl/src/main/conf/META-INF/faces-config-base.xml (original)
    +++ myfaces/trinidad/trunk/trinidad-impl/src/main/conf/META-INF/faces-config-base.xml Tue Apr 20 19:19:36 2010
    @@ -42,6 +42,9 @@
    <view-declaration-language-factory>
    org.apache.myfaces.trinidadinternal.application.ViewDeclarationLanguageFactoryImpl
    </view-declaration-language-factory>
    + <partial-view-context-factory>
    + org.apache.myfaces.trinidadinternal.context.PartialViewContextFactoryImpl
    + </partial-view-context-factory>
    </factory>

    <lifecycle>

    Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/xmlHttp/XmlHttpConfigurator.java
    URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/xmlHttp/XmlHttpConfigurator.java?rev=936035&r1=936034&r2=936035&view=diff
    ==============================================================================
    --- myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/xmlHttp/XmlHttpConfigurator.java (original)
    +++ myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/config/xmlHttp/XmlHttpConfigurator.java Tue Apr 20 19:19:36 2010
    @@ -90,12 +90,11 @@ public class XmlHttpConfigurator extends
    {
    XmlResponseWriter rw = new XmlResponseWriter(writer, "UTF-8");
    rw.startDocument();
    - // Add another PI indicating that this is a rich response
    - // FIXME: this code is duplicated in PPRResponseWriter - fix that
    - rw.write("<?Tr-XHR-Response-Type ?>\n");
    + rw.startElement("partial-response", null);
    rw.startElement("redirect", null);
    - rw.writeText(url, null);
    + rw.writeAttribute("url", url, null);
    rw.endElement("redirect");
    + rw.endElement("partial-response");
    rw.endDocument();
    rw.close();
    }
    @@ -115,13 +114,16 @@ public class XmlHttpConfigurator extends
    PrintWriter writer = response.getWriter();
    XmlResponseWriter rw = new XmlResponseWriter(writer, "UTF-8");
    rw.startDocument();
    - // Add another PI indicating that this is a rich response
    - // FIXME: this code is duplicated in PPRResponseWriter - fix that
    - rw.write("<?Tr-XHR-Response-Type ?>\n");
    + rw.startElement("partial-response", null);
    rw.startElement("error", null);
    - rw.writeAttribute("status", HttpServletResponse.SC_INTERNAL_SERVER_ERROR, null);
    + rw.startElement("error-name", null);
    + rw.writeText(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, null);
    + rw.endElement("error-name");
    + rw.startElement("error-message", null);
    rw.writeText(_getExceptionString(t) + _PLEASE_SEE_ERROR_LOG + error, null);
    + rw.endElement("error-message");
    rw.endElement("error");
    + rw.endElement("partial-response");
    rw.endDocument();
    rw.close();
    }

    Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextImpl.java
    URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextImpl.java?rev=936035&r1=936034&r2=936035&view=diff
    ==============================================================================
    --- myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextImpl.java (original)
    +++ myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextImpl.java Tue Apr 20 19:19:36 2010
    @@ -218,7 +218,7 @@ public class RequestContextImpl extends
    @Override
    public boolean isPartialRequest(FacesContext context)
    {
    - return CoreRenderKit.isPartialRequest(context.getExternalContext());
    + return context.getPartialViewContext().isAjaxRequest();
    }



    Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/CoreRenderKit.java
    URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/CoreRenderKit.java?rev=936035&r1=936034&r2=936035&view=diff
    ==============================================================================
    --- myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/CoreRenderKit.java (original)
    +++ myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/CoreRenderKit.java Tue Apr 20 19:19:36 2010
    @@ -143,27 +143,43 @@ public class CoreRenderKit extends Rende
    return "org.apache.myfaces.trinidad.core.desktop";
    }

    - static public boolean isAjaxRequest(ExternalContext ec)
    + static public boolean isLegacyAjaxRequest(ExternalContext ec)
    {
    return "true".equals(ec.getRequestHeaderMap().get(_PPR_REQUEST_HEADER));
    }

    - static public boolean isPartialRequest(Map<String, String[]> parameters)
    + static public boolean isLegacyPartialRequest(Map<String, String[]> parameters)
    {
    - String[] array = parameters.get(_PPR_REQUEST_HEADER);
    - if ((array == null) || (array.length != 1))
    - return false;
    - return "true".equals(array[0]);
    + return _checkParameter(parameters, _PPR_REQUEST_HEADER, "true");
    }

    - static public boolean isPartialRequest(ExternalContext ec)
    + static public boolean isLegacyPartialRequest(ExternalContext ec)
    {
    // A partial request could be an AJAX request, or it could
    // be an IFRAME-postback to handle file upload
    - return isAjaxRequest(ec) ||
    + return isLegacyAjaxRequest(ec) ||
    "true".equals(ec.getRequestParameterMap().get(_PPR_REQUEST_HEADER));
    }

    + static public boolean isPartialRequest(Map<String, String[]> parameters)
    + {
    + if (isLegacyPartialRequest(parameters))
    + {
    + return true;
    + }
    + // Check for the jsf:ajax requests too
    + return _checkParameter(parameters, _FACES_REQUEST, _PARTIAL_AJAX);
    + }
    +
    + static public boolean isPartialRequest(ExternalContext ec)
    + {
    + if (isLegacyPartialRequest(ec))
    + {
    + return true;
    + }
    + return _PARTIAL_AJAX.equals(ec.getRequestHeaderMap().get(_FACES_REQUEST));
    + }
    +
    public CoreRenderKit()
    {
    _modifyBasicHTMLRenderKit();
    @@ -597,7 +613,10 @@ public class CoreRenderKit extends Rende
    rw = new HtmlResponseWriter(writer, characterEncoding);
    }

    - RenderingContext rc = RenderingContext.getCurrentInstance();
    + // mstarets - PPRResponseWriter will be created in the PartialViewContextImpl
    + // for both the JSF2-style ajax requests and legacy requests
    +
    + /*RenderingContext rc = RenderingContext.getCurrentInstance();
    if (rc == null)
    {
    // TODO: is this always indicative of something being very wrong?
    @@ -607,7 +626,7 @@ public class CoreRenderKit extends Rende
    {
    if (isPartialRequest(fContext.getExternalContext()))
    rw = new PPRResponseWriter(rw, rc);
    - }
    + }*/

    return _addDebugResponseWriters(rw);
    }
    @@ -791,6 +810,14 @@ public class CoreRenderKit extends Rende
    // Default to HTML if we couldn't find anything directly applicable
    return _HTML_MIME_TYPE;
    }
    +
    + private static boolean _checkParameter(Map<String, String[]> parameters, String name, String value)
    + {
    + String[] array = parameters.get(name);
    + if ((array == null) || (array.length != 1))
    + return false;
    + return value.equals(array[0]);
    + }

    private static final String _XHTML_MIME_TYPE = "application/xhtml+xml";
    private static final String _APPLICATION_XML_MIME_TYPE = "application/xml";
    @@ -803,6 +830,8 @@ public class CoreRenderKit extends Rende
    static private final String _SCRIPT_LIST_KEY =
    "org.apache.myfaces.trinidadinternal.renderkit.ScriptList";
    static private final String _PPR_REQUEST_HEADER = "Tr-XHR-Message";
    + private static final String _FACES_REQUEST = "Faces-Request";
    + private static final String _PARTIAL_AJAX = "partial/ajax";

    static private final String _USE_DIALOG_POPUP_INIT_PARAM =
    "org.apache.myfaces.trinidad.ENABLE_LIGHTWEIGHT_DIALOGS";

    Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/ppr/PPRResponseWriter.java
    URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/ppr/PPRResponseWriter.java?rev=936035&r1=936034&r2=936035&view=diff
    ==============================================================================
    --- myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/ppr/PPRResponseWriter.java (original)
    +++ myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/ppr/PPRResponseWriter.java Tue Apr 20 19:19:36 2010
    @@ -23,11 +23,13 @@ import java.io.IOException;
    import java.io.Writer;

    import java.util.ArrayList;
    +import java.util.Arrays;
    import java.util.List;

    import javax.faces.component.UIComponent;
    import javax.faces.context.ExternalContext;
    import javax.faces.context.FacesContext;
    +import javax.faces.context.PartialResponseWriter;
    import javax.faces.context.ResponseWriter;

    import org.apache.myfaces.trinidad.context.PartialPageContext;
    @@ -36,6 +38,7 @@ import org.apache.myfaces.trinidad.loggi
    import org.apache.myfaces.trinidad.render.ExtendedRenderKitService;
    import org.apache.myfaces.trinidad.util.Service;

    +import org.apache.myfaces.trinidadinternal.io.ResponseWriterDecorator;
    import org.apache.myfaces.trinidadinternal.renderkit.core.pages.GenericEntry;

    /**
    @@ -51,15 +54,17 @@ import org.apache.myfaces.trinidadintern
    public class PPRResponseWriter extends ScriptBufferingResponseWriter
    {
    public PPRResponseWriter(ResponseWriter out,
    - RenderingContext rc)
    + RenderingContext rc,
    + boolean bufferScripts)
    {
    - super(out);
    + super(out, bufferScripts);
    PartialPageContext pprContext = rc.getPartialPageContext();
    if (!(pprContext instanceof PartialPageContextImpl))
    throw new IllegalArgumentException();

    _state = new State((PartialPageContextImpl) pprContext);
    _xml = new XmlResponseWriter(out, out.getCharacterEncoding());
    + _bufferScripts = bufferScripts;
    }

    /**
    @@ -68,11 +73,12 @@ public class PPRResponseWriter extends S
    PPRResponseWriter(ResponseWriter out,
    PPRResponseWriter base)
    {
    - super(out, base);
    + super(out, base._bufferScripts);
    // New XmlResponseWriter
    _xml = new XmlResponseWriter(out, out.getCharacterEncoding());
    // But the rest of the state is shared
    _state = base._state;
    + _bufferScripts = base._bufferScripts;
    }


    @@ -116,37 +122,32 @@ public class PPRResponseWriter extends S
    // Stick another PI indicating that this is a rich reponse
    // Used for an Iframe based communication channel, since it cannot
    // read response headers
    - _xml.write("<?Tr-XHR-Response-Type ?>\n");
    + // TODO: Do we need this?
    + // _xml.write("<?Tr-XHR-Response-Type ?>\n");

    - _xml.startElement("content", null);
    - String viewId = _facesContext.getViewRoot().getViewId();
    - // HACK: don't write out an "action" for PPR on a GenericEntry page
    - // (basically entirely for the InlineDatePicker case)
    - if (!GenericEntry.getViewId().equals(viewId))
    - {
    - String actionURL = _facesContext.getApplication().
    - getViewHandler().getActionURL(_facesContext, viewId);
    - ExternalContext external = _facesContext.getExternalContext();
    -
    - _xml.writeURIAttribute("action", external.encodeActionURL(actionURL), null);
    - }
    + _xml.startElement(_ELEMENT_PARTIAL_RESPONSE, null);

    // TODO: Portlet support for PPR?
    -
    - _xml.writeText(" ", null);
    + // TODO: PS - Not sure why this extra space is being written out, but this causes an 'malformed
    + // XML error to be thrown by JSF 2 Ajax. Commented out the line.
    + // _xml.writeText(" ", null);

    _state.documentStarting = false;
    }

    public void endDocument() throws IOException
    {
    + _writeFormActionScript();
    +
    // Write out any buffered <script src=""> or inline scripts
    - writeBufferedScripts();
    + if (_bufferScripts)
    + writeBufferedScripts();

    // Write out all of the framework-level scripts
    writeFrameworkScripts();

    - _xml.endElement("content");
    + _endChanges();
    + _xml.endElement(_ELEMENT_PARTIAL_RESPONSE);
    _xml.endDocument();

    // Force "inside target mode" - this is for Facelets,
    @@ -301,6 +302,18 @@ public class PPRResponseWriter extends S
    }
    }

    + public void writeViewState(String state) throws IOException
    + {
    + _startChanges();
    + _xml.startElement(_ELEMENT_CHANGES_UPDATE, null);
    + _xml.writeAttribute(_ATTRIBUTE_ID, PartialResponseWriter.VIEW_STATE_MARKER, null);
    + _xml.startCDATA();
    + _xml.write(state);
    + _xml.endCDATA();
    + _xml.endElement(_ELEMENT_CHANGES_UPDATE);
    + _xml.flush();
    + }
    +
    /*
    * Allows subclasses to retrieve the underlying response writer and bypass PPR logic
    * allowing content to be written only by partial targets
    @@ -311,9 +324,12 @@ public class PPRResponseWriter extends S
    return _xml;
    }

    +
    +
    /*
    * Writes out buffered inline scripts and script libraries
    */
    +
    protected void writeBufferedScripts() throws IOException
    {
    List<String> libraries = getBufferedLibraries();
    @@ -321,9 +337,10 @@ public class PPRResponseWriter extends S
    {
    for (String library : libraries)
    {
    - _xml.startElement("script-library", null);
    + _xml.startElement(_ELEMENT_EXTENSION, null);
    + _xml.writeAttribute(_ATTRIBUTE_ID, "tr-script-library", null);
    _xml.writeText(library, null);
    - _xml.endElement("script-library");
    + _xml.endElement(_ELEMENT_EXTENSION);
    }
    }

    @@ -332,17 +349,17 @@ public class PPRResponseWriter extends S
    {
    for (String script : scripts)
    {
    - _xml.startElement("script", null);
    - _xml.write("<![CDATA[");
    + _xml.startElement(_ELEMENT_EVAL, null);
    + _xml.startCDATA();
    _xml.write(script);
    - _xml.write("]]>");
    - _xml.endElement("script");
    + _xml.endCDATA();
    + _xml.endElement(_ELEMENT_EVAL);
    }
    }

    // Clear out any buffered scripts/libraries
    clearBufferedContents();
    - }
    + }

    /*
    * Writes out framework-level scripts
    @@ -350,7 +367,32 @@ public class PPRResponseWriter extends S
    protected void writeFrameworkScripts() throws IOException
    {
    ResponseWriter old = _facesContext.getResponseWriter();
    - _facesContext.setResponseWriter(_xml);
    +
    + // ExtendedRenderKitService will write out a <script> element.
    + // We want to replace it with <eval> and surround the script with CDATA
    + // All attributes will be ignored
    + ResponseWriter xml = new ResponseWriterDecorator(_xml)
    + {
    + public void startElement(String name, UIComponent component) throws IOException
    + {
    + if ("script".equalsIgnoreCase(name))
    + {
    + _xml.startElement(_ELEMENT_EVAL, null);
    + }
    + }
    + public void endElement(String name) throws IOException
    + {
    + if ("script".equalsIgnoreCase(name))
    + {
    + _xml.endElement(_ELEMENT_EVAL);
    + }
    + }
    + public void writeAttribute(String name, Object value, String attrName) throws IOException
    + {
    + }
    + };
    +
    + _facesContext.setResponseWriter(xml);
    try
    {
    // And also encode ExtendedRenderKitService scripts. (ERKS
    @@ -366,6 +408,36 @@ public class PPRResponseWriter extends S
    _facesContext.setResponseWriter(old);
    }
    }
    +
    + // We need to set form action URL by writing out a JS call because the response
    + // may be processed by jsf.ajax
    + private void _writeFormActionScript() throws IOException
    + {
    + String viewId = _facesContext.getViewRoot().getViewId();
    + // HACK: don't write out an "action" for PPR on a GenericEntry page
    + // (basically entirely for the InlineDatePicker case)
    + if (!GenericEntry.getViewId().equals(viewId))
    + {
    + _xml.startElement(_ELEMENT_EVAL, null);
    + _xml.startCDATA();
    +
    +
    + StringBuilder script = new StringBuilder(128);
    + script.append("TrPage.getInstance().__handlePprResponseAction('");
    +
    + String actionURL = _facesContext.getApplication().
    + getViewHandler().getActionURL(_facesContext, viewId);
    + ExternalContext external = _facesContext.getExternalContext();
    +
    + script.append(external.encodeActionURL(actionURL));
    + script.append("');");
    +
    + _xml.write(script.toString());
    +
    + _xml.endCDATA();
    + _xml.endElement(_ELEMENT_EVAL);
    + }
    + }

    private void _pushPartialTarget(
    UIComponent component,
    @@ -391,7 +463,7 @@ public class PPRResponseWriter extends S
    if (tag != null)
    {
    super.flush();
    - tag.start(_state.pprContext, elementName);
    + tag.startUpdate(_state.pprContext, elementName);
    }

    _state.componentStack.add(tag);
    @@ -405,7 +477,7 @@ public class PPRResponseWriter extends S
    componentStack.remove(pos);

    if (tag != null)
    - tag.finish(_state.pprContext, elementName);
    + tag.finishUpdate(_state.pprContext, elementName);
    }

    private boolean _isInsideTarget()
    @@ -415,7 +487,6 @@ public class PPRResponseWriter extends S
    // output.
    return _state.forceInsideTarget ||
    _state.pprContext.isInsidePartialTarget();
    -
    }


    @@ -468,7 +539,24 @@ public class PPRResponseWriter extends S
    }
    }

    + private void _startChanges() throws IOException
    + {
    + if (!_state.changesStarted)
    + {
    + _xml.startElement(_ELEMENT_CHANGES, null);
    + _state.changesStarted = true;
    + }
    + }

    + private void _endChanges()
    + throws IOException
    + {
    + if (_state.changesStarted)
    + {
    + _xml.endElement("changes");
    + _state.changesStarted = false;
    + }
    + }
    //
    // Class representing PPR behavior associated with a tag. The
    // base class simply tells PPR when it's working with a partial target
    @@ -480,14 +568,16 @@ public class PPRResponseWriter extends S
    _id = id;
    }

    - public void start(
    + public void startUpdate(
    PartialPageContextImpl pprContext,
    String elementName) throws IOException
    {
    if (_id != null)
    {
    + _startChanges();
    pprContext.pushRenderedPartialTarget(_id);
    - _xml.startElement("fragment",null);
    + _xml.startElement(_ELEMENT_CHANGES_UPDATE, null);
    + _xml.writeAttribute(_ATTRIBUTE_ID, _id, null);
    _xml.write("<![CDATA[");
    _xml.flush(); // NEW

    @@ -501,7 +591,7 @@ public class PPRResponseWriter extends S
    }
    }

    - public void finish(
    + public void finishUpdate(
    PartialPageContextImpl pprContext,
    String elementName) throws IOException
    {
    @@ -520,7 +610,7 @@ public class PPRResponseWriter extends S
    PPRResponseWriter.super.flush();

    _xml.write("]]>");
    - _xml.endElement("fragment");
    + _xml.endElement(_ELEMENT_CHANGES_UPDATE);
    _xml.flush();

    pprContext.popRenderedPartialTarget();
    @@ -568,11 +658,6 @@ public class PPRResponseWriter extends S
    }


    - private State _state;
    - private ResponseWriter _xml;
    - private final FacesContext _facesContext =
    - FacesContext.getCurrentInstance();
    -
    static private class State
    {
    public State(PartialPageContextImpl pprContext)
    @@ -585,9 +670,23 @@ public class PPRResponseWriter extends S
    public int elementDepth;
    public boolean documentStarted;
    public boolean documentStarting;
    + public boolean changesStarted;
    public final List<PPRTag> componentStack = new ArrayList<PPRTag>(50);
    public final PartialPageContextImpl pprContext;
    }

    + private State _state;
    + private ResponseWriter _xml;
    + private boolean _bufferScripts;
    + private final FacesContext _facesContext = FacesContext.getCurrentInstance();
    +
    static private final TrinidadLogger _LOG = TrinidadLogger.createTrinidadLogger(PPRResponseWriter.class);
    + private static final String _ELEMENT_PARTIAL_RESPONSE = "partial-response";
    + private static final String _ELEMENT_CHANGES = "changes";
    + private static final String _ELEMENT_CHANGES_UPDATE = "update";
    + private static final String _ELEMENT_EVAL = "eval";
    + private static final String _ELEMENT_EXTENSION = "extension";
    + private static final String _ATTRIBUTE_ID = "id";
    + private static final List<String> _allowedIds = Arrays.asList(PartialResponseWriter.VIEW_STATE_MARKER);
    +
    }

    Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/ppr/ScriptBufferingResponseWriter.java
    URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/ppr/ScriptBufferingResponseWriter.java?rev=936035&r1=936034&r2=936035&view=diff
    ==============================================================================
    --- myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/ppr/ScriptBufferingResponseWriter.java (original)
    +++ myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/ppr/ScriptBufferingResponseWriter.java Tue Apr 20 19:19:36 2010
    @@ -41,6 +41,12 @@ public class ScriptBufferingResponseWrit
    {
    super(out);
    }
    +
    + public ScriptBufferingResponseWriter(ResponseWriter out, boolean enabled)
    + {
    + super(out);
    + _enabled = enabled;
    + }

    /**
    * Constructor for clones - share the scripts and libraries list.
    @@ -50,7 +56,7 @@ public class ScriptBufferingResponseWrit
    super(out);
    _scripts = base._scripts;
    _libraries = base._libraries;
    -
    + _enabled = base._enabled;
    }

    // Returns a List of Strings containing script content, or null
    @@ -195,7 +201,7 @@ public class ScriptBufferingResponseWrit
    public void startElement(String name, UIComponent component)
    throws IOException
    {
    - if ("script".equals(name))
    + if (_enabled && "script".equals(name))
    {
    _inScript = true;
    }
    @@ -278,5 +284,6 @@ public class ScriptBufferingResponseWrit
    private StringBuilder _scriptBuilder;
    private List<String> _libraries = new ArrayList<String>();
    private List<String> _scripts = new ArrayList<String>();
    + private boolean _enabled = true;
    }


    Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/BodyRenderer.java
    URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/BodyRenderer.java?rev=936035&r1=936034&r2=936035&view=diff
    ==============================================================================
    --- myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/BodyRenderer.java (original)
    +++ myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/BodyRenderer.java Tue Apr 20 19:19:36 2010
    @@ -23,6 +23,7 @@ import java.beans.Beans;
    import java.io.IOException;

    import javax.faces.component.UIComponent;
    +import javax.faces.context.ExternalContext;
    import javax.faces.context.FacesContext;
    import javax.faces.context.ResponseWriter;

    @@ -98,6 +99,8 @@ public class BodyRenderer extends PanelP
    context.getResponseWriter().endElement("body");

    _renderInitialFocusScript(context, rc);
    +
    + _renderDisableJsfAjaxScript(context, rc);
    }

    @Override
    @@ -379,6 +382,27 @@ public class BodyRenderer extends PanelP
    writer.endElement("script");
    }
    }
    +
    + // Reverts to the legacy PPR channel (disables PPR over JSF Ajax)
    + // if teh conetxt parameter is set
    + private void _renderDisableJsfAjaxScript(
    + FacesContext context,
    + RenderingContext rc
    + ) throws IOException
    + {
    + if (!supportsScripting(rc))
    + {
    + return;
    + }
    + ExternalContext extContext = context.getExternalContext();
    + if ("off".equalsIgnoreCase(extContext.getInitParameter(_PPR_OVER_JSF_AJAX)))
    + {
    + ResponseWriter writer = context.getResponseWriter();
    + writer.startElement("script", null);
    + writer.write("TrPage.getInstance().__disablePprOverJsfAjax()");
    + writer.endElement("script");
    + }
    + }

    // If partial back is supported,
    // render a span with the _PPR_BACK_CONTENT_ID id.
    @@ -577,4 +601,6 @@ public class BodyRenderer extends PanelP
    static private final String _PPR_BACK_SAVE_CONTENT_ID = "_pprSavePage";
    static private final String _PPR_BACK_SAVE_SCRIPT_ID = "_pprSaveScript";
    static private final String _PPR_BACK_SAVE_LIBRARY_ID = "_pprSaveLib";
    +
    + static private final String _PPR_OVER_JSF_AJAX = "org.apache.myfaces.trinidadinternal.PPR_OVER_JSF_AJAX";
    }

    Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/CommandLinkRenderer.java
    URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/CommandLinkRenderer.java?rev=936035&r1=936034&r2=936035&view=diff
    ==============================================================================
    --- myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/CommandLinkRenderer.java (original)
    +++ myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/CommandLinkRenderer.java Tue Apr 20 19:19:36 2010
    @@ -77,7 +77,14 @@ public class CommandLinkRenderer extends
    Map<String, String> parameterMap =
    facesContext.getExternalContext().getRequestParameterMap();

    - Object source = parameterMap.get("source");
    + Object source = parameterMap.get("javax.faces.source");
    +
    + // Support the legacy as well as JSF2 parameter name
    + if (source == null)
    + {
    + source = parameterMap.get("source");
    + }
    +
    if (clientId == null)
    {
    clientId = component.getClientId(facesContext);

    Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/DocumentRenderer.java
    URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/DocumentRenderer.java?rev=936035&r1=936034&r2=936035&view=diff
    ==============================================================================
    --- myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/DocumentRenderer.java (original)
    +++ myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/DocumentRenderer.java Tue Apr 20 19:19:36 2010
    @@ -21,6 +21,7 @@ package org.apache.myfaces.trinidadinter
    import java.io.IOException;

    import javax.faces.application.StateManager;
    +import javax.faces.application.ResourceDependency;
    import javax.faces.component.UIComponent;
    import javax.faces.context.FacesContext;

    @@ -38,6 +39,7 @@ import org.apache.myfaces.trinidadintern
    * <p>
    * @version $Name: $ ($Revision: adfrt/faces/adf-faces-impl/src/main/java/oracle/adfinternal/view/faces/renderkit/core/xhtml/DocumentRenderer.java#0 $) $Date: 10-nov-2005.19:01:25 $
    */
    +@ResourceDependency(target = "head", library = "javax.faces", name = "jsf.js")
    public class DocumentRenderer extends XhtmlRenderer
    {
    public DocumentRenderer()

    Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/FormRenderer.java
    URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/FormRenderer.java?rev=936035&r1=936034&r2=936035&view=diff
    ==============================================================================
    --- myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/FormRenderer.java (original)
    +++ myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/FormRenderer.java Tue Apr 20 19:19:36 2010
    @@ -407,6 +407,9 @@ public class FormRenderer extends XhtmlR
    }

    // Include JSF state.
    + // Note that MultiViewHandler in JSF RI will not write the state
    + // for any AJAX requests. PartialViewContextImpl will write out the state
    + // for these requets
    context.getApplication().getViewHandler().writeState(context);

    // Include the Window state, if any

    Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/HeadRenderer.java
    URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/HeadRenderer.java?rev=936035&r1=936034&r2=936035&view=diff
    ==============================================================================
    --- myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/HeadRenderer.java (original)
    +++ myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/HeadRenderer.java Tue Apr 20 19:19:36 2010
    @@ -20,6 +20,7 @@ package org.apache.myfaces.trinidadinter

    import java.io.IOException;

    +import javax.faces.application.ResourceDependency;
    import javax.faces.component.UIComponent;
    import javax.faces.context.FacesContext;
    import javax.faces.context.ResponseWriter;
    @@ -36,6 +37,7 @@ import org.apache.myfaces.trinidad.rende
    * <p>
    * @version $Name: $ ($Revision: adfrt/faces/adf-faces-impl/src/main/java/oracle/adfinternal/view/faces/renderkit/core/xhtml/HeadRenderer.java#0 $) $Date: 10-nov-2005.19:01:29 $
    */
    +@ResourceDependency(target = "head", library = "javax.faces", name = "jsf.js")
    public class HeadRenderer extends XhtmlRenderer
    {
    public HeadRenderer()

    Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/PartialPageUtils.java
    URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/PartialPageUtils.java?rev=936035&r1=936034&r2=936035&view=diff
    ==============================================================================
    --- myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/PartialPageUtils.java (original)
    +++ myfaces/trinidad/trunk/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/PartialPageUtils.java Tue Apr 20 19:19:36 2010
    @@ -57,15 +57,22 @@ public final class PartialPageUtils
    if (!checkIsPPR ||
    (PartialPageUtils.isPartialRequest(context) && PartialPageUtils.isPPRActive(context)))
    {
    - ExternalContext external = context.getExternalContext();
    -
    - // see if PPR optimization is enabled for the servlet (the default is off)
    - if ("true".equalsIgnoreCase(external.getInitParameter(_INIT_PROP_PPR_OPTIMIZATION_ENABLED)))
    + if (Boolean.TRUE.equals(context.getAttributes().get(_FORCE_OPTIMIZED_PPR)))
    + {
    + optimizedPPREnabled = true;
    + }
    + else
    {
    - // see if PPR optimization is enabled for the application (the default is on)
    - optimizedPPREnabled = !Boolean.TRUE.equals(
    - external.getApplicationMap().get(_APP_PROP_PPR_OPTIMIZATION_DISABLED));
    - }
    + ExternalContext external = context.getExternalContext();
    +
    + // see if PPR optimization is enabled for the servlet (the default is off)
    + if ("true".equalsIgnoreCase(external.getInitParameter(_INIT_PROP_PPR_OPTIMIZATION_ENABLED)))
    + {
    + // see if PPR optimization is enabled for the application (the default is on)
    + optimizedPPREnabled = !Boolean.TRUE.equals(
    + external.getApplicationMap().get(_APP_PROP_PPR_OPTIMIZATION_DISABLED));
    + }
    + }
    }

    return optimizedPPREnabled;
    @@ -111,12 +118,27 @@ public final class PartialPageUtils
    return false;
    }

    + /**
    + * This method delegates to the RequestContext.isPartialRequest() with the
    + * exception that JSF Ajax render="@all" requests are reported as non-partial
    + * @param context
    + * @return
    + */
    public static boolean isPartialRequest(FacesContext context)
    {
    RequestContext rc = RequestContext.getCurrentInstance();
    if (rc == null)
    return false;
    - return rc.isPartialRequest(context);
    + boolean isPartial = rc.isPartialRequest(context);
    +
    + if (isPartial && context.getPartialViewContext().isRenderAll())
    + {
    + // We do not want to create PartialPageContext and use the tree visit (if enabled)
    + // for the 'render all' <f:ajax> case
    + isPartial = false;
    + }
    +
    + return isPartial;
    }


    @@ -217,6 +239,15 @@ public final class PartialPageUtils

    requestScope.put(_PPR_ACTIVE_FLAG_NAME, Boolean.TRUE);
    }
    +
    + /**
    + * Forces optimized PPR (using tree visit to render components)
    + * @param context
    + */
    + public static void forceOptimizedPPR(FacesContext context)
    + {
    + context.getAttributes().put(_FORCE_OPTIMIZED_PPR, Boolean.TRUE);
    + }

    // temporary servlet initialization flag controlling whether PPR optimization is enabled for the servlet
    private static final String _INIT_PROP_PPR_OPTIMIZATION_ENABLED =
    @@ -230,4 +261,7 @@ public final class PartialPageUtils
    // an iFrame is built yet.
    private static final String _PPR_ACTIVE_FLAG_NAME =
    "org.apache.myfaces.trinidadinternal.renderkit._pprActiveOnPage";
    +
    +
    + private static final Object _FORCE_OPTIMIZED_PPR = new Object();
    }

    Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Core.js
    URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Core.js?rev=936035&r1=936034&r2=936035&view=diff
    ==============================================================================
    --- myfaces/trinidad/trunk/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Core.js (original)
    +++ myfaces/trinidad/trunk/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Core.js Tue Apr 20 19:19:36 2010
    @@ -228,6 +228,10 @@ function _agentInit()

    // Indicate browser's PPR capability support
    var pprUnsupported = false;
    +
    + // Indicate whether the browser and platform are capable of
    + // sending PPR requests via JSF Ajax
    + var useJsfAjax = true;

    // Flag to indicate that document object is sufficiently implemented to
    // provide good level of access to HTML, XHTML and XML document.
    @@ -390,6 +394,7 @@ function _agentInit()
    _agent.isWindowsMobile6 = isWindowsMobile6;
    _agent.kind = kind;
    _agent.pprUnsupported = pprUnsupported;
    + _agent.useJsfAjax = useJsfAjax;
    _agent.supportsDomDocument = supportsDomDocument;
    _agent.supportsNodeType = supportsNodeType;
    _agent.supportsValidation = supportsValidation;
    @@ -1701,7 +1706,8 @@ function submitForm(
    form,
    doValidate,
    parameters,
    - isPartial
    + isPartial,
    + event
    )
    {
    // If we've delayed any sort of event submission, we won't want to do it at
    @@ -1862,7 +1868,7 @@ function submitForm(
    }
    else
    {
    - TrPage.getInstance().sendPartialFormPost(form, parameters);
    + TrPage.getInstance().sendPartialFormPost(form, parameters, null, event);
    }
    }
    else
    @@ -3636,7 +3642,6 @@ function _doPprStartBlocking (win)
    //
    function _pprStopBlocking(win)
    {
    -
    // No blocking is performed on Nokia, PPC and BlackBerry devices
    if (_agent.isPIE || _agent.isNokiaPhone || _agent.isBlackBerry)
    return;
    @@ -3868,7 +3873,8 @@ function _firePartialChange(url)
    function _submitPartialChange(
    form,
    doValidate,
    - parameters)
    + parameters,
    + event)
    {
    // If there's no PPR iframe, then just perform a normal,
    // full-page submission.
    @@ -3889,7 +3895,7 @@ function _submitPartialChange(
    _pprStartBlocking(window);

    // Submit the form
    - var submitted = submitForm(form, doValidate, parameters, true);
    + var submitted = submitForm(form, doValidate, parameters, true, event);

    // If the form wasn't actually submitted, update the ref count
    if (!submitted)

    Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Page.js
    URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Page.js?rev=936035&r1=936034&r2=936035&view=diff
    ==============================================================================
    --- myfaces/trinidad/trunk/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Page.js (original)
    +++ myfaces/trinidad/trunk/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Page.js Tue Apr 20 19:19:36 2010
    @@ -18,15 +18,16 @@
    */
    function TrPage()
    {
    - this._loadedLibraries = TrPage._collectLoadedLibraries();
    this._requestQueue = new TrRequestQueue(window);
    + this._loadedLibraries = TrPage._collectLoadedLibraries();
    }

    +TrPage._VIEW_STATE_ID = "javax.faces.ViewState";

    /**
    * Get the shared instance of the page object.
    */
    -TrPage.getInstance = function()
    +TrPage.getInstance = function ()
    {
    if (TrPage._INSTANCE == null)
    TrPage._INSTANCE = new TrPage();
    @@ -37,7 +38,7 @@ TrPage.getInstance = function()
    /**
    * Return the shared request queue for the page.
    */
    -TrPage.prototype.getRequestQueue = function()
    +TrPage.prototype.getRequestQueue = function ()
    {
    return this._requestQueue;
    }
    @@ -50,26 +51,34 @@ TrPage.prototype.getRequestQueue = funct
    * @param headerParams{Object} HTTP headers to include (ignored if
    * the request must be a multipart/form post)
    */
    -TrPage.prototype.sendPartialFormPost = function(
    - actionForm,
    - params,
    - headerParams)
    +TrPage.prototype.sendPartialFormPost = function (actionForm, params, headerParams, event)
    {
    - this.getRequestQueue().sendFormPost(
    - this, this._requestStatusChanged,
    - actionForm, params, headerParams);
    + var queue =this.getRequestQueue();
    + if (!this._xhrInited)
    + {
    + this._xhrInited = true;
    + if (this._noPprOverJsfAjax)
    + {
    + queue.__disableJsfBuiltInAjaxForXhr();
    + }
    + else if (queue.__useJsfBuiltInAjaxForXhr())
    + {
    + jsf.ajax.addOnEvent(TrUIUtils.createCallback(this, this._jsfAjaxCallback));
    + }
    + }
    + queue.sendFormPost(this, this._requestStatusChanged, actionForm, params, headerParams, event);
    }

    -TrPage.prototype._requestStatusChanged = function(requestEvent)
    +TrPage.prototype._requestStatusChanged = function (requestEvent)
    {
    if (requestEvent.getStatus() == TrXMLRequestEvent.STATUS_COMPLETE)
    {
    var statusCode = requestEvent.getResponseStatusCode();

    // The server might not return successfully, for example if an
    - // exception is thrown. When that happens, a non-200 (OK) status
    - // code is returned as part of the HTTP prototcol.
    - if (statusCode == 200)
    + // exception is thrown. When that happens, a status that is below
    + // 200 or 300 or above is returned as part of the HTTP prototcol.
    + if (statusCode >= 200 && statusCode < 300)
    {
    _pprStopBlocking(window);

    @@ -86,7 +95,14 @@ TrPage.prototype._requestStatusChanged =
    // Nokia browser is officially supported.
    if (responseDocument != null)
    {
    - this._handlePprResponse(responseDocument.documentElement);
    + if (requestEvent.isJsfAjaxRequest())
    + {
    + this._handleJsfAjaxResponse(requestEvent);
    + }
    + else
    + {
    + this._handlePprResponse(requestEvent, responseDocument);
    + }
    }
    }
    else
    @@ -101,60 +117,128 @@ TrPage.prototype._requestStatusChanged =
    // wrong - we should do the handling here
    _pprStopBlocking(window);
    }
    -
    + }
    + if (requestEvent.isJsfAjaxRequest())
    + {
    + this._handleJsfAjaxResponse(requestEvent);
    }
    }

    -TrPage.prototype._handlePprResponse = function(documentElement)
    +TrPage.prototype._handleJsfAjaxResponse = function (requestEvent)
    {
    - var rootNodeName = TrPage._getNodeName(documentElement);
    + try
    + {
    + var statusCode = requestEvent.getResponseStatusCode();
    + if (statusCode >= 200 && statusCode < 300)
    + {
    + if (this._ajaxOldDomElements)
    + {
    + this._notifyDomReplacementListeners(this._ajaxOldDomElements);
    + }

    - if (rootNodeName == "content")
    + if (this._activeNode)
    + {
    + var activeNode = this._activeNode;
    + delete this._activeNode;
    + var index = - 1;
    + if (activeNode.id)
    + {
    + for (var i = 0, size = this._ajaxOldDomElements.length;i < size;++i)
    + {
    + if (TrPage._isDomAncestorOf(activeNode, this._ajaxOldDomElements[i].element))
    + {
    + index = i;
    + break;
    + }
    + }
    + if (index >= 0)
    + {
    + activeNode = document.getElementById(activeNode.id);
    + window._trActiveElement = activeNode;
    + if (activeNode)
    + {
    + activeNode.focus();
    + }
    + }
    + }
    + }
    + }
    + // TODO: do we need to do any additional processing here, for instance,
    + // error processing?
    + }
    + finally
    {
    - // Update the form action
    - this._handlePprResponseAction(documentElement);
    + delete this._ajaxOldDomElements;
    + delete this._activeNode;
    + }
    +}
    +
    +TrPage.prototype._handlePprResponse = function (requestEvent, document)
    +{
    + // -- This is only called for iFrame cases --
    + // Note that at first, it was attempted to delegate the response to
    + // the jsf.ajax.response method using a mock-XHR object
    + // The problem with this approach is that we have no way to fire the
    + // JSF AJAX events. If we only call jsf.ajax.response, we'll only get a
    + // success event, but no complete event and there is no public API to
    + // fire these events. So instead, let the iframe use all legacy code
    + // and only fire Trinidad events and not jsf.ajax events.

    + var documentElement = document.documentElement;
    + var rootNodeName = TrPage._getNodeName(documentElement);
    + if (rootNodeName == "partial-response")
    + {
    var childNodes = documentElement.childNodes;
    var length = childNodes.length;

    - for (var i = 0; i < length; i++)
    + for (var i = 0;i < length;i++)
    {
    var childNode = childNodes[i];
    - var childNodeName = TrPage._getNodeName(childNode);

    - if (childNodeName == "fragment")
    + switch (TrPage._getNodeName(childNode))
    {
    - this._handlePprResponseFragment(childNode);
    - }
    - else if (childNodeName == "script")
    - {
    - this._handlePprResponseScript(childNode);
    - }
    - else if (childNodeName == "script-library")
    - {
    - this._handlePprResponseLibrary(childNode);
    + case "changes":
    + for (var j = 0, size = childNode.childNodes.length;j < size;++j)
    + {
    + var changeNode = childNode.childNodes[j];
    + switch (TrPage._getNodeName(changeNode))
    + {
    + case "update":
    + this._handlePprResponseFragment(changeNode, requestEvent.getFormId());
    + break;
    +
    + case "eval":
    + this._handlePprResponseScript(changeNode);
    + break;
    +
    + case "extension":
    + if (changeNode.getAttribute("id") == "tr-script-library")
    + {
    + this._handlePprResponseLibrary(changeNode);
    + }
    + break;
    +
    + // Do not support the new updates with the Trinidad legacy fallback code
    + // for now
    + default:
    + break;
    + }
    + }
    + break;
    + case "error":
    + var nodeText = TrPage._getTextContent(childNode.firstChild.nextSibling);
    + // This should not happen - there should always be an error message
    + if (nodeText == null)
    + nodeText = "Unknown error during PPR";
    + alert(nodeText);
    + return;
    + case "redirect":
    + var url = childNode.getAttribute("url");
    + // TODO: fix for portlets???
    + window.location.href = url;
    }
    }
    }
    - else if (rootNodeName == "redirect")
    - {
    - var url = TrPage._getTextContent(documentElement);
    - // TODO: fix for portlets???
    - window.location.href = url;
    - }
    - else if (rootNodeName == "error")
    - {
    - var nodeText = TrPage._getTextContent(documentElement);
    - // This should not happen - there should always be an error
    - // message
    - if (nodeText == null)
    - nodeText = "Unknown error during PPR";
    - alert(nodeText);
    - }
    - else if (rootNodeName == "noop")
    - {
    - // No op
    - }
    else
    {
    // FIXME: log an error
    @@ -162,7 +246,12 @@ TrPage.prototype._handlePprResponse = fu
    }
    }

    -TrPage.prototype._addResetFields = function(formName, resetNames)
    +TrPage.prototype.__disablePprOverJsfAjax = function()
    +{
    + this._noPprOverJsfAjax = true;
    +}
    +
    +TrPage.prototype._addResetFields = function (formName, resetNames)
    {
    // Create the necessary objects
    var resetFields = this._resetFields;
    @@ -180,13 +269,13 @@ TrPage.prototype._addResetFields = funct
    }

    // Store "name":true in the map for each such item
    - for (var i = 0; i < resetNames.length; i++)
    + for (var i = 0;i < resetNames.length;i++)
    {
    formReset[resetNames[i]] = true;
    }
    }

    -TrPage.prototype._resetHiddenValues = function(form)
    +TrPage.prototype._resetHiddenValues = function (form)
    {
    var resetFields = this._resetFields;
    if (resetFields)
    @@ -215,9 +304,7 @@ TrPage.prototype._resetHiddenValues = fu
    * @param callMap a map from clientId to the JS function
    * that will reset that component
    */
    -TrPage.prototype._addResetCalls = function(
    - formName,
    - callMap)
    +TrPage.prototype._addResetCalls = function (formName, callMap)
    {
    // Create the necessary objects
    var resetCalls = this._resetCalls;
    @@ -247,7 +334,7 @@ TrPage.prototype._addResetCalls = functi
    * TODO: remove entire Core.js code, move to public TrPage.resetForm()
    * call.
    */
    -TrPage.prototype._resetForm = function(form)
    +TrPage.prototype._resetForm = function (form)
    {
    var resetCalls = this._resetCalls;
    if (!resetCalls)
    @@ -268,7 +355,7 @@ TrPage.prototype._resetForm = function(f
    }

    // TODO move to agent code
    -TrPage._getNodeName = function(element)
    +TrPage._getNodeName = function (element)
    {
    var nodeName = element.nodeName;
    if (!nodeName)
    @@ -276,31 +363,37 @@ TrPage._getNodeName = function(element)
    return nodeName;
    }

    -
    // Update the form with the new action provided in the response
    -TrPage.prototype._handlePprResponseAction = function(contentNode)
    +TrPage.prototype.__handlePprResponseAction = function (actionURL)
    {
    - var action = contentNode.getAttribute("action");
    -
    - if (action)
    - {
    - var doc = window.document;
    + var doc = window.document;

    - // Replace the form action used by the next postback
    - // Particularly important for PageFlowScope which might
    - // change value of the pageflow scope token url parameter.
    - // TODO: track submitted form name at client, instead of
    - // just updating the first form
    - doc.forms[0].action = action;
    - }
    + // Replace the form action used by the next postback
    + // Particularly important for PageFlowScope which might
    + // change value of the pageflow scope token url parameter.
    + // TODO: track submitted form name at client, instead of
    + // just updating the first form
    + doc.forms[0].action = actionURL;

    // TODO: support Portal
    }

    // Handles a single fragment node in a ppr response.
    -TrPage.prototype._handlePprResponseFragment = function(fragmentNode)
    +TrPage.prototype._handlePprResponseFragment = function (fragmentNode, formId)
    {
    var doc = window.document;
    +
    + if (fragmentNode.getAttribute("id") == TrPage._VIEW_STATE_ID)
    + {
    + // JSF2 short-circuits writeState() during partial requets. The state
    + // is always written out as a special "update" element
    + // Perform special handling for the javax.faces.ViewState Id here just
    + // like jsf.ajax.request() does
    + this._updateViewState(doc, fragmentNode, formId);
    +
    + return;
    + }
    +
    var targetNode;
    var activeNode;
    var refocusId = null;
    @@ -314,9 +407,13 @@ TrPage.prototype._handlePprResponseFragm
    // Get the first child node in fragmentNote
    var firstFragmenChildNode = fragmentNode.childNodes[0];
    if (!firstFragmenChildNode)
    - return;
    + return;

    - var outerHTML = firstFragmenChildNode.data;
    + var outerHTML = "";
    + for (var i = 0, size = fragmentNode.childNodes.length;i < size;++i)
    + {
    + outerHTML += fragmentNode.childNodes[i].data;
    + }

    // Windows Mobile 6 requires the element to be a child of
    // document.body to allow setting its innerHTML property.
    @@ -333,7 +430,7 @@ TrPage.prototype._handlePprResponseFragm

    var sourceNode = TrPage._getFirstElementWithId(tempDiv);

    - var targetNode = _getElementById(doc, sourceNode.id);
    + targetNode = _getElementById(doc, sourceNode.id);
    if (!targetNode)
    {
    return;
    @@ -370,7 +467,7 @@ TrPage.prototype._handlePprResponseFragm
    // never gets any attributes on it, we actually strip that
    // span, so we can get something that has no elements at all!
    if (!sourceNode)
    - return;
    + return;

    // Grab the id of the source node - we need this to locate the
    // target node that will be replaced
    @@ -393,10 +490,10 @@ TrPage.prototype._handlePprResponseFragm
    var listeners = this._domReplaceListeners;
    if (listeners)
    {
    - for (var i = 0; i < listeners.length; i+=2)
    + for (var i = 0;i < listeners.length;i += 2)
    {
    var currListener = listeners[i];
    - var currInstance = listeners[i+1];
    + var currInstance = listeners[i + 1];
    if (currInstance != null)
    currListener.call(currInstance, targetNode, sourceNode);
    else
    @@ -416,11 +513,36 @@ TrPage.prototype._handlePprResponseFragm
    }
    }

    +TrPage.prototype._updateViewState = function(doc, sourceNode, formId)
    +{
    + var form = null;
    +
    + if (formId)
    + form = doc.getElementById(formId);
    +
    + if (!form)
    + form = doc.forms[0];
    +
    + if (!form)
    + return;
    +
    + var input = form[TrPage._VIEW_STATE_ID];
    +
    + if (!input)
    + {
    + input = doc.createElement("input");
    + input.type = 'hidden';
    + input.name = TrPage._VIEW_STATE_ID;
    + form.appendChild(input);
    + }
    +
    + input.value = TrPage._getTextContent(sourceNode);
    +}

    /**
    * Return true if "parent" is an ancestor of (or equal to) "child"
    */
    -TrPage._isDomAncestorOf = function(child, parent)
    +TrPage._isDomAncestorOf = function (child, parent)
    {
    while (child)
    {
    @@ -437,27 +559,27 @@ TrPage._isDomAncestorOf = function(child
    return false;
    }

    -
    /**
    * Replaces the a dom element contained in a peer.
    *
    * @param newElement{DOMElement} the new dom element
    * @param oldElement{DOMElement} the old dom element
    */
    -TrPage.prototype.__replaceDomElement = function(newElement, oldElement)
    +TrPage.prototype.__replaceDomElement = function (newElement, oldElement)
    {
    oldElement.parentNode.replaceChild(newElement, oldElement);
    }

    // Extracts the text contents from a rich response fragment node and
    // creates an HTML element for the first element that is found.
    -TrPage.prototype._getFirstElementFromFragment = function(fragmentNode)
    +TrPage.prototype._getFirstElementFromFragment = function (fragmentNode)
    {
    // Fragment nodes contain a single CDATA section
    var fragmentChildNodes = fragmentNode.childNodes;
    +
    // assert((fragmentChildNodes.length == 0), "invalid fragment child count");
    var outerHTML = "";
    - for (var i = 0, size = fragmentChildNodes.length; i < size; ++i)
    + for (var i = 0, size = fragmentChildNodes.length;i < size;++i)
    {
    // The new HTML content is in the CDATA section.
    if (fragmentChildNodes[i].nodeType == 4)
    @@ -478,13 +600,12 @@ TrPage.prototype._getFirstElementFromFra

    // Returns the first element underneath the specified dom node
    // which has an id.
    -TrPage._getFirstElementWithId = function(domNode)
    +TrPage._getFirstElementWithId = function (domNode)
    {
    -
    var childNodes = domNode.childNodes;
    var length = childNodes.length;

    - for (var i = 0; i < length; i++)
    + for (var i = 0;i < length;i++)
    {
    var childNode = childNodes[i];
    if (childNode.id)
    @@ -506,7 +627,7 @@ TrPage._getFirstElementWithId = function
    return null;
    }

    -TrPage.prototype._loadScript = function(source)
    +TrPage.prototype._loadScript = function (source)
    {
    // Make sure we only load each library once
    var loadedLibraries = this._loadedLibraries;
    @@ -534,7 +655,7 @@ TrPage.prototype._loadScript = function(
    }

    // Handles a single script node in a rich response
    -TrPage.prototype._handlePprResponseScript = function(scriptNode)
    +TrPage.prototype._handlePprResponseScript = function (scriptNode)
    {
    var source = scriptNode.getAttribute("src");
    if (source)
    @@ -554,14 +675,14 @@ TrPage.prototype._handlePprResponseScrip
    }
    }

    -TrPage.prototype._handlePprResponseLibrary = function(scriptNode)
    +TrPage.prototype._handlePprResponseLibrary = function (scriptNode)
    {
    var nodeText = TrPage._getTextContent(scriptNode);
    this._loadScript(nodeText);
    }

    // TODO: move to agent API
    -TrPage._getTextContent = function(element)
    +TrPage._getTextContent = function (element)
    {
    if (_agent.isIE)
    {
    @@ -593,7 +714,7 @@ TrPage._getTextContent = function(elemen
    return element.textContent;
    }

    -TrPage._collectLoadedLibraries = function()
    +TrPage._collectLoadedLibraries = function ()
    {
    if (!_agent.supportsDomDocument)
    {
    @@ -606,15 +727,15 @@ TrPage._collectLoadedLibraries = functio
    {
    var loadedLibraries = new Object();

    - // We use document.getElementsByTagName() to locate all scripts
    - // in the page. In theory this could be slow if the DOM is huge,
    - // but so far seems extremely efficient.
    + // We use document.getElementsByTagName() to locate all scripts
    + // in the page. In theory this could be slow if the DOM is huge,
    + // but so far seems extremely efficient.
    var domDocument = window.document;
    var scripts = domDocument.getElementsByTagName("script");

    if (scripts != null)
    {
    - for (var i = 0; i < scripts.length; i++)
    + for (var i = 0;i < scripts.length;i++)
    {
    // Note: we use node.getAttribute("src") instead of node.src as
    // FF returns a fully-resolved URI for node.src. In theory we could
    @@ -625,7 +746,6 @@ TrPage._collectLoadedLibraries = functio
    // we could evalute a library an extra time (if it appears once fully
    // resolved and another time as a relative URI), but this seems like
    // an unlikely case which does not warrant extra code.
    -
    var src = scripts[i].getAttribute("src");

    if (src)
    @@ -643,7 +763,7 @@ TrPage._collectLoadedLibraries = functio
    * @param {function} listener listener function to add
    * @param {object} instance to pass as "this" when calling function (optional)
    */
    -TrPage.prototype.addDomReplaceListener = function(listener, instance)
    +TrPage.prototype.addDomReplaceListener = function (listener, instance)
    {
    var domReplaceListeners = this._domReplaceListeners;
    if (!domReplaceListeners)
    @@ -657,17 +777,17 @@ TrPage.prototype.addDomReplaceListener =
    }

    /**
    -* 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)
    + * 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++)
    + for (var i = 0;i < length;i++)
    {
    var currListener = domReplaceListeners[i];
    i++;
    @@ -696,7 +816,7 @@ TrPage.prototype.removeDomReplaceListene
    * getStyleClass function.
    * @param styleClassMap() {key: styleClass, ...}
    */
    -TrPage.prototype.addStyleClassMap = function(styleClassMap)
    +TrPage.prototype.addStyleClassMap = function (styleClassMap)
    {
    if (!styleClassMap)
    return;
    @@ -714,7 +834,7 @@ TrPage.prototype.addStyleClassMap = func
    * @param key(String) Unique key to retrieve the styleClass
    * @return (String) The styleClass, or undefined if not exist
    */
    -TrPage.prototype.getStyleClass = function(key)
    +TrPage.prototype.getStyleClass = function (key)
    {
    if (key && this._styleClassMap)
    {
    @@ -736,7 +856,7 @@ TrPage.prototype.getStyleClass = functio
    * @param event(Event) The javascript event object.
    * @param validateForm(boolean) true if the whole form should be validated.
    */
    -TrPage._autoSubmit = function(formId, inputId, event, validateForm, params)
    +TrPage._autoSubmit = function (formId, inputId, event, validateForm, params)
    {
    if (_agent.isIE)
    {
    @@ -761,6 +881,98 @@ TrPage._autoSubmit = function(formId, in
    params.event = "autosub";
    params.source = inputId;

    - _submitPartialChange(formId, validateForm, params);
    + _submitPartialChange(formId, validateForm, params, event);
    + }
    +}
    +
    +TrPage.prototype._jsfAjaxCallback = function (data)
    +{
    + if (data.status == "complete")
    + {
    + // Collect the DOM elements that will be replaced to be able to fire the
    + // DOM replacement events.
    + // This information is used in the _handleJsfAjaxResponse function that is called
    + // as a result of the request queue firing the XMLRequestEvent.
    + this._ajaxOldDomElements = this._getDomToBeUpdated(data.responseCode, data.responseXML);
    + this._activeNode = _getActiveElement();
    }
    }
    +
    +TrPage.prototype._notifyDomReplacementListeners = function (dataArray)
    +{
    + var listeners = this._domReplaceListeners;
    + if (!listeners || listeners.length == 0)
    + {
    + return;
    + }
    + for (var i = 0, isize = dataArray.length;i < isize;++i)
    + {
    + var oldElem = dataArray[i].element;
    + var id = dataArray[i].id;
    + var newElem = id == null ? document.body : document.getElementById(id);
    + for (var j = 0, jsize = listeners.length;j < jsize;++j)
    + {
    + var currListener = listeners[j];
    + var currInstance = listeners[++j];
    + if (currInstance != null)
    + {
    + currListener.call(currInstance, oldElem, newElem);
    + }
    + else
    + {
    + currListener(oldElem, newElem);
    + }
    + }
    + }
    +}
    +
    +TrPage.prototype._getDomToBeUpdated = function (status, responseXML)
    +{
    + // check for a successful request
    + if (status < 200 || status >= 300)
    + {
    + return null;
    + }
    + // see if the response contains changes (not a redirect for example)
    + var nodes = responseXML.getElementsByTagName("partial-response");
    + var responseTypeNode = nodes.length ? nodes[0].firstChild : null;
    + if (!responseTypeNode || responseTypeNode.nodeName !== "changes")
    + {
    + return null;
    + }
    +
    + var changeNodes = responseTypeNode.childNodes;
    + var oldElements = [];
    + for (var i = 0, size = changeNodes.length;i < size;++i)
    + {
    + var node = changeNodes[i];
    + if (node.nodeName !== "update")
    + {
    + // We only care about updates as that is what Trinidad supported for the DOM
    + // replacement notification API
    + continue;
    + }
    +
    + var id = node.getAttribute("id");
    + if (id == TrPage._VIEW_STATE_ID)
    + {
    + continue;
    + }
    + if (id == "javax.faces.ViewRoot" || id == "javax.faces.ViewBody")
    + {
    + oldElements.push(
    + {
    + "id" : null, "element" : document.body
    + });
    + }
    + else
    + {
    + oldElements.push(
    + {
    + "id" : id, "element" : document.getElementById(id)
    + });
    + }
    + }
    +
    + return oldElements;
    +}
    \ No newline at end of file

    Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/xhr/IFrameXMLRequestEvent.js
    URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/xhr/IFrameXMLRequestEvent.js?rev=936035&r1=936034&r2=936035&view=diff
    ==============================================================================
    --- myfaces/trinidad/trunk/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/xhr/IFrameXMLRequestEvent.js (original)
    +++ myfaces/trinidad/trunk/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/xhr/IFrameXMLRequestEvent.js Tue Apr 20 19:19:36 2010
    @@ -24,11 +24,24 @@
    * @ see TrXMLRequestEvent
    */
    function TrIFrameXMLRequestEvent(
    - iframeDoc)
    + iframeDoc,
    + source,
    + formId)
    {
    this._iframeDoc = iframeDoc;
    + this._source = source;
    + this._formId = formId;
    }

    +TrIFrameXMLRequestEvent.prototype.getSource = function()
    +{
    + return this._source;
    +}
    +
    +TrIFrameXMLRequestEvent.prototype.getFormId = function()
    +{
    + return this._formId;
    +}

    TrIFrameXMLRequestEvent.prototype.getStatus = function()
    {
    @@ -45,13 +58,12 @@ TrIFrameXMLRequestEvent.prototype.getRes
    {
    var agentIsIE = _agent.isIE;
    var iframeDoc = this._iframeDoc;
    - if(agentIsIE && iframeDoc.XMLDocument)
    + if (agentIsIE && iframeDoc.XMLDocument)
    return iframeDoc.XMLDocument;
    else
    return iframeDoc;
    }

    -
    /**
    * Returns the response of the Data Transfer Request as text.
    * NOTE: this method is valid only for TrXMLRequestEvent.STATUS_COMPLETE
    @@ -90,9 +102,9 @@ TrIFrameXMLRequestEvent.prototype._isRes
    var agentIsIE = _agent.isIE;
    var iframeDoc = this._iframeDoc;

    - if(agentIsIE && iframeDoc.XMLDocument)
    + if (agentIsIE && iframeDoc.XMLDocument)
    return true;
    - else if(window.XMLDocument && (iframeDoc instanceof XMLDocument))
    + else if (window.XMLDocument && (iframeDoc instanceof XMLDocument))
    return true;
    else if (_agent.isSafari && iframeDoc.xmlVersion != null)
    return true;
    @@ -125,12 +137,12 @@ TrIFrameXMLRequestEvent.prototype.isPprR
    {
    var xmlDocument = iframeDoc.XMLDocument, childNodes = xmlDocument.childNodes;
    // In IE the xml PI is the first node
    - if(childNodes.length >= 2 && childNodes[1].nodeName == "Tr-XHR-Response-Type")
    + if(childNodes.length >= 2 && childNodes[1].nodeName == "partial-response")
    pprResponse = true;
    }
    else
    {
    - if(iframeDoc.firstChild && iframeDoc.firstChild.nodeName == "Tr-XHR-Response-Type")
    + if (iframeDoc.firstChild && iframeDoc.firstChild.nodeName == "partial-response")
    pprResponse = true;
    }

    @@ -147,4 +159,12 @@ TrIFrameXMLRequestEvent.prototype.getRes
    return "text/xml";

    return "text/html";
    -}
    \ No newline at end of file
    +}
    +
    +/**
    + * Returns if the request was made by the built in JSF AJAX APIs
    + */
    +TrIFrameXMLRequestEvent.prototype.isJsfAjaxRequest = function()
    +{
    + return false;
    +};

    Modified: myfaces/trinidad/trunk/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/xhr/RequestQueue.js
    URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/xhr/RequestQueue.js?rev=936035&r1=936034&r2=936035&view=diff
    ==============================================================================
    --- myfaces/trinidad/trunk/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/xhr/RequestQueue.js (original)
    +++ myfaces/trinidad/trunk/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/xhr/RequestQueue.js Tue Apr 20 19:19:36 2010
    @@ -31,6 +31,7 @@ function TrRequestQueue(domWindow)

    // Stash away the DOM window for later reference.
    this._window = domWindow;
    + this._useJsfBuiltInAjaxForXhr = (_agent.useJsfAjax && typeof jsf != "undefined");
    }

    // Class constants
    @@ -57,7 +58,10 @@ TrRequestQueue._RequestItem = function(
    actionURL,
    headerParams,
    content,
    - method
    + method,
    + event,
    + source,
    + formId
    )
    {
    this._type = type;
    @@ -66,6 +70,9 @@ TrRequestQueue._RequestItem = function(
    this._headerParams = headerParams;
    this._content = content;
    this._method = method;
    + this._event = event;
    + this._source = source;
    + this._formId = formId;
    }

    TrRequestQueue.prototype._broadcastRequestStatusChanged = function(
    @@ -92,18 +99,34 @@ TrRequestQueue.prototype._addRequestToQu
    listener,
    actionURL,
    content,
    - headerParams
    + headerParams,
    + event,
    + source,
    + formId
    )
    {
    var newRequest = new TrRequestQueue._RequestItem(
    - type, context, actionURL, headerParams, content, listener);
    + type, context, actionURL, headerParams, content,
    + listener, event, source, formId);
    +
    + if (this._useJsfBuiltInAjaxForXhr && type == TrRequestQueue._XMLHTTP_TYPE)
    + {
    + // Since JSF 2 already has a queue, we need not queue the request here, instead we should
    + // immediately process the request
    + this._state = TrRequestQueue.STATE_BUSY;
    + this._broadcastStateChangeEvent(TrRequestQueue.STATE_BUSY);
    + this._doXmlHttpRequest(newRequest);
    + return;
    + }
    +
    this._requestQueue.push(newRequest);

    try
    {
    var dtsRequestEvent = new TrXMLRequestEvent(
    TrXMLRequestEvent.STATUS_QUEUED,
    - null); // no xmlhttp object at this time
    + null, // no xmlhttp object at this time
    + source);

    this._broadcastRequestStatusChanged(context, listener, dtsRequestEvent);
    }
    @@ -131,7 +154,8 @@ TrRequestQueue.prototype.sendFormPost =
    method,
    actionForm,
    params,
    - headerParams
    + headerParams,
    + event
    )
    {
    //this retrieves the action url for PPR. Generally this will be the action property on
    @@ -145,9 +169,7 @@ TrRequestQueue.prototype.sendFormPost =
    {
    pprURL = actionForm.getAttribute("_trinPPRAction");
    }
    - catch (e)
    - {
    - }
    + catch (e) { ; }
    var action = pprURL?pprURL:actionForm.action;

    if (this._isMultipartForm(actionForm))
    @@ -158,13 +180,26 @@ TrRequestQueue.prototype.sendFormPost =
    }
    else
    {
    - var content = this._getPostbackContent(actionForm, params);
    -
    // IE BUG, see TRINIDAD-704
    if(_agent.isIE)
    this._autoCompleteForm(actionForm);

    - this.sendRequest(context, method, action, content, headerParams);
    + if (this._useJsfBuiltInAjaxForXhr)
    + {
    + // JSF 2 AJAX will take the parameters and it will determine the form
    + // content itself, so we should not convert the data to a string or
    + // gather the form values
    + // TODO: log a warning if we're dropping any headers? Or
    + // come up with a hack to send "headers" via a multipart request?
    + this.sendRequest(context, method, action, params, headerParams, event,
    + params ? params.source : null, actionForm.id);
    + }
    + else
    + {
    + var content = this._getPostbackContent(actionForm, params);
    + this.sendRequest(context, method, action, content, headerParams, event,
    + params ? params.source : null, actionForm.id);
    +}
    }
    }

    @@ -349,22 +384,29 @@ TrRequestQueue._appendUrlFormEncoded = f

    /**
    * Performs Asynchronous XML HTTP Request with the Server
    -* @param context any object that is sent back to the callback when the request
    +* @param context Any object that is sent back to the callback when the request
    * is complete. This object can be null.
    * @param method Javascript method
    -* @param actionURL the url to send the request to
    +* @param actionURL The url to send the request to
    * @param headerParams Option HTTP header parameters to attach to the request
    -* @param content the content of the Asynchronous XML HTTP Post
    +* @param content The content of the Asynchronous XML HTTP Post
    +* @param event The browser event that triggered the request, if any
    +* @param source The ID of the source element for the request
    +* @param formId The ID of the form element
    */
    TrRequestQueue.prototype.sendRequest = function(
    context,
    method,
    actionURL,
    content,
    - headerParams
    + headerParams,
    + event,
    + source,
    + formId
    )
    {
    - this._addRequestToQueue(TrRequestQueue._XMLHTTP_TYPE, context, method, actionURL, content, headerParams);
    + this._addRequestToQueue(TrRequestQueue._XMLHTTP_TYPE, context, method, actionURL, content,
    + headerParams, event, source, formId);
    }

    /**
    @@ -388,10 +430,10 @@ TrRequestQueue.prototype.sendMultipartRe
    var privateContext =
    {"htmlForm":htmlForm, "params": params, "context": context, "method": method};

    - this._addRequestToQueue(TrRequestQueue._MULTIPART_TYPE, privateContext, null, actionURL);
    + this._addRequestToQueue(TrRequestQueue._MULTIPART_TYPE, privateContext, null, actionURL,
    + params ? params.source : null, htmlForm.id);
    }

    -
    TrRequestQueue.prototype._doRequest = function()
    {
    // currently we are posting only one request at a time. In future we may batch
    @@ -411,12 +453,26 @@ TrRequestQueue.prototype._doRequest = fu

    TrRequestQueue.prototype._doXmlHttpRequest = function(requestItem)
    {
    - var xmlHttp = new TrXMLRequest();
    + var xmlHttp;
    + if (this._useJsfBuiltInAjaxForXhr)
    + {
    + xmlHttp = new TrXMLJsfAjaxRequest(requestItem._event, requestItem._content);
    + }
    + else
    + {
    + xmlHttp = new TrXMLRequest();
    + }
    +
    xmlHttp.__dtsRequestContext = requestItem._context;
    xmlHttp.__dtsRequestMethod = requestItem._method;
    + xmlHttp.__dtsRequestSource = requestItem._source;
    + xmlHttp.__dtsRequestFormId = requestItem._formId;
    +
    var callback = TrUIUtils.createCallback(this, this._handleRequestCallback);
    xmlHttp.setCallback(callback);

    + if (!this._useJsfBuiltInAjaxForXhr)
    + {
    // xmlhttp request uses the same charset as its parent document's charset.
    // There is no need to set the charset.
    xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    @@ -437,6 +493,7 @@ TrRequestQueue.prototype._doXmlHttpReque
    xmlHttp.setRequestHeader(headerName, currHeader);
    }
    }
    + }

    xmlHttp.send(requestItem._actionURL, requestItem._content);
    }
    @@ -488,9 +545,12 @@ TrRequestQueue.prototype._doRequestThrou
    iframeDoc.removeChild(iframeDoc.firstChild);

    // store our context variables for later use
    + this._source = requestItem.params ?
    + requestItem.params["javax.faces.source"] || requestItem.params["source"] : null;
    this._dtsContext = requestItem._context.context;
    this._dtsRequestMethod = requestItem._context.method;
    this._htmlForm = htmlForm;
    + this._dtsSource = requestItem._source;
    this._savedActionUrl = htmlForm.action;
    this._savedTarget = htmlForm.target;

    @@ -503,13 +563,17 @@ TrRequestQueue.prototype._doRequestThrou
    htmlForm.target = frameName;

    this._appendParamNode(domDocument, htmlForm, "Tr-XHR-Message", "true");
    - //this._appendParamNode(domDocument, htmlForm, "partial", "true");
    +
    + // mstarets - not including jsf ajax parameter will let the server know that
    + // this is a 'legacy' PPR request
    + // this._appendParamNode(domDocument, htmlForm, "javax.faces.partial.ajax", "true");

    if(params)
    {
    for (var key in params)
    {
    - this._appendParamNode(domDocument, htmlForm, key, params[key]);
    + var paramValue = params[key];
    + this._appendParamNode(domDocument, htmlForm, key, paramValue);
    }
    }

    @@ -662,7 +726,9 @@ TrRequestQueue.prototype._onIFrameLoadCo
    try
    {
    var dtsRequestEvent = new TrIFrameXMLRequestEvent(
    - iframeDoc);
    + iframeDoc,
    + this._dtsSource,
    + this._htmlForm.id);

    this._broadcastRequestStatusChanged(context, requestMethod,dtsRequestEvent);
    }
    @@ -673,6 +739,7 @@ TrRequestQueue.prototype._onIFrameLoadCo
    iframeDoc.removeChild(iframeDoc.firstChild);
    this._htmlForm.action = this._savedActionUrl;
    this._htmlForm.target = this._savedTarget;
    + delete this._dtsSource;
    //clear the parameter nodes
    this._clearParamNodes();
    this._requestDone();
    @@ -702,7 +769,7 @@ TrRequestQueue.prototype._handleRequestC
    // the Http connection has been closed
    }

    - if ((statusCode != 200) && (statusCode != 0))
    + if ((statusCode < 200 || statusCode >= 300) && (statusCode != 0))
    {
    TrRequestQueue._alertError();
    TrRequestQueue._logError("Error StatusCode(",
    @@ -717,7 +784,9 @@ TrRequestQueue.prototype._handleRequestC
    {
    var dtsRequestEvent = new TrXMLRequestEvent(
    TrXMLRequestEvent.STATUS_COMPLETE,
    - xmlHttp);
    + xmlHttp,
    + xmlHttp.__dtsRequestSource,
    + xmlHttp.__dtsRequestFormId);
    this._broadcastRequestStatusChanged(
    xmlHttp.__dtsRequestContext,
    xmlHttp.__dtsRequestMethod,
    @@ -823,6 +892,16 @@ TrRequestQueue.prototype.getDTSState = f
    return this._state;
    }

    +TrRequestQueue.prototype.__useJsfBuiltInAjaxForXhr = function()
    +{
    + return this._useJsfBuiltInAjaxForXhr;
    +}
    +
    +TrRequestQueue.prototype.__disableJsfBuiltInAjaxForXhr = function()
    +{
    + this._useJsfBuiltInAjaxForXhr = false;
    +}
    +
    /**
    * broadcast the state change of the request queue to its listeners
    */
    @@ -888,6 +967,9 @@ TrRequestQueue._logWarning = function(va
    TrRequestQueue._logError = function(varArgs)
    {
    if (window.console && console.error)
    + {
    console.error(arguments);
    + }
    +
    // else???
    -}
    +}
    \ No newline at end of file

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcommits @
categoriesmyfaces
postedApr 20, '10 at 7:20p
activeApr 20, '10 at 7:20p
posts2
users1
websitemyfaces.apache.org

1 user in discussion

Arobinson74: 2 posts

People

Translate

site design / logo © 2019 Grokbase