Author: nbelaevski
Date: 2010-05-26 11:54:58 -0400 (Wed, 26 May 2010)
New Revision: 17269
Modified:
root/ui/core/trunk/api/src/main/java/org/ajax4jsf/component/behavior/AjaxBehavior.java
root/ui/core/trunk/api/src/main/java/org/ajax4jsf/renderkit/AjaxBehaviorRenderer.java
Log:
https://jira.jboss.org/browse/RF-7825
Modified:
root/ui/core/trunk/api/src/main/java/org/ajax4jsf/component/behavior/AjaxBehavior.java
===================================================================
---
root/ui/core/trunk/api/src/main/java/org/ajax4jsf/component/behavior/AjaxBehavior.java 2010-05-26
15:52:25 UTC (rev 17268)
+++
root/ui/core/trunk/api/src/main/java/org/ajax4jsf/component/behavior/AjaxBehavior.java 2010-05-26
15:54:58 UTC (rev 17269)
@@ -29,7 +29,10 @@
import javax.faces.FacesException;
import javax.faces.component.behavior.ClientBehaviorHint;
+import javax.faces.context.FacesContext;
+import javax.faces.event.AbortProcessingException;
import javax.faces.event.AjaxBehaviorListener;
+import javax.faces.event.BehaviorEvent;
import org.ajax4jsf.component.AjaxClientBehavior;
import org.ajax4jsf.renderkit.AjaxRendererUtils;
@@ -51,7 +54,8 @@
.of(ClientBehaviorHint.SUBMITTING));
enum PropertyKeys {
- data, execute, onbeforedomupdate, onbegin, oncomplete, onerror, onevent, queueId,
render, similarityGroupingId, status, disabled, limitRender, immediate
+ data, execute, onbeforedomupdate, onbegin, oncomplete, onerror, onevent, queueId,
render, similarityGroupingId,
+ status, disabled, limitRender, immediate, bypassUpdates
}
private static final Set<String> ALL_SINGLETON_SET =
Collections.singleton(AjaxRendererUtils.ALL);
@@ -104,6 +108,8 @@
setLimitRender((Boolean) value);
} else if (compare(PropertyKeys.immediate, name)) {
setImmediate((Boolean) value);
+ } else if (compare(PropertyKeys.bypassUpdates, name)) {
+ setBypassUpdates((Boolean) value);
}
}
@@ -265,6 +271,14 @@
getStateHelper().put(PropertyKeys.limitRender, immediate);
}
+ public boolean isBypassUpdates() {
+ return (Boolean) getStateHelper().eval(PropertyKeys.bypassUpdates, false);
+ }
+
+ public void setBypassUpdates(boolean bypassUpdates) {
+ getStateHelper().put(PropertyKeys.bypassUpdates, bypassUpdates);
+ }
+
@Override
public String getRendererType() {
return BEHAVIOR_ID;
@@ -283,4 +297,12 @@
removeBehaviorListener(listener);
}
+ @Override
+ public void broadcast(BehaviorEvent event) throws AbortProcessingException {
+ if (this.equals(event.getBehavior()) && isBypassUpdates()) {
+ FacesContext.getCurrentInstance().renderResponse();
+ }
+
+ super.broadcast(event);
+ }
}
Modified:
root/ui/core/trunk/api/src/main/java/org/ajax4jsf/renderkit/AjaxBehaviorRenderer.java
===================================================================
---
root/ui/core/trunk/api/src/main/java/org/ajax4jsf/renderkit/AjaxBehaviorRenderer.java 2010-05-26
15:52:25 UTC (rev 17268)
+++
root/ui/core/trunk/api/src/main/java/org/ajax4jsf/renderkit/AjaxBehaviorRenderer.java 2010-05-26
15:54:58 UTC (rev 17269)
@@ -55,6 +55,9 @@
)
public class AjaxBehaviorRenderer extends ClientBehaviorRenderer {
+
+ private final RendererUtils utils = RendererUtils.getInstance();
+
@Override
public void decode(FacesContext context, UIComponent component, ClientBehavior
behavior) {
if (null == context || null == component || null == behavior) {
@@ -74,19 +77,27 @@
component.queueEvent(createEvent(component, ajaxBehavior));
}
- private static AjaxBehaviorEvent createEvent(UIComponent component, AjaxBehavior
ajaxBehavior) {
+ private AjaxBehaviorEvent createEvent(UIComponent component, AjaxBehavior
ajaxBehavior) {
AjaxBehaviorEvent event = new AjaxBehaviorEvent(component, ajaxBehavior);
- PhaseId phaseId = isImmediate(component, ajaxBehavior)
- ? PhaseId.APPLY_REQUEST_VALUES : PhaseId.INVOKE_APPLICATION;
+ PhaseId phaseId;
+
+ if (isImmediate(component, ajaxBehavior)) {
+ phaseId = PhaseId.APPLY_REQUEST_VALUES;
+ } else if (isBypassUpdates(component, ajaxBehavior)) {
+ //TODO nick - what if behavior is immediate & bypassUpdates in the same
time?
+ phaseId = PhaseId.PROCESS_VALIDATIONS;
+ } else {
+ phaseId = PhaseId.INVOKE_APPLICATION;
+ }
event.setPhaseId(phaseId);
return event;
}
- private static boolean isImmediate(UIComponent component, AjaxBehavior ajaxBehavior)
{
+ private boolean isImmediate(UIComponent component, AjaxBehavior ajaxBehavior) {
boolean immediate = ajaxBehavior.isImmediate();
- if(!immediate) {
+ if (!immediate) {
if (component instanceof EditableValueHolder) {
immediate = ((EditableValueHolder) component).isImmediate();
} else if (component instanceof ActionSource) {
@@ -97,6 +108,15 @@
return immediate;
}
+ private boolean isBypassUpdates(UIComponent component, AjaxBehavior ajaxBehavior) {
+ boolean bypassUpdates = ajaxBehavior.isBypassUpdates();
+ if (!bypassUpdates) {
+ bypassUpdates = utils.isBooleanAttribute(component,
"bypassUpdates");
+ }
+
+ return bypassUpdates;
+ }
+
@Override
public String getScript(ClientBehaviorContext behaviorContext, ClientBehavior
behavior) {
String script = null;