Aneesha Govil wrote:


On 11/30/06, *Simon Kitching* <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> wrote:

    I would recommend writing your own class (in your own package namespace)
    that subclasses HtmlInputDate. Add the methods that are needed.

    You can then add a <component> tag to your web.xml to map the component
    id used by the InputDateTag to your subclass instead of the "real" one.

oops - I meant add a <component> tag to your faces config file.


    The result is that you should then be able to use t:inputDate in your
    pages but an instance of your patched component will be created
    instead.

    Once you've proved this works, you canthen attach your patched class to
    the JIRA issue; it would be a pretty simple task for a MyFaces committer
    to merge the code into the "real" component.

    And while you're waiting for the real component to be patched, you've
    got a working solution....

    Regards,

    Simon


Any resources on doing this? I am stuck in a couple of places like do I need to change the DEFAULT_RENDERER_TYPE? I think I would have to patch the renderer too, how to configure it etc.

To update the renderer to make use of these new properties just subclass the original renderer. Then in your faces config file, map the DEFAULT_RENDERER_TYPE to your new class.

Alternately you could have your custom component class declare a new renderer-type string, then in the faces config file map that new string to your customised renderer.

These layers of indirection/configurability are a little confusing at first, but are quite useful once you understand them.

Here's some code directly from the app I'm currently working on; we override the datatable component to fix a bug in tomahawk 1.1.3, and override the label renderer to automatically add an asterisk next to required fields:

  <component>
   <component-type>
     org.apache.myfaces.patch.HtmlDataTable
   </component-type>
   <component-class>
    our.package.myfaces.patch.HtmlDataTable
   </component-class>
  </component>

  <render-kit>
    <render-kit-id>HTML_BASIC</render-kit-id>

    <!-- Custom label renderer -->
    <renderer>
      <component-family>javax.faces.Output</component-family>
      <renderer-type>javax.faces.Label</renderer-type>
      <renderer-class>
        our.package.jsf.component.LabelRenderer
      </renderer-class>
    </renderer>


Regards,

Simon


Reply via email to