Author: nbelaevski
Date: 2011-01-12 15:08:46 -0500 (Wed, 12 Jan 2011)
New Revision: 20973
Modified:
trunk/ui/core/ui/src/main/java/org/richfaces/view/facelets/html/BehaviorsAddingComponentHandlerWrapper.java
trunk/ui/core/ui/src/main/java/org/richfaces/view/facelets/html/BehaviorsTagHandlerDelegateFactoryImpl.java
Log:
https://issues.jboss.org/browse/RF-9025
https://issues.jboss.org/browse/RF-9138
Modified:
trunk/ui/core/ui/src/main/java/org/richfaces/view/facelets/html/BehaviorsAddingComponentHandlerWrapper.java
===================================================================
---
trunk/ui/core/ui/src/main/java/org/richfaces/view/facelets/html/BehaviorsAddingComponentHandlerWrapper.java 2011-01-12
19:40:52 UTC (rev 20972)
+++
trunk/ui/core/ui/src/main/java/org/richfaces/view/facelets/html/BehaviorsAddingComponentHandlerWrapper.java 2011-01-12
20:08:46 UTC (rev 20973)
@@ -27,6 +27,7 @@
import javax.el.ELException;
import javax.faces.FacesException;
+import javax.faces.FacesWrapper;
import javax.faces.component.UIComponent;
import javax.faces.component.behavior.ClientBehaviorHolder;
import javax.faces.context.FacesContext;
@@ -38,7 +39,7 @@
/**
* @author Nick Belaevski
*/
-public class BehaviorsAddingComponentHandlerWrapper extends ComponentHandler {
+public class BehaviorsAddingComponentHandlerWrapper extends ComponentHandler implements
FacesWrapper<ComponentHandler> {
private ComponentHandler componentHandler;
public BehaviorsAddingComponentHandlerWrapper(ComponentHandler componentHandler) {
@@ -63,6 +64,11 @@
}
public TagAttribute getTagAttribute(String localName) {
+ //workaround for MyFaces
+ if (componentHandler == null) {
+ return getComponentConfig().getTag().getAttributes().get(localName);
+ }
+
return componentHandler.getTagAttribute(localName);
}
@@ -108,4 +114,8 @@
public void setAttributes(FaceletContext ctx, Object instance) {
componentHandler.setAttributes(ctx, instance);
}
+
+ public ComponentHandler getWrapped() {
+ return componentHandler;
+ }
}
Modified:
trunk/ui/core/ui/src/main/java/org/richfaces/view/facelets/html/BehaviorsTagHandlerDelegateFactoryImpl.java
===================================================================
---
trunk/ui/core/ui/src/main/java/org/richfaces/view/facelets/html/BehaviorsTagHandlerDelegateFactoryImpl.java 2011-01-12
19:40:52 UTC (rev 20972)
+++
trunk/ui/core/ui/src/main/java/org/richfaces/view/facelets/html/BehaviorsTagHandlerDelegateFactoryImpl.java 2011-01-12
20:08:46 UTC (rev 20973)
@@ -23,9 +23,7 @@
package org.richfaces.view.facelets.html;
-import java.util.Locale;
-
-import javax.faces.application.Application;
+import javax.faces.FacesWrapper;
import javax.faces.view.facelets.BehaviorHandler;
import javax.faces.view.facelets.ComponentHandler;
import javax.faces.view.facelets.ConverterHandler;
@@ -33,40 +31,17 @@
import javax.faces.view.facelets.TagHandlerDelegateFactory;
import javax.faces.view.facelets.ValidatorHandler;
-import org.richfaces.log.RichfacesLogger;
-import org.richfaces.log.Logger;
-
/**
* @author Nick Belaevski
*/
-public class BehaviorsTagHandlerDelegateFactoryImpl extends TagHandlerDelegateFactory {
+public class BehaviorsTagHandlerDelegateFactoryImpl extends TagHandlerDelegateFactory
implements FacesWrapper<TagHandlerDelegateFactory> {
- private static final Logger LOGGER = RichfacesLogger.WEBAPP.getLogger();
-
private TagHandlerDelegateFactory factory;
- private boolean isMyFaces = false;
-
public BehaviorsTagHandlerDelegateFactoryImpl(TagHandlerDelegateFactory factory) {
this.factory = factory;
- detectMyFaces();
}
- private void detectMyFaces() {
- String implementationTitle =
Application.class.getPackage().getImplementationTitle();
- if (implementationTitle != null) {
- isMyFaces =
implementationTitle.toLowerCase(Locale.US).contains("myfaces");
-
- if (isMyFaces) {
- //TODO - RF M3 workaround for
https://jira.jboss.org/browse/RF-9025 /
https://issues.apache.org/jira/browse/MYFACES-2888
- LOGGER.warn("MyFaces implementation of JavaServer Faces detected.
"
- + "Wrapping of components using RichFaces behaviors (a4j:ajax
etc.) won't work!");
- }
- } else {
- LOGGER.warn("Cannot detect Mojarra vs MyFaces implementation of
JavaServer Faces");
- }
- }
-
/*
* (non-Javadoc)
* @see
javax.faces.view.facelets.TagHandlerDelegateFactory#createBehaviorHandlerDelegate(javax.faces.view.facelets.BehaviorHandler)
@@ -86,13 +61,14 @@
// TagHandlers structure is created when view is compiled
// so there's no need to check for BehaviorsStack
- ComponentHandler handler = owner;
-
- if (!isMyFaces) {
- handler = new BehaviorsAddingComponentHandlerWrapper(owner);
+ if (owner instanceof BehaviorsAddingComponentHandlerWrapper) {
+ //this is to avoid StackOverflowError because of ComponentHandler constructor
call
+ return null;
}
- return factory.createComponentHandlerDelegate(handler);
+ ComponentHandler wrappedHandler = new
BehaviorsAddingComponentHandlerWrapper(owner);
+
+ return factory.createComponentHandlerDelegate(wrappedHandler);
}
/*
@@ -112,4 +88,8 @@
public TagHandlerDelegate createValidatorHandlerDelegate(ValidatorHandler owner) {
return factory.createValidatorHandlerDelegate(owner);
}
+
+ public TagHandlerDelegateFactory getWrapped() {
+ return factory;
+ }
}