You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ms...@apache.org on 2010/03/27 01:20:04 UTC
svn commit: r928111 - in /myfaces/trinidad/branches/jsf2_ajax.3:
trinidad-api/src/main/java/org/apache/myfaces/trinidad/render/
trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/
trinidad-impl/src/main/java/org/apache/myfaces/trin...
Author: mstarets
Date: Sat Mar 27 00:20:04 2010
New Revision: 928111
URL: http://svn.apache.org/viewvc?rev=928111&view=rev
Log:
Wired up legacy and f:ajax support in PartialViewContextImpl and PPRResponseWriter
Modified:
myfaces/trinidad/branches/jsf2_ajax.3/trinidad-api/src/main/java/org/apache/myfaces/trinidad/render/CoreRenderer.java
myfaces/trinidad/branches/jsf2_ajax.3/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/PartialViewContextImpl.java
myfaces/trinidad/branches/jsf2_ajax.3/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextImpl.java
myfaces/trinidad/branches/jsf2_ajax.3/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/CoreRenderKit.java
myfaces/trinidad/branches/jsf2_ajax.3/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/ppr/PPRResponseWriter.java
myfaces/trinidad/branches/jsf2_ajax.3/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/ppr/ScriptBufferingResponseWriter.java
myfaces/trinidad/branches/jsf2_ajax.3/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/CommandLinkRenderer.java
myfaces/trinidad/branches/jsf2_ajax.3/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/FormRenderer.java
myfaces/trinidad/branches/jsf2_ajax.3/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/PartialPageUtils.java
myfaces/trinidad/branches/jsf2_ajax.3/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Page.js
myfaces/trinidad/branches/jsf2_ajax.3/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/xhr/RequestQueue.js
myfaces/trinidad/branches/jsf2_ajax.3/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/xhr/XMLRequest.js
Modified: myfaces/trinidad/branches/jsf2_ajax.3/trinidad-api/src/main/java/org/apache/myfaces/trinidad/render/CoreRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/jsf2_ajax.3/trinidad-api/src/main/java/org/apache/myfaces/trinidad/render/CoreRenderer.java?rev=928111&r1=928110&r2=928111&view=diff
==============================================================================
--- myfaces/trinidad/branches/jsf2_ajax.3/trinidad-api/src/main/java/org/apache/myfaces/trinidad/render/CoreRenderer.java (original)
+++ myfaces/trinidad/branches/jsf2_ajax.3/trinidad-api/src/main/java/org/apache/myfaces/trinidad/render/CoreRenderer.java Sat Mar 27 00:20:04 2010
@@ -944,7 +944,7 @@ public class CoreRenderer extends Render
// Does the component have behaviors for this event type?
List<ClientBehavior> behaviors = bean.getClientBehaviors().get(event);
- if (behaviors.isEmpty())
+ if (behaviors == null || behaviors.isEmpty())
{
return null;
}
Modified: myfaces/trinidad/branches/jsf2_ajax.3/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/PartialViewContextImpl.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/jsf2_ajax.3/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/PartialViewContextImpl.java?rev=928111&r1=928110&r2=928111&view=diff
==============================================================================
--- myfaces/trinidad/branches/jsf2_ajax.3/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/PartialViewContextImpl.java (original)
+++ myfaces/trinidad/branches/jsf2_ajax.3/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/PartialViewContextImpl.java Sat Mar 27 00:20:04 2010
@@ -20,16 +20,18 @@ package org.apache.myfaces.trinidadinter
import java.io.IOException;
-import java.util.ArrayList;
+import java.io.Writer;
+
import java.util.Collection;
import java.util.Collections;
import java.util.EnumSet;
+import java.util.HashSet;
import java.util.Iterator;
-import java.util.List;
import java.util.Set;
+
import javax.faces.FacesException;
import javax.faces.component.UIComponent;
import javax.faces.component.UIViewRoot;
@@ -41,6 +43,7 @@ import javax.faces.context.ResponseWrite
import javax.faces.event.PhaseId;
import org.apache.myfaces.trinidad.component.UIXComponent;
+
import javax.faces.component.visit.VisitCallback;
import javax.faces.component.visit.VisitContext;
import javax.faces.component.visit.VisitHint;
@@ -49,15 +52,34 @@ import javax.faces.component.visit.Visit
import org.apache.myfaces.trinidad.component.visit.VisitTreeUtils;
import org.apache.myfaces.trinidad.context.PartialPageContext;
import org.apache.myfaces.trinidad.context.RenderingContext;
-import org.apache.myfaces.trinidad.context.RequestContext;
+import org.apache.myfaces.trinidad.logging.TrinidadLogger;
import org.apache.myfaces.trinidadinternal.renderkit.core.ppr.PPRResponseWriter;
import org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.PartialPageUtils;
+import org.apache.myfaces.trinidadinternal.renderkit.core.CoreRenderKit;
-public class PartialViewContextImpl extends PartialViewContext
+public class PartialViewContextImpl
+ extends PartialViewContext
{
- public PartialViewContextImpl(FacesContext context)
+ public PartialViewContextImpl(FacesContext context)
{
_context = context;
+
+ ExternalContext extContext = context.getExternalContext();
+
+ _requestType = ReqType.FULL;
+
+ if (_PARTIAL_AJAX.equals(extContext.getRequestHeaderMap().get(_FACES_REQUEST)))
+ {
+ // This request was sent with jsf.ajax.request()
+ if (extContext.getRequestParameterMap().get(_TRINIDAD_PPR) != null)
+ _requestType = ReqType.AJAX_LEGACY;
+ else
+ _requestType = ReqType.AJAX;
+ }
+ else if (CoreRenderKit.isPartialRequest(extContext))
+ {
+ _requestType = ReqType.AJAX_LEGACY;
+ }
}
/**
@@ -66,86 +88,154 @@ public class PartialViewContextImpl exte
*/
public Collection<String> getExecuteIds()
{
- /*
- if (_executeIds == null)
- {
- String executeStr = _facesContext.getExternalContext().getRequestParameterMap().get(
- PartialViewContext.PARTIAL_EXECUTE_PARAM_NAME);
- }
- else
+ _assertNotReleased();
+ if (_executeIds == null)
{
- _executeIds = new ArrayList<String>();
+ _executeIds = _getIds(PARTIAL_EXECUTE_PARAM_NAME);
+
+ // force view parameter facet ID to be executed if we are executing anything else
+ if (!_executeIds.isEmpty())
+ {
+ UIViewRoot root = _context.getViewRoot();
+ if (root.getFacetCount() > 0)
+ {
+ UIComponent facet =
+ root.getFacet(UIViewRoot.METADATA_FACET_NAME);
+ if (facet != null)
+ {
+ _executeIds.add(facet.getClientId(_context));
+ }
+ }
+ }
}
- */
- _executeIds = new ArrayList<String>();
+
return _executeIds;
}
public Collection<String> getRenderIds()
{
- return Collections.emptySet();
- }
-
- /**
- * Return a PartialResponseWriter that consumes the Trinidad PprResponseWriter.
- * @return
- */
- public PartialResponseWriter getPartialResponseWriter()
- {
- if (_partialResponseWriter == null)
+ _assertNotReleased();
+ if (_renderIds == null)
{
- _partialResponseWriter = new PPRPartialResponseWriter(_context.getResponseWriter());
+ _renderIds = _getIds(PARTIAL_RENDER_PARAM_NAME);
}
- return _partialResponseWriter;
+ return _renderIds;
}
+
public boolean isAjaxRequest()
{
_assertNotReleased();
- if (_ajaxRequest == null)
- {
- _ajaxRequest = _PARTIAL_AJAX.equals(_context.
- getExternalContext().getRequestHeaderMap().get(_FACES_REQUEST));
- }
- return _ajaxRequest;
+ return (_requestType != ReqType.FULL);
}
public boolean isPartialRequest()
{
_assertNotReleased();
- if (_partialRequest == null) {
- _partialRequest = isAjaxRequest() ||
- _PARTIAL_PROCESS.equals(_context.
- getExternalContext().getRequestHeaderMap().get(_FACES_REQUEST));
+ if (_partialRequest == null)
+ {
+ _partialRequest =
+ isAjaxRequest() || _PARTIAL_PROCESS.equals(_context.getExternalContext().getRequestHeaderMap().get(_FACES_REQUEST));
}
- return _partialRequest;
+ return _partialRequest;
}
- /**
- * Trinidad PPR currently does a full decode/validate/update. So we return 'false' here, but in
- * processPartial, turn into a 'full tree visit'.
- * @return true as the default executeList is set to be '@all'.
- */
+ @Override
public boolean isExecuteAll()
{
_assertNotReleased();
- /*String execute = _context.getExternalContext().getRequestParameterMap()
- .get(PARTIAL_EXECUTE_PARAM_NAME);
-
- return execute.equals(this.ALL_PARTIAL_PHASE_CLIENT_IDS);*/
- return true;
+ if (_requestType == ReqType.AJAX_LEGACY ||
+ _requestType == ReqType.LEGACY)
+ {
+ // We are preserving old behavior (execute everything) for the legacy 'partialSubmit=true'
+ // Trinidad requests
+ return true;
+ }
+
+ String execute =
+ _context.getExternalContext().getRequestParameterMap().get(PARTIAL_EXECUTE_PARAM_NAME);
+
+ return execute.equals(ALL_PARTIAL_PHASE_CLIENT_IDS);
}
public boolean isRenderAll()
{
_assertNotReleased();
- if (_renderAll == null) {
- String render = _context.getExternalContext().getRequestParameterMap()
- .get(PARTIAL_RENDER_PARAM_NAME);
- _renderAll = (ALL_PARTIAL_PHASE_CLIENT_IDS.equals(render));
+ if (_renderAll == null)
+ {
+ String render =
+ _context.getExternalContext().getRequestParameterMap().get(PARTIAL_RENDER_PARAM_NAME);
+ _renderAll = ALL_PARTIAL_PHASE_CLIENT_IDS.equals(render);
+ }
+
+ return _renderAll;
+ }
+
+ @Override
+ public void processPartial(PhaseId phaseId)
+ {
+ UIViewRoot viewRoot = _context.getViewRoot();
+ if (phaseId == PhaseId.APPLY_REQUEST_VALUES ||
+ phaseId == PhaseId.PROCESS_VALIDATIONS ||
+ phaseId == PhaseId.UPDATE_MODEL_VALUES)
+ {
+ _processExecute(viewRoot, phaseId);
+ }
+ else if (phaseId == PhaseId.RENDER_RESPONSE)
+ {
+ _processRender(viewRoot, phaseId);
}
- return _renderAll;
+ }
+
+ @Override
+ public PartialResponseWriter getPartialResponseWriter()
+ {
+ ResponseWriter current = _context.getResponseWriter();
+ if (current != null && current instanceof PartialResponseWriter)
+ {
+ return (PartialResponseWriter)current;
+ }
+
+ if (_context.getCurrentPhaseId() == PhaseId.RENDER_RESPONSE)
+ {
+ _LOG.warning("getPartialResponseWriter() called during render_reponse. " +
+ "The returned writer is not integrated with PPRResponseWriter");
+ ResponseWriter rw = _context.getResponseWriter();
+
+ return new PartialResponseWriter(rw);
+ }
+
+ // Create PartialResponseWriter for sending errors, redirects, etc. outside
+ // of the render phase
+
+ if (current != null)
+ {
+ return new PartialResponseWriter(current);
+ }
+
+ ExternalContext extContext = _context.getExternalContext();
+ String encoding = "UTF-8";
+ extContext.setResponseCharacterEncoding(encoding);
+ Writer out = null;
+ try
+ {
+ out = extContext.getResponseOutputWriter();
+ }
+ catch (IOException ioe)
+ {
+ _LOG.severe(ioe.toString(), ioe);
+ }
+
+ if (out != null)
+ {
+ ResponseWriter responseWriter =
+ _context.getRenderKit().createResponseWriter(out, "text/xml",
+ encoding);
+ return new PartialResponseWriter(responseWriter);
+ }
+
+ return null;
}
public void setRenderAll(boolean renderAll)
@@ -160,298 +250,255 @@ public class PartialViewContextImpl exte
public void release()
{
- _ajaxRequest = null;
_executeIds = null;
_context = null;
_partialRequest = null;
- _partialResponseWriter = null;
_released = true;
_renderAll = null;
_renderIds = null;
}
- /**
- * Handles the render phase alone as we perform a full 'execute' always.
- *
- * @param phaseId
- */
- public void processPartial(PhaseId phaseId)
- {
- UIViewRoot viewRoot = _context.getViewRoot();
- if (phaseId == PhaseId.APPLY_REQUEST_VALUES ||
- phaseId == PhaseId.PROCESS_VALIDATIONS ||
- phaseId == PhaseId.UPDATE_MODEL_VALUES)
- {
- // Assume the executeIds is set to @all to mimic a full tree visit.
- // Create a FullVisitContext
- Collection <String> executeIds = getExecuteIds();
-
- try
- {
- _processExecute(viewRoot, phaseId, executeIds);
- }
- catch (Exception e)
- {
- // RELEASE_PENDING LOG EXCEPTION
- }
-
- }
- else if (phaseId == PhaseId.RENDER_RESPONSE)
- {
- _processRender(viewRoot, phaseId);
- }
-
- }
-
- /**
- * Performs a 'full' execute if executeIds is empty, in order to build the partialTrigger
- * listeners. Later, support for an 'optimized execute' will be added that 'visits' the executeId
- * components using the Trinidad visitTree implementation (that accounts for setup/teardown of
- * contexts.)
- * @param component the UIViewRoot
- * @param phaseId
- * @param executeIds the Collection of ids to execute
- */
- private void _processExecute(
- UIViewRoot component,
- PhaseId phaseId,
- Collection<String> executeIds)
+ private void _processExecute(UIViewRoot component, PhaseId phaseId)
{
+ // We are only handling visit-based (partial) execution here.
+ // Full execution (isExecuteAll() == true) is handled by the UIViewRoot
+ // Note that this is different from the render phase
+
+ Collection<String> executeIds = getExecuteIds();
if (executeIds == null || executeIds.isEmpty())
{
- // We use the tree visitor mechanism to locate the components to process. For now we ignore the
- // executeIds as we always want to perform a full decode. So a FullVisitContext is created and
- // the VisitCallback invoked for every component in the tree.
- VisitContext visitContext =
- VisitTreeUtils.createVisitContext(_context,
- executeIds,
- _EXECUTE_VISIT_HINTS);
- VisitCallback visitCallback = new ExecuteAllCallback(_context, phaseId);
- UIXComponent.visitTree(visitContext, component, visitCallback);
- }
- else
- {
- // TODO: optimized decode??
+ _LOG.warning("No execute Ids were supplied for the Ajax request");
+ return;
}
+
+ VisitContext visitContext = VisitTreeUtils.createVisitContext(_context, executeIds,
+ EnumSet.of(VisitHint.SKIP_UNRENDERED, VisitHint.EXECUTE_LIFECYCLE));
+ VisitCallback visitCallback = new ProcessPhaseCallback(_context, phaseId);
+
+ component.visitTree(visitContext, visitCallback);
}
- /**
- * Performs a partial optimized rendering, if PPROptimization is enabled, otherwise defaults to a
- * full render.
- *
- * @param viewRoot
- * @param phaseId
- */
+
private void _processRender(UIComponent viewRoot, PhaseId phaseId)
{
- boolean documentStarted = false;
-
- PartialResponseWriter partialResponseWriter = getPartialResponseWriter();
- // Hold onto the original writer for later
- ResponseWriter origResponseWriter = _context.getResponseWriter();
- _context.setResponseWriter(partialResponseWriter);
-
ExternalContext extContext = _context.getExternalContext();
extContext.setResponseContentType(_RESPONSE_CONTENT_TYPE);
extContext.addResponseHeader("Pragma", "no-cache");
extContext.addResponseHeader("Cache-control", "no-cache");
- try
+ if (isRenderAll())
{
- partialResponseWriter.startDocument();
- documentStarted = true;
+ _renderAll(_context, viewRoot);
+ return;
+ }
+
+ ResponseWriter origResponseWriter = _context.getResponseWriter();
+
+ RenderingContext rc = RenderingContext.getCurrentInstance();
+ assert (rc != null);
+
+ boolean bufferScripts = _requestType == ReqType.LEGACY;
+ PPRResponseWriter pprWriter =
+ new PPRResponseWriter(origResponseWriter, rc, bufferScripts);
+
+ _context.setResponseWriter(pprWriter);
- // determine whether we should try and optimize the PPR rendering
- boolean encodeAllChildren = !PartialPageUtils.isOptimizedPPREnabled(_context, true);
+ if (_requestType == ReqType.AJAX)
+ {
+ // Add render Ids as partial targets for the request from <f:ajax>
+ _addRenderIdsAsPartialTargets(rc);
- if (encodeAllChildren)
- {
- // We are guaranteed to be called on UIViewRoot.
- if (!viewRoot.isRendered())
- {
- return;
- }
+ // Force visit-based rendering for the <f:ajax> requests
+ PartialPageUtils.forceOptimizedPPR(_context);
+ }
+
+ try
+ {
+ pprWriter.startDocument();
+
+ // Note that PanelPartialRootRenderer will perform partial visit for the optimized PPR
+ // if it is enabled
+ _renderChildren(_context, viewRoot);
- // No PPR optimization, so encode all children
- Iterator<UIComponent> children = viewRoot.getFacetsAndChildren();
- while (children.hasNext())
- {
- children.next().encodeAll(_context);
- }
-
- // TODO: Explcitly render out the view state as an update element.
- _renderViewState(partialResponseWriter);
- }
- else
- {
- // TODO
- // HINT: PartialPageContext already creates a partial visit context. Reuse it??
-
- // Only visit tree if renderIds exist
- Collection <String> renderIds = getRenderIds();
- if (renderIds != null && !renderIds.isEmpty())
- {
- // perform an optimized partial visit of the children
- RenderingContext rContext = RenderingContext.getCurrentInstance();
- PartialPageContext pprContext = rContext.getPartialPageContext();
-
- VisitContext visitContext = pprContext.getVisitContext();
- // component.visitTree(visitContext, new PhaseAwareVisitCallback(_context, phaseId));
- }
- }
+ // Always write out ViewState as a separate update element.
+ String state =
+ _context.getApplication().getStateManager().getViewState(_context);
+ pprWriter.writeViewState(state);
+
+ pprWriter.endDocument();
}
catch (IOException e)
{
// launder the IOException as a FacesException, we'll unwrap this later
- throw new FacesException(e);
+ throw new FacesException(e);
}
finally
{
- try
- {
- if (documentStarted)
- {
- partialResponseWriter.endDocument();
- documentStarted = false;
- }
- }
- catch (IOException ioe2)
- {
- // TODO log exception
- }
_context.setResponseWriter(origResponseWriter);
}
}
- private void _renderViewState(PartialResponseWriter writer)
- throws IOException
+ private void _renderAll(FacesContext context, UIComponent viewRoot)
{
- // Get the view state and write it to the response..
- writer.startUpdate(PartialResponseWriter.VIEW_STATE_MARKER);
- String state = _context.getApplication().getStateManager().getViewState(_context);
- writer.write(state);
- writer.endUpdate();
+ ResponseWriter origResponseWriter = context.getResponseWriter();
+
+ // Use JSF-supplied PartialResponseWriter, since we are rendering the full page
+ PartialResponseWriter rw = new PartialResponseWriter(origResponseWriter);
+
+ context.setResponseWriter(rw);
+
+ try
+ {
+ rw.startDocument();
+
+ rw.startUpdate(PartialResponseWriter.RENDER_ALL_MARKER);
+ _renderChildren(context, viewRoot);
+ rw.endUpdate();
+
+ //write out JSF state
+ rw.startUpdate(PartialResponseWriter.VIEW_STATE_MARKER);
+ String state = context.getApplication().getStateManager().getViewState(context);
+ rw.write(state);
+ rw.endUpdate();
+
+ rw.endDocument();
+ }
+ catch(IOException e)
+ {
+ throw new FacesException(e);
+ }
+ finally
+ {
+ context.setResponseWriter(origResponseWriter);
+ }
}
- @SuppressWarnings({"FinalPrivateMethod"})
- private final void _assertNotReleased()
+ private void _addRenderIdsAsPartialTargets(RenderingContext rc)
{
- if (_released) {
- throw new IllegalStateException();
+ Collection<String> renderIds = getRenderIds();
+ PartialPageContext pc = rc.getPartialPageContext();
+ for (String id: renderIds)
+ {
+ pc.addPartialTarget(id);
}
}
-
-
-
-
- /**
- * A simple PartialRepsonseWriter implementation that delegates most of its calls to the
- * PPRResponseWriter as it already has the smarts to generate XML partial Ajax responses using the
- * Trinidad partialTriggers mechanism.
- */
- private static final class PPRPartialResponseWriter extends PartialResponseWriter
+
+
+ private static void _renderChildren(FacesContext context, UIComponent root) throws IOException
{
- public PPRPartialResponseWriter(ResponseWriter writer)
+ Iterator<UIComponent> iterator = root.getFacetsAndChildren();
+ while (iterator.hasNext())
{
- super(null);
- assert(writer instanceof PPRResponseWriter);
- _pprWriter = (PPRResponseWriter) writer;
+ UIComponent child = iterator.next();
+ if (child.isRendered())
+ child.encodeAll(context);
}
+ }
+
- @Override
- public void endDocument() throws IOException
- {
- getWrapped().endDocument();
- }
- @Override
- public ResponseWriter getWrapped()
+ @SuppressWarnings(
+ { "FinalPrivateMethod" })
+ private final void _assertNotReleased()
+ {
+ if (_released)
{
- return _pprWriter;
+ throw new IllegalStateException();
}
+ }
- @Override
- public void startDocument() throws IOException
+ private Set<String> _getIds(String parameter)
+ {
+ String param =
+ _context.getExternalContext().getRequestParameterMap().get(parameter);
+ if (param != null)
{
- getWrapped().startDocument();
+ String ids[] = param.split("[ \t]+");
+ if (ids != null && ids.length > 0)
+ {
+ HashSet<String> idSet = new HashSet<String>(ids.length);
+ for (int i = 0; i < ids.length; i++)
+ {
+ idSet.add(ids[i]);
+ }
+ return idSet;
+ }
}
+ return Collections.emptySet();
+ }
- @Override
- public void endUpdate()
- throws IOException
- {
- _pprWriter.endUpdate();
- }
-
- @Override
- public void startUpdate(String string) throws IOException
- {
- _pprWriter.startUpdate(string);
- }
- private PPRResponseWriter _pprWriter;
- }
- /**
- * Callback for encoding subtrees during optimized PPR tree visits
- */
- private static final class ExecuteAllCallback implements VisitCallback
+ private static final class ProcessPhaseCallback
+ implements VisitCallback
{
- public ExecuteAllCallback(
- FacesContext context,
- PhaseId phaseId)
+ ProcessPhaseCallback(FacesContext context, PhaseId phaseId)
{
- _context= context;
+ _context = context;
_phaseId = phaseId;
}
-
+
public VisitResult visit(VisitContext context, UIComponent target)
{
-
- // For UIViewRoot it's important to return VisitResult.ACCEPT to indicate that the tree
- // visit start processing its children. This is also required to not get into a recursive
- // hell as we got here to begin from UIViewRoot.processDecodes()
- if (target instanceof UIViewRoot)
- return VisitResult.ACCEPT;
-
- // we have the subtree we want, execute it
- if (_phaseId == PhaseId.APPLY_REQUEST_VALUES)
+ if (_phaseId == PhaseId.RENDER_RESPONSE)
+ {
+ try
+ {
+ target.encodeAll(_context);
+ }
+ catch(IOException e)
+ {
+ throw new FacesException(e);
+ }
+ }
+ else if (_phaseId == PhaseId.APPLY_REQUEST_VALUES)
{
target.processDecodes(_context);
- }
- else if (_phaseId == PhaseId.PROCESS_VALIDATIONS)
+ }
+ else if (_phaseId == PhaseId.PROCESS_VALIDATIONS)
{
target.processValidators(_context);
- }
- else if (_phaseId == PhaseId.UPDATE_MODEL_VALUES)
+ }
+ else if (_phaseId == PhaseId.UPDATE_MODEL_VALUES)
{
target.processUpdates(_context);
- }
+ }
+
- // we have finished processing desired target
+ // No need to visit children, since they will be executed/rendred by their parents
return VisitResult.REJECT;
}
-
+
private FacesContext _context;
- private PhaseId _phaseId;
- }
-
- private Boolean _ajaxRequest;
- private List<String> _executeIds;
- private FacesContext _context = null;
+ private PhaseId _phaseId;
+ }
+
+ private ReqType _requestType;
+ private Set<String> _executeIds;
+ private Set<String> _renderIds;
+ private FacesContext _context = null;
private Boolean _partialRequest;
- private PartialResponseWriter _partialResponseWriter;
private boolean _released;
private Boolean _renderAll;
- private Collection<String> _renderIds;
- private static final Set<VisitHint> _EXECUTE_VISIT_HINTS = EnumSet.of(VisitHint.SKIP_UNRENDERED,
- VisitHint.EXECUTE_LIFECYCLE);
-
+
private static final String _RESPONSE_CONTENT_TYPE = "text/xml";
private static final String _FACES_REQUEST = "Faces-Request";
private static final String _PARTIAL_AJAX = "partial/ajax";
private static final String _PARTIAL_PROCESS = "partial/process";
+ private static final String _TRINIDAD_PPR = "Tr-PPR-Message";
+
+
+ private static enum ReqType
+ {
+ FULL,
+ AJAX,
+ AJAX_LEGACY,
+ LEGACY;
+ }
+
+ private static final TrinidadLogger _LOG =
+ TrinidadLogger.createTrinidadLogger(PartialViewContextImpl.class);
}
Modified: myfaces/trinidad/branches/jsf2_ajax.3/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextImpl.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/jsf2_ajax.3/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextImpl.java?rev=928111&r1=928110&r2=928111&view=diff
==============================================================================
--- myfaces/trinidad/branches/jsf2_ajax.3/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextImpl.java (original)
+++ myfaces/trinidad/branches/jsf2_ajax.3/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/context/RequestContextImpl.java Sat Mar 27 00:20:04 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/branches/jsf2_ajax.3/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/CoreRenderKit.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/jsf2_ajax.3/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/CoreRenderKit.java?rev=928111&r1=928110&r2=928111&view=diff
==============================================================================
--- myfaces/trinidad/branches/jsf2_ajax.3/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/CoreRenderKit.java (original)
+++ myfaces/trinidad/branches/jsf2_ajax.3/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/CoreRenderKit.java Sat Mar 27 00:20:04 2010
@@ -143,23 +143,11 @@ public class CoreRenderKit extends Rende
return "org.apache.myfaces.trinidad.core.desktop";
}
- /**
- * Return <code>true</code> if the request header <code>Faces-Request</code> is present with the
- * value <code>partial/ajax</code>. Otherwise, return <code>false</code>.
- *
- * @param ec the ExternalContext instance.
- * @return
- */
static public boolean isAjaxRequest(ExternalContext ec)
{
- return _PARTIAL_AJAX.equals(ec.getRequestHeaderMap().get(_FACES_REQUEST_HEADER));
+ return "true".equals(ec.getRequestHeaderMap().get(_PPR_REQUEST_HEADER));
}
- /**
- * TODO: Use JSF2.0 <code>Faces-Request</code> parameter.
- * @param parameters
- * @return
- */
static public boolean isPartialRequest(Map<String, String[]> parameters)
{
String[] array = parameters.get(_PPR_REQUEST_HEADER);
@@ -168,11 +156,6 @@ public class CoreRenderKit extends Rende
return "true".equals(array[0]);
}
- /**
- * TODO: Use JSF2.0 <code>Faces-Request</code> parameter.
- * @param ec
- * @return
- */
static public boolean isPartialRequest(ExternalContext ec)
{
// A partial request could be an AJAX request, or it could
@@ -614,7 +597,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?
@@ -624,7 +610,7 @@ public class CoreRenderKit extends Rende
{
if (isPartialRequest(fContext.getExternalContext()))
rw = new PPRResponseWriter(rw, rc);
- }
+ }*/
return _addDebugResponseWriters(rw);
}
@@ -820,9 +806,6 @@ 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_HEADER = "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/branches/jsf2_ajax.3/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/ppr/PPRResponseWriter.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/jsf2_ajax.3/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/ppr/PPRResponseWriter.java?rev=928111&r1=928110&r2=928111&view=diff
==============================================================================
--- myfaces/trinidad/branches/jsf2_ajax.3/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/ppr/PPRResponseWriter.java (original)
+++ myfaces/trinidad/branches/jsf2_ajax.3/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/ppr/PPRResponseWriter.java Sat Mar 27 00:20:04 2010
@@ -51,18 +51,20 @@ import org.apache.myfaces.trinidadintern
* TODO: write out fragments only once we've detected the
* ID, to avoid sending unnecessary fragments
*/
-public class PPRResponseWriter extends ResponseWriterDecorator // ScriptBufferingResponseWriter
+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;
}
/**
@@ -71,11 +73,12 @@ public class PPRResponseWriter extends R
PPRResponseWriter(ResponseWriter out,
PPRResponseWriter base)
{
- super(out);
+ 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;
}
@@ -123,17 +126,6 @@ public class PPRResponseWriter extends R
// _xml.write("<?Tr-XHR-Response-Type ?>\n");
_xml.startElement(_ELEMENT_PARTIAL_RESPONSE, 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);
- }
// TODO: Portlet support for PPR?
// TODO: PS - Not sure why this extra space is being written out, but this causes an 'malformed
@@ -145,12 +137,15 @@ public class PPRResponseWriter extends R
public void endDocument() throws IOException
{
+ _writeFormActionScript();
+
// Write out any buffered <script src=""> or inline scripts
- // TODO: No need to write buffered scripts as we directly let script pass through
- // writeBufferedScripts();
+ if (_bufferScripts)
+ writeBufferedScripts();
// Write out all of the framework-level scripts
writeFrameworkScripts();
+
_endChanges();
_xml.endElement(_ELEMENT_PARTIAL_RESPONSE);
_xml.endDocument();
@@ -307,6 +302,17 @@ public class PPRResponseWriter extends R
}
}
+ public void writeViewState(String state) throws IOException
+ {
+ _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
@@ -318,48 +324,11 @@ public class PPRResponseWriter extends R
}
- public void endUpdate() throws IOException
- {
- super.flush();
-
- if (_state._allowedUpdateStarted)
- {
- _xml.write("]]>");
- _xml.endElement(_ELEMENT_CHANGES_UPDATE);
- _xml.flush();
- _state._allowedUpdateStarted = false;
- }
- }
-
-
- /**
- * Starts an update element for non-PPR based content. For e.g., for rendering out the
- * "javax.faces.ViewState" id.
- * @param id the id to use for the update element
- */
- public void startUpdate(String id) throws IOException
- {
- if (id != null && _allowedIds.contains(id))
- {
- _startChanges();
-
- if (!_state._allowedUpdateStarted)
- {
- _state._allowedUpdateStarted = true;
- _xml.startElement(_ELEMENT_CHANGES_UPDATE, null);
- _xml.writeAttribute(_ATTRIBUTE_ID, id, null);
- _xml.write("<![CDATA[");
- _xml.flush();
- }
- }
- }
-
/*
* Writes out buffered inline scripts and script libraries
*/
-
-/*
+
protected void writeBufferedScripts() throws IOException
{
List<String> libraries = getBufferedLibraries();
@@ -367,9 +336,10 @@ public class PPRResponseWriter extends R
{
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);
}
}
@@ -379,17 +349,16 @@ public class PPRResponseWriter extends R
for (String script : scripts)
{
_xml.startElement(_ELEMENT_EVAL, null);
- _xml.write("<![CDATA[");
+ _xml.startCDATA();
_xml.write(script);
- _xml.write("]]>");
+ _xml.endCDATA();
_xml.endElement(_ELEMENT_EVAL);
}
}
// Clear out any buffered scripts/libraries
clearBufferedContents();
- }
-*/
+ }
/*
* Writes out framework-level scripts
@@ -397,7 +366,34 @@ public class PPRResponseWriter extends R
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);
+ _xml.startCDATA();
+ }
+ }
+ public void endElement(String name) throws IOException
+ {
+ if ("script".equalsIgnoreCase(name))
+ {
+ _xml.endCDATA();
+ _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
@@ -413,6 +409,36 @@ public class PPRResponseWriter extends R
_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,
@@ -461,9 +487,7 @@ public class PPRResponseWriter extends R
// a partial target subtree. Otherwise, we discard all
// output.
return _state.forceInsideTarget ||
- _state.pprContext.isInsidePartialTarget() ||
- _state._allowedUpdateStarted;
-
+ _state.pprContext.isInsidePartialTarget();
}
@@ -648,13 +672,13 @@ public class PPRResponseWriter extends R
public boolean documentStarted;
public boolean documentStarting;
public boolean changesStarted;
- private boolean _allowedUpdateStarted;
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);
@@ -662,6 +686,7 @@ public class PPRResponseWriter extends R
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/branches/jsf2_ajax.3/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/ppr/ScriptBufferingResponseWriter.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/jsf2_ajax.3/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/ppr/ScriptBufferingResponseWriter.java?rev=928111&r1=928110&r2=928111&view=diff
==============================================================================
--- myfaces/trinidad/branches/jsf2_ajax.3/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/ppr/ScriptBufferingResponseWriter.java (original)
+++ myfaces/trinidad/branches/jsf2_ajax.3/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/ppr/ScriptBufferingResponseWriter.java Sat Mar 27 00:20:04 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/branches/jsf2_ajax.3/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/CommandLinkRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/jsf2_ajax.3/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/CommandLinkRenderer.java?rev=928111&r1=928110&r2=928111&view=diff
==============================================================================
--- myfaces/trinidad/branches/jsf2_ajax.3/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/CommandLinkRenderer.java (original)
+++ myfaces/trinidad/branches/jsf2_ajax.3/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/CommandLinkRenderer.java Sat Mar 27 00:20:04 2010
@@ -78,6 +78,13 @@ public class CommandLinkRenderer extends
facesContext.getExternalContext().getRequestParameterMap();
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/branches/jsf2_ajax.3/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/FormRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/jsf2_ajax.3/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/FormRenderer.java?rev=928111&r1=928110&r2=928111&view=diff
==============================================================================
--- myfaces/trinidad/branches/jsf2_ajax.3/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/FormRenderer.java (original)
+++ myfaces/trinidad/branches/jsf2_ajax.3/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/FormRenderer.java Sat Mar 27 00:20:04 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/branches/jsf2_ajax.3/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/PartialPageUtils.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/jsf2_ajax.3/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/PartialPageUtils.java?rev=928111&r1=928110&r2=928111&view=diff
==============================================================================
--- myfaces/trinidad/branches/jsf2_ajax.3/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/PartialPageUtils.java (original)
+++ myfaces/trinidad/branches/jsf2_ajax.3/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/renderkit/core/xhtml/PartialPageUtils.java Sat Mar 27 00:20:04 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;
@@ -116,7 +123,16 @@ public final class PartialPageUtils
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 +233,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 +255,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/branches/jsf2_ajax.3/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Page.js
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/jsf2_ajax.3/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Page.js?rev=928111&r1=928110&r2=928111&view=diff
==============================================================================
--- myfaces/trinidad/branches/jsf2_ajax.3/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Page.js (original)
+++ myfaces/trinidad/branches/jsf2_ajax.3/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Page.js Sat Mar 27 00:20:04 2010
@@ -24,13 +24,13 @@ function TrPage()
if (this._requestQueue.__useJsfBuiltInAjaxForXhr())
{
jsf.ajax.addOnEvent(TrUIUtils.createCallback(this, this._jsfAjaxCallback));
-}
+ }
}
/**
* Get the shared instance of the page object.
*/
-TrPage.getInstance = function()
+TrPage.getInstance = function ()
{
if (TrPage._INSTANCE == null)
TrPage._INSTANCE = new TrPage();
@@ -38,7 +38,7 @@ TrPage.getInstance = function()
return TrPage._INSTANCE;
}
-TrPage._MockXHR = function(requestEvent)
+TrPage._MockXHR = function (requestEvent)
{
this.UNSENT = 0;
this.OPENED = 1;
@@ -54,26 +54,25 @@ TrPage._MockXHR = function(requestEvent)
}
// Unsupported API methods that require a return value:
-TrPage._MockXHR.prototype.getResponseHeader = function(header)
+TrPage._MockXHR.prototype.getResponseHeader = function (header)
{
return this._requestEvent.getResponseHeader(header);
}
-TrPage._MockXHR.prototype.getAllResponseHeaders = function()
+TrPage._MockXHR.prototype.getAllResponseHeaders = function ()
{
return this._requestEvent._getAllResponseHeaders();
}
// No-op API methods:
-TrPage._MockXHR.prototype.open =
-TrPage._MockXHR.prototype.setRequestHeader =
-TrPage._MockXHR.prototype.send =
-TrPage._MockXHR.prototype.abort = function () {};
+TrPage._MockXHR.prototype.open = TrPage._MockXHR.prototype.setRequestHeader = TrPage._MockXHR.prototype.send = TrPage._MockXHR.prototype.abort = function ()
+{
+};
/**
* Return the shared request queue for the page.
*/
-TrPage.prototype.getRequestQueue = function()
+TrPage.prototype.getRequestQueue = function ()
{
return this._requestQueue;
}
@@ -86,18 +85,12 @@ 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,
- event)
-{
- this.getRequestQueue().sendFormPost(
- this, this._requestStatusChanged,
- actionForm, params, headerParams, event);
+TrPage.prototype.sendPartialFormPost = function (actionForm, params, headerParams, event)
+{
+ this.getRequestQueue().sendFormPost(this, this._requestStatusChanged, actionForm, params, headerParams, event);
}
-TrPage.prototype._requestStatusChanged = function(requestEvent)
+TrPage.prototype._requestStatusChanged = function (requestEvent)
{
if (requestEvent.getStatus() == TrXMLRequestEvent.STATUS_COMPLETE)
{
@@ -126,14 +119,14 @@ TrPage.prototype._requestStatusChanged =
if (requestEvent.isJsfAjaxRequest())
{
this._handleJsfAjaxResponse(requestEvent);
- }
- else
+ }
+ else
{
this._handlePprResponse(requestEvent, responseDocument);
- }
+ }
}
}
- else
+ else
{
// Should log some warning that we got an invalid response
}
@@ -152,9 +145,9 @@ TrPage.prototype._requestStatusChanged =
}
}
-TrPage.prototype._handleJsfAjaxResponse = function(requestEvent)
+TrPage.prototype._handleJsfAjaxResponse = function (requestEvent)
{
- try
+ try
{
var statusCode = requestEvent.getResponseStatusCode();
if (statusCode >= 200 && statusCode < 300)
@@ -168,16 +161,16 @@ TrPage.prototype._handleJsfAjaxResponse
{
var activeNode = this._activeNode;
delete this._activeNode;
- var index = -1;
+ var index = - 1;
if (activeNode.id)
{
- for (var i = 0, size = this._ajaxOldDomElements.length; i < size; ++i)
+ 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)
{
@@ -194,7 +187,7 @@ TrPage.prototype._handleJsfAjaxResponse
// TODO: do we need to do any additional processing here, for instance,
// error processing?
}
- finally
+ finally
{
delete this._ajaxOldDomElements;
delete this._activeNode;
@@ -205,9 +198,9 @@ TrPage.prototype._handleJsfAjaxResponse
* Method to bridge compatibility between the Trinidad IFrame-PPR implementation
* an the JSF 2 AJAX javascript API
*/
-TrPage.prototype._delegateResponseToJsfAjax = function(requestEvent, document)
+TrPage.prototype._delegateResponseToJsfAjax = function (requestEvent, document)
{
-console.log("_delegateResponseToJsfAjax");
+ console.log("_delegateResponseToJsfAjax");
// We wish to have JSF 2 handle the response. In order to do that we need to
// construct the necessary parameters for the jsf.ajax.response method.
//
@@ -223,47 +216,40 @@ console.log("_delegateResponseToJsfAjax"
{
source = document.getElementById(source);
}
- var context =
+ var context =
{
- "onevent": null,
- "onerror": null,
- "source": source,
- "formid": requestEvent.getFormId(),
- "render": null
+ "onevent" : null, "onerror" : null, "source" : source, "formid" : requestEvent.getFormId(), "render" : null
};
jsf.ajax.response(request, context);
}
-TrPage.prototype._handlePprResponse = function(requestEvent, document)
+TrPage.prototype._handlePprResponse = function (requestEvent, document)
{
if (this._requestQueue.__useJsfBuiltInAjaxForXhr())
{
return this._delegateResponseToJsfAjax(requestEvent, document);
}
-console.log("_handlePprResponse");
+ console.log("_handlePprResponse");
var documentElement = document.documentElement;
var rootNodeName = TrPage._getNodeName(documentElement);
if (rootNodeName == "partial-response")
{
- // Update the form action
- this._handlePprResponseAction(documentElement);
-
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];
switch (TrPage._getNodeName(childNode))
{
case "changes":
- for (var j = 0, size = childNode.childNodes.length; j < size; ++j)
- {
+ 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);
break;
@@ -273,42 +259,40 @@ console.log("_handlePprResponse");
break;
case "extension":
- for (var k = 0, extsize = changeNode.childNodes.length; k < extsize; ++k)
+ if (changeNode.id == "tr-script-library")
{
- if (changeNode.childNodes[k].nodeName == "script-library")
- {
- this._handlePprResponseLibrary(changeNode.childNodes[k]);
- }
- }
+ this._handlePprResponseLibrary(changeNode);
+ }
break;
// Do not support the new updates with the Trinidad legacy fallback code:
- default: break;
- }
- }
+ default:
+ break;
+ }
+ }
break;
case "error":
var nodeText = TrPage._getTextContent(childNode.nextSibling.firstChild);
// This should not happen - there should always be an error message
- if (nodeText == null)
- nodeText = "Unknown error during PPR";
- alert(nodeText);
+ if (nodeText == null)
+ nodeText = "Unknown error during PPR";
+ alert(nodeText);
return;
case "redirect":
var url = TrPage._getTextContent(childNode);
// TODO: fix for portlets???
window.location.href = url;
+ }
+ }
}
- }
- }
- else
+ else
{
// FIXME: log an error
window.location.reload(true);
}
}
-TrPage.prototype._addResetFields = function(formName, resetNames)
+TrPage.prototype._addResetFields = function (formName, resetNames)
{
// Create the necessary objects
var resetFields = this._resetFields;
@@ -326,13 +310,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)
@@ -361,9 +345,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;
@@ -393,7 +375,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)
@@ -414,7 +396,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)
@@ -422,29 +404,23 @@ 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)
{
var doc = window.document;
var targetNode;
@@ -460,10 +436,10 @@ TrPage.prototype._handlePprResponseFragm
// Get the first child node in fragmentNote
var firstFragmenChildNode = fragmentNode.childNodes[0];
if (!firstFragmenChildNode)
- return;
+ return;
var outerHTML = "";
- for (var i = 0, size = fragmentNode.childNodes.length; i < size; ++i)
+ for (var i = 0, size = fragmentNode.childNodes.length;i < size;++i)
{
outerHTML += fragmentNode.childNodes[i].data;
}
@@ -506,7 +482,7 @@ TrPage.prototype._handlePprResponseFragm
tempDiv.innerHTML = "";
bodyElement.removeChild(tempDiv);
}
- else
+ else
{
// Convert the content of the fragment node into an HTML node that
// we can insert into the document
@@ -520,7 +496,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
@@ -543,13 +519,13 @@ 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
+ else
currListener(targetNode, sourceNode);
}
}
@@ -566,11 +542,10 @@ TrPage.prototype._handlePprResponseFragm
}
}
-
/**
* Return true if "parent" is an ancestor of (or equal to) "child"
*/
-TrPage._isDomAncestorOf = function(child, parent)
+TrPage._isDomAncestorOf = function (child, parent)
{
while (child)
{
@@ -587,28 +562,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)
@@ -629,12 +603,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)
@@ -656,7 +630,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;
@@ -674,7 +648,7 @@ TrPage.prototype._loadScript = function(
{
if (_agent.isIE)
window.execScript(responseText);
- else
+ else
window.eval(responseText);
}
}
@@ -684,34 +658,34 @@ 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)
{
this._loadScript(source);
}
- else
+ else
{
var nodeText = TrPage._getTextContent(scriptNode);
if (nodeText)
{
if (_agent.isIE)
window.execScript(nodeText);
- else
+ else
window.eval(nodeText);
}
}
}
-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)
{
@@ -743,7 +717,7 @@ TrPage._getTextContent = function(elemen
return element.textContent;
}
-TrPage._collectLoadedLibraries = function()
+TrPage._collectLoadedLibraries = function ()
{
if (!_agent.supportsDomDocument)
{
@@ -752,19 +726,19 @@ TrPage._collectLoadedLibraries = functio
// and firstChild) and it is not possible to implement this function.
return null;
}
- else
+ else
{
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
@@ -775,7 +749,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)
@@ -793,7 +766,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)
@@ -807,17 +780,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++;
@@ -846,7 +819,7 @@ TrPage.prototype.removeDomReplaceListene
* getStyleClass function.
* @param styleClassMap() {key: styleClass, ...}
*/
-TrPage.prototype.addStyleClassMap = function(styleClassMap)
+TrPage.prototype.addStyleClassMap = function (styleClassMap)
{
if (!styleClassMap)
return;
@@ -864,7 +837,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)
{
@@ -886,7 +859,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)
{
@@ -899,7 +872,6 @@ TrPage._autoSubmit = function(formId, in
// If onchange is used for validation, then first validate
// just the current input
-
var isValid = true;
if (_TrEventBasedValidation)
isValid = _validateInput(event, true);
@@ -916,7 +888,7 @@ TrPage._autoSubmit = function(formId, in
}
}
-TrPage.prototype._jsfAjaxCallback = function(data)
+TrPage.prototype._jsfAjaxCallback = function (data)
{
if (data.status == "complete")
{
@@ -929,19 +901,19 @@ TrPage.prototype._jsfAjaxCallback = func
}
}
-TrPage.prototype._notifyDomReplacementListeners = function(dataArray)
+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)
+ 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)
+ for (var j = 0, jsize = listeners.length;j < jsize;++j)
{
var currListener = listeners[j];
var currInstance = listeners[++j];
@@ -949,7 +921,7 @@ TrPage.prototype._notifyDomReplacementLi
{
currListener.call(currInstance, oldElem, newElem);
}
- else
+ else
{
currListener(oldElem, newElem);
}
@@ -957,7 +929,7 @@ TrPage.prototype._notifyDomReplacementLi
}
}
-TrPage.prototype._getDomToBeUpdated = function(status, responseXML)
+TrPage.prototype._getDomToBeUpdated = function (status, responseXML)
{
// check for a successful request
if (status < 200 || status >= 300)
@@ -974,7 +946,7 @@ TrPage.prototype._getDomToBeUpdated = fu
var changeNodes = responseTypeNode.childNodes;
var oldElements = [];
- for (var i = 0, size = changeNodes.length; i < size; ++i)
+ for (var i = 0, size = changeNodes.length;i < size;++i)
{
var node = changeNodes[i];
if (node.nodeName !== "update")
@@ -991,13 +963,19 @@ TrPage.prototype._getDomToBeUpdated = fu
}
if (id == "javax.faces.ViewRoot" || id == "javax.faces.ViewBody")
{
- oldElements.push({ "id": null, "element": document.body });
+ oldElements.push(
+ {
+ "id" : null, "element" : document.body
+ });
}
- else
+ else
{
- oldElements.push({ "id": id, "element": document.getElementById(id) });
+ oldElements.push(
+ {
+ "id" : id, "element" : document.getElementById(id)
+ });
}
}
return oldElements;
-}
+}
\ No newline at end of file
Modified: myfaces/trinidad/branches/jsf2_ajax.3/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/xhr/RequestQueue.js
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/jsf2_ajax.3/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/xhr/RequestQueue.js?rev=928111&r1=928110&r2=928111&view=diff
==============================================================================
--- myfaces/trinidad/branches/jsf2_ajax.3/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/xhr/RequestQueue.js (original)
+++ myfaces/trinidad/branches/jsf2_ajax.3/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/xhr/RequestQueue.js Sat Mar 27 00:20:04 2010
@@ -88,6 +88,7 @@ TrRequestQueue.prototype._broadcastReque
}
catch (e)
{
+ alert(e);
TrRequestQueue._logError(
"Error ", e, " delivering XML request status changed to ",
currMethod);
@@ -565,7 +566,10 @@ TrRequestQueue.prototype._doRequestThrou
htmlForm.target = frameName;
this._appendParamNode(domDocument, htmlForm, "Tr-XHR-Message", "true");
- this._appendParamNode(domDocument, htmlForm, "javax.faces.partial.ajax", "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)
{
Modified: myfaces/trinidad/branches/jsf2_ajax.3/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/xhr/XMLRequest.js
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/jsf2_ajax.3/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/xhr/XMLRequest.js?rev=928111&r1=928110&r2=928111&view=diff
==============================================================================
--- myfaces/trinidad/branches/jsf2_ajax.3/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/xhr/XMLRequest.js (original)
+++ myfaces/trinidad/branches/jsf2_ajax.3/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/xhr/XMLRequest.js Sat Mar 27 00:20:04 2010
@@ -296,14 +296,21 @@ TrXMLJsfAjaxRequest.prototype.send = fun
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,
- {
- "onevent": ajaxCallback,
- "onerror": ajaxCallback,
- "params": this._params
- });
+ payload);
// No need for the event anymore, release the resource
delete this._event;