myfaces-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ali Ok <>
Subject Tag handler for custom Behavior (not ClientBehavior)
Date Mon, 17 May 2010 22:41:20 GMT
I was playing with JSF2 behaviors and I wrote a new behavior (not
ClientBehavior). Problem I described here doesn't seem like a impl bug,
instead it seems like a missing thing in the spec to me.

Let me explain my structure first. I have two abstract stuff in

   - "ByPassAttributeBehavior"

@FacesBehavior(value = "org.apache.myfaces.html5.ByPassAttributeBehavior")
public class ByPassAttributeBehavior extends *BehaviorBase*

   - "ByPassAttributeBehaviorHolder" (which does not extend anything. it
   would extend "BehaviorHolder", if it was existed)

public interface ByPassAttributeBehaviorHolder

And implementing component side (please note that I am using MyFaces builder

   - "AbstractByPassTestComponent"

@JSFComponent(name = "hx:bypassTest",
        clazz = "",
        tagClass = "")
public abstract class AbstractByPassTestComponent extends UIComponentBase
implements *ByPassAttributeBehaviorHolder*

   - "ByPassTestRenderer"

    renderKitId = "HTML_BASIC",
    family = "",
    type = "")
public class ByPassTestRenderer extends Renderer

Registration in ...taglib.xml:


At last, my usage:
<hx:bypassTest ...>
                <hx:byPassAttributeBehavior .../>

In this case, at
an exception is thrown if the parent is not a ClientBehaviorHolder or a
composite component.

I think I can solve this problem by writing a tag handler, but why not
supporting this feature without a tag handler just like ClientBehaviors?

We don't have to write tag handlers for "ClientBehavior"s, but this is not
the case for "Behavior"s. Seems like the problem is: there is no interface
like "BehaviorHolder". Thus the delegate BehaviorTagHandlerDelegate cannot
determine whether the parent is Behavior 'attachable', so it cannot attach
Behaviors to parent.

However, I couldn't understand why there is no interface like BehaviorHolder
and why we need to write a tag handler for a "Behavior" that doesn't extend
"ClientBehavior"? If something similar is discussed before, what was the
purpose of this decision?

I see that, we have "addClientBehavior" method in "ClientBehaviorHolder"
class. Behaviors are here to get attached, right? So, why this attaching
logic only pushed for 'ClientBehavior's?


My Blog:

View raw message