Skip to main content

Resource Management in JSF 2.0

6 replies [Last post]
youness_teimoury
Offline
Joined: 2010-02-23
Points: 0

Hi,
Is there any sample or documentation about Resource Management in JSF 2.0?
After deploying my resources into a jar package I am having problem with referencing it in a Facelets page.

Special thanks
Youness

Reply viewing options

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

Ryan Lubke did a 2 part blog entry on Resource Management in JSF 2.0.

http://blogs.sun.com/rlubke/entry/jsf_2_0_new_feature5

http://blogs.sun.com/rlubke/entry/jsf_2_0_new_feature

It may help.
Joel

On Sat, Apr 24, 2010 at 5:22 AM, wrote:

> Hi,
> Is there any sample or documentation about Resource Management in JSF 2.0?
> After deploying my resources into a jar package I am having problem with
> referencing it in a Facelets page.
>
> Special thanks
> Youness
> [Message sent by forum member 'youness_teimoury']
>
> http://forums.java.net/jive/thread.jspa?messageID=398795
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: webtier-help@glassfish.dev.java.net
>
>
[att1.html]

youness_teimoury
Offline
Joined: 2010-02-23
Points: 0

Thanks Joel, but the question still remains.
If there be a simple sample about the following scenario, it would be great;
Imagine there exists a resource (a jpg picture) bundled in a jar file. Therefore resource1.jar.
Where is resource1.jar placed in the resource directory?
How the jpg file is bound to for example a ?
Special thanks

vladperl
Offline
Joined: 2004-08-11
Points: 0

> Where is resource1.jar placed in the resource
> directory?
Probably the following blog will be helpful for you.
I used the approach for sharing composite components and it works for me.
http://digitaljoel.wordpress.com/2009/12/14/sharing-jsf-2-composite-comp...

> How the jpg file is bound to for example a
> ?

There is related example in Mojarra source code called "helloworld" included in part "jsf-demo".
Here is a piece from the example:

By the way I'm wondering if Joel Weight is the same person who wrote the mentioned above blog :)

Good luck,
Vladimir

youness_teimoury
Offline
Joined: 2010-02-23
Points: 0

Thanks Vladimir,
I read the blog carefully and looked through everywhere but one question still remains and that is how to package a list of resources in a jar file in a way that the jar file could be considered as a resource package and can be used as a resource in my JSF.
Bests
Youness

Joel Weight

Ryan's first entry in the series has a large section on packaging which has
great detail on pretty much everything you would need to know about how to
put the resource (image, javascript, css) in a jar, and even version it. It
says:

The default implementation will look for resources in two locations
and in the following order:

1. */resources* this location represents resources in the webapp itself
and if present, must be in the root of the web application
2. */META-INF/resources* this location represents resources on the
classpath

Then, in my blog (yes it's mine and I was surprised to see you link to it :)
it says:

In order to redistribute those components, you simply add them to a jar
under META-INF/resources, and then make sure that your META-INF directory
also contains a faces-config.xml file.

So, if you put your resources in META-INF/resources you should be able to
reference them. Optionally, and I would highly recommend it, you can put
them within a library, which is simply another directory under
META-INF/resources, something like META-INF/resources/images and then
"images" is your library. I believe it will only look in jars that contain
a faces-config.xml file, so make sure you have one of those in your jar
within the META-INF directory. The faces-config.xml file doesn't need to
contain anything other than what is shown in my blog. Then you should be
able to include the jar as a library within your web project and references
the resources.

Joel

On Sun, Apr 25, 2010 at 6:11 AM, wrote:

> Thanks Vladimir,
> I read the blog carefully and looked through everywhere but one question
> still remains and that is how to package a list of resources in a jar file
> in a way that the jar file could be considered as a resource package and can
> be used as a resource in my JSF.
> Bests
> Youness
> [Message sent by forum member 'youness_teimoury']
>
> http://forums.java.net/jive/thread.jspa?messageID=398903
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: webtier-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: webtier-help@glassfish.dev.java.net
>
>
[att1.html]

vladperl
Offline
Joined: 2004-08-11
Points: 0

Joel,
I glad that you are the author of the blog.
Big thanks to you for your idea!
It makes sense to put your idea in production :)
I suggest that you fill out enhancement to netbeans team where ask them to create ant task called something like "create-jsf-resource-jar".
It will take just a few minutes to do it.
In case you will do it place the corresponding link here and people will vote for it.
At least I will put some supportive comments.
Youness probably will do the same.

One more suggestion for your new blog.
It would be interesting to read how to share web pages between applications.

Best regards,
Vladimir