Author: nbelaevski
Date: 2010-06-30 15:46:12 -0400 (Wed, 30 Jun 2010)
New Revision: 17691
Modified:
root/core/trunk/impl/src/main/java/org/ajax4jsf/renderkit/AjaxRendererUtils.java
root/core/trunk/impl/src/main/java/org/ajax4jsf/renderkit/RendererBase.java
root/core/trunk/impl/src/main/resources/META-INF/resources/richfaces.js
root/core/trunk/impl/src/test/resources/javascript/4_0_0.html
root/ui/core/trunk/ui/src/main/java/org/richfaces/component/AbstractPush.java
root/ui/core/trunk/ui/src/main/java/org/richfaces/renderkit/AjaxCommandRendererBase.java
root/ui/core/trunk/ui/src/main/java/org/richfaces/renderkit/html/AjaxPushRenderer.java
Log:
https://jira.jboss.org/browse/RF-8744
Modified:
root/core/trunk/impl/src/main/java/org/ajax4jsf/renderkit/AjaxRendererUtils.java
===================================================================
---
root/core/trunk/impl/src/main/java/org/ajax4jsf/renderkit/AjaxRendererUtils.java 2010-06-30
19:32:51 UTC (rev 17690)
+++
root/core/trunk/impl/src/main/java/org/ajax4jsf/renderkit/AjaxRendererUtils.java 2010-06-30
19:46:12 UTC (rev 17691)
@@ -360,6 +360,8 @@
ajaxEventOptions.set(behaviorName, handlerScript);
}
}
+
+ ajaxEventOptions.set("incId", "1");
}
// public static AjaxEventOptions buildEventOptions(FacesContext facesContext,
@@ -779,6 +781,7 @@
* @param component for wich calculate function name
* @return name of JavaScript function or <code>null</code>
*/
+ //TODO nick - refactor - remove this method?
public static String getAjaxOncomplete(UIComponent component) {
if (component instanceof AjaxComponent) {
return ((AjaxComponent) component).getOncomplete();
@@ -793,6 +796,7 @@
* @param component for wich calculate function name
* @return name of JavaScript function or <code>null</code>
*/
+ //TODO nick - refactor - remove this method?
public static String getAjaxOnBeforeDomUpdate(UIComponent component) {
if (component instanceof AjaxComponent) {
return ((AjaxComponent) component).getOnbeforedomupdate();
@@ -801,6 +805,7 @@
return (String) component.getAttributes().get(ONBEFOREDOMUPDATE_ATTR_NAME);
}
+ //TODO nick - refactor - remove this method?
public static String getAjaxOnBegin(UIComponent component) {
if (component instanceof AjaxComponent) {
return ((AjaxComponent) component).getOnbegin();
Modified: root/core/trunk/impl/src/main/java/org/ajax4jsf/renderkit/RendererBase.java
===================================================================
--- root/core/trunk/impl/src/main/java/org/ajax4jsf/renderkit/RendererBase.java 2010-06-30
19:32:51 UTC (rev 17690)
+++ root/core/trunk/impl/src/main/java/org/ajax4jsf/renderkit/RendererBase.java 2010-06-30
19:46:12 UTC (rev 17691)
@@ -45,11 +45,6 @@
*/
public abstract class RendererBase extends Renderer {
- /**
- * logger for common cases.
- */
- protected static final String JAVASCRIPT_NAMESPACE = "Exadel";
-
private static final Logger LOG = RichfacesLogger.RENDERKIT.getLogger();
private static final RendererUtils UTILS = RendererUtils.getInstance();
@@ -79,11 +74,19 @@
// TODO - create set od common decoders ( UIInput, ActionSource etc. ) for
process decoding.
if (component.isRendered()) {
- RenderKitUtils.decodeBehaviors(context, component);
+ String behaviorEventName = RenderKitUtils.decodeBehaviors(context,
component);
+ if (behaviorEventName != null) {
+ queueComponentEventForBehaviorEvent(context, component,
behaviorEventName);
+ }
+
doDecode(context, component);
}
}
+ protected void queueComponentEventForBehaviorEvent(FacesContext context, UIComponent
component, String eventName) {
+
+ }
+
protected void preDecode(FacesContext context, UIComponent component) {
}
Modified: root/core/trunk/impl/src/main/resources/META-INF/resources/richfaces.js
===================================================================
--- root/core/trunk/impl/src/main/resources/META-INF/resources/richfaces.js 2010-06-30
19:32:51 UTC (rev 17690)
+++ root/core/trunk/impl/src/main/resources/META-INF/resources/richfaces.js 2010-06-30
19:46:12 UTC (rev 17691)
@@ -560,7 +560,6 @@
richfaces.ajax = function(source, event, options) {
var sourceId = (typeof source == 'object' && source.id) ? source.id :
source;
- var sourceElt = (typeof source == 'object') ? source :
document.getElementById(sourceId);
options = options || {};
@@ -600,7 +599,7 @@
}
}
- if (!jQuery(sourceElt).is(":input:not(:submit, :button, :image, :reset)")) {
+ if (options.incId) {
parameters[sourceId] = sourceId;
}
Modified: root/core/trunk/impl/src/test/resources/javascript/4_0_0.html
===================================================================
--- root/core/trunk/impl/src/test/resources/javascript/4_0_0.html 2010-06-30 19:32:51 UTC
(rev 17690)
+++ root/core/trunk/impl/src/test/resources/javascript/4_0_0.html 2010-06-30 19:46:12 UTC
(rev 17691)
@@ -137,13 +137,27 @@
adapter(eventData);
});
- test("RichFaces.ajax test", function() {
- expect(7);
+ test("RichFaces.ajax behavior test", function() {
+ expect(1);
+
var ajaxSource = "source";
var ajaxEvent = "event";
var ajaxOptions = {parameters: {'param': 'value'}};
jsf.ajax = {
request : function(source, event, options) {
+ ok(!options['source']);
+ }
+ }
+ RichFaces.ajax(ajaxSource, ajaxEvent, ajaxOptions);
+ });
+
+ test("RichFaces.ajax component test", function() {
+ expect(7);
+ var ajaxSource = "source";
+ var ajaxEvent = "event";
+ var ajaxOptions = {parameters: {'param': 'value'}, incId: 1};
+ jsf.ajax = {
+ request : function(source, event, options) {
equals(source, ajaxSource);
equals(event, ajaxEvent);
equals(options['execute'], '@component');
Modified: root/ui/core/trunk/ui/src/main/java/org/richfaces/component/AbstractPush.java
===================================================================
---
root/ui/core/trunk/ui/src/main/java/org/richfaces/component/AbstractPush.java 2010-06-30
19:32:51 UTC (rev 17690)
+++
root/ui/core/trunk/ui/src/main/java/org/richfaces/component/AbstractPush.java 2010-06-30
19:46:12 UTC (rev 17691)
@@ -29,8 +29,6 @@
import javax.el.MethodExpression;
import javax.faces.component.NamingContainer;
import javax.faces.context.FacesContext;
-import javax.faces.event.BehaviorEvent;
-import javax.faces.event.FacesEvent;
import javax.servlet.http.HttpSession;
import org.richfaces.cdk.annotations.Attribute;
@@ -58,8 +56,6 @@
public static final String ON_DATA_AVAILABLE = "ondataavailable";
- private transient boolean hasActiveBehavior = false;
-
@Override
public void encodeBegin(FacesContext context) throws IOException {
MethodExpression producer = getEventProducer();
@@ -95,22 +91,6 @@
return id.toString();
}
- @Override
- public void queueEvent(FacesEvent e) {
- if (e instanceof BehaviorEvent) {
- hasActiveBehavior = true;
- }
-
- super.queueEvent(e);
- }
-
- /**
- * @return the hasActiveBehavior
- */
- public boolean isHasActiveBehavior() {
- return hasActiveBehavior;
- }
-
// ---------------------------------------
@Attribute(signature = @Signature(parameters = EventListener.class))
public abstract MethodExpression getEventProducer();
Modified:
root/ui/core/trunk/ui/src/main/java/org/richfaces/renderkit/AjaxCommandRendererBase.java
===================================================================
---
root/ui/core/trunk/ui/src/main/java/org/richfaces/renderkit/AjaxCommandRendererBase.java 2010-06-30
19:32:51 UTC (rev 17690)
+++
root/ui/core/trunk/ui/src/main/java/org/richfaces/renderkit/AjaxCommandRendererBase.java 2010-06-30
19:46:12 UTC (rev 17691)
@@ -53,6 +53,15 @@
private static final Logger LOG = RichfacesLogger.RENDERKIT.getLogger();
@Override
+ protected void queueComponentEventForBehaviorEvent(FacesContext context, UIComponent
component, String eventName) {
+ super.queueComponentEventForBehaviorEvent(context, component, eventName);
+
+ if ("action".equals(eventName) || "click".equals(eventName))
{
+ new ActionEvent(component).queue();
+ }
+ }
+
+ @Override
protected void doDecode(FacesContext facesContext, UIComponent uiComponent) {
if (isSubmitted(facesContext, uiComponent)) {
new ActionEvent(uiComponent).queue();
Modified:
root/ui/core/trunk/ui/src/main/java/org/richfaces/renderkit/html/AjaxPushRenderer.java
===================================================================
---
root/ui/core/trunk/ui/src/main/java/org/richfaces/renderkit/html/AjaxPushRenderer.java 2010-06-30
19:32:51 UTC (rev 17690)
+++
root/ui/core/trunk/ui/src/main/java/org/richfaces/renderkit/html/AjaxPushRenderer.java 2010-06-30
19:46:12 UTC (rev 17691)
@@ -21,6 +21,17 @@
package org.richfaces.renderkit.html;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.faces.application.ResourceDependencies;
+import javax.faces.application.ResourceDependency;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.event.ActionEvent;
+
import org.ajax4jsf.javascript.JSFunction;
import org.ajax4jsf.javascript.JSFunctionDefinition;
import org.ajax4jsf.javascript.JSReference;
@@ -29,28 +40,15 @@
import org.ajax4jsf.renderkit.HandlersChain;
import org.ajax4jsf.renderkit.RendererBase;
import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.richfaces.cdk.annotations.JsfRenderer;
import org.richfaces.component.AbstractPush;
import org.richfaces.resource.PushResource;
-import org.richfaces.cdk.annotations.JsfRenderer;
-import javax.faces.application.ResourceDependencies;
-import javax.faces.application.ResourceDependency;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-import javax.faces.event.ActionEvent;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
/**
* @author shura
*/
-@ResourceDependencies(value = {
- @ResourceDependency(library = "javax.faces", name =
"jsf.js"),
- @ResourceDependency(name = "jquery.js"),
- @ResourceDependency(name = "richfaces.js")
- })
+@ResourceDependencies({@ResourceDependency(library = "javax.faces", name =
"jsf.js") ,
+ @ResourceDependency(name = "jquery.js") , @ResourceDependency(name =
"richfaces.js")})
@JsfRenderer
public class AjaxPushRenderer extends RendererBase {
@@ -64,6 +62,15 @@
public static final int DEFAULT_PUSH_WAIT = Integer.MIN_VALUE;
+ @Override
+ protected void queueComponentEventForBehaviorEvent(FacesContext context, UIComponent
component, String eventName) {
+ super.queueComponentEventForBehaviorEvent(context, component, eventName);
+
+ if (AbstractPush.DATA_AVAILABLE.equals(eventName) ||
AbstractPush.ON_DATA_AVAILABLE.equals(eventName)) {
+ new ActionEvent(component).queue();
+ }
+ }
+
/* (non-Javadoc)
* @see
org.ajax4jsf.renderkit.RendererBase#doEncodeEnd(javax.faces.context.ResponseWriter,
* javax.faces.context.FacesContext, javax.faces.component.UIComponent)
@@ -148,7 +155,7 @@
AbstractPush push = (AbstractPush) component;
if (push.isEnabled()) {
Map<String, String> requestParameterMap =
context.getExternalContext().getRequestParameterMap();
- if (requestParameterMap.get(push.getClientId(context)) != null ||
push.isHasActiveBehavior()) {
+ if (requestParameterMap.get(push.getClientId(context)) != null) {
new ActionEvent(push).queue();
}
}