Skip to main content

JSF2: Exposing dynamic content as a Resource?

4 replies [Last post]
rsitze
Offline
Joined: 2004-04-07
Points: 0

Trying to determine how best to expose an image kept in a database as a resource via JSF2.

Resources as specified look great for serving static content.

Up front, it seems I may have to override the default ResourceHandler. But how best to do that portably and without stomping on primefaces/richfaces etc is not clear (these seem to provide their own resource handlers as well).

Ideally, it would be nice to bind a class implementing 'ResourceBundle' as a library visible to the ResourceHandler, where Object's returned by the bundle would have a data stream, and a content type.

Any thoughts on how best to do this?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joel Weight

I know this thread is long dead, but for posterity's sake, I just thought I
would let you know that I implemented a custom ResourceHandler so I could
pull images and css from the database and it does not appear to be
interfering with primefaces. I can't say for rich faces since I don't use
it.

Joel

On Thu, Apr 29, 2010 at 4:41 PM, wrote:

> Trying to determine how best to expose an image kept in a database as a
> resource via JSF2.
>
> Resources as specified look great for serving static content.
>
> Up front, it seems I may have to override the default ResourceHandler. But
> how best to do that portably and without stomping on primefaces/richfaces
> etc is not clear (these seem to provide their own resource handlers as
> well).
>
> Ideally, it would be nice to bind a class implementing 'ResourceBundle' as
> a library visible to the ResourceHandler, where Object's returned by the
> bundle would have a data stream, and a content type.
>
> Any thoughts on how best to do this?
> [Message sent by forum member 'rsitze']
>
> http://forums.java.net/jive/thread.jspa?messageID=399674
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: webtier-help@glassfish.dev.java.net
>
>
[att1.html]

Jason Lee

On 4/29/10 5:41 PM, webtier@javadesktop.org wrote:
> Trying to determine how best to expose an image kept in a database as a resource via JSF2.
>
> Resources as specified look great for serving static content.
>
> Up front, it seems I may have to override the default ResourceHandler. But how best to do that portably and without stomping on primefaces/richfaces etc is not clear (these seem to provide their own resource handlers as well).
>
> Ideally, it would be nice to bind a class implementing 'ResourceBundle' as a library visible to the ResourceHandler, where Object's returned by the bundle would have a data stream, and a content type.
>
> Any thoughts on how best to do this?
>
Mojarra Scales has a component for that:

http://demo.steeplesoft.com/mojarra-scales-demo/download.jsf

Source is on kenai.com

--
Jason Lee
Senior Member of Technical Staff
GlassFish Administration Console

Oracle Corporation
Phone x31197/+1 405-343-1964
Blog http://blogs.steeplesoft.com

---------------------------------------------------------------------
To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: webtier-help@glassfish.dev.java.net

rsitze
Offline
Joined: 2004-04-07
Points: 0

Hmm... a bit round-about, but looks like it'll accomplish what I need. Any idea if scales will play nice with primefaces?

My 'ideal' would be more direct:

Where myLibrary is mapped to some dynamic resource provider (class instance) that can lookup & provide the byte stream content representing 'myResource'.

Wouldn't be limited to graphicImages (I'm making an assumption based on what I saw in the demo!).

Regardless, thank for the pointer.

jdlee
Offline
Joined: 2006-01-25
Points: 0

> My 'ideal' would be more direct:
>
> > value="#{resource['myLibrary:myResource']}" ... />
>
> Where myLibrary is mapped to some dynamic resource
> provider (class instance) that can lookup & provide
> the byte stream content representing 'myResource'.
>
> Wouldn't be limited to graphicImages (I'm making an
> assumption based on what I saw in the demo!).

That PDF is served via that component as well, fwiw. Any type of data can be served, as long as you can make the client understand it (via img, object, etc. on the page).

Would this blog entry be more helpful?

http://blogs.steeplesoft.com/2010/05/putting-facelets-in-a-jar/