Author: nbelaevski
Date: 2010-05-04 18:40:24 -0400 (Tue, 04 May 2010)
New Revision: 16890
Modified:
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/behavior/AjaxBehavior.java
root/ui/trunk/components/core/src/main/java/org/richfaces/component/AbstractAttachQueue.java
root/ui/trunk/components/core/src/main/java/org/richfaces/view/facelets/html/AjaxHandler.java
root/ui/trunk/components/core/src/main/java/org/richfaces/view/facelets/html/AttachQueueHandler.java
root/ui/trunk/components/core/src/main/java/org/richfaces/view/facelets/html/AttachQueueInfo.java
root/ui/trunk/components/core/src/main/resources/META-INF/a4j.taglib.xml
Log:
https://jira.jboss.org/jira/browse/RFPL-518
Modified:
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/behavior/AjaxBehavior.java
===================================================================
---
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/behavior/AjaxBehavior.java 2010-05-04
18:06:22 UTC (rev 16889)
+++
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/behavior/AjaxBehavior.java 2010-05-04
22:40:24 UTC (rev 16890)
@@ -6,6 +6,7 @@
import javax.el.ELContext;
import javax.el.ValueExpression;
+import javax.faces.component.UIComponent;
import javax.faces.component.UIComponentBase;
import javax.faces.component.behavior.FacesBehavior;
import javax.faces.context.FacesContext;
@@ -239,6 +240,10 @@
this.queueId = queueId;
clearInitialState();
}
+
+ public void attachToQueue(FacesContext context, UIComponent queueComponent) {
+ setQueueId(queueComponent.getClientId(context));
+ }
public boolean isLimitRender() {
if (this.limitRender != null) {
Modified:
root/ui/trunk/components/core/src/main/java/org/richfaces/component/AbstractAttachQueue.java
===================================================================
---
root/ui/trunk/components/core/src/main/java/org/richfaces/component/AbstractAttachQueue.java 2010-05-04
18:06:22 UTC (rev 16889)
+++
root/ui/trunk/components/core/src/main/java/org/richfaces/component/AbstractAttachQueue.java 2010-05-04
22:40:24 UTC (rev 16890)
@@ -21,12 +21,14 @@
*/
package org.richfaces.component;
+import javax.faces.component.UIComponent;
import javax.faces.component.UIComponentBase;
+import javax.faces.context.FacesContext;
+import org.richfaces.cdk.annotations.Attribute;
import org.richfaces.cdk.annotations.JsfComponent;
import org.richfaces.cdk.annotations.Tag;
import org.richfaces.cdk.annotations.TagType;
-import org.richfaces.cdk.annotations.Attribute;
/**
* @author Nick Belaevski
@@ -40,7 +42,13 @@
public abstract class AbstractAttachQueue extends UIComponentBase {
public static final String COMPONENT_TYPE = "org.richfaces.AttachQueue";
+
+ public static final String QUEUE_ID_ATTRIBUTE = "queueId";
+ private enum PropertyKeys {
+ attachToParent
+ }
+
@Attribute
public abstract String getRequestSimilarityId();
@@ -51,7 +59,7 @@
public abstract int getTimeout();
@Attribute
- public abstract boolean isIgnoreDupresponses();
+ public abstract boolean isIgnoreDupResponses();
@Attribute
public abstract String getOnrequestqueue();
@@ -64,4 +72,37 @@
return null;
}
+ public boolean isAttachToParent() {
+ Object propertyValue = getStateHelper().get(PropertyKeys.attachToParent);
+ if (propertyValue == null) {
+ //default value is true
+ return true;
+ } else {
+ return Boolean.TRUE.equals(propertyValue);
+ }
+ }
+
+ public void setAttachToParent(boolean attachToParent) {
+ getStateHelper().put(PropertyKeys.attachToParent, attachToParent);
+ }
+
+ @Override
+ public void setParent(UIComponent parent) {
+ UIComponent oldParent = getParent();
+
+ super.setParent(parent);
+
+ if (isAttachToParent()) {
+ if (oldParent != null) {
+ oldParent.getAttributes().remove(QUEUE_ID_ATTRIBUTE);
+ }
+
+ if (parent != null) {
+ FacesContext context = getFacesContext();
+ String clientId = getClientId(context);
+
+ parent.getAttributes().put(QUEUE_ID_ATTRIBUTE, clientId);
+ }
+ }
+ }
}
Modified:
root/ui/trunk/components/core/src/main/java/org/richfaces/view/facelets/html/AjaxHandler.java
===================================================================
---
root/ui/trunk/components/core/src/main/java/org/richfaces/view/facelets/html/AjaxHandler.java 2010-05-04
18:06:22 UTC (rev 16889)
+++
root/ui/trunk/components/core/src/main/java/org/richfaces/view/facelets/html/AjaxHandler.java 2010-05-04
22:40:24 UTC (rev 16890)
@@ -53,8 +53,10 @@
import javax.faces.view.facelets.TagHandler;
import org.ajax4jsf.component.behavior.AjaxBehavior;
+import org.richfaces.component.AbstractAttachQueue;
import org.richfaces.view.facelets.html.BehaviorStack.BehaviorInfo;
+//TODO nick - use TagHandlerDelegate
public class AjaxHandler extends TagHandler implements
BehaviorHolderAttachedObjectHandler {
// TODO - is that implementation dependency?
@@ -110,7 +112,7 @@
BehaviorInfo behaviorInfo = ajaxBehaviors.popBehavior();
if (behaviorInfo != null) {
if (behaviorInfo.isWrapping()) {
- UIComponent attachQueue = attachQueueInfo.getAttachQueue();
+ AbstractAttachQueue attachQueue = attachQueueInfo.getAttachQueue();
assignAttachQueueComponent(context, attachQueue,
behaviorInfo.getBehaviors());
} else {
applyNested(ctx, parent, ajaxBehavior);
@@ -192,19 +194,17 @@
}
}
- private void assignAttachQueueComponent(FacesContext context, UIComponent
attachQueue,
+ private void assignAttachQueueComponent(FacesContext context, AbstractAttachQueue
attachQueue,
List<ClientBehavior> behaviors) {
if (behaviors != null && attachQueue != null) {
- String queueId = attachQueue.getClientId(context);
-
for (ClientBehavior behavior : behaviors) {
if (!(behavior instanceof AjaxBehavior)) {
continue;
}
AjaxBehavior ajaxBehavior = (AjaxBehavior) behavior;
- ajaxBehavior.setQueueId(queueId);
+ ajaxBehavior.attachToQueue(context, attachQueue);
}
}
}
Modified:
root/ui/trunk/components/core/src/main/java/org/richfaces/view/facelets/html/AttachQueueHandler.java
===================================================================
---
root/ui/trunk/components/core/src/main/java/org/richfaces/view/facelets/html/AttachQueueHandler.java 2010-05-04
18:06:22 UTC (rev 16889)
+++
root/ui/trunk/components/core/src/main/java/org/richfaces/view/facelets/html/AttachQueueHandler.java 2010-05-04
22:40:24 UTC (rev 16890)
@@ -26,6 +26,8 @@
import javax.faces.view.facelets.ComponentHandler;
import javax.faces.view.facelets.FaceletContext;
+import org.richfaces.component.AbstractAttachQueue;
+
/**
* @author Nick Belaevski
*
@@ -49,7 +51,9 @@
if (attachQueueInfo != null) {
UIComponent queueInfoParent = attachQueueInfo.getParentComponent();
if (queueInfoParent.equals(parent)) {
- attachQueueInfo.setAttachQueue(c);
+ AbstractAttachQueue attachQueue = ((AbstractAttachQueue) c);
+ attachQueueInfo.setAttachQueue(attachQueue);
+ attachQueue.setAttachToParent(false);
}
}
}
Modified:
root/ui/trunk/components/core/src/main/java/org/richfaces/view/facelets/html/AttachQueueInfo.java
===================================================================
---
root/ui/trunk/components/core/src/main/java/org/richfaces/view/facelets/html/AttachQueueInfo.java 2010-05-04
18:06:22 UTC (rev 16889)
+++
root/ui/trunk/components/core/src/main/java/org/richfaces/view/facelets/html/AttachQueueInfo.java 2010-05-04
22:40:24 UTC (rev 16890)
@@ -23,6 +23,8 @@
import javax.faces.component.UIComponent;
+import org.richfaces.component.AbstractAttachQueue;
+
/**
* @author Nick Belaevski
*
@@ -31,7 +33,7 @@
private UIComponent parentComponent;
- private UIComponent attachQueue;
+ private AbstractAttachQueue attachQueue;
public AttachQueueInfo(UIComponent parentComponent) {
super();
@@ -42,11 +44,11 @@
return parentComponent;
}
- public void setAttachQueue(UIComponent attachQueue) {
+ public void setAttachQueue(AbstractAttachQueue attachQueue) {
this.attachQueue = attachQueue;
}
- public UIComponent getAttachQueue() {
+ public AbstractAttachQueue getAttachQueue() {
return attachQueue;
}
Modified: root/ui/trunk/components/core/src/main/resources/META-INF/a4j.taglib.xml
===================================================================
--- root/ui/trunk/components/core/src/main/resources/META-INF/a4j.taglib.xml 2010-05-04
18:06:22 UTC (rev 16889)
+++ root/ui/trunk/components/core/src/main/resources/META-INF/a4j.taglib.xml 2010-05-04
22:40:24 UTC (rev 16890)
@@ -89,4 +89,11 @@
<handler-class>org.richfaces.view.facelets.html.AjaxHandler</handler-class>
</behavior>
</tag>
+ <tag>
+ <tag-name>attachQueue</tag-name>
+ <component>
+ <component-type>org.richfaces.AttachQueue</component-type>
+
<handler-class>org.richfaces.view.facelets.html.AttachQueueHandler</handler-class>
+ </component>
+ </tag>
</facelet-taglib>