I would like to just add another value for an existing property. I have
extended the renderer for the messages component. Now I just need the
component to use that renderer. And the component to pass to the renderer
the new property value. The property is layout and its accepted values are
table|list. I want to add 'text' as an additional value. I have included
this new value in my new class.

I think I am getting way in over my head. It looks like there is quite a bit
more involved than what I expected.

> -----Original Message-----
> From: Simon Kitching [mailto:[EMAIL PROTECTED]
> Sent: Thursday, November 10, 2005 4:15 PM
> To: MyFaces Discussion
> Subject: Re: Messages as text only?
>
>
> Warren Bell wrote:
> > Would I just use <t:messages layout="text"/> in my jsp where
> layout="text"
> > would be implemented in my my.package.extend.MyMsgRenderer class that
> > extends org.apache.myfaces.renderkit.html.HtmlMessagesRenderer?
>
> Ah, now you're wanting to add extra properties to a component rather
> than just changing the renderer, and things get *much* more complicated.
>
> First, you need to create a new .tld file with the new attribute defined
> in it, so that the JSP processor recognises the new attribute as valid.
> You define your own namespace for this new tag library, eg
> "warren.com/taglib1" then add references to this taglib in your .jsp
> files with some unique prefix.
>
> See tomahawk/tld/tomahawk.tld from the MyFaces source for an example tld.
>
> However JSP provides no mechanism to "inherit" attributes, so your new
> TLD entry needs to contain a copy-and-paste of the entire set of
> attribute definitions from the parent tag's tld. Ecch. MyFaces work
> around this by using XML entity definitions, but many servlet engines
> (incl. tomcat) don't correctly process entity references in .tld files
> so a preprocessing stage that uses XSLT to expand the entities is needed.
>
> Your tag class needs to have a setter for this new layout property, and
> update the component with it in its setProperties method.
>
> Having written your tag, you then need to subclass the UIComponent to
> add your new field. Well, actually you can be sneaky and skip this step,
>   as a component has an attributes map that stores any "properties" that
> aren't defined via setter/getter methods on the UIComponent. Generally
> that's bad form I think but probably ok in this case.
>
> Your custom renderer can then use component.getAttribute("layout") to
> determine what layout was defined via the JSP tag and do the right thing.
>
> About now is when you start thinking about using Facelets instead of
> JSP. I have only read the basic docs, but avoiding all this JSP tag
> garbage can't be bad.
>
> Regards,
>
> Simon
>
> __________ NOD32 1.1283 (20051110) Information __________
>
> This message was checked by NOD32 antivirus system.
> http://www.eset.com
>
>

Reply via email to