2 Replies Latest reply on Oct 24, 2008 6:28 PM by nbelaevski

    The easiest way to add an attribute to a component

    aparij

      I just want to extend a component and add additional attribute .
      What is the minimal set of files I need to extend ?
      May be someone can point me to some tutorials or forum posts ?

        • 1. Re: The easiest way to add an attribute to a component
          aparij

          The only help source I could find was
          in the CDK Developer guide in section
          4.4.1. Templating. But it is about creating a completely new component...


          • 2. Re: The easiest way to add an attribute to a component
            nbelaevski

            If you need to read this attribute by another component or from Java code you can use <f:attribute> tag/javax.faces.component.UIComponent#getAttributes() method.

            To extend the component you have to:

            1. Extend Html* component class - add getter/setter for your property together with overriding saveState/restoreState

            2. Write your own renderer (or use ours if you find the way to extend it)

            3. Create *.tld/faces-config.xml/*.taglib.xml files for your component

            4. Extend JSP tag handler class

            5. Extend or create Facelet handler class (that's necessary in rare cases like adding method attributes)

            That's all and I hope that I didn't forget anything :).

            In fact it would be much easier to modify CDK files for component (SVN_ROOT/ui/component/src/main/config and SVN_ROOT/ui/component/src/main/templates) and rebuild it than creating/extending all the stuff mentioned above.