I would like to ask you a question, which is related to another question I asked some times ago (without answer unfortunately :( )
Imagine that your project is divided into several web-apps. You also have many shared resources (JS, CSS, images). The idea is to avoid duplications in each web-app, as you will be forced to synchronize your changes among all the web-applications.
So it seems better to have these resources on a single place.
If I have a look on the Richfaces project, all their resources are managed by JSF.
For example, the <rich:calendar>
component displays a little icon.
If we look the HTML code for this image, we see that the src
attribute refers to a jsf
link, not a .png
directly:
<img src="/richfaces-demo/a4j/g/3_3_3.Finalorg.richfaces.renderkit.html.iconimages.CalendarIcon/DATB/eAH7cW0fw6znAA8XBA4_.jsf"
style="vertical-align: middle" id="j_id354:j_id355PopupButton" class="rich-calendar-button " alt="">
I see the following advantages of such approach:
- Include the resources in a classical library (i.e. in a JAR), which eases the deployment on Eclipse;
- Allow to generate dynamic file (i.e. CSS or JS that only contain the required properties);
- Allow the inclusion of only the required resources (for ex. we will not load a CSS file if it is not required by a component on the page).
Regarding my application, I will only need the first point, but it is really important to me (cf. my other related question on SO).
The main drawback of this solution is that the browser will not be able to cache the resources as they are considered as JSF requests. Also, each of these requests will have to go through the whole JSF lifecycle, which can be a performance issue if the number of resources in the current page is important...
Questions
- What do you think of this approach?
- How will you do that? I already used weblets some years ago, but this project does seem to be maintained since 2006. The website URL returns a 404, but the version 0.4 can be found in the Maven global repository.
- Do you see any other solution for my problem?
Thanks.