Author: alexsmirnov
Date: 2008-03-13 20:24:19 -0400 (Thu, 13 Mar 2008)
New Revision: 6797
Added:
trunk/framework/test/src/main/java/org/ajax4jsf/tests/MockUIComponent.java
trunk/framework/test/src/test/java/org/ajax4jsf/component/
trunk/framework/test/src/test/java/org/ajax4jsf/component/AjaxViewRootTest.java
Modified:
trunk/framework/api/src/main/java/org/ajax4jsf/component/AjaxContainerBase.java
trunk/framework/impl/src/main/java/org/ajax4jsf/application/AjaxViewHandler.java
trunk/framework/impl/src/main/java/org/ajax4jsf/component/AjaxRegionBrige.java
trunk/framework/impl/src/main/java/org/ajax4jsf/component/AjaxViewRoot.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxChildrenRenderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxContainerRenderer.java
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxViewRootRenderer.java
trunk/framework/test/src/main/java/org/ajax4jsf/tests/MockViewRoot.java
trunk/ui/core/src/main/java/org/ajax4jsf/component/UIAjaxRegion.java
trunk/ui/drag-drop/src/test/java/org/richfaces/component/DragDropTest.java
trunk/ui/menu-components/src/test/java/org/richfaces/component/MenuItemComponentTest.java
trunk/ui/panelbar/src/test/java/org/richfaces/component/PanelBarComponentTest.java
trunk/ui/togglePanel/src/test/java/org/richfaces/component/TogglePanelComponentTest.java
trunk/ui/tree/src/test/java/org/richfaces/component/events/TreeEventsTest.java
Log:
Continue to refactor JSF 1.2 compatibility.
Modified: trunk/framework/api/src/main/java/org/ajax4jsf/component/AjaxContainerBase.java
===================================================================
---
trunk/framework/api/src/main/java/org/ajax4jsf/component/AjaxContainerBase.java 2008-03-13
20:37:14 UTC (rev 6796)
+++
trunk/framework/api/src/main/java/org/ajax4jsf/component/AjaxContainerBase.java 2008-03-14
00:24:19 UTC (rev 6797)
@@ -81,15 +81,5 @@
public void setSubmitted(boolean submitted);
- /**
- * Render AJAX response for this container from stored View.
- * @param context
- * @throws FacesException
- */
-// public void renderAjaxRegion(FacesContext context) throws FacesException ;
- public abstract void setSubmittedControlId(String string);
-
- public abstract String getSubmittedControlId();
-
}
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/application/AjaxViewHandler.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/application/AjaxViewHandler.java 2008-03-13
20:37:14 UTC (rev 6796)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/application/AjaxViewHandler.java 2008-03-14
00:24:19 UTC (rev 6797)
@@ -30,15 +30,11 @@
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
-import javax.servlet.http.HttpServletResponse;
import org.ajax4jsf.Messages;
-import org.ajax4jsf.application.ViewHandlerWrapper;
import org.ajax4jsf.component.AjaxViewRoot;
import org.ajax4jsf.context.AjaxContext;
import org.ajax4jsf.context.ViewIdHolder;
-import org.ajax4jsf.renderkit.AjaxContainerRenderer;
-import org.ajax4jsf.renderkit.AjaxRendererUtils;
import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.ajax4jsf.resource.InternetResource;
import org.ajax4jsf.resource.InternetResourceBuilder;
@@ -88,35 +84,11 @@
viewIdHolder.setViewId(viewId);
riRoot = facesContext.getViewRoot();
} else {
- UIViewRoot root = super.createView(facesContext, viewId);
- // TODO -setup render-kit where instead of Listener ?
- if (null == root || root instanceof AjaxViewRoot) {
- riRoot = root;
- } else {
- // HACK - since only RI 1.1 use new for create ViewRoot instead
- // of Application.createComponent,
- // we can use it as flag for custom creation.
- riRoot = (UIViewRoot) facesContext.getApplication()
- .createComponent(UIViewRoot.COMPONENT_TYPE);
- // fill properties from default.
- riRoot.setViewId(root.getViewId());
- riRoot.setLocale(root.getLocale());
- String renderKitId = root.getRenderKitId();
- // Fix facelets bug - for debug requests renderKitId is null !
- if (null == renderKitId) {
- renderKitId = calculateRenderKitId(facesContext);
- }
- riRoot.setRenderKitId(renderKitId);
- }
- // if (null ==
- // facesContext.getExternalContext().getRequestMap().get(VIEW_EXPIRED))
- // {
- // Clear ajax request flag ( except new view creation )- for navigation states, full
page will be
- // send.
+ riRoot = super.createView(facesContext, viewId);
+ // Reset ajax request status for a navigation case.
if(null != facesContext.getViewRoot()){
ajaxContext.setAjaxRequest(false);
}
- // }
}
return riRoot;
}
@@ -128,8 +100,8 @@
*/
public void writeState(FacesContext context) throws IOException {
AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
- if (ajaxContext.isAjaxRequest()) {
- // TODO - detect case of JSF 1.1 + JSP. for all other we need own
+ if (ajaxContext.isAjaxRequest() && ajaxContext.isSelfRender()) {
+ // We need own
// state marker for
// self-rendered regions only.
// write marker html element - input field. Will be parsed in filter
@@ -139,10 +111,10 @@
writer.startElement(HTML.SPAN_ELEM, null);
writer.writeAttribute(HTML.id_ATTRIBUTE, STATE_MARKER_KEY, null);
writer.writeAttribute(HTML.NAME_ATTRIBUTE, STATE_MARKER_KEY, null);
- // writer.writeAttribute("style", "display:none;", null);
- if (!ajaxContext.isSelfRender()) {
- super.writeState(context);
- }
+// // writer.writeAttribute("style", "display:none;", null);
+// if (!ajaxContext.isSelfRender()) {
+// super.writeState(context);
+// }
writer.endElement(HTML.SPAN_ELEM);
} else {
super.writeState(context);
@@ -158,7 +130,7 @@
public UIViewRoot restoreView(FacesContext context, String viewId) {
UIViewRoot viewRoot = super.restoreView(context, viewId);
ExternalContext externalContext = context.getExternalContext();
- Map requestMap = externalContext.getRequestMap();
+ Map<String, Object> requestMap = externalContext.getRequestMap();
if (null == viewRoot) {
requestMap.put(VIEW_EXPIRED, Messages
.getMessage(Messages.AJAX_VIEW_EXPIRED));
@@ -205,39 +177,12 @@
// Broadcast Ajax events before rendering, to setup areas to update.
if (root instanceof AjaxViewRoot) {
AjaxViewRoot ajaxRoot = (AjaxViewRoot) root;
- Map requestMap = context.getExternalContext().getRequestMap();
// broadcast ajax events before render response.
- if (ajaxContext.isAjaxRequest()
- && null == requestMap
- .get(AjaxRendererUtils.AJAX_AREAS_RENDERED)) {
+ if (ajaxContext.isAjaxRequest()) {
processAjaxEvents(context, ajaxRoot);
}
if (!context.getResponseComplete()) {
super.renderView(context, root);
- if (ajaxContext.isAjaxRequest()
- && null == requestMap
- .get(AjaxRendererUtils.AJAX_AREAS_RENDERED)) {
- // HACK for MyFaces ( <f:view> tag not call renderers )
- if (_log.isDebugEnabled()) {
- _log
- .debug(Messages
- .getMessage(Messages.AJAX_RESPONSE_NOT_RENDERED_INFO));
- }
- ajaxContext.setSelfRender(true);
- // ServletResponse response = (ServletResponse) context
- // .getExternalContext().getResponse();
- Object response = (Object) context.getExternalContext()
- .getResponse();
- try {
- response.getClass().getDeclaredMethod("reset",
- new Class[0]).invoke(response, new Object[0]);
- // response.reset();
- } catch (Exception e) {
- // Do nothing - we will use directly and reset
- // wrapper
- }
- ajaxContext.renderSubmittedAjaxRegion(context, true);
- }
}
} else {
super.renderView(context, root);
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/component/AjaxRegionBrige.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/component/AjaxRegionBrige.java 2008-03-13
20:37:14 UTC (rev 6796)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/component/AjaxRegionBrige.java 2008-03-14
00:24:19 UTC (rev 6797)
@@ -80,8 +80,6 @@
private boolean selfRendered = false;
private boolean selfRenderedSet = false;
- private String submittedControlId;
-
private boolean transientFlag = false;
private UIComponent component ;
@@ -358,19 +356,6 @@
this.transientFlag = transientFlag;
}
- /**
- * @return the submittedControlId
- */
- public String getSubmittedControlId() {
- return submittedControlId;
- }
- /**
- * @param submittedControlId the submittedControlId to set
- */
- public void setSubmittedControlId(String submittedControlId) {
- this.submittedControlId = submittedControlId;
}
-
- }
Modified: trunk/framework/impl/src/main/java/org/ajax4jsf/component/AjaxViewRoot.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/component/AjaxViewRoot.java 2008-03-13
20:37:14 UTC (rev 6796)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/component/AjaxViewRoot.java 2008-03-14
00:24:19 UTC (rev 6797)
@@ -22,16 +22,26 @@
package org.ajax4jsf.component;
import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
import java.util.NoSuchElementException;
import javax.el.MethodExpression;
import javax.faces.FacesException;
+import javax.faces.FactoryFinder;
+import javax.faces.component.ContextCallback;
import javax.faces.component.UIComponent;
import javax.faces.component.UIViewRoot;
import javax.faces.context.FacesContext;
import javax.faces.event.AbortProcessingException;
import javax.faces.event.FacesEvent;
+import javax.faces.event.PhaseEvent;
import javax.faces.event.PhaseId;
+import javax.faces.event.PhaseListener;
+import javax.faces.lifecycle.Lifecycle;
+import javax.faces.lifecycle.LifecycleFactory;
+import javax.faces.webapp.FacesServlet;
import org.ajax4jsf.Messages;
import org.ajax4jsf.context.AjaxContext;
@@ -41,6 +51,8 @@
import org.ajax4jsf.event.AjaxListener;
import org.ajax4jsf.event.EventsQueue;
import org.ajax4jsf.renderkit.AjaxContainerRenderer;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
/**
* Custom ViewRoot for support render parts of tree for Ajax requests. Main
@@ -55,514 +67,580 @@
*/
public class AjaxViewRoot extends UIViewRoot implements AjaxContainer {
- public static final String ROOT_ID = "_viewRoot";
+ public static final String ROOT_ID = "_viewRoot";
- private AjaxRegionBrige _brige;
+ private Lifecycle lifecycle;
- /**
- *
- */
- public AjaxViewRoot() {
- super();
- super.setId(ROOT_ID);
- _brige = new AjaxRegionBrige(this);
- }
+ private AjaxRegionBrige _brige;
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.component.UIComponentBase#getId()
- */
- // public String getId() {
- // return ROOT_ID;
- // }
- public String getRendererType() {
- return (COMPONENT_FAMILY);
- }
+ private static final Log _log = LogFactory.getLog(AjaxViewRoot.class);
- /*
- * (non-Javadoc)
- *
- * @see
org.ajax4jsf.framework.ajax.AjaxViewBrige#broadcast(javax.faces.event.FacesEvent)
- */
- public void broadcast(FacesEvent event) throws AbortProcessingException {
- super.broadcast(event);
- getBrige().broadcast(event);
- }
+ /**
+ *
+ */
+ public AjaxViewRoot() {
+ super();
+ super.setId(ROOT_ID);
+ _brige = new AjaxRegionBrige(this);
+ }
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.framework.ajax.AjaxViewBrige#getAjaxListener()
- */
- public MethodExpression getAjaxListener() {
- return getBrige().getAjaxListener();
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.component.UIComponentBase#getId()
+ */
+ // public String getId() {
+ // return ROOT_ID;
+ // }
+ public String getRendererType() {
+ return (COMPONENT_FAMILY);
+ }
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.framework.ajax.AjaxViewBrige#isImmediate()
- */
- public boolean isImmediate() {
- return getBrige().isImmediate();
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.ajax4jsf.framework.ajax.AjaxViewBrige#broadcast(javax.faces.event.FacesEvent)
+ */
+ public void broadcast(FacesEvent event) throws AbortProcessingException {
+ super.broadcast(event);
+ getBrige().broadcast(event);
+ }
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.framework.ajax.AjaxViewBrige#isSubmitted()
- */
- public boolean isSubmitted() {
- return getBrige().isSubmitted();
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.framework.ajax.AjaxViewBrige#getAjaxListener()
+ */
+ public MethodExpression getAjaxListener() {
+ return getBrige().getAjaxListener();
+ }
- /*
- * (non-Javadoc)
- *
- * @see
javax.faces.component.UIComponent#queueEvent(javax.faces.event.FacesEvent)
- */
- public void queueEvent(FacesEvent event) {
- if (event == null)
- throw new NullPointerException(Messages
- .getMessage(Messages.NULL_EVENT_SUBMITTED_ERROR));
- if (event.getPhaseId().compareTo(PhaseId.RENDER_RESPONSE) == 0) {
- // HACK - Special case - Ajax Events to RenderResponse phase
- // queue.
- // in future, with JSF 1.2 it must be done by invokeOnComponent
- // method.
- // In 1.1 , events to RENDER_RESPONSE phase not used.
- getAjaxEventsQueue(getFacesContext()).offer(event);
- } else {
- getEventsQueue(getFacesContext(), event.getPhaseId()).offer(event);
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.framework.ajax.AjaxViewBrige#isImmediate()
+ */
+ public boolean isImmediate() {
+ return getBrige().isImmediate();
}
- }
- /**
- * Broadcast events for specified Phase
- *
- * @param context
- * @param phaseId -
- * phase, for wich events must be processed.
- */
- void broadcastEvents(FacesContext context, PhaseId phaseId) {
- EventsQueue[] events = getEvents(context);
- EventsQueue anyPhaseEvents = events[PhaseId.ANY_PHASE.getOrdinal()];
- EventsQueue phaseEvents = events[phaseId.getOrdinal()];
- if (phaseEvents.isEmpty() && anyPhaseEvents.isEmpty())
- return;
- // FacesEvent event = null;
- boolean haveAnyPhaseEvents = !anyPhaseEvents.isEmpty();
- boolean havePhaseEvents = !phaseEvents.isEmpty();
- do {
- // ANY_PHASE first
- processEvents(anyPhaseEvents, haveAnyPhaseEvents);
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.framework.ajax.AjaxViewBrige#isSubmitted()
+ */
+ public boolean isSubmitted() {
+ return getBrige().isSubmitted();
+ }
- processEvents(phaseEvents, havePhaseEvents);
- // Events can queued in other events processing
- haveAnyPhaseEvents = !anyPhaseEvents.isEmpty();
- havePhaseEvents = !phaseEvents.isEmpty();
- } while (haveAnyPhaseEvents || havePhaseEvents);
- if (context.getRenderResponse() || context.getResponseComplete()) {
- clearEvents(context);
+ /**
+ * Use own {@link PhaseListener}'s list, to use with AJAX processing.
+ * phases.
+ */
+ private List<PhaseListener> phaseListeners = null;
+
+ public void removePhaseListener(PhaseListener toRemove) {
+ if (null != phaseListeners) {
+ phaseListeners.remove(toRemove);
+ }
+ super.removePhaseListener(toRemove);
}
- }
+ public void addPhaseListener(PhaseListener newPhaseListener) {
+ if (null == phaseListeners) {
+ phaseListeners = new ArrayList<PhaseListener>();
+ }
+ phaseListeners.add(newPhaseListener);
+ super.addPhaseListener(newPhaseListener);
+ }
- /**
- * @param phaseEventsQueue
- * @param havePhaseEvents
- */
- public void processEvents(EventsQueue phaseEventsQueue, boolean havePhaseEvents) {
- FacesEvent event;
- while (havePhaseEvents) {
- try {
- event = (FacesEvent) phaseEventsQueue.remove();
- UIComponent source = event.getComponent();
- try {
- source.broadcast(event);
- } catch (AbortProcessingException e) {
- // abort event processing
- // Page 3-30 of JSF 1.1 spec: "Throw an
- // AbortProcessingException, to tell the JSF
- // implementation
- // that no further broadcast of this event, or any
- // further
- // events, should take place."
- // clearEvents();
- // return;
+ /**
+ * Send notification to a view-scope phase listeners.
+ *
+ * @param context
+ * @param phase
+ * @param before
+ */
+ protected void processPhaseListeners(FacesContext context, PhaseId phase,
+ boolean before) {
+ MethodExpression listenerExpression = before ? getBeforePhaseListener()
+ : getAfterPhaseListener();
+ PhaseEvent event = null;
+ if (null != listenerExpression) {
+ event = createPhaseEvent(context, phase);
+ listenerExpression.invoke(context.getELContext(),
+ new Object[] { event });
}
- } catch (NoSuchElementException e) {
- havePhaseEvents = false;
- }
+ if (null != this.phaseListeners) {
+ for (PhaseListener listener : phaseListeners) {
+ PhaseId phaseId = listener.getPhaseId();
+ if (phaseId == phase || phaseId == PhaseId.ANY_PHASE) {
+ if (null == event) {
+ event = createPhaseEvent(context, phase);
+ }
+ if (before) {
+ listener.beforePhase(event);
+ } else {
+ listener.afterPhase(event);
+ }
+ }
+ }
+ }
}
- }
- public void broadcastAjaxEvents(FacesContext context) {
- EventsQueue queue = getAjaxEventsQueue(context);
- processEvents(queue, !queue.isEmpty());
- }
+ protected PhaseEvent createPhaseEvent(FacesContext context, PhaseId phaseId)
+ throws FacesException {
+ if (lifecycle == null) {
+ LifecycleFactory lifecycleFactory = (LifecycleFactory) FactoryFinder
+ .getFactory(FactoryFinder.LIFECYCLE_FACTORY);
+ String lifecycleId = context.getExternalContext().getInitParameter(
+ FacesServlet.LIFECYCLE_ID_ATTR);
+ if (lifecycleId == null) {
+ lifecycleId = LifecycleFactory.DEFAULT_LIFECYCLE;
+ }
+ lifecycle = lifecycleFactory.getLifecycle(lifecycleId);
+ }
+ return (new PhaseEvent(context, phaseId, lifecycle));
+ }
- private EventsQueue[] events;
+ protected void processPhase(FacesContext context, PhaseId phase,
+ InvokerCallback callback) {
+ // Process phase listeners before phase.
+ processPhaseListeners(context, phase, true);
+ // Process phase. Run callback method by invokeOnComponent for a
+ // submitted region.
+ if (!(null == callback || context.getRenderResponse() || context
+ .getResponseComplete())) {
+ AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
+ String submittedRegionClientId = ajaxContext
+ .getSubmittedRegionClientId();
+ if (ajaxContext.isAjaxRequest() && submittedRegionClientId != null
+ && !submittedRegionClientId.equals(getClientId(context))) {
+ invokeOnComponent(context, submittedRegionClientId, callback);
+ } else {
+ // For a root region, call invokeRoot method, then process all
+ // facets and children by invoke method.
+ try {
+ callback.invokeRoot(context);
+ } catch (RuntimeException e) {
+ context.renderResponse();
+ throw e;
+ }
+ String ajaxSingleClientId = ajaxContext.getAjaxSingleClientId();
+ if (null == ajaxSingleClientId) {
+ for (Iterator<UIComponent> iter = getFacetsAndChildren(); iter
+ .hasNext();) {
+ callback.invokeContextCallback(context, iter.next());
+ }
+ } else {
+ invokeOnComponent(context, ajaxSingleClientId, callback);
+ }
+ }
+ }
+ // Broadcast phase events.
+ broadcastEvents(context, phase);
+ // Process afterPhase listeners.
+ processPhaseListeners(context, phase, false);
+ }
- private EventsQueue ajaxEvents = new EventsQueue();
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.component.UIComponent#queueEvent(javax.faces.event.FacesEvent)
+ */
+ public void queueEvent(FacesEvent event) {
+ if (event == null)
+ throw new NullPointerException(Messages
+ .getMessage(Messages.NULL_EVENT_SUBMITTED_ERROR));
+ if (event.getPhaseId().compareTo(PhaseId.RENDER_RESPONSE) == 0) {
+ // HACK - Special case - Ajax Events to RenderResponse phase
+ // queue.
+ getAjaxEventsQueue().offer(event);
+ } else {
+ getEventsQueue(event.getPhaseId()).offer(event);
+ }
+ }
- /**
- * Use FIFO buffers for hold Faces Events. Hold this buffers in Request
- * scope parameters for support any concurrent requests for same
- * component tree ( since RI hold component tree in session ).
- *
- * @param context
- * @param phase
- * @return
- */
- protected EventsQueue getEventsQueue(FacesContext context, PhaseId phase) {
- return getEvents(context)[phase.getOrdinal()];
- }
+ /**
+ * Broadcast events for specified Phase
+ *
+ * @param context
+ * @param phaseId -
+ * phase, for which events must be processed.
+ */
+ void broadcastEvents(FacesContext context, PhaseId phaseId) {
+ EventsQueue[] events = getEvents();
+ EventsQueue anyPhaseEvents = events[PhaseId.ANY_PHASE.getOrdinal()];
+ EventsQueue phaseEvents = events[phaseId.getOrdinal()];
+ if (phaseEvents.isEmpty() && anyPhaseEvents.isEmpty())
+ return;
+ // FacesEvent event = null;
+ boolean haveAnyPhaseEvents = !anyPhaseEvents.isEmpty();
+ boolean havePhaseEvents = !phaseEvents.isEmpty();
+ do {
+ // ANY_PHASE first
+ processEvents(context, anyPhaseEvents, haveAnyPhaseEvents);
- /**
- * @return
- */
- protected EventsQueue[] getEvents(FacesContext context) {
- if (events == null) {
- clearEvents(context);
+ processEvents(context, phaseEvents, havePhaseEvents);
+ // Events can queued in other events processing
+ haveAnyPhaseEvents = !anyPhaseEvents.isEmpty();
+ havePhaseEvents = !phaseEvents.isEmpty();
+ } while (haveAnyPhaseEvents || havePhaseEvents);
+ if (context.getRenderResponse() || context.getResponseComplete()) {
+ clearEvents();
+ }
+
}
- return events;
- }
- /**
- * Special Fifo Buffer for ajax events to Render Responce phase.
- *
- * @param context
- * @return
- */
- protected EventsQueue getAjaxEventsQueue(FacesContext context) {
+ /**
+ * @param context
+ * TODO
+ * @param phaseEventsQueue
+ * @param havePhaseEvents
+ */
+ public void processEvents(FacesContext context,
+ EventsQueue phaseEventsQueue, boolean havePhaseEvents) {
+ FacesEvent event;
+ while (havePhaseEvents) {
+ try {
+ event = (FacesEvent) phaseEventsQueue.remove();
+ UIComponent source = event.getComponent();
+ try {
+ source.broadcast(event);
+ } catch (AbortProcessingException e) {
+ if (_log.isErrorEnabled()) {
+ UIComponent component = event.getComponent();
+ String id = null != component ? component
+ .getClientId(context) : "";
+ _log.error(
+ "Error processing faces event for the component "
+ + id, e);
+ }
+ }
+ } catch (NoSuchElementException e) {
+ havePhaseEvents = false;
+ }
+ }
+ }
- return ajaxEvents;
- }
+ public void broadcastAjaxEvents(FacesContext context) {
+ EventsQueue queue = getAjaxEventsQueue();
+ processEvents(context, queue, !queue.isEmpty());
+ }
- public void clearEvents(FacesContext context) {
- int len;
- events = new EventsQueue[len = PhaseId.VALUES.size()];
- for (int i = 0; i < len; i++) {
- events[i] = new EventsQueue();
+ private EventsQueue[] events;
+
+ private EventsQueue ajaxEvents = new EventsQueue();
+
+ /**
+ * Use FIFO buffers for hold Faces Events. Hold this buffers in Request
+ * scope parameters for support any concurrent requests for same component
+ * tree ( since RI hold component tree in session ).
+ *
+ * @param phase
+ *
+ * @return
+ */
+ protected EventsQueue getEventsQueue(PhaseId phase) {
+ return getEvents()[phase.getOrdinal()];
}
- }
- private InvokerCallback _decodeInvoker = new InvokerCallback() {
+ /**
+ * @return
+ */
+ protected EventsQueue[] getEvents() {
+ if (events == null) {
+ clearEvents();
+ }
+ return events;
+ }
- public void invokeContextCallback(FacesContext context, UIComponent component) {
- component.processDecodes(context);
+ /**
+ * Special Fifo Buffer for ajax events to Render Responce phase.
+ *
+ * @return
+ */
+ protected EventsQueue getAjaxEventsQueue() {
+
+ return ajaxEvents;
}
- public void invokeRoot(FacesContext context) {
- AjaxViewRoot.super.processDecodes(context);
+ public void clearEvents() {
+ int len;
+ events = new EventsQueue[len = PhaseId.VALUES.size()];
+ for (int i = 0; i < len; i++) {
+ events[i] = new EventsQueue();
+ }
}
- };
+ private InvokerCallback _decodeInvoker = new InvokerCallback() {
+ public void invokeContextCallback(FacesContext context,
+ UIComponent component) {
+ component.processDecodes(context);
+ }
- /*
- * (non-Javadoc)
- *
- * @see
org.ajax4jsf.framework.ajax.AjaxViewBrige#processDecodes(javax.faces.context.FacesContext)
- */
- public void processDecodes(FacesContext context) {
- if (context == null)
- throw new NullPointerException("context");
- AjaxContextImpl.invokeOnRegionOrRoot(this, context, _decodeInvoker);
- broadcastEvents(context, PhaseId.APPLY_REQUEST_VALUES);
- }
+ public void invokeRoot(FacesContext context) {
+ decode(context);
+ }
- private InvokerCallback _updatesInvoker = new InvokerCallback() {
+ };
- public void invokeContextCallback(FacesContext context, UIComponent component) {
- component.processUpdates(context);
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.ajax4jsf.framework.ajax.AjaxViewBrige#processDecodes(javax.faces.context.FacesContext)
+ */
+ public void processDecodes(FacesContext context) {
+ if (context == null)
+ throw new NullPointerException("context");
+ processPhase(context, PhaseId.APPLY_REQUEST_VALUES, _decodeInvoker);
}
- public void invokeRoot(FacesContext context) {
- AjaxViewRoot.super.processUpdates(context);
+ private InvokerCallback _updatesInvoker = new InvokerCallback() {
+
+ public void invokeContextCallback(FacesContext context,
+ UIComponent component) {
+ component.processUpdates(context);
+ }
+
+ public void invokeRoot(FacesContext context) {
+ }
+
+ };
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.ajax4jsf.framework.ajax.AjaxViewBrige#processUpdates(javax.faces.context.FacesContext)
+ */
+ public void processUpdates(FacesContext context) {
+ if (context == null)
+ throw new NullPointerException("context");
+ processPhase(context, PhaseId.UPDATE_MODEL_VALUES, _updatesInvoker);
}
- };
+ private InvokerCallback _validatorsInvoker = new InvokerCallback() {
- /*
- * (non-Javadoc)
- *
- * @see
org.ajax4jsf.framework.ajax.AjaxViewBrige#processUpdates(javax.faces.context.FacesContext)
- */
- public void processUpdates(FacesContext context) {
- if (context == null)
- throw new NullPointerException("context");
- AjaxContextImpl.invokeOnRegionOrRoot(this, context, _updatesInvoker);
- broadcastEvents(context, PhaseId.UPDATE_MODEL_VALUES);
- }
+ public void invokeContextCallback(FacesContext context,
+ UIComponent component) {
+ component.processValidators(context);
+ }
- private InvokerCallback _validatorsInvoker = new InvokerCallback() {
+ public void invokeRoot(FacesContext context) {
+ }
- public void invokeContextCallback(FacesContext context, UIComponent component) {
- component.processValidators(context);
+ };
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.ajax4jsf.framework.ajax.AjaxViewBrige#processValidators(javax.faces.context.FacesContext)
+ */
+ public void processValidators(FacesContext context) {
+ if (context == null)
+ throw new NullPointerException("context");
+ processPhase(context, PhaseId.PROCESS_VALIDATIONS, _validatorsInvoker);
}
- public void invokeRoot(FacesContext context) {
- AjaxViewRoot.super.processValidators(context);
+ /*
+ * (non-Javadoc)
+ *
+ * @see
javax.faces.component.UIViewRoot#processApplication(javax.faces.context.FacesContext)
+ */
+ public void processApplication(FacesContext context) {
+ if (context == null)
+ throw new NullPointerException("context");
+ processPhase(context, PhaseId.INVOKE_APPLICATION, null);
}
- };
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.component.UIViewRoot#encodeBegin(javax.faces.context.FacesContext)
+ */
+ // public void encodeBegin(FacesContext context) throws IOException {
+ // UIComponent submittedComponent = getSubmittedRegion(context);
+ // if(null == submittedComponent){
+ // super.encodeBegin(context);
+ // } else {
+ // submittedComponent.encodeBegin(context);
+ // }
+ // }
+ private ContextCallback _ajaxInvoker = new ContextCallback() {
- /*
- * (non-Javadoc)
- *
- * @see
org.ajax4jsf.framework.ajax.AjaxViewBrige#processValidators(javax.faces.context.FacesContext)
- */
- public void processValidators(FacesContext context) {
- if (context == null)
- throw new NullPointerException("context");
- AjaxContextImpl.invokeOnRegionOrRoot(this, context, _validatorsInvoker);
- broadcastEvents(context, PhaseId.PROCESS_VALIDATIONS);
- }
+ public void invokeContextCallback(FacesContext context,
+ UIComponent component) {
+ try {
+ if (component instanceof AjaxContainer) {
+ AjaxContainer ajax = (AjaxContainer) component;
+ ajax.encodeAjax(context);
+ } else {
+ // Container not found, use Root for encode.
+ encodeAjax(context);
+ }
+ } catch (IOException e) {
+ throw new FacesException(e);
+ }
+ }
- /*
- * (non-Javadoc)
- *
- * @see
javax.faces.component.UIViewRoot#processApplication(javax.faces.context.FacesContext)
- */
- public void processApplication(FacesContext context) {
- if (context == null)
- throw new NullPointerException("context");
- // UIComponent component = getSubmittedRegion(context);
- // TODO - process JSF 1.2 listeners
- broadcastEvents(context, PhaseId.INVOKE_APPLICATION);
- }
- /*
- * (non-Javadoc)
- *
- * @see
javax.faces.component.UIViewRoot#encodeBegin(javax.faces.context.FacesContext)
- */
- // public void encodeBegin(FacesContext context) throws IOException {
- // UIComponent submittedComponent = getSubmittedRegion(context);
- // if(null == submittedComponent){
- // super.encodeBegin(context);
- // } else {
- // submittedComponent.encodeBegin(context);
- // }
- // }
- private InvokerCallback _ajaxInvoker = new InvokerCallback() {
+ };
- public void invokeContextCallback(FacesContext context, UIComponent component) {
- try {
- if (component instanceof AjaxContainer) {
- AjaxContainer ajax = (AjaxContainer) component;
- ajax.encodeAjax(context);
+ /*
+ * (non-Javadoc)
+ *
+ * @see
javax.faces.component.UIComponentBase#encodeChildren(javax.faces.context.FacesContext)
+ */
+ public void encodeChildren(FacesContext context) throws IOException {
+ AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
+ if (ajaxContext.isAjaxRequest()) {
+ String submittedRegionClientId = ajaxContext
+ .getSubmittedRegionClientId();
+ if (submittedRegionClientId != null
+ && !submittedRegionClientId.equals(getClientId(context))) {
+ invokeOnComponent(context, submittedRegionClientId,
+ _ajaxInvoker);
+ } else {
+ encodeAjax(context);
+ }
} else {
- // Container not found, use Root for encode.
- encodeAjax(context);
+ super.encodeChildren(context);
}
- } catch (IOException e) {
- throw new FacesException(e);
- }
}
- public void invokeRoot(FacesContext context) {
- try {
- encodeAjax(context);
- } catch (IOException e) {
- throw new FacesException(e);
- }
+ public void restoreState(FacesContext context, Object state) {
+ Object[] mystate = (Object[]) state;
+ super.restoreState(context, mystate[0]);
+ getBrige().restoreState(context, mystate[1]);
+ Object listeners = restoreAttachedState(context, mystate[2]);
+ if (null != listeners) {
+ phaseListeners = (List<PhaseListener>) listeners;
+ }
}
- };
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.ajax4jsf.framework.ajax.AjaxViewBrige#saveState(javax.faces.context.FacesContext)
+ */
+ public Object saveState(FacesContext context) {
+ Object[] state = new Object[3];
+ state[0] = super.saveState(context);
+ state[1] = getBrige().saveState(context);
+ state[2] = saveAttachedState(context, phaseListeners);
+ return state;
+ }
- /*
- * (non-Javadoc)
- *
- * @see
javax.faces.component.UIComponentBase#encodeChildren(javax.faces.context.FacesContext)
- */
- public void encodeChildren(FacesContext context) throws IOException {
- if (!isHavePage()
- && AjaxContext.getCurrentInstance(context).isAjaxRequest()) {
- AjaxContextImpl.invokeOnRegionOrRoot(this, context, _ajaxInvoker);
- } else {
- super.encodeChildren(context);
+ public String getViewId() {
+ ViewIdHolder viewIdHolder = AjaxContext.getCurrentInstance()
+ .getViewIdHolder();
+ String viewId;
+ if (null != viewIdHolder) {
+ viewId = viewIdHolder.getViewId();
+ } else {
+ viewId = super.getViewId();
+ }
+ return viewId;
}
- }
- /*
- * (non-Javadoc)
- *
- * @see
javax.faces.component.UIComponentBase#encodeEnd(javax.faces.context.FacesContext)
- */
- // public void encodeEnd(FacesContext context) throws IOException {
- // UIComponent submittedComponent = getSubmittedRegion(context);
- // if (null == submittedComponent) {
- // super.encodeEnd(context);
- // } else {
- // submittedComponent.encodeEnd(context);
- // }
- // }
- public void restoreState(FacesContext context, Object state) {
- Object[] mystate = (Object[]) state;
- super.restoreState(context, mystate[0]);
- getBrige().restoreState(context, mystate[1]);
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see
org.ajax4jsf.framework.ajax.AjaxViewBrige#setAjaxListener(javax.faces.el.MethodBinding)
+ */
+ public void setAjaxListener(MethodExpression ajaxListener) {
+ getBrige().setAjaxListener(ajaxListener);
+ }
- /*
- * (non-Javadoc)
- *
- * @see
org.ajax4jsf.framework.ajax.AjaxViewBrige#saveState(javax.faces.context.FacesContext)
- */
- public Object saveState(FacesContext context) {
- Object[] state = new Object[2];
- state[0] = super.saveState(context);
- state[1] = getBrige().saveState(context);
- return state;
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.framework.ajax.AjaxViewBrige#setImmediate(boolean)
+ */
+ public void setImmediate(boolean immediate) {
+ getBrige().setImmediate(immediate);
+ }
- public String getViewId() {
- ViewIdHolder viewIdHolder = AjaxContext.getCurrentInstance()
- .getViewIdHolder();
- String viewId;
- if (null != viewIdHolder) {
- viewId = viewIdHolder.getViewId();
- } else {
- viewId = super.getViewId();
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.framework.ajax.AjaxViewBrige#setSubmitted(boolean)
+ */
+ public void setSubmitted(boolean submitted) {
+ getBrige().setSubmitted(submitted);
}
- return viewId;
- }
- /*
- * (non-Javadoc)
- *
- * @see
org.ajax4jsf.framework.ajax.AjaxViewBrige#setAjaxListener(javax.faces.el.MethodBinding)
- */
- public void setAjaxListener(MethodExpression ajaxListener) {
- getBrige().setAjaxListener(ajaxListener);
- }
+ public void addAjaxListener(AjaxListener listener) {
+ addFacesListener(listener);
+ }
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.framework.ajax.AjaxViewBrige#setImmediate(boolean)
- */
- public void setImmediate(boolean immediate) {
- getBrige().setImmediate(immediate);
- }
+ public AjaxListener[] getAjaxListeners() {
+ return (AjaxListener[]) getFacesListeners(AjaxListener.class);
+ }
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.framework.ajax.AjaxViewBrige#setSubmitted(boolean)
- */
- public void setSubmitted(boolean submitted) {
- getBrige().setSubmitted(submitted);
- }
+ public void removeAjaxListener(AjaxListener listener) {
+ removeFacesListener(listener);
- public void addAjaxListener(AjaxListener listener) {
- addFacesListener(listener);
- }
+ }
- public AjaxListener[] getAjaxListeners() {
- return (AjaxListener[]) getFacesListeners(AjaxListener.class);
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.framework.ajax.AjaxViewBrige#isSelfRendered()
+ */
+ public boolean isSelfRendered() {
+ return false;// _brige.isSelfRendered();
+ }
- public void removeAjaxListener(AjaxListener listener) {
- removeFacesListener(listener);
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.framework.ajax.AjaxViewBrige#setSelfRendered(boolean)
+ */
+ public void setSelfRendered(boolean selfRendered) {
+ // _brige.setSelfRendered(selfRendered);
+ }
- }
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.framework.ajax.AjaxViewBrige#isSelfRendered()
- */
- public boolean isSelfRendered() {
- return false;// _brige.isSelfRendered();
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.component.UIComponentBase#getRendersChildren()
+ */
+ public boolean getRendersChildren() {
+ FacesContext context = FacesContext.getCurrentInstance();
+ // For non Ajax request, view root not render children
+ if (!AjaxContext.getCurrentInstance(context).isAjaxRequest()) {
+ return false;
+ }
+ // Ajax Request. Control all output.
+ return true;
+ }
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.framework.ajax.AjaxViewBrige#setSelfRendered(boolean)
- */
- public void setSelfRendered(boolean selfRendered) {
- // _brige.setSelfRendered(selfRendered);
- }
+ public boolean isRenderRegionOnly() {
+ // for viewroot it not applicable.
+ return false;
+ }
- /**
- * Check for AjaxContainer component in childreh. This is workaround for
- * MyFaces JSP tag implementation, not called any encode... methods in
- * <f:view> tag. If only one AjaxContainer present as children for
- * viewRoot, decoding methods delegated to them.
- *
- * @return Returns the havePage.
- */
- public boolean isHavePage() {
- return (getChildCount() == 1 && getChildren().get(0) instanceof AjaxContainer);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.component.UIComponentBase#getRendersChildren()
- */
- public boolean getRendersChildren() {
- FacesContext context = FacesContext.getCurrentInstance();
- // For non Ajax request, view root not render children
- if (!AjaxContext.getCurrentInstance(context).isAjaxRequest()) {
- return false;
+ public void setRenderRegionOnly(boolean reRenderPage) {
+ // Ignore for a ViewRoot.
}
- // Also, if have page component as clild - delegate rendering of
- // children to it.
- if (isHavePage()) {
- return false;
- }
- // Ajax Request. Control all output.
- return true;
- }
- public boolean isRenderRegionOnly() {
- // for viewroot it not applicable.
- return false;
- }
+ public void encodeAjax(FacesContext context) throws IOException {
+ String rendererType = getRendererType();
+ if (rendererType != null) {
+ ((AjaxContainerRenderer) getRenderer(context)).encodeAjax(context,
+ this);
+ }
- public void setRenderRegionOnly(boolean reRenderPage) {
- // Ignore for a ViewRoot.
-
- }
-
-
-
- /**
- * @return
- * @see org.ajax4jsf.component.AjaxRegionBrige#getSubmittedControlId()
- */
- public String getSubmittedControlId() {
- return _brige.getSubmittedControlId();
}
/**
- * @param submittedControlId
- * @see org.ajax4jsf.component.AjaxRegionBrige#setSubmittedControlId(java.lang.String)
+ * @return the brige
*/
- public void setSubmittedControlId(String submittedControlId) {
- _brige.setSubmittedControlId(submittedControlId);
+ protected AjaxRegionBrige getBrige() {
+ return _brige;
}
- public void encodeAjax(FacesContext context) throws IOException {
- String rendererType = getRendererType();
- if (rendererType != null) {
- ((AjaxContainerRenderer) getRenderer(context)).encodeAjax(context,
- this);
- }
-
- }
-
- /**
- * @return the brige
- */
- protected AjaxRegionBrige getBrige() {
- return _brige;
- }
-
}
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxChildrenRenderer.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxChildrenRenderer.java 2008-03-13
20:37:14 UTC (rev 6796)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxChildrenRenderer.java 2008-03-14
00:24:19 UTC (rev 6797)
@@ -50,24 +50,6 @@
"org.apache.myfaces.AliasBeansScope" };
private static final String SPECIAL_TYPES_PARAMETER =
"org.ajax4jsf.CONTROL_COMPONENTS";
- /**
- * Iterate over all childs of components. If component id contains in list ,
- * or, if list is empty, compotents is submitted form - render it. TODO -
- * Instead of calculate full path for every component, build current Path
- * for componet and send as parameter.
- *
- * @param context -
- * current context
- * @param component -
- * curent faces component.
- * @param ids -
- * list of Id to render.
- * @throws IOException
- * @deprecated Use {@link #encodeAjaxChildren(FacesContext,UIComponent,String,Set,Set)}
instead
- */
- public void encodeAjaxChild(FacesContext context, UIComponent component, String path,
Set<String> ids, Set<String> renderedAreas) throws IOException {
- encodeAjaxChildren(context, component, path, ids, renderedAreas);
- }
/* (non-Javadoc)
* @see
org.ajax4jsf.renderkit.AjaxRenderer#encodeAjaxChildren(javax.faces.context.FacesContext,
javax.faces.component.UIComponent, java.lang.String, java.util.Set, java.util.Set)
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxContainerRenderer.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxContainerRenderer.java 2008-03-13
20:37:14 UTC (rev 6796)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxContainerRenderer.java 2008-03-14
00:24:19 UTC (rev 6797)
@@ -156,7 +156,6 @@
AjaxContainer ajaxContainer = (AjaxContainer) component;
if (null != ajaxParameter && ajaxParameter.equals(clientId)) {
ajaxContainer.setSubmitted(true);
- ajaxContainer.setSubmittedControlId(paramMap.get(AjaxRendererUtils.AJAX_SINGLE_ATTR));
AjaxEvent event = new AjaxEvent(component);
component.queueEvent(event);
} else {
Modified:
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxViewRootRenderer.java
===================================================================
---
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxViewRootRenderer.java 2008-03-13
20:37:14 UTC (rev 6796)
+++
trunk/framework/impl/src/main/java/org/ajax4jsf/renderkit/AjaxViewRootRenderer.java 2008-03-14
00:24:19 UTC (rev 6797)
@@ -46,23 +46,6 @@
}
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.renderkit.RendererBase#doDecode(javax.faces.context.FacesContext,
- * javax.faces.component.UIComponent)
- */
-// protected void doDecode(FacesContext context, UIComponent component) {
-// AjaxViewRoot root = (AjaxViewRoot) component;
-// if(root.isSubmitted()) {
-// // Find submitted ajax region.
-// String ajaxId = (String)
context.getExternalContext().getRequestParameterMap().get(AJAX_PARAMETER_NAME);
-// String ajaxRegion = root.getAjaxRegionId(ajaxId);
-// if(null != ajaxRegion){
-// root.setSubmittedRegion(ajaxRegion);
-// }
-// }
-// }
/*
* (non-Javadoc)
@@ -73,38 +56,5 @@
return AjaxViewRoot.class;
}
- /*
- * (non-Javadoc)
- *
- * @see
org.ajax4jsf.renderkit.RendererBase#doEncodeEnd(javax.faces.context.ResponseWriter,
- * javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
-// protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException {
-// UIComponent submittedComponent = ((AjaxViewRoot)
component).getSubmittedRegion(context);
-// if (null == submittedComponent) {
-// super.doEncodeEnd(writer,context,component);
-// } else {
-// submittedComponent.encodeEnd(context);
-// }
-// }
-
- /*
- * (non-Javadoc)
- *
- * @see
org.ajax4jsf.renderkit.RendererBase#doEncodeBegin(javax.faces.context.ResponseWriter,
- * javax.faces.context.FacesContext, javax.faces.component.UIComponent)
- */
-// protected void doEncodeBegin(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException {
-// // Reset instance of submitted region
-// AjaxViewRoot ajaxViewRoot = ((AjaxViewRoot) component);
-// ajaxViewRoot.resetSubmittedRegionInstance();
-// UIComponent submittedComponent = ajaxViewRoot.getSubmittedRegion(context);
-// if (null == submittedComponent) {
-// super.doEncodeBegin(writer, context, component);
-// } else {
-// submittedComponent.encodeBegin(context);
-// }
-// }
-
}
Added: trunk/framework/test/src/main/java/org/ajax4jsf/tests/MockUIComponent.java
===================================================================
--- trunk/framework/test/src/main/java/org/ajax4jsf/tests/MockUIComponent.java
(rev 0)
+++ trunk/framework/test/src/main/java/org/ajax4jsf/tests/MockUIComponent.java 2008-03-14
00:24:19 UTC (rev 6797)
@@ -0,0 +1,114 @@
+/**
+ *
+ */
+package org.ajax4jsf.tests;
+
+import javax.faces.FacesException;
+import javax.faces.component.ContextCallback;
+import javax.faces.component.UIComponentBase;
+import javax.faces.context.FacesContext;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.FacesEvent;
+
+/**
+ * "probe" component, to chek runs of the component methods during tests.
+ * @author asmirnov
+ *
+ */
+public class MockUIComponent extends UIComponentBase {
+
+ private int runsProcessDecodes = 0;
+ private int runsDecode = 0;
+ private int runsBroadcast=0;
+ private int runsInvokeOnComponent=0;
+ private int runsProcessUpdates=0;
+ private int runsProcessValidators=0;
+
+ /**
+ * @return the runsProcessDecodes
+ */
+ public int getRunsProcessDecodes() {
+ return runsProcessDecodes;
+ }
+
+ /**
+ * @return the runsDecode
+ */
+ public int getRunsDecode() {
+ return runsDecode;
+ }
+
+ /**
+ * @return the runsBroadcast
+ */
+ public int getRunsBroadcast() {
+ return runsBroadcast;
+ }
+
+ /**
+ * @return the runsInvokeOnComponent
+ */
+ public int getRunsInvokeOnComponent() {
+ return runsInvokeOnComponent;
+ }
+
+ /**
+ * @return the runsProcessUpdates
+ */
+ public int getRunsProcessUpdates() {
+ return runsProcessUpdates;
+ }
+
+ /**
+ * @return the runsProcessValidators
+ */
+ public int getRunsProcessValidators() {
+ return runsProcessValidators;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.component.UIComponent#getFamily()
+ */
+ @Override
+ public String getFamily() {
+ // TODO Auto-generated method stub
+ return "org.ajax4jsf.test";
+ }
+
+ @Override
+ public void processDecodes(FacesContext context) {
+ runsProcessDecodes++;
+ super.processDecodes(context);
+ }
+
+ @Override
+ public void decode(FacesContext context) {
+ runsDecode++;
+ super.decode(context);
+ }
+
+ @Override
+ public void broadcast(FacesEvent event) throws AbortProcessingException {
+ runsBroadcast++;
+ super.broadcast(event);
+ }
+
+ @Override
+ public boolean invokeOnComponent(FacesContext context, String clientId,
+ ContextCallback callback) throws FacesException {
+ runsInvokeOnComponent++;
+ return super.invokeOnComponent(context, clientId, callback);
+ }
+
+ @Override
+ public void processUpdates(FacesContext context) {
+ runsProcessUpdates++;
+ super.processUpdates(context);
+ }
+
+ @Override
+ public void processValidators(FacesContext context) {
+ runsProcessValidators++;
+ super.processValidators(context);
+ }
+}
Property changes on:
trunk/framework/test/src/main/java/org/ajax4jsf/tests/MockUIComponent.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Date Revision Author
Modified: trunk/framework/test/src/main/java/org/ajax4jsf/tests/MockViewRoot.java
===================================================================
--- trunk/framework/test/src/main/java/org/ajax4jsf/tests/MockViewRoot.java 2008-03-13
20:37:14 UTC (rev 6796)
+++ trunk/framework/test/src/main/java/org/ajax4jsf/tests/MockViewRoot.java 2008-03-14
00:24:19 UTC (rev 6797)
@@ -21,7 +21,6 @@
package org.ajax4jsf.tests;
-import javax.faces.context.FacesContext;
import javax.faces.event.PhaseId;
import org.ajax4jsf.component.AjaxViewRoot;
@@ -34,16 +33,16 @@
*/
public class MockViewRoot extends AjaxViewRoot {
- public EventsQueue getAjaxEventsQueue(FacesContext context) {
- return super.getAjaxEventsQueue(context);
+ public EventsQueue getAjaxEventsQueue() {
+ return super.getAjaxEventsQueue();
}
- public EventsQueue[] getEvents(FacesContext context) {
- return super.getEvents(context);
+ public EventsQueue[] getEvents() {
+ return super.getEvents();
}
- public EventsQueue getEventsQueue(FacesContext context, PhaseId phase) {
- return super.getEventsQueue(context, phase);
+ public EventsQueue getEventsQueue(PhaseId phase) {
+ return super.getEventsQueue(phase);
}
}
Added: trunk/framework/test/src/test/java/org/ajax4jsf/component/AjaxViewRootTest.java
===================================================================
--- trunk/framework/test/src/test/java/org/ajax4jsf/component/AjaxViewRootTest.java
(rev 0)
+++
trunk/framework/test/src/test/java/org/ajax4jsf/component/AjaxViewRootTest.java 2008-03-14
00:24:19 UTC (rev 6797)
@@ -0,0 +1,289 @@
+package org.ajax4jsf.component;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.el.MethodExpression;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIPanel;
+import javax.faces.context.FacesContext;
+import javax.faces.event.PhaseEvent;
+import javax.faces.event.PhaseId;
+import javax.faces.event.PhaseListener;
+import javax.faces.render.RenderKitFactory;
+
+import org.ajax4jsf.context.AjaxContext;
+import org.ajax4jsf.context.InvokerCallback;
+import org.ajax4jsf.renderkit.AjaxContainerRenderer;
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.ajax4jsf.tests.MockUIComponent;
+
+public class AjaxViewRootTest extends AbstractAjax4JsfTestCase {
+
+ /**
+ * @author asmirnov
+ *
+ */
+ public static class InvokerCallbackImpl implements InvokerCallback {
+
+ private int runsRoot = 0;
+
+ private List<UIComponent> callbackComponents = new
ArrayList<UIComponent>();
+
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.context.InvokerCallback#invokeContextCallback(javax.faces.context.FacesContext,
javax.faces.component.UIComponent)
+ */
+ public void invokeContextCallback(FacesContext context,
+ UIComponent component) {
+ callbackComponents.add(component);
+ }
+
+ /* (non-Javadoc)
+ * @see
org.ajax4jsf.context.InvokerCallback#invokeRoot(javax.faces.context.FacesContext)
+ */
+ public void invokeRoot(FacesContext context) {
+ runsRoot++;
+
+ }
+
+ }
+
+ public static final class PhaseListenerImplementation implements PhaseListener {
+ private int runsBefore = 0;
+ private int runsAfter = 0;
+ private PhaseId phase = PhaseId.ANY_PHASE;
+
+ public void afterPhase(PhaseEvent event) {
+ runsAfter++;
+ }
+
+ public void beforePhase(PhaseEvent event) {
+ runsBefore++;
+
+ }
+
+ public PhaseId getPhaseId() {
+
+ return phase;
+ }
+
+ /**
+ * @return the runsBefore
+ */
+ int getRunsBefore() {
+ return runsBefore;
+ }
+
+ /**
+ * @return the runsAfter
+ */
+ int getRunsAfter() {
+ return runsAfter;
+ }
+
+ /**
+ * @param phase the phase to set
+ */
+ void setPhaseId(PhaseId phase) {
+ this.phase = phase;
+ }
+ }
+
+ private AjaxViewRoot _ajaxRoot;
+ private PhaseListenerImplementation _testListener;
+ private PhaseListenerImplementation _phaseListener;
+ private MockUIComponent _panel;
+ private MockUIComponent _mockComponent;
+
+ public AjaxViewRootTest(String name) {
+ super(name);
+ }
+
+ public void setUp() throws Exception {
+ super.setUp();
+ _ajaxRoot = new AjaxViewRoot();
+ _ajaxRoot.setViewId("/viewId");
+ _ajaxRoot.setRenderKitId(RenderKitFactory.HTML_BASIC_RENDER_KIT);
+ _testListener = new PhaseListenerImplementation();
+ externalContext.getRequestMap().put("listener", _testListener);
+ facesContext.setViewRoot(_ajaxRoot);
+ }
+
+ public void tearDown() throws Exception {
+ _ajaxRoot = null;
+ _testListener = null;
+ super.tearDown();
+ }
+
+ public final void testProcessPhaseListeners() {
+ MethodExpression beforeExpression =
application.getExpressionFactory().createMethodExpression(elContext,
"#{listener.beforePhase}", null, new Class<?>[]{PhaseEvent.class});
+ MethodExpression afterExpression =
application.getExpressionFactory().createMethodExpression(elContext,
"#{listener.afterPhase}", null, new Class<?>[]{PhaseEvent.class});
+ _ajaxRoot.setBeforePhaseListener(beforeExpression);
+ _ajaxRoot.setAfterPhaseListener(afterExpression);
+ PhaseListenerImplementation phaseListener = new PhaseListenerImplementation();
+ _ajaxRoot.addPhaseListener(phaseListener);
+ _ajaxRoot.processPhaseListeners(facesContext, PhaseId.RESTORE_VIEW, true);
+ assertEquals(1, this._testListener.runsBefore);
+ assertEquals(0, this._testListener.runsAfter);
+ assertEquals(1, phaseListener.runsBefore);
+ assertEquals(0, phaseListener.runsAfter);
+ phaseListener.setPhaseId(PhaseId.PROCESS_VALIDATIONS);
+ _ajaxRoot.processPhaseListeners(facesContext, PhaseId.RESTORE_VIEW, false);
+ assertEquals(1, this._testListener.runsBefore);
+ assertEquals(1, this._testListener.runsAfter);
+ assertEquals(1, phaseListener.runsBefore);
+ assertEquals(0, phaseListener.runsAfter);
+ }
+
+ public final void testCreatePhaseEvent() {
+ PhaseEvent phaseEvent = _ajaxRoot.createPhaseEvent(facesContext,
PhaseId.APPLY_REQUEST_VALUES);
+ assertSame(facesContext, phaseEvent.getFacesContext());
+ assertSame(PhaseId.APPLY_REQUEST_VALUES, phaseEvent.getPhaseId());
+ assertSame(lifecycle, phaseEvent.getSource());
+ }
+
+ public final void testProcessPhase() {
+ prepareView(PhaseId.APPLY_REQUEST_VALUES);
+ InvokerCallbackImpl callback = new InvokerCallbackImpl(){
+ @Override
+ public void invokeContextCallback(FacesContext context,
+ UIComponent component) {
+ super.invokeContextCallback(context, component);
+ component.processDecodes(context);
+ }
+ };
+ _ajaxRoot.processPhase(facesContext, PhaseId.APPLY_REQUEST_VALUES, callback);
+ // Check phase listeners calls.
+ assertEquals(1, this._testListener.runsBefore);
+ assertEquals(1, this._testListener.runsAfter);
+ assertEquals(1, _phaseListener.runsBefore);
+ assertEquals(1, _phaseListener.runsAfter);
+ // Check callbacks runs.
+ assertEquals(1, callback.runsRoot);
+ assertEquals(1, callback.callbackComponents.size());
+ assertSame(_panel,callback.callbackComponents.get(0));
+ assertEquals(1, _mockComponent.getRunsDecode());
+
+ }
+
+ public final void testProcessAjaxPhase() {
+ externalContext.addRequestParameterMap(AjaxContext.AJAX_CONTEXT_KEY,
_ajaxRoot.getClientId(facesContext));
+ ajaxContext.decode(facesContext);
+ prepareView(PhaseId.APPLY_REQUEST_VALUES);
+ InvokerCallbackImpl callback = new InvokerCallbackImpl(){
+ @Override
+ public void invokeContextCallback(FacesContext context,
+ UIComponent component) {
+ super.invokeContextCallback(context, component);
+ component.processDecodes(context);
+ }
+ };
+ _ajaxRoot.processPhase(facesContext, PhaseId.APPLY_REQUEST_VALUES, callback);
+ // Check phase listeners calls.
+ assertEquals(1, this._testListener.runsBefore);
+ assertEquals(1, this._testListener.runsAfter);
+ assertEquals(1, _phaseListener.runsBefore);
+ assertEquals(1, _phaseListener.runsAfter);
+ // Check callbacks runs.
+ assertEquals(1, callback.runsRoot);
+ assertEquals(1, callback.callbackComponents.size());
+ assertSame(_panel,callback.callbackComponents.get(0));
+ assertEquals(1, _mockComponent.getRunsDecode());
+
+ }
+
+ public final void testProcessAjaxRegionPhase() {
+ prepareView(PhaseId.APPLY_REQUEST_VALUES);
+ externalContext.addRequestParameterMap(AjaxContainerRenderer.AJAX_PARAMETER_NAME,
_mockComponent.getClientId(facesContext));
+ ajaxContext.decode(facesContext);
+ InvokerCallbackImpl callback = new InvokerCallbackImpl(){
+ @Override
+ public void invokeContextCallback(FacesContext context,
+ UIComponent component) {
+ super.invokeContextCallback(context, component);
+ component.processDecodes(context);
+ }
+ };
+ _ajaxRoot.processPhase(facesContext, PhaseId.APPLY_REQUEST_VALUES, callback);
+ // Check phase listeners calls.
+ assertEquals(1, this._testListener.runsBefore);
+ assertEquals(1, this._testListener.runsAfter);
+ assertEquals(1, _phaseListener.runsBefore);
+ assertEquals(1, _phaseListener.runsAfter);
+ // Check callbacks runs.
+ assertEquals(0, callback.runsRoot);
+ assertEquals(1, callback.callbackComponents.size());
+ assertSame(_mockComponent,callback.callbackComponents.get(0));
+ assertEquals(1, _mockComponent.getRunsDecode());
+
+ }
+ /**
+ * @param phaseId TODO
+ *
+ */
+ private void prepareView(PhaseId phaseId) {
+ MethodExpression beforeExpression =
application.getExpressionFactory().createMethodExpression(elContext,
"#{listener.beforePhase}", null, new Class<?>[]{PhaseEvent.class});
+ MethodExpression afterExpression =
application.getExpressionFactory().createMethodExpression(elContext,
"#{listener.afterPhase}", null, new Class<?>[]{PhaseEvent.class});
+ _ajaxRoot.setBeforePhaseListener(beforeExpression);
+ _ajaxRoot.setAfterPhaseListener(afterExpression);
+ _phaseListener = new PhaseListenerImplementation();
+ _phaseListener.setPhaseId(phaseId);
+ _ajaxRoot.addPhaseListener(_phaseListener);
+ _panel = new MockUIComponent();
+ _panel.setId("panel");
+ _mockComponent = new MockUIComponent();
+ _mockComponent.setId("component");
+ _panel.getChildren().add(_mockComponent);
+ _ajaxRoot.getChildren().add(_panel);
+ }
+
+
+
+ public final void testProcessDecodes() {
+ prepareView(PhaseId.APPLY_REQUEST_VALUES);
+ externalContext.addRequestParameterMap(AjaxContainerRenderer.AJAX_PARAMETER_NAME,
_mockComponent.getClientId(facesContext));
+ ajaxContext.decode(facesContext);
+ _ajaxRoot.processDecodes(facesContext);
+ // Check phase listeners calls.
+ assertEquals(1, this._testListener.runsBefore);
+ assertEquals(1, this._testListener.runsAfter);
+ assertEquals(1, _phaseListener.runsBefore);
+ assertEquals(1, _phaseListener.runsAfter);
+ assertEquals(0, _panel.getRunsDecode());
+ assertEquals(1, _mockComponent.getRunsDecode());
+ }
+
+ public final void testQueueEventFacesEvent() {
+ // fail("Not yet implemented");
+ }
+
+ public final void testBroadcastEvents() {
+ // fail("Not yet implemented");
+ }
+
+ public final void testProcessEvents() {
+ // fail("Not yet implemented");
+ }
+
+ public final void testBroadcastAjaxEvents() {
+ // fail("Not yet implemented");
+ }
+
+ public final void testGetEventsQueue() {
+ // fail("Not yet implemented");
+ }
+
+ public final void testGetEvents() {
+ // fail("Not yet implemented");
+ }
+
+ public final void testGetAjaxEventsQueue() {
+ // fail("Not yet implemented");
+ }
+
+ public final void testClearEvents() {
+ // fail("Not yet implemented");
+ }
+
+}
Property changes on:
trunk/framework/test/src/test/java/org/ajax4jsf/component/AjaxViewRootTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Date Revision Author
Modified: trunk/ui/core/src/main/java/org/ajax4jsf/component/UIAjaxRegion.java
===================================================================
--- trunk/ui/core/src/main/java/org/ajax4jsf/component/UIAjaxRegion.java 2008-03-13
20:37:14 UTC (rev 6796)
+++ trunk/ui/core/src/main/java/org/ajax4jsf/component/UIAjaxRegion.java 2008-03-14
00:24:19 UTC (rev 6797)
@@ -22,9 +22,11 @@
package org.ajax4jsf.component;
import java.io.IOException;
+import java.util.Iterator;
import javax.el.MethodExpression;
import javax.faces.FacesException;
+import javax.faces.component.ContextCallback;
import javax.faces.component.UIComponent;
import javax.faces.component.UIPanel;
import javax.faces.component.UIViewRoot;
@@ -47,6 +49,27 @@
private AjaxRegionBrige brige;
+ private static final ContextCallback decodeCallback= new ContextCallback(){
+ public void invokeContextCallback(FacesContext context,
+ UIComponent target) {
+ target.processDecodes(context);
+ }
+ };
+
+ private static final ContextCallback validateCallback= new ContextCallback(){
+ public void invokeContextCallback(FacesContext context,
+ UIComponent target) {
+ target.processValidators(context);
+ }
+ };
+
+ private static final ContextCallback updateCallback= new ContextCallback(){
+ public void invokeContextCallback(FacesContext context,
+ UIComponent target) {
+ target.processUpdates(context);
+ }
+ };
+
public static final String COMPONENT_TYPE = "org.ajax4jsf.AjaxRegion";
/**
@@ -56,64 +79,50 @@
brige = new AjaxRegionBrige(this);
}
- /*
- * (non-Javadoc)
- *
- * @see
javax.faces.component.UIComponentBase#encodeBegin(javax.faces.context.FacesContext)
- */
-// public void encodeBegin(FacesContext context) throws IOException {
-// UIViewRoot root = context.getViewRoot();
-// if (root instanceof AjaxViewRoot) {
-// ((AjaxViewRoot) root).addAjaxRegion(this);
-// }
-// super.encodeBegin(context);
-// }
-
- private InvokerCallback _ajaxInvoker = new InvokerCallback() {
-
- public void invokeContextCallback(FacesContext context, UIComponent component) {
- try {
- if (component instanceof AjaxContainer) {
- AjaxContainer ajax = (AjaxContainer) component;
- ajax.encodeAjax(context);
- } else {
- // Container not found, use Root for encode.
- encodeAjax(context);
- }
- } catch (IOException e) {
- throw new FacesException(e);
- }
+ @Override
+ public void processDecodes(FacesContext context) {
+ AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
+ String ajaxSingleClientId = ajaxContext.getAjaxSingleClientId();
+ // Process this component itself
+ try {
+ decode(context);
+ } catch (RuntimeException e) {
+ context.renderResponse();
+ throw e;
}
-
- public void invokeRoot(FacesContext context) {
- try {
- encodeAjax(context);
- } catch (IOException e) {
- throw new FacesException(e);
+ if (ajaxContext.isAjaxRequest() && null != ajaxSingleClientId) {
+ invokeOnComponent(context, ajaxSingleClientId, decodeCallback);
+ } else {
+ // Process all facets and children of this component
+ Iterator<UIComponent> kids = getFacetsAndChildren();
+ while (kids.hasNext()) {
+ UIComponent kid = kids.next();
+ kid.processDecodes(context);
}
}
- };
+ }
- /*
- * (non-Javadoc)
- *
- * @see
javax.faces.component.UIComponentBase#encodeChildren(javax.faces.context.FacesContext)
- */
- public void encodeChildren(FacesContext context) throws IOException {
- // If this region is single child of ViewRoot, encode Ajax response for
- // submitted container.
- UIViewRoot viewRoot = context.getViewRoot();
+ @Override
+ public void processValidators(FacesContext context) {
AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
- if ( (getParent() == viewRoot) &&
- (viewRoot instanceof AjaxViewRoot) &&
- ((AjaxViewRoot) viewRoot).isHavePage() &&
- (ajaxContext.isAjaxRequest())) {
- AjaxContextImpl.invokeOnRegionOrRoot((AjaxViewRoot) viewRoot, context, _ajaxInvoker);
+ String ajaxSingleClientId = ajaxContext.getAjaxSingleClientId();
+ if (ajaxContext.isAjaxRequest() && null != ajaxSingleClientId) {
+ invokeOnComponent(context, ajaxSingleClientId, validateCallback);
} else {
- super.encodeChildren(context);
+ super.processValidators(context);
}
}
+ @Override
+ public void processUpdates(FacesContext context) {
+ AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
+ String ajaxSingleClientId = ajaxContext.getAjaxSingleClientId();
+ if (ajaxContext.isAjaxRequest() && null != ajaxSingleClientId) {
+ invokeOnComponent(context, ajaxSingleClientId, updateCallback);
+ } else {
+ super.processUpdates(context);
+ }
+ }
/*
* (non-Javadoc)
*
@@ -242,13 +251,6 @@
}
- /**
- * @return
- * @see org.ajax4jsf.component.AjaxRegionBrige#getSubmittedControlId()
- */
- public String getSubmittedControlId() {
- return brige.getSubmittedControlId();
- }
/**
* @return
@@ -258,13 +260,6 @@
return brige.isTransient();
}
- /**
- * @param submittedControlId
- * @see org.ajax4jsf.component.AjaxRegionBrige#setSubmittedControlId(java.lang.String)
- */
- public void setSubmittedControlId(String submittedControlId) {
- brige.setSubmittedControlId(submittedControlId);
- }
/**
* @param transientFlag
Modified: trunk/ui/drag-drop/src/test/java/org/richfaces/component/DragDropTest.java
===================================================================
--- trunk/ui/drag-drop/src/test/java/org/richfaces/component/DragDropTest.java 2008-03-13
20:37:14 UTC (rev 6796)
+++ trunk/ui/drag-drop/src/test/java/org/richfaces/component/DragDropTest.java 2008-03-14
00:24:19 UTC (rev 6797)
@@ -198,7 +198,7 @@
MockViewRoot root = (MockViewRoot) facesContext.getViewRoot();
EventsQueue queue = root
- .getEventsQueue(facesContext, PhaseId.ANY_PHASE);
+ .getEventsQueue(PhaseId.ANY_PHASE);
assertNotNull(queue);
while (true) {
try {
Modified:
trunk/ui/menu-components/src/test/java/org/richfaces/component/MenuItemComponentTest.java
===================================================================
---
trunk/ui/menu-components/src/test/java/org/richfaces/component/MenuItemComponentTest.java 2008-03-13
20:37:14 UTC (rev 6796)
+++
trunk/ui/menu-components/src/test/java/org/richfaces/component/MenuItemComponentTest.java 2008-03-14
00:24:19 UTC (rev 6797)
@@ -320,8 +320,7 @@
menuItem.decode(facesContext);
MockViewRoot mockViewRoot = (MockViewRoot) facesContext.getViewRoot();
- EventsQueue events = mockViewRoot.getEventsQueue(facesContext,
- PhaseId.APPLY_REQUEST_VALUES);
+ EventsQueue events = mockViewRoot.getEventsQueue(PhaseId.APPLY_REQUEST_VALUES);
assertNotNull(events);
assertEquals(1, events.size());
}
@@ -339,8 +338,7 @@
menuItem.decode(facesContext);
MockViewRoot mockViewRoot = (MockViewRoot) facesContext.getViewRoot();
- EventsQueue events = mockViewRoot.getEventsQueue(facesContext,
- PhaseId.INVOKE_APPLICATION);
+ EventsQueue events = mockViewRoot.getEventsQueue(PhaseId.INVOKE_APPLICATION);
assertNotNull(events);
assertEquals(1, events.size());
}
Modified:
trunk/ui/panelbar/src/test/java/org/richfaces/component/PanelBarComponentTest.java
===================================================================
---
trunk/ui/panelbar/src/test/java/org/richfaces/component/PanelBarComponentTest.java 2008-03-13
20:37:14 UTC (rev 6796)
+++
trunk/ui/panelbar/src/test/java/org/richfaces/component/PanelBarComponentTest.java 2008-03-14
00:24:19 UTC (rev 6797)
@@ -255,8 +255,7 @@
panelBar.decode(facesContext);
MockViewRoot mockViewRoot = (MockViewRoot) facesContext.getViewRoot();
- EventsQueue events = mockViewRoot.getEventsQueue(facesContext,
- PhaseId.APPLY_REQUEST_VALUES);
+ EventsQueue events = mockViewRoot.getEventsQueue(PhaseId.APPLY_REQUEST_VALUES);
assertNotNull(events);
assertEquals(1, events.size());
@@ -275,8 +274,7 @@
panelBar.decode(facesContext);
MockViewRoot mockViewRoot = (MockViewRoot) facesContext.getViewRoot();
- EventsQueue events = mockViewRoot.getEventsQueue(facesContext,
- PhaseId.INVOKE_APPLICATION);
+ EventsQueue events = mockViewRoot.getEventsQueue(PhaseId.INVOKE_APPLICATION);
assertNotNull(events);
assertEquals(0, events.size());
}
Modified:
trunk/ui/togglePanel/src/test/java/org/richfaces/component/TogglePanelComponentTest.java
===================================================================
---
trunk/ui/togglePanel/src/test/java/org/richfaces/component/TogglePanelComponentTest.java 2008-03-13
20:37:14 UTC (rev 6796)
+++
trunk/ui/togglePanel/src/test/java/org/richfaces/component/TogglePanelComponentTest.java 2008-03-14
00:24:19 UTC (rev 6797)
@@ -335,8 +335,7 @@
toggleControl.decode(facesContext);
MockViewRoot mockViewRoot = (MockViewRoot) facesContext.getViewRoot();
- EventsQueue events = mockViewRoot.getEventsQueue(facesContext,
- PhaseId.APPLY_REQUEST_VALUES);
+ EventsQueue events = mockViewRoot.getEventsQueue(PhaseId.APPLY_REQUEST_VALUES);
assertNotNull(events);
assertEquals(2, events.size());
@@ -345,8 +344,7 @@
SwitchablePanelSwitchEvent switchEvent = (SwitchablePanelSwitchEvent) event;
assertEquals(switchEvent.getValue(), "ABYBC");
- events = mockViewRoot.getEventsQueue(facesContext,
- PhaseId.INVOKE_APPLICATION);
+ events = mockViewRoot.getEventsQueue(PhaseId.INVOKE_APPLICATION);
assertNotNull(events);
assertEquals(1, events.size());
@@ -370,8 +368,7 @@
togglePanel.decode(facesContext);
MockViewRoot mockViewRoot = (MockViewRoot) facesContext.getViewRoot();
- EventsQueue events = mockViewRoot.getEventsQueue(facesContext,
- PhaseId.INVOKE_APPLICATION);
+ EventsQueue events = mockViewRoot.getEventsQueue(PhaseId.INVOKE_APPLICATION);
assertNotNull(events);
assertEquals(0, events.size());
@@ -384,8 +381,7 @@
togglePanel.decode(facesContext);
mockViewRoot = (MockViewRoot) facesContext.getViewRoot();
- events = mockViewRoot.getEventsQueue(facesContext,
- PhaseId.INVOKE_APPLICATION);
+ events = mockViewRoot.getEventsQueue(PhaseId.INVOKE_APPLICATION);
assertNotNull(events);
assertEquals(0, events.size());
}
Modified: trunk/ui/tree/src/test/java/org/richfaces/component/events/TreeEventsTest.java
===================================================================
---
trunk/ui/tree/src/test/java/org/richfaces/component/events/TreeEventsTest.java 2008-03-13
20:37:14 UTC (rev 6796)
+++
trunk/ui/tree/src/test/java/org/richfaces/component/events/TreeEventsTest.java 2008-03-14
00:24:19 UTC (rev 6797)
@@ -102,7 +102,7 @@
MockMethodBinding binding = new MockMethodBinding();
treeNode.setNodeSelectListener(binding);
- EventsQueue events = mockViewRoot.getAjaxEventsQueue(facesContext);
+ EventsQueue events = mockViewRoot.getAjaxEventsQueue();
assertNotNull(events);
assertEquals(0, events.size());
@@ -125,7 +125,7 @@
MockMethodBinding binding = new MockMethodBinding();
treeNode.setNodeSelectListener(binding);
- EventsQueue events = mockViewRoot.getAjaxEventsQueue(facesContext);
+ EventsQueue events = mockViewRoot.getAjaxEventsQueue();
assertNotNull(events);
assertEquals(0, events.size());
assertEquals(0, binding.getInvocationArgs().length);