How To Create ClientBehavior

Version 4

    ** Note this article is a work in progress -- feel free to add to it should you find any information to be missing **

    How to Create Client Behavior

    ClientBehavior is responsible for attaching arbitrary client-side functionality to JSF 2 UI components.

    Client Behavior Class

    The JSF Cient Behavior class extends the org.richfaces.component.behavior.ClientBehavior base class, and should be annotated with a @JsfBehavior annotation that describes:


    • id() behavior-id with which instances of implementation class can be created b JSF Application implementation. If this value is empty, behavior-id will be inferred from class name.
    • generate() fully qualified class name of the generated Behavior implementation. Default value means nothing to genrate from concrete class, or infer name by convention for abstract class.
    • tag()  is an array of @Tag annotations. Using multiply tags for a single component is necessary to define tags for different VDL ( View Description Language ), or to make aliasesTag description. If generated tags require special handlers, provide separate description for every type of tag, JSP and Facelets. Otherwise, the only one tag tag description with name and type TagType
    • renderer() JsfBehaviorRenderer associated with generated ClientBehavior. default @JsfBehaviorRenderer()
    • description() Description used by IDE
    • attributes() Defines file names for fragment of faces-config.xml that contain standard attribute definitions. All names relative to the META-INF/cdk/attributes/ folder in classpath. CDK also tries to read META-INF/cdk/attributes/[classname].xml file for all component superclasses and interfaces. Therefore, it is not necessary to explicitly include definitions for Converter and any other standard JSF classes.
    • interfaces() Interfaces that should be implemented in the generated class. CDK processes all {@link Attribute} annotations in these interfaces


    Client Behavior Renderer Class

    The renderer class for a client behavior extends javax.faces.render.ClientBehaviorRenderer, and should be annotated with a @FacesBehaviorRenderer annotation that describes:

    • renderKitId() the JSF render kit for which the generated renderer belongs to. By default, this value is the JSF "HTML_BASIC" render kit.
    • rendererType() he JSF Renderer type assigned to the generated renderer. Same as for the component family, its value can be inferred or taken from the ClientBehavior.