Author: nbelaevski
Date: 2010-04-17 09:25:25 -0400 (Sat, 17 Apr 2010)
New Revision: 16772
Added:
root/ui/trunk/components/core/src/main/java/org/richfaces/taglib/html/facelets/AjaxHandler.java
root/ui/trunk/components/core/src/main/java/org/richfaces/taglib/html/facelets/BehaviorStack.java
root/ui/trunk/components/core/src/main/java/org/richfaces/taglib/html/facelets/BehaviorsAddingComponentHandlerWrapper.java
root/ui/trunk/components/core/src/main/java/org/richfaces/taglib/html/facelets/BehaviorsTagHandlerDelegateFactoryImpl.java
Removed:
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/facelets/tag/AjaxHandler.java
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/facelets/tag/BehaviorStack.java
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/facelets/tag/BehaviorsAddingComponentHandlerWrapper.java
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/facelets/tag/BehaviorsTagHandlerDelegateFactoryImpl.java
Modified:
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/behavior/AjaxBehavior.java
root/ui/trunk/components/core/src/main/resources/META-INF/a4j.taglib.xml
root/ui/trunk/components/core/src/main/resources/META-INF/behaviors-handler-delegate.faces-config.xml
Log:
a4j:ajax tag handlers package refactoring
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-04-17
13:21:26 UTC (rev 16771)
+++
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/component/behavior/AjaxBehavior.java 2010-04-17
13:25:25 UTC (rev 16772)
@@ -1,26 +1,27 @@
package org.ajax4jsf.component.behavior;
-import org.ajax4jsf.component.AjaxClientBehavior;
-import org.ajax4jsf.renderkit.AjaxRendererUtils;
-import org.richfaces.cdk.annotations.JsfBehavior;
-import org.richfaces.cdk.annotations.Tag;
-import org.richfaces.cdk.annotations.TagType;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Set;
import javax.el.ELContext;
import javax.el.ValueExpression;
import javax.faces.component.UIComponentBase;
import javax.faces.component.behavior.FacesBehavior;
import javax.faces.context.FacesContext;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Set;
+import org.ajax4jsf.component.AjaxClientBehavior;
+import org.ajax4jsf.renderkit.AjaxRendererUtils;
+import org.richfaces.cdk.annotations.JsfBehavior;
+import org.richfaces.cdk.annotations.Tag;
+import org.richfaces.cdk.annotations.TagType;
+
/**
* @author Anton Belevich
*/
@JsfBehavior(
id = "org.ajax4jsf.behavior.Ajax",
- tag = @Tag(name = "ajax", handler =
"org.ajax4jsf.facelets.tag.AjaxHandler",type=TagType.Facelets)
+ tag = @Tag(name = "ajax", handler =
"org.richfaces.taglib.html.facelets.AjaxHandler", type = TagType.Facelets)
)
@FacesBehavior(value = "org.ajax4jsf.behavior.Ajax")
public class AjaxBehavior extends javax.faces.component.behavior.AjaxBehavior implements
AjaxClientBehavior {
Deleted:
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/facelets/tag/AjaxHandler.java
===================================================================
---
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/facelets/tag/AjaxHandler.java 2010-04-17
13:21:26 UTC (rev 16771)
+++
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/facelets/tag/AjaxHandler.java 2010-04-17
13:25:25 UTC (rev 16772)
@@ -1,269 +0,0 @@
-package org.ajax4jsf.facelets.tag;
-
-import java.beans.BeanDescriptor;
-import java.beans.BeanInfo;
-
-import java.io.IOException;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-
-import javax.el.ELContext;
-import javax.el.MethodExpression;
-
-import javax.faces.application.Application;
-import javax.faces.component.UIComponent;
-import javax.faces.component.behavior.ClientBehaviorHolder;
-import javax.faces.context.FacesContext;
-import javax.faces.event.AbortProcessingException;
-import javax.faces.event.AjaxBehaviorEvent;
-import javax.faces.event.AjaxBehaviorListener;
-import javax.faces.view.AttachedObjectHandler;
-import javax.faces.view.AttachedObjectTarget;
-import javax.faces.view.BehaviorHolderAttachedObjectHandler;
-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;
-
-public class AjaxHandler extends TagHandler implements
BehaviorHolderAttachedObjectHandler {
-
- // TODO - is that implementation dependency?
- private static final String JAVAX_FACES_RETARGETABLE_HANDLERS =
"javax.faces.RetargetableHandlers";
- private final TagAttribute disabled;
- private final TagAttribute event;
- private final TagAttribute execute;
- private final TagAttribute immediate;
- private final TagAttribute limitRender;
- private final TagAttribute listener;
- private final TagAttribute onbeforedomupdate;
- private final TagAttribute onbegin;
- 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);
- this.event = this.getAttribute("event");
- this.execute = this.getAttribute("execute");
- this.render = this.getAttribute("render");
- this.disabled = this.getAttribute("disabled");
- 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");
- this.onerror = this.getAttribute("onerror");
- 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 {
- String eventName = getEventName();
-
- if (this.wrapping) {
- applyWrapping(fContext, parent, eventName);
- } else {
- applyNested(fContext, parent, eventName);
- }
- }
-
- private static List<AttachedObjectHandler>
getOrCreateRetargetableHandlersList(UIComponent component) {
- Map<String, Object> attrs = component.getAttributes();
- @SuppressWarnings({
- "unchecked"}) List<AttachedObjectHandler> list =
- (List<AttachedObjectHandler>)
attrs.get(JAVAX_FACES_RETARGETABLE_HANDLERS);
-
- if (list == null) {
- list = new ArrayList<AttachedObjectHandler>();
- attrs.put(JAVAX_FACES_RETARGETABLE_HANDLERS, list);
- }
-
- return list;
- }
-
- private void applyNested(FaceletContext ctx, UIComponent parent, String eventName) {
- if (!ComponentHandler.isNew(parent)) {
- return;
- }
-
- if (UIComponent.isCompositeComponent(parent)) {
- BeanInfo componentBeanInfo = (BeanInfo)
parent.getAttributes().get(UIComponent.BEANINFO_KEY);
-
- if (null == componentBeanInfo) {
- throw new TagException(tag, "Error: enclosing composite component
does not have BeanInfo attribute");
- }
-
- BeanDescriptor componentDescriptor = componentBeanInfo.getBeanDescriptor();
-
- if (null == componentDescriptor) {
- throw new TagException(tag,
- "Error: enclosing composite component
BeanInfo does not have BeanDescriptor");
- }
-
- @SuppressWarnings(
- "unchecked") List<AttachedObjectTarget> targetList =
- (List<AttachedObjectTarget>) componentDescriptor.getValue(
- AttachedObjectTarget.ATTACHED_OBJECT_TARGETS_KEY);
-
- if (null == targetList) {
- throw new TagException(tag, "Error: enclosing composite component
does not support behavior events");
- }
-
- boolean supportedEvent = false;
-
- for (AttachedObjectTarget target : targetList) {
- if (target instanceof BehaviorHolderAttachedObjectTarget) {
- BehaviorHolderAttachedObjectTarget behaviorTarget =
(BehaviorHolderAttachedObjectTarget) target;
-
- if ((null != eventName &&
eventName.equals(behaviorTarget.getName()))
- || (null == eventName &&
behaviorTarget.isDefaultEvent())) {
- supportedEvent = true;
-
- break;
- }
- }
- }
-
- if (supportedEvent) {
- getOrCreateRetargetableHandlersList(parent).add(this);
- } else {
- throw new TagException(tag, "Error: enclosing composite component
does not support event " + eventName);
- }
- } else if (parent instanceof ClientBehaviorHolder) {
- applyAttachedObject(ctx, parent, eventName);
- } 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);
-
- ajaxBehaviors.pushBehavior(context, ajaxBehavior, AjaxBehavior.BEHAVIOR_ID,
eventName);
- nextHandler.apply(ctx, parent);
- ajaxBehaviors.popBehavior();
- }
-
- public void applyAttachedObject(FaceletContext fContext, UIComponent parent, String
eventName) {
- ClientBehaviorHolder bHolder = (ClientBehaviorHolder) parent;
-
- if (null == eventName) {
- eventName = bHolder.getDefaultEventName();
-
- if (null == eventName) {
- throw new TagException(this.tag, "Event attribute could not be
determined: " + eventName);
- }
- } else {
- Collection<String> eventNames = bHolder.getEventNames();
-
- if (!eventNames.contains(eventName)) {
- throw new TagException(this.tag,
- eventName + "event is not supported for the
"
- + parent.getClass().getSimpleName());
- }
- }
-
- AjaxBehavior ajaxBehavior = createAjaxBehavior(fContext, eventName);
-
- bHolder.addClientBehavior(eventName, ajaxBehavior);
- }
-
- public AjaxBehavior createAjaxBehavior(FaceletContext fContext, String eventName) {
- Application application = fContext.getFacesContext().getApplication();
- AjaxBehavior ajaxBehavior = (AjaxBehavior)
application.createBehavior(AjaxBehavior.BEHAVIOR_ID);
-
- setBehaviorAttribute(fContext, ajaxBehavior, this.disabled, Boolean.class);
- setBehaviorAttribute(fContext, ajaxBehavior, this.immediate, Boolean.class);
- 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);
- setBehaviorAttribute(fContext, ajaxBehavior, this.onerror, String.class);
- setBehaviorAttribute(fContext, ajaxBehavior, this.onbegin, String.class);
- setBehaviorAttribute(fContext, ajaxBehavior, this.oncomplete, String.class);
- setBehaviorAttribute(fContext, ajaxBehavior, this.onbeforedomupdate,
String.class);
- registerBehaviorListener(fContext, ajaxBehavior, listener);
-
- return ajaxBehavior;
- }
-
- public void applyAttachedObject(FacesContext context, UIComponent parent) {
- FaceletContext ctx = (FaceletContext)
context.getAttributes().get(FaceletContext.FACELET_CONTEXT_KEY);
-
- applyAttachedObject(ctx, parent, getEventName());
- }
-
- private void setBehaviorAttribute(FaceletContext ctx, AjaxBehavior behavior,
TagAttribute attr, Class<?> type) {
- if (attr != null) {
- behavior.setValueExpression(attr.getLocalName(), attr.getValueExpression(ctx,
type));
- }
- }
-
- public String getEventName() {
- return (this.event != null) ? this.event.getValue() : null;
- }
-
- public String getFor() {
- 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,
- new Class[] {AjaxBehaviorEvent.class});
-
- behavior.addAjaxBehaviorListener(new AjaxBehaviorListenerImpl(mExpression));
- }
- }
-
- public class AjaxBehaviorListenerImpl implements AjaxBehaviorListener {
- private MethodExpression methodExpression;
-
- public AjaxBehaviorListenerImpl() {}
-
- public AjaxBehaviorListenerImpl(MethodExpression expression) {
- this.methodExpression = expression;
- }
-
- public void processAjaxBehavior(AjaxBehaviorEvent event) throws
AbortProcessingException {
- if (methodExpression != null) {
- ELContext elContext = FacesContext.getCurrentInstance().getELContext();
-
- try {
- methodExpression.invoke(elContext, new Object[] {event});
- } catch (Exception e) {
-
- // TODO: log or message ??
- throw new AbortProcessingException(e);
- }
- }
- }
- }
-}
Deleted:
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/facelets/tag/BehaviorStack.java
===================================================================
---
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/facelets/tag/BehaviorStack.java 2010-04-17
13:21:26 UTC (rev 16771)
+++
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/facelets/tag/BehaviorStack.java 2010-04-17
13:25:25 UTC (rev 16772)
@@ -1,152 +0,0 @@
-/*
- * 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.ajax4jsf.facelets.tag;
-
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.faces.application.Application;
-import javax.faces.component.StateHolder;
-import javax.faces.component.behavior.ClientBehavior;
-import javax.faces.component.behavior.ClientBehaviorHint;
-import javax.faces.component.behavior.ClientBehaviorHolder;
-import javax.faces.context.FacesContext;
-
-/**
- * @author Nick Belaevski
- *
- * This class is necessary to handle nesting wrapping behaviors properly and is created
- * to work around this issue:
https://javaserverfaces-spec-public.dev.java.net/issues/show_bug.cgi?id=655
- *
- */
-
-//TODO - check for bug resolution
-final class BehaviorStack {
- private static final String BEHAVIOR_STACK =
"org.richfaces.BehaviorStack";
- private LinkedList<BehaviorInfo> behaviorStack = null;
-
- public BehaviorStack() {
- behaviorStack = new LinkedList<BehaviorInfo>();
- }
-
- public static BehaviorStack getBehaviorStack(FacesContext context, boolean
createIfNull) {
- Map<Object, Object> attributes = context.getAttributes();
- BehaviorStack behaviorStack = (BehaviorStack) attributes.get(BEHAVIOR_STACK);
-
- if (behaviorStack == null && createIfNull) {
- behaviorStack = new BehaviorStack();
- attributes.put(BEHAVIOR_STACK, behaviorStack);
- }
-
- return behaviorStack;
- }
-
- public void addBehaviors(FacesContext context, ClientBehaviorHolder behaviorHolder)
{
- if (behaviorStack == null || behaviorStack.isEmpty()) {
- return;
- }
-
- for (BehaviorInfo behaviorInfo : behaviorStack) {
- behaviorInfo.addBehavior(context, behaviorHolder);
- }
- }
-
- 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));
- }
-
- public void popBehavior() {
- if (!behaviorStack.isEmpty()) {
- behaviorStack.removeFirst();
- }
- }
-
- private static class BehaviorInfo {
- private String behaviorId;
- private Object behaviorState;
- private String eventName;
-
- public BehaviorInfo(String behaviorId, String eventName, Object behaviorState) {
- this.behaviorId = behaviorId;
- this.eventName = eventName;
- this.behaviorState = behaviorState;
- }
-
- public void addBehavior(FacesContext context, ClientBehaviorHolder
behaviorHolder) {
- String eventName = this.eventName;
-
- if (eventName == null) {
- eventName = behaviorHolder.getDefaultEventName();
-
- if (eventName == null) {
- return;
- }
- }
-
- if (shouldAddBehavior(behaviorHolder, eventName)) {
- ClientBehavior behavior = createBehavior(context);
-
- behaviorHolder.addClientBehavior(eventName, behavior);
- }
- }
-
- private boolean shouldAddBehavior(ClientBehaviorHolder behaviorHolder, String
eventName) {
- if (!behaviorHolder.getEventNames().contains(eventName)) {
- return false;
- }
-
- Map<String, List<ClientBehavior>> clientBehaviorsMap =
behaviorHolder.getClientBehaviors();
- List<ClientBehavior> clientBehaviors =
clientBehaviorsMap.get(eventName);
-
- if (clientBehaviors == null || clientBehaviors.isEmpty()) {
- return true;
- }
-
- for (ClientBehavior behavior : clientBehaviors) {
- Set<ClientBehaviorHint> hints = behavior.getHints();
-
- if (hints.contains(ClientBehaviorHint.SUBMITTING)) {
- return false;
- }
- }
-
- return true;
- }
-
- private ClientBehavior createBehavior(FacesContext context) {
- Application application = context.getApplication();
- ClientBehavior behavior = (ClientBehavior)
application.createBehavior(this.behaviorId);
-
- ((StateHolder) behavior).restoreState(context, behaviorState);
-
- return behavior;
- }
- }
-}
Deleted:
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/facelets/tag/BehaviorsAddingComponentHandlerWrapper.java
===================================================================
---
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/facelets/tag/BehaviorsAddingComponentHandlerWrapper.java 2010-04-17
13:21:26 UTC (rev 16771)
+++
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/facelets/tag/BehaviorsAddingComponentHandlerWrapper.java 2010-04-17
13:25:25 UTC (rev 16772)
@@ -1,118 +0,0 @@
-/*
- * 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.ajax4jsf.facelets.tag;
-
-import java.io.IOException;
-
-import javax.el.ELException;
-
-import javax.faces.FacesException;
-import javax.faces.component.UIComponent;
-import javax.faces.component.behavior.ClientBehaviorHolder;
-import javax.faces.context.FacesContext;
-import javax.faces.view.facelets.ComponentConfig;
-import javax.faces.view.facelets.ComponentHandler;
-import javax.faces.view.facelets.FaceletContext;
-import javax.faces.view.facelets.Tag;
-import javax.faces.view.facelets.TagAttribute;
-
-/**
- * @author Nick Belaevski
- */
-public class BehaviorsAddingComponentHandlerWrapper extends ComponentHandler {
- private ComponentHandler componentHandler;
-
- public BehaviorsAddingComponentHandlerWrapper(ComponentHandler componentHandler) {
- super(componentHandler.getComponentConfig());
- this.componentHandler = componentHandler;
- }
-
- public void apply(FaceletContext ctx, UIComponent parent) throws IOException {
- componentHandler.apply(ctx, parent);
- }
-
- public void applyNextHandler(FaceletContext ctx, UIComponent c) throws IOException,
FacesException, ELException {
- componentHandler.applyNextHandler(ctx, c);
- }
-
- public TagAttribute getBinding() {
- return componentHandler.getBinding();
- }
-
- public ComponentConfig getComponentConfig() {
- return componentHandler.getComponentConfig();
- }
-
- public Tag getTag() {
- return componentHandler.getTag();
- }
-
- public TagAttribute getTagAttribute(String localName) {
- return componentHandler.getTagAttribute(localName);
- }
-
- public String getTagId() {
- return componentHandler.getTagId();
- }
-
- public boolean equals(Object obj) {
- return componentHandler.equals(obj);
- }
-
- public int hashCode() {
- return componentHandler.hashCode();
- }
-
- public String toString() {
- return componentHandler.toString();
- }
-
- public boolean isDisabled(FaceletContext ctx) {
- return componentHandler.isDisabled(ctx);
- }
-
- public void onComponentCreated(FaceletContext ctx, UIComponent c, UIComponent parent)
{
- componentHandler.onComponentCreated(ctx, c, parent);
- }
-
- public void onComponentPopulated(FaceletContext ctx, UIComponent c, UIComponent
parent) {
- FacesContext facesContext = ctx.getFacesContext();
- BehaviorStack behaviorStack = BehaviorStack.getBehaviorStack(facesContext,
false);
-
- if (behaviorStack != null) {
- if (c instanceof ClientBehaviorHolder) {
- ClientBehaviorHolder behaviorHolder = (ClientBehaviorHolder) c;
-
- behaviorStack.addBehaviors(facesContext, behaviorHolder);
- }
- }
-
- componentHandler.onComponentPopulated(ctx, c, parent);
- }
-
- public void setAttributes(FaceletContext ctx, Object instance) {
- componentHandler.setAttributes(ctx, instance);
- }
-}
Deleted:
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/facelets/tag/BehaviorsTagHandlerDelegateFactoryImpl.java
===================================================================
---
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/facelets/tag/BehaviorsTagHandlerDelegateFactoryImpl.java 2010-04-17
13:21:26 UTC (rev 16771)
+++
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/facelets/tag/BehaviorsTagHandlerDelegateFactoryImpl.java 2010-04-17
13:25:25 UTC (rev 16772)
@@ -1,82 +0,0 @@
-/*
- * 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.ajax4jsf.facelets.tag;
-
-import javax.faces.view.facelets.BehaviorHandler;
-import javax.faces.view.facelets.ComponentHandler;
-import javax.faces.view.facelets.ConverterHandler;
-import javax.faces.view.facelets.TagHandlerDelegate;
-import javax.faces.view.facelets.TagHandlerDelegateFactory;
-import javax.faces.view.facelets.ValidatorHandler;
-
-/**
- * @author Nick Belaevski
- */
-public class BehaviorsTagHandlerDelegateFactoryImpl extends TagHandlerDelegateFactory {
- private TagHandlerDelegateFactory factory;
-
- public BehaviorsTagHandlerDelegateFactoryImpl(TagHandlerDelegateFactory factory) {
- this.factory = factory;
- }
-
- /*
- * (non-Javadoc)
- * @see
javax.faces.view.facelets.TagHandlerDelegateFactory#createBehaviorHandlerDelegate(javax.faces.view.facelets.BehaviorHandler)
- */
- @Override
- public TagHandlerDelegate createBehaviorHandlerDelegate(BehaviorHandler owner) {
- return factory.createBehaviorHandlerDelegate(owner);
- }
-
- /*
- * (non-Javadoc)
- * @see
javax.faces.view.facelets.TagHandlerDelegateFactory#createComponentHandlerDelegate(javax.faces.view.facelets.ComponentHandler)
- */
- @Override
- public TagHandlerDelegate createComponentHandlerDelegate(ComponentHandler owner) {
-
- // TagHandlers structure is created when view is compiled
- // so there's no need to check for BehaviorsStack
- return factory.createComponentHandlerDelegate(new
BehaviorsAddingComponentHandlerWrapper(owner));
- }
-
- /*
- * (non-Javadoc)
- * @see
javax.faces.view.facelets.TagHandlerDelegateFactory#createConverterHandlerDelegate(javax.faces.view.facelets.ConverterHandler)
- */
- @Override
- public TagHandlerDelegate createConverterHandlerDelegate(ConverterHandler owner) {
- return factory.createConverterHandlerDelegate(owner);
- }
-
- /*
- * (non-Javadoc)
- * @see
javax.faces.view.facelets.TagHandlerDelegateFactory#createValidatorHandlerDelegate(javax.faces.view.facelets.ValidatorHandler)
- */
- @Override
- public TagHandlerDelegate createValidatorHandlerDelegate(ValidatorHandler owner) {
- return factory.createValidatorHandlerDelegate(owner);
- }
-}
Copied:
root/ui/trunk/components/core/src/main/java/org/richfaces/taglib/html/facelets/AjaxHandler.java
(from rev 16764,
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/facelets/tag/AjaxHandler.java)
===================================================================
---
root/ui/trunk/components/core/src/main/java/org/richfaces/taglib/html/facelets/AjaxHandler.java
(rev 0)
+++
root/ui/trunk/components/core/src/main/java/org/richfaces/taglib/html/facelets/AjaxHandler.java 2010-04-17
13:25:25 UTC (rev 16772)
@@ -0,0 +1,272 @@
+package org.richfaces.taglib.html.facelets;
+
+import java.beans.BeanDescriptor;
+import java.beans.BeanInfo;
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+import javax.el.ELContext;
+import javax.el.MethodExpression;
+import javax.faces.application.Application;
+import javax.faces.component.UIComponent;
+import javax.faces.component.behavior.ClientBehaviorHolder;
+import javax.faces.context.FacesContext;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.AjaxBehaviorEvent;
+import javax.faces.event.AjaxBehaviorListener;
+import javax.faces.view.AttachedObjectHandler;
+import javax.faces.view.AttachedObjectTarget;
+import javax.faces.view.BehaviorHolderAttachedObjectHandler;
+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;
+
+public class AjaxHandler extends TagHandler implements
BehaviorHolderAttachedObjectHandler {
+
+ // TODO - is that implementation dependency?
+ private static final String JAVAX_FACES_RETARGETABLE_HANDLERS =
"javax.faces.RetargetableHandlers";
+ private final TagAttribute disabled;
+ private final TagAttribute event;
+ private final TagAttribute execute;
+ private final TagAttribute immediate;
+ private final TagAttribute limitRender;
+ private final TagAttribute listener;
+ private final TagAttribute onbeforedomupdate;
+ private final TagAttribute onbegin;
+ 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);
+ this.event = this.getAttribute("event");
+ this.execute = this.getAttribute("execute");
+ this.render = this.getAttribute("render");
+ this.disabled = this.getAttribute("disabled");
+ 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");
+ this.onerror = this.getAttribute("onerror");
+ 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 {
+ String eventName = getEventName();
+
+ if (this.wrapping) {
+ applyWrapping(fContext, parent, eventName);
+ } else {
+ applyNested(fContext, parent, eventName);
+ }
+ }
+
+ private static List<AttachedObjectHandler>
getOrCreateRetargetableHandlersList(UIComponent component) {
+ Map<String, Object> attrs = component.getAttributes();
+ @SuppressWarnings({
+ "unchecked"}) List<AttachedObjectHandler> list =
+ (List<AttachedObjectHandler>)
attrs.get(JAVAX_FACES_RETARGETABLE_HANDLERS);
+
+ if (list == null) {
+ list = new ArrayList<AttachedObjectHandler>();
+ attrs.put(JAVAX_FACES_RETARGETABLE_HANDLERS, list);
+ }
+
+ return list;
+ }
+
+ private void applyNested(FaceletContext ctx, UIComponent parent, String eventName) {
+ if (!ComponentHandler.isNew(parent)) {
+ return;
+ }
+
+ if (UIComponent.isCompositeComponent(parent)) {
+ BeanInfo componentBeanInfo = (BeanInfo)
parent.getAttributes().get(UIComponent.BEANINFO_KEY);
+
+ if (null == componentBeanInfo) {
+ throw new TagException(tag, "Error: enclosing composite component
does not have BeanInfo attribute");
+ }
+
+ BeanDescriptor componentDescriptor = componentBeanInfo.getBeanDescriptor();
+
+ if (null == componentDescriptor) {
+ throw new TagException(tag,
+ "Error: enclosing composite component
BeanInfo does not have BeanDescriptor");
+ }
+
+ @SuppressWarnings(
+ "unchecked") List<AttachedObjectTarget> targetList =
+ (List<AttachedObjectTarget>) componentDescriptor.getValue(
+ AttachedObjectTarget.ATTACHED_OBJECT_TARGETS_KEY);
+
+ if (null == targetList) {
+ throw new TagException(tag, "Error: enclosing composite component
does not support behavior events");
+ }
+
+ boolean supportedEvent = false;
+
+ for (AttachedObjectTarget target : targetList) {
+ if (target instanceof BehaviorHolderAttachedObjectTarget) {
+ BehaviorHolderAttachedObjectTarget behaviorTarget =
(BehaviorHolderAttachedObjectTarget) target;
+
+ if ((null != eventName &&
eventName.equals(behaviorTarget.getName()))
+ || (null == eventName &&
behaviorTarget.isDefaultEvent())) {
+ supportedEvent = true;
+
+ break;
+ }
+ }
+ }
+
+ if (supportedEvent) {
+ getOrCreateRetargetableHandlersList(parent).add(this);
+ } else {
+ throw new TagException(tag, "Error: enclosing composite component
does not support event " + eventName);
+ }
+ } else if (parent instanceof ClientBehaviorHolder) {
+ applyAttachedObject(ctx, parent, eventName);
+ } 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);
+
+ ajaxBehaviors.pushBehavior(context, ajaxBehavior, AjaxBehavior.BEHAVIOR_ID,
eventName);
+ nextHandler.apply(ctx, parent);
+ ajaxBehaviors.popBehavior();
+ }
+
+ public void applyAttachedObject(FaceletContext fContext, UIComponent parent, String
eventName) {
+ ClientBehaviorHolder bHolder = (ClientBehaviorHolder) parent;
+
+ if (null == eventName) {
+ eventName = bHolder.getDefaultEventName();
+
+ if (null == eventName) {
+ throw new TagException(this.tag, "Event attribute could not be
determined: " + eventName);
+ }
+ } else {
+ Collection<String> eventNames = bHolder.getEventNames();
+
+ if (!eventNames.contains(eventName)) {
+ throw new TagException(this.tag,
+ eventName + "event is not supported for the
"
+ + parent.getClass().getSimpleName());
+ }
+ }
+
+ AjaxBehavior ajaxBehavior = createAjaxBehavior(fContext, eventName);
+
+ bHolder.addClientBehavior(eventName, ajaxBehavior);
+ }
+
+ public AjaxBehavior createAjaxBehavior(FaceletContext fContext, String eventName) {
+ Application application = fContext.getFacesContext().getApplication();
+ AjaxBehavior ajaxBehavior = (AjaxBehavior)
application.createBehavior(AjaxBehavior.BEHAVIOR_ID);
+
+ setBehaviorAttribute(fContext, ajaxBehavior, this.disabled, Boolean.class);
+ setBehaviorAttribute(fContext, ajaxBehavior, this.immediate, Boolean.class);
+ 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);
+ setBehaviorAttribute(fContext, ajaxBehavior, this.onerror, String.class);
+ setBehaviorAttribute(fContext, ajaxBehavior, this.onbegin, String.class);
+ setBehaviorAttribute(fContext, ajaxBehavior, this.oncomplete, String.class);
+ setBehaviorAttribute(fContext, ajaxBehavior, this.onbeforedomupdate,
String.class);
+ registerBehaviorListener(fContext, ajaxBehavior, listener);
+
+ return ajaxBehavior;
+ }
+
+ public void applyAttachedObject(FacesContext context, UIComponent parent) {
+ FaceletContext ctx = (FaceletContext)
context.getAttributes().get(FaceletContext.FACELET_CONTEXT_KEY);
+
+ applyAttachedObject(ctx, parent, getEventName());
+ }
+
+ private void setBehaviorAttribute(FaceletContext ctx, AjaxBehavior behavior,
TagAttribute attr, Class<?> type) {
+ if (attr != null) {
+ behavior.setValueExpression(attr.getLocalName(), attr.getValueExpression(ctx,
type));
+ }
+ }
+
+ public String getEventName() {
+ return (this.event != null) ? this.event.getValue() : null;
+ }
+
+ public String getFor() {
+ 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,
+ new Class[] {AjaxBehaviorEvent.class});
+
+ behavior.addAjaxBehaviorListener(new AjaxBehaviorListenerImpl(mExpression));
+ }
+ }
+
+ static class AjaxBehaviorListenerImpl implements AjaxBehaviorListener, Serializable
{
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1812543470662919310L;
+
+ private MethodExpression methodExpression;
+
+ public AjaxBehaviorListenerImpl() {}
+
+ public AjaxBehaviorListenerImpl(MethodExpression expression) {
+ this.methodExpression = expression;
+ }
+
+ public void processAjaxBehavior(AjaxBehaviorEvent event) throws
AbortProcessingException {
+ if (methodExpression != null) {
+ ELContext elContext = FacesContext.getCurrentInstance().getELContext();
+
+ try {
+ methodExpression.invoke(elContext, new Object[] {event});
+ } catch (Exception e) {
+
+ // TODO: log or message ??
+ throw new AbortProcessingException(e);
+ }
+ }
+ }
+ }
+}
Copied:
root/ui/trunk/components/core/src/main/java/org/richfaces/taglib/html/facelets/BehaviorStack.java
(from rev 16764,
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/facelets/tag/BehaviorStack.java)
===================================================================
---
root/ui/trunk/components/core/src/main/java/org/richfaces/taglib/html/facelets/BehaviorStack.java
(rev 0)
+++
root/ui/trunk/components/core/src/main/java/org/richfaces/taglib/html/facelets/BehaviorStack.java 2010-04-17
13:25:25 UTC (rev 16772)
@@ -0,0 +1,152 @@
+/*
+ * 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.taglib.html.facelets;
+
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.faces.application.Application;
+import javax.faces.component.StateHolder;
+import javax.faces.component.behavior.ClientBehavior;
+import javax.faces.component.behavior.ClientBehaviorHint;
+import javax.faces.component.behavior.ClientBehaviorHolder;
+import javax.faces.context.FacesContext;
+
+/**
+ * @author Nick Belaevski
+ *
+ * This class is necessary to handle nesting wrapping behaviors properly and is created
+ * to work around this issue:
https://javaserverfaces-spec-public.dev.java.net/issues/show_bug.cgi?id=655
+ *
+ */
+
+//TODO - check for bug resolution
+final class BehaviorStack {
+ private static final String BEHAVIOR_STACK =
"org.richfaces.BehaviorStack";
+ private LinkedList<BehaviorInfo> behaviorStack = null;
+
+ public BehaviorStack() {
+ behaviorStack = new LinkedList<BehaviorInfo>();
+ }
+
+ public static BehaviorStack getBehaviorStack(FacesContext context, boolean
createIfNull) {
+ Map<Object, Object> attributes = context.getAttributes();
+ BehaviorStack behaviorStack = (BehaviorStack) attributes.get(BEHAVIOR_STACK);
+
+ if (behaviorStack == null && createIfNull) {
+ behaviorStack = new BehaviorStack();
+ attributes.put(BEHAVIOR_STACK, behaviorStack);
+ }
+
+ return behaviorStack;
+ }
+
+ public void addBehaviors(FacesContext context, ClientBehaviorHolder behaviorHolder)
{
+ if (behaviorStack == null || behaviorStack.isEmpty()) {
+ return;
+ }
+
+ for (BehaviorInfo behaviorInfo : behaviorStack) {
+ behaviorInfo.addBehavior(context, behaviorHolder);
+ }
+ }
+
+ 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));
+ }
+
+ public void popBehavior() {
+ if (!behaviorStack.isEmpty()) {
+ behaviorStack.removeFirst();
+ }
+ }
+
+ private static class BehaviorInfo {
+ private String behaviorId;
+ private Object behaviorState;
+ private String eventName;
+
+ public BehaviorInfo(String behaviorId, String eventName, Object behaviorState) {
+ this.behaviorId = behaviorId;
+ this.eventName = eventName;
+ this.behaviorState = behaviorState;
+ }
+
+ public void addBehavior(FacesContext context, ClientBehaviorHolder
behaviorHolder) {
+ String eventName = this.eventName;
+
+ if (eventName == null) {
+ eventName = behaviorHolder.getDefaultEventName();
+
+ if (eventName == null) {
+ return;
+ }
+ }
+
+ if (shouldAddBehavior(behaviorHolder, eventName)) {
+ ClientBehavior behavior = createBehavior(context);
+
+ behaviorHolder.addClientBehavior(eventName, behavior);
+ }
+ }
+
+ private boolean shouldAddBehavior(ClientBehaviorHolder behaviorHolder, String
eventName) {
+ if (!behaviorHolder.getEventNames().contains(eventName)) {
+ return false;
+ }
+
+ Map<String, List<ClientBehavior>> clientBehaviorsMap =
behaviorHolder.getClientBehaviors();
+ List<ClientBehavior> clientBehaviors =
clientBehaviorsMap.get(eventName);
+
+ if (clientBehaviors == null || clientBehaviors.isEmpty()) {
+ return true;
+ }
+
+ for (ClientBehavior behavior : clientBehaviors) {
+ Set<ClientBehaviorHint> hints = behavior.getHints();
+
+ if (hints.contains(ClientBehaviorHint.SUBMITTING)) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ private ClientBehavior createBehavior(FacesContext context) {
+ Application application = context.getApplication();
+ ClientBehavior behavior = (ClientBehavior)
application.createBehavior(this.behaviorId);
+
+ ((StateHolder) behavior).restoreState(context, behaviorState);
+
+ return behavior;
+ }
+ }
+}
Copied:
root/ui/trunk/components/core/src/main/java/org/richfaces/taglib/html/facelets/BehaviorsAddingComponentHandlerWrapper.java
(from rev 16764,
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/facelets/tag/BehaviorsAddingComponentHandlerWrapper.java)
===================================================================
---
root/ui/trunk/components/core/src/main/java/org/richfaces/taglib/html/facelets/BehaviorsAddingComponentHandlerWrapper.java
(rev 0)
+++
root/ui/trunk/components/core/src/main/java/org/richfaces/taglib/html/facelets/BehaviorsAddingComponentHandlerWrapper.java 2010-04-17
13:25:25 UTC (rev 16772)
@@ -0,0 +1,118 @@
+/*
+ * 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.taglib.html.facelets;
+
+import java.io.IOException;
+
+import javax.el.ELException;
+
+import javax.faces.FacesException;
+import javax.faces.component.UIComponent;
+import javax.faces.component.behavior.ClientBehaviorHolder;
+import javax.faces.context.FacesContext;
+import javax.faces.view.facelets.ComponentConfig;
+import javax.faces.view.facelets.ComponentHandler;
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.Tag;
+import javax.faces.view.facelets.TagAttribute;
+
+/**
+ * @author Nick Belaevski
+ */
+public class BehaviorsAddingComponentHandlerWrapper extends ComponentHandler {
+ private ComponentHandler componentHandler;
+
+ public BehaviorsAddingComponentHandlerWrapper(ComponentHandler componentHandler) {
+ super(componentHandler.getComponentConfig());
+ this.componentHandler = componentHandler;
+ }
+
+ public void apply(FaceletContext ctx, UIComponent parent) throws IOException {
+ componentHandler.apply(ctx, parent);
+ }
+
+ public void applyNextHandler(FaceletContext ctx, UIComponent c) throws IOException,
FacesException, ELException {
+ componentHandler.applyNextHandler(ctx, c);
+ }
+
+ public TagAttribute getBinding() {
+ return componentHandler.getBinding();
+ }
+
+ public ComponentConfig getComponentConfig() {
+ return componentHandler.getComponentConfig();
+ }
+
+ public Tag getTag() {
+ return componentHandler.getTag();
+ }
+
+ public TagAttribute getTagAttribute(String localName) {
+ return componentHandler.getTagAttribute(localName);
+ }
+
+ public String getTagId() {
+ return componentHandler.getTagId();
+ }
+
+ public boolean equals(Object obj) {
+ return componentHandler.equals(obj);
+ }
+
+ public int hashCode() {
+ return componentHandler.hashCode();
+ }
+
+ public String toString() {
+ return componentHandler.toString();
+ }
+
+ public boolean isDisabled(FaceletContext ctx) {
+ return componentHandler.isDisabled(ctx);
+ }
+
+ public void onComponentCreated(FaceletContext ctx, UIComponent c, UIComponent parent)
{
+ componentHandler.onComponentCreated(ctx, c, parent);
+ }
+
+ public void onComponentPopulated(FaceletContext ctx, UIComponent c, UIComponent
parent) {
+ FacesContext facesContext = ctx.getFacesContext();
+ BehaviorStack behaviorStack = BehaviorStack.getBehaviorStack(facesContext,
false);
+
+ if (behaviorStack != null) {
+ if (c instanceof ClientBehaviorHolder) {
+ ClientBehaviorHolder behaviorHolder = (ClientBehaviorHolder) c;
+
+ behaviorStack.addBehaviors(facesContext, behaviorHolder);
+ }
+ }
+
+ componentHandler.onComponentPopulated(ctx, c, parent);
+ }
+
+ public void setAttributes(FaceletContext ctx, Object instance) {
+ componentHandler.setAttributes(ctx, instance);
+ }
+}
Copied:
root/ui/trunk/components/core/src/main/java/org/richfaces/taglib/html/facelets/BehaviorsTagHandlerDelegateFactoryImpl.java
(from rev 16764,
root/ui/trunk/components/core/src/main/java/org/ajax4jsf/facelets/tag/BehaviorsTagHandlerDelegateFactoryImpl.java)
===================================================================
---
root/ui/trunk/components/core/src/main/java/org/richfaces/taglib/html/facelets/BehaviorsTagHandlerDelegateFactoryImpl.java
(rev 0)
+++
root/ui/trunk/components/core/src/main/java/org/richfaces/taglib/html/facelets/BehaviorsTagHandlerDelegateFactoryImpl.java 2010-04-17
13:25:25 UTC (rev 16772)
@@ -0,0 +1,82 @@
+/*
+ * 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.taglib.html.facelets;
+
+import javax.faces.view.facelets.BehaviorHandler;
+import javax.faces.view.facelets.ComponentHandler;
+import javax.faces.view.facelets.ConverterHandler;
+import javax.faces.view.facelets.TagHandlerDelegate;
+import javax.faces.view.facelets.TagHandlerDelegateFactory;
+import javax.faces.view.facelets.ValidatorHandler;
+
+/**
+ * @author Nick Belaevski
+ */
+public class BehaviorsTagHandlerDelegateFactoryImpl extends TagHandlerDelegateFactory {
+ private TagHandlerDelegateFactory factory;
+
+ public BehaviorsTagHandlerDelegateFactoryImpl(TagHandlerDelegateFactory factory) {
+ this.factory = factory;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
javax.faces.view.facelets.TagHandlerDelegateFactory#createBehaviorHandlerDelegate(javax.faces.view.facelets.BehaviorHandler)
+ */
+ @Override
+ public TagHandlerDelegate createBehaviorHandlerDelegate(BehaviorHandler owner) {
+ return factory.createBehaviorHandlerDelegate(owner);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
javax.faces.view.facelets.TagHandlerDelegateFactory#createComponentHandlerDelegate(javax.faces.view.facelets.ComponentHandler)
+ */
+ @Override
+ public TagHandlerDelegate createComponentHandlerDelegate(ComponentHandler owner) {
+
+ // TagHandlers structure is created when view is compiled
+ // so there's no need to check for BehaviorsStack
+ return factory.createComponentHandlerDelegate(new
BehaviorsAddingComponentHandlerWrapper(owner));
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
javax.faces.view.facelets.TagHandlerDelegateFactory#createConverterHandlerDelegate(javax.faces.view.facelets.ConverterHandler)
+ */
+ @Override
+ public TagHandlerDelegate createConverterHandlerDelegate(ConverterHandler owner) {
+ return factory.createConverterHandlerDelegate(owner);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see
javax.faces.view.facelets.TagHandlerDelegateFactory#createValidatorHandlerDelegate(javax.faces.view.facelets.ValidatorHandler)
+ */
+ @Override
+ public TagHandlerDelegate createValidatorHandlerDelegate(ValidatorHandler owner) {
+ return factory.createValidatorHandlerDelegate(owner);
+ }
+}
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-04-17
13:21:26 UTC (rev 16771)
+++ root/ui/trunk/components/core/src/main/resources/META-INF/a4j.taglib.xml 2010-04-17
13:25:25 UTC (rev 16772)
@@ -86,7 +86,7 @@
<tag-name>ajax</tag-name>
<behavior>
<behavior-id>org.ajax4jsf.behavior.Ajax</behavior-id>
- <handler-class>org.ajax4jsf.facelets.tag.AjaxHandler</handler-class>
+ <handler-class>org.richfaces.taglib.html.facelets.AjaxHandler</handler-class>
</behavior>
</tag>
</facelet-taglib>
Modified:
root/ui/trunk/components/core/src/main/resources/META-INF/behaviors-handler-delegate.faces-config.xml
===================================================================
---
root/ui/trunk/components/core/src/main/resources/META-INF/behaviors-handler-delegate.faces-config.xml 2010-04-17
13:21:26 UTC (rev 16771)
+++
root/ui/trunk/components/core/src/main/resources/META-INF/behaviors-handler-delegate.faces-config.xml 2010-04-17
13:25:25 UTC (rev 16772)
@@ -12,7 +12,7 @@
</ordering>
<factory>
- <tag-handler-delegate-factory>org.ajax4jsf.facelets.tag.BehaviorsTagHandlerDelegateFactoryImpl</tag-handler-delegate-factory>
+ <tag-handler-delegate-factory>org.richfaces.taglib.html.facelets.BehaviorsTagHandlerDelegateFactoryImpl</tag-handler-delegate-factory>
</factory>
</faces-config>
\ No newline at end of file