Warren Bell wrote:
I am kinda playing around with extending
org.apache.myfaces.renderkit.html.HtmlMessagesRenderer. I found the
renderMessages method and see where I would call a new method that would
render the messages the way I want.

private void renderText(FacesContext facesContext,
                            UIComponent messages,
                            MessagesIterator messagesIterator)
            throws IOException
{
  // format messages as text
  ...
}

I am not quite sure how to proceed from there. Would I list the new class in
the faces-config file like this?

<render-kit>
        <render-kit-id>textMessages</render-kit-id>
        
<render-kit-class>my.package.extend.MyNewHtmlTextMessagesRenderer</render
-kit-class>
</render-kit>

You don't want to override the *render kit* itself. You want to modify the html render kit's configuration. As the html render kit is the default render kit, you need:

 <render-kit>
   <renderer>
     <component-family>javax.faces.Output</component-family>
     <renderer-type>
       org.apache.myfaces.renderkit.html.HtmlMessagesRenderer
     </renderer-type>
     <renderer-class>my.package.extend.MyMsgRenderer</renderer-class>
    </renderer>
 </render-kit>



And then how would I actually use this in a page? Is there a good
tutorial/example of how to do this?

The page doesn't need altering at all, as you haven't changed what JSP *tag* is being used, just what renderer is used.

There's no tutorial on overriding renderers as far as I know. Maybe that would be a nice addition to:
  http://wiki.apache.org/myfaces/
even though it's really generic JSF stuff.

The O'Reilly JavaServer Faces book is pretty good (I'd give it 7 out of 10) and does talk about this stuff.

See class UIComponentBase method getRenderer for the real details of how a renderer is located for a component.

Regards,

Simon

Reply via email to