webtier@glassfish.java.net

RE: [webtier] ResourceHandler[Wrapper] in JSF 2.0

From: Giampaolo Tomassoni <Giampaolo_at_Tomassoni.biz>
Date: Fri, 24 Sep 2010 20:55:16 +0200

> Agreed that it could be more clear, but I was looking at the javadoc,
> not the spec.  I finally found the info in Ed Burns book page 361.
>
> One gotcha I found was that if you want to override createResource,
> then you also must override handleResourceRequest, because the wrapper
> implementation of handleResourceRequest delegates to the wrapped instance,
> which calls its own createResource instead of the one you implemented
> in your extension of ResourceHandlerWrapper.

Nah. At least, not in mojarra-2.0.3.

This is from
com.sun.faces.application.resource.ResourceHandlerImpl#handleResourceRequest
:

        resource =
context.getApplication().getResourceHandler().createResource(resourceName,
libraryName);


However, I don't know if there is any gotcha of the kind you pointed out.

I have to code my own handleResourceRequest method anyway, so.


> Good luck,

Thank you, Joel.

Giampaolo


>
> Joel
> http://digitaljoel.nerd-herders.com
>
On Fri, Sep 24, 2010 at 10:36 AM, Giampaolo Tomassoni
<Giampaolo_at_tomassoni.biz> wrote:
>   I think you can do that by adding a constructor that takes a
> ResourceHandler:
>
> public MyResourceHandler(ResourceHandler wrapped) {
>      this.wrapped = wrapped;
> }
Eh, you're right.

Now I see
com.sun.faces.config.processor.AbstractConfigProcessor#createInstance works
that way...

Thank you very much.

Shouldn't this be better stated in the JSF specs?

Regards,

Giampaolo


> On 9/24/10 10:53 AM, Giampaolo Tomassoni wrote:
> > Hi,
> >
> > I have a (hopefully basic) question about implementing and
> instantiating a
> > ResourceHandlerWrapper in JSF 2.0.
> >
> > How can I wrap in a ResourceHandlerWrapper any "underlying"
> ResourceHandler?
> >
> > I'm working on a library which would need to override some of the
> behavior
> > defined by the ResourceHandler, but I would like to be kind with the
> > specific JSF 2.0 flavor my library may be going to run on.
> >
> > In example, I would like to avoid to make a direct reference to the
> > com.sun.faces.application.resource.ResourceHandlerImpl in my
> > ResourceHandlerWrapper implementation. Also, if a third-party library
> is
> > actually wrapping any "official" ResourceHandler implementation, I
> would
> > like to avoid breaking things by letting my library directly wrap the
> > official handler, and instead wrap the third-party one.
> >
> > Is there any way to do this?
> >
> > I attempted looking for a reply to this at the JSF 2.0 specifications
> as
> > well as to the JSF-ri documents and sources, but I was unable to find
> any.
> >
> > Thank you in advance,
> >
> > Giampaolo
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: webtier-unsubscribe_at_glassfish.dev.java.net
> > For additional commands, e-mail: webtier-help_at_glassfish.dev.java.net
> >
>
>
> --
> Jason Lee
> Senior Member of Technical Staff
> GlassFish Administration Console
>
> Oracle Corporation
> Phone +1 405-216-3193
> Blog http://blogs.steeplesoft.com
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: webtier-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: webtier-help_at_glassfish.dev.java.net


---------------------------------------------------------------------
To unsubscribe, e-mail: webtier-unsubscribe_at_glassfish.dev.java.net
For additional commands, e-mail: webtier-help_at_glassfish.dev.java.net