Author: nbelaevski
Date: 2010-04-21 13:29:01 -0400 (Wed, 21 Apr 2010)
New Revision: 16793
Added:
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/AttachQueueHandler.java
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/AttachQueueStack.java
Removed:
root/ui/trunk/components/core/src/main/java/org/richfaces/taglib/html/facelets/
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/BehaviorStack.java
root/ui/trunk/components/core/src/main/java/org/richfaces/view/facelets/html/BehaviorsAddingComponentHandlerWrapper.java
Log:
https://jira.jboss.org/jira/browse/RFPL-518
Added:
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
(rev 0)
+++
root/ui/trunk/components/core/src/main/java/org/richfaces/component/AbstractAttachQueue.java 2010-04-21
17:29:01 UTC (rev 16793)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.richfaces.component;
+
+import javax.faces.component.UIComponentBase;
+
+import org.richfaces.cdk.annotations.JsfComponent;
+import org.richfaces.cdk.annotations.Tag;
+import org.richfaces.cdk.annotations.TagType;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+@JsfComponent(
+ tag = @Tag(name = "attachQueue",
+ handler = "org.richfaces.taglib.html.facelets.AttachQueueHandler",
+ generate = false, type = TagType.Facelets)
+)
+public abstract class AbstractAttachQueue extends UIComponentBase {
+
+ public static final String COMPONENT_TYPE = "org.richfaces.AttachQueue";
+
+ public abstract String getRequestSimilarityId();
+
+ public abstract int getRequestDelay();
+
+ public abstract int getTimeout();
+
+ public abstract boolean isIgnoreDupresponses();
+
+ public abstract String getOnrequestqueue();
+
+ public abstract String getOnrequestdequeue();
+
+ @Override
+ public String getFamily() {
+ return null;
+ }
+
+}
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-04-21
17:14:13 UTC (rev 16792)
+++
root/ui/trunk/components/core/src/main/java/org/richfaces/view/facelets/html/AjaxHandler.java 2010-04-21
17:29:01 UTC (rev 16793)
@@ -1,3 +1,25 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
package org.richfaces.view.facelets.html;
import java.beans.BeanDescriptor;
@@ -13,6 +35,7 @@
import javax.el.MethodExpression;
import javax.faces.application.Application;
import javax.faces.component.UIComponent;
+import javax.faces.component.behavior.ClientBehavior;
import javax.faces.component.behavior.ClientBehaviorHolder;
import javax.faces.context.FacesContext;
import javax.faces.event.AbortProcessingException;
@@ -24,13 +47,13 @@
import javax.faces.view.BehaviorHolderAttachedObjectTarget;
import javax.faces.view.facelets.BehaviorConfig;
import javax.faces.view.facelets.ComponentHandler;
-import javax.faces.view.facelets.CompositeFaceletHandler;
import javax.faces.view.facelets.FaceletContext;
import javax.faces.view.facelets.TagAttribute;
import javax.faces.view.facelets.TagException;
import javax.faces.view.facelets.TagHandler;
import org.ajax4jsf.component.behavior.AjaxBehavior;
+import org.richfaces.view.facelets.html.BehaviorStack.BehaviorInfo;
public class AjaxHandler extends TagHandler implements
BehaviorHolderAttachedObjectHandler {
@@ -47,11 +70,9 @@
private final TagAttribute oncomplete;
private final TagAttribute onerror;
private final TagAttribute onevent;
- private final TagAttribute queueId;
private final TagAttribute render;
private final TagAttribute similarityGroupingId;
private final TagAttribute statusId;
- private final boolean wrapping;
public AjaxHandler(BehaviorConfig config) {
super(config);
@@ -62,7 +83,6 @@
this.immediate = this.getAttribute("immediate");
this.listener = this.getAttribute("listener");
this.limitRender = this.getAttribute("limitRender");
- this.queueId = this.getAttribute("queueId");
this.statusId = this.getAttribute("status");
this.similarityGroupingId = this.getAttribute("similarityGroupingId");
this.onevent = this.getAttribute("onevent");
@@ -70,16 +90,33 @@
this.onbegin = this.getAttribute("onbegin");
this.oncomplete = this.getAttribute("oncomplete");
this.onbeforedomupdate = this.getAttribute("onbeforedomupdate");
- this.wrapping = isWrapping();
}
- public void apply(FaceletContext fContext, UIComponent parent) throws IOException {
+ public void apply(FaceletContext ctx, UIComponent parent) throws IOException {
String eventName = getEventName();
+ AjaxBehavior ajaxBehavior = createAjaxBehavior(ctx, eventName);
+ FacesContext context = ctx.getFacesContext();
+ BehaviorStack ajaxBehaviors = BehaviorStack.getBehaviorStack(context, true);
+ ajaxBehaviors.pushBehavior(context, ajaxBehavior, AjaxBehavior.BEHAVIOR_ID,
eventName);
- if (this.wrapping) {
- applyWrapping(fContext, parent, eventName);
+ AttachQueueStack attachQueueStack = AttachQueueStack.getStack(context, true);
+ AttachQueueInfo attachQueueInfo = new AttachQueueInfo(parent);
+ attachQueueStack.push(attachQueueInfo);
+
+ nextHandler.apply(ctx, parent);
+
+ attachQueueStack.pop();
+
+ BehaviorInfo behaviorInfo = ajaxBehaviors.popBehavior();
+ if (behaviorInfo != null) {
+ if (behaviorInfo.isWrapping()) {
+ UIComponent attachQueue = attachQueueInfo.getAttachQueue();
+ assignAttachQueueComponent(context, attachQueue,
behaviorInfo.getBehaviors());
+ } else {
+ applyNested(ctx, parent, ajaxBehavior);
+ }
} else {
- applyNested(fContext, parent, eventName);
+ //TODO nick - is this possible?
}
}
@@ -97,11 +134,12 @@
return list;
}
- private void applyNested(FaceletContext ctx, UIComponent parent, String eventName) {
+ private void applyNested(FaceletContext ctx, UIComponent parent, AjaxBehavior
behavior) {
if (!ComponentHandler.isNew(parent)) {
return;
}
+ String eventName = getEventName();
if (UIComponent.isCompositeComponent(parent)) {
BeanInfo componentBeanInfo = (BeanInfo)
parent.getAttributes().get(UIComponent.BEANINFO_KEY);
@@ -146,25 +184,33 @@
throw new TagException(tag, "Error: enclosing composite component
does not support event " + eventName);
}
} else if (parent instanceof ClientBehaviorHolder) {
- applyAttachedObject(ctx, parent, eventName);
+ ClientBehaviorHolder bHolder = (ClientBehaviorHolder) parent;
+ eventName = resolveEventName(bHolder);
+ bHolder.addClientBehavior(eventName, behavior);
} else {
throw new TagException(this.tag, "Unable to attach <a4j:ajax> to
non-ClientBehaviorHolder parent");
}
}
- private void applyWrapping(FaceletContext ctx, UIComponent parent, String eventName)
throws IOException {
- AjaxBehavior ajaxBehavior = createAjaxBehavior(ctx, eventName);
- FacesContext context = ctx.getFacesContext();
- BehaviorStack ajaxBehaviors = BehaviorStack.getBehaviorStack(context, true);
+ private void assignAttachQueueComponent(FacesContext context, UIComponent
attachQueue,
+ List<ClientBehavior> behaviors) {
- ajaxBehaviors.pushBehavior(context, ajaxBehavior, AjaxBehavior.BEHAVIOR_ID,
eventName);
- nextHandler.apply(ctx, parent);
- ajaxBehaviors.popBehavior();
+ 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);
+ }
+ }
}
- public void applyAttachedObject(FaceletContext fContext, UIComponent parent, String
eventName) {
- ClientBehaviorHolder bHolder = (ClientBehaviorHolder) parent;
-
+ private String resolveEventName(ClientBehaviorHolder bHolder) {
+ String eventName = getEventName();
if (null == eventName) {
eventName = bHolder.getDefaultEventName();
@@ -177,13 +223,11 @@
if (!eventNames.contains(eventName)) {
throw new TagException(this.tag,
eventName + "event is not supported for the
"
- + parent.getClass().getSimpleName());
+ + bHolder.getClass().getSimpleName());
}
}
- AjaxBehavior ajaxBehavior = createAjaxBehavior(fContext, eventName);
-
- bHolder.addClientBehavior(eventName, ajaxBehavior);
+ return eventName;
}
public AjaxBehavior createAjaxBehavior(FaceletContext fContext, String eventName) {
@@ -195,7 +239,6 @@
setBehaviorAttribute(fContext, ajaxBehavior, this.execute, Object.class);
setBehaviorAttribute(fContext, ajaxBehavior, this.render, Object.class);
setBehaviorAttribute(fContext, ajaxBehavior, this.limitRender, Boolean.class);
- setBehaviorAttribute(fContext, ajaxBehavior, this.queueId, String.class);
setBehaviorAttribute(fContext, ajaxBehavior, this.statusId, String.class);
setBehaviorAttribute(fContext, ajaxBehavior, this.similarityGroupingId,
String.class);
setBehaviorAttribute(fContext, ajaxBehavior, this.onevent, String.class);
@@ -211,7 +254,11 @@
public void applyAttachedObject(FacesContext context, UIComponent parent) {
FaceletContext ctx = (FaceletContext)
context.getAttributes().get(FaceletContext.FACELET_CONTEXT_KEY);
- applyAttachedObject(ctx, parent, getEventName());
+ ClientBehaviorHolder bHolder = (ClientBehaviorHolder) parent;
+ String eventName = resolveEventName(bHolder);
+
+ AjaxBehavior ajaxBehavior = createAjaxBehavior(ctx, eventName);
+ bHolder.addClientBehavior(eventName, ajaxBehavior);
}
private void setBehaviorAttribute(FaceletContext ctx, AjaxBehavior behavior,
TagAttribute attr, Class<?> type) {
@@ -228,10 +275,6 @@
return null;
}
- private boolean isWrapping() {
- return (this.nextHandler instanceof TagHandler) || (this.nextHandler instanceof
CompositeFaceletHandler);
- }
-
public void registerBehaviorListener(FaceletContext fContext, AjaxBehavior behavior,
TagAttribute listenerAttr) {
if (listenerAttr != null) {
MethodExpression mExpression = listenerAttr.getMethodExpression(fContext,
Object.class,
Added:
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
(rev 0)
+++
root/ui/trunk/components/core/src/main/java/org/richfaces/view/facelets/html/AttachQueueHandler.java 2010-04-21
17:29:01 UTC (rev 16793)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.richfaces.view.facelets.html;
+
+import javax.faces.component.UIComponent;
+import javax.faces.view.facelets.ComponentConfig;
+import javax.faces.view.facelets.ComponentHandler;
+import javax.faces.view.facelets.FaceletContext;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public class AttachQueueHandler extends ComponentHandler {
+
+ /**
+ * @param config
+ */
+ public AttachQueueHandler(ComponentConfig config) {
+ super(config);
+ }
+
+ @Override
+ public void onComponentCreated(FaceletContext ctx, UIComponent c, UIComponent parent)
{
+ super.onComponentCreated(ctx, c, parent);
+
+ AttachQueueStack attachQueueStack =
AttachQueueStack.getStack(ctx.getFacesContext(), false);
+ if (attachQueueStack != null) {
+ AttachQueueInfo attachQueueInfo = attachQueueStack.peek();
+ if (attachQueueInfo != null) {
+ UIComponent queueInfoParent = attachQueueInfo.getParentComponent();
+ if (queueInfoParent.equals(parent)) {
+ attachQueueInfo.setAttachQueue(c);
+ }
+ }
+ }
+ }
+}
Added:
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
(rev 0)
+++
root/ui/trunk/components/core/src/main/java/org/richfaces/view/facelets/html/AttachQueueInfo.java 2010-04-21
17:29:01 UTC (rev 16793)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.richfaces.view.facelets.html;
+
+import javax.faces.component.UIComponent;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+final class AttachQueueInfo {
+
+ private UIComponent parentComponent;
+
+ private UIComponent attachQueue;
+
+ public AttachQueueInfo(UIComponent parentComponent) {
+ super();
+ this.parentComponent = parentComponent;
+ }
+
+ public UIComponent getParentComponent() {
+ return parentComponent;
+ }
+
+ public void setAttachQueue(UIComponent attachQueue) {
+ this.attachQueue = attachQueue;
+ }
+
+ public UIComponent getAttachQueue() {
+ return attachQueue;
+ }
+
+}
Added:
root/ui/trunk/components/core/src/main/java/org/richfaces/view/facelets/html/AttachQueueStack.java
===================================================================
---
root/ui/trunk/components/core/src/main/java/org/richfaces/view/facelets/html/AttachQueueStack.java
(rev 0)
+++
root/ui/trunk/components/core/src/main/java/org/richfaces/view/facelets/html/AttachQueueStack.java 2010-04-21
17:29:01 UTC (rev 16793)
@@ -0,0 +1,70 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.richfaces.view.facelets.html;
+
+import java.util.LinkedList;
+import java.util.Map;
+
+import javax.faces.context.FacesContext;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+final class AttachQueueStack {
+
+ private static final String STACK_ATTRIBUTE_NAME =
"org.richfaces.AttachQueueStack";
+
+ private LinkedList<AttachQueueInfo> stack = null;
+
+ public AttachQueueStack() {
+ stack = new LinkedList<AttachQueueInfo>();
+ }
+
+ public static AttachQueueStack getStack(FacesContext context, boolean createIfNull)
{
+ Map<Object, Object> attributes = context.getAttributes();
+ AttachQueueStack attachQueueStack = (AttachQueueStack)
attributes.get(STACK_ATTRIBUTE_NAME);
+
+ if (attachQueueStack == null && createIfNull) {
+ attachQueueStack = new AttachQueueStack();
+ attributes.put(STACK_ATTRIBUTE_NAME, attachQueueStack);
+ }
+
+ return attachQueueStack;
+ }
+
+ public void push(AttachQueueInfo info) {
+ stack.addFirst(info);
+ }
+
+ public AttachQueueInfo pop() {
+ return stack.removeFirst();
+ }
+
+ public AttachQueueInfo peek() {
+ if (!stack.isEmpty()) {
+ return stack.getFirst();
+ } else {
+ return null;
+ }
+ }
+}
Modified:
root/ui/trunk/components/core/src/main/java/org/richfaces/view/facelets/html/BehaviorStack.java
===================================================================
---
root/ui/trunk/components/core/src/main/java/org/richfaces/view/facelets/html/BehaviorStack.java 2010-04-21
17:14:13 UTC (rev 16792)
+++
root/ui/trunk/components/core/src/main/java/org/richfaces/view/facelets/html/BehaviorStack.java 2010-04-21
17:29:01 UTC (rev 16793)
@@ -21,8 +21,10 @@
*/
+
package org.richfaces.view.facelets.html;
+import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@@ -46,10 +48,10 @@
//TODO - check for bug resolution
final class BehaviorStack {
private static final String BEHAVIOR_STACK =
"org.richfaces.BehaviorStack";
- private LinkedList<BehaviorInfo> behaviorStack = null;
+ private LinkedList<BehaviorInfoImpl> behaviorStack = null;
public BehaviorStack() {
- behaviorStack = new LinkedList<BehaviorInfo>();
+ behaviorStack = new LinkedList<BehaviorInfoImpl>();
}
public static BehaviorStack getBehaviorStack(FacesContext context, boolean
createIfNull) {
@@ -64,41 +66,65 @@
return behaviorStack;
}
+ public boolean isEmpty() {
+ return behaviorStack.isEmpty();
+ }
+
public void addBehaviors(FacesContext context, ClientBehaviorHolder behaviorHolder)
{
if (behaviorStack == null || behaviorStack.isEmpty()) {
return;
}
- for (BehaviorInfo behaviorInfo : behaviorStack) {
+ for (BehaviorInfoImpl behaviorInfo : behaviorStack) {
behaviorInfo.addBehavior(context, behaviorHolder);
}
}
+ void markWrapping() {
+ if (!behaviorStack.isEmpty()) {
+ BehaviorInfoImpl behaviorInfo = behaviorStack.getFirst();
+ behaviorInfo.markWrapping();
+ }
+ }
+
public void pushBehavior(FacesContext context, ClientBehavior clientBehavior, String
behaviorId, String eventName) {
+
Object behaviorState = ((StateHolder) clientBehavior).saveState(context);
// closer behaviors are processed earlier
- behaviorStack.addFirst(new BehaviorInfo(behaviorId, eventName, behaviorState));
+ behaviorStack.addFirst(new BehaviorInfoImpl(behaviorId, eventName,
behaviorState));
}
- public void popBehavior() {
+ public BehaviorInfo popBehavior() {
if (!behaviorStack.isEmpty()) {
- behaviorStack.removeFirst();
+ return behaviorStack.removeFirst();
+ } else {
+ return null;
}
}
- private static class BehaviorInfo {
+ static interface BehaviorInfo {
+
+ public List<ClientBehavior> getBehaviors();
+
+ public boolean isWrapping();
+ }
+
+ private static class BehaviorInfoImpl implements BehaviorInfo {
+
private String behaviorId;
private Object behaviorState;
private String eventName;
+ private List<ClientBehavior> behaviors;
+ private boolean wrapping = false;
- public BehaviorInfo(String behaviorId, String eventName, Object behaviorState) {
+ public BehaviorInfoImpl(String behaviorId, String eventName, Object
behaviorState) {
this.behaviorId = behaviorId;
this.eventName = eventName;
this.behaviorState = behaviorState;
}
- public void addBehavior(FacesContext context, ClientBehaviorHolder
behaviorHolder) {
+ private void addBehavior(FacesContext context, ClientBehaviorHolder
behaviorHolder) {
String eventName = this.eventName;
if (eventName == null) {
@@ -116,6 +142,18 @@
}
}
+ public List<ClientBehavior> getBehaviors() {
+ return behaviors;
+ }
+
+ public boolean isWrapping() {
+ return wrapping;
+ }
+
+ private void markWrapping() {
+ wrapping = true;
+ }
+
private boolean shouldAddBehavior(ClientBehaviorHolder behaviorHolder, String
eventName) {
if (!behaviorHolder.getEventNames().contains(eventName)) {
return false;
@@ -145,6 +183,12 @@
((StateHolder) behavior).restoreState(context, behaviorState);
+ if (behaviors == null) {
+ behaviors = new ArrayList<ClientBehavior>();
+ }
+
+ behaviors.add(behavior);
+
return behavior;
}
}
Modified:
root/ui/trunk/components/core/src/main/java/org/richfaces/view/facelets/html/BehaviorsAddingComponentHandlerWrapper.java
===================================================================
---
root/ui/trunk/components/core/src/main/java/org/richfaces/view/facelets/html/BehaviorsAddingComponentHandlerWrapper.java 2010-04-21
17:14:13 UTC (rev 16792)
+++
root/ui/trunk/components/core/src/main/java/org/richfaces/view/facelets/html/BehaviorsAddingComponentHandlerWrapper.java 2010-04-21
17:29:01 UTC (rev 16793)
@@ -26,7 +26,6 @@
import java.io.IOException;
import javax.el.ELException;
-
import javax.faces.FacesException;
import javax.faces.component.UIComponent;
import javax.faces.component.behavior.ClientBehaviorHolder;
@@ -100,7 +99,9 @@
FacesContext facesContext = ctx.getFacesContext();
BehaviorStack behaviorStack = BehaviorStack.getBehaviorStack(facesContext,
false);
- if (behaviorStack != null) {
+ if (behaviorStack != null && !behaviorStack.isEmpty()) {
+ behaviorStack.markWrapping();
+
if (c instanceof ClientBehaviorHolder) {
ClientBehaviorHolder behaviorHolder = (ClientBehaviorHolder) c;