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>

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


> -----Original Message-----
> From: Mike Kienenberger [mailto:[EMAIL PROTECTED]
> Sent: Thursday, November 10, 2005 12:15 PM
> To: MyFaces Discussion
> Subject: Re: Messages as text only?
>
>
> I think it would require a custom renderer, but I don't think it's as
> difficult as you suspect.
>
> You'd need to subclass either
> org.apache.myfaces.renderkit.html.HtmlMessagesRenderer or
> org.apache.myfaces.renderkit.html.HtmlMessageRenderer and override
> renderSingleFacesMessage (actually in
> org.apache.myfaces.renderkit.html.HtmlMessageRendererBase).
>
> The new method would just be stripping out all of the styling
> information and outputting the javascript.
>
> Then you specify your new renderer class in the faces-config file.
>
> I've never written a custom renderer myself, but the process looks
> pretty simple.
>
> I suppose another way to do it would be to retrieve the messages out
> of the request map, and iterate over them manually, but that seems
> like a lot more difficult task.   A custom renderer seems easier and
> more maintainable.
>
> On 11/10/05, Warren Bell <[EMAIL PROTECTED]> wrote:
> > I would like to take messages and place them into some
> JavaScript less the
> > HTML. Is there a way to render messages as text only, or would I have to
> > create a custom rederer? Writing a custom renderer will not
> happen, I am way
> > to new to JSF.
> >
> > Thanks,
> >
> > Warren Bell
> >
> >

Reply via email to