[JAVASERVERFACES_SPEC_PUBLIC-946] Provide internal server path of resources from Resource API via EL Created: 20/Feb/11  Updated: 12/Aug/14

Status: Open
Project: javaserverfaces-spec-public
Component/s: EL, Resources
Affects Version/s: 2.0, 2.1
Fix Version/s: None

Type: Improvement Priority: Minor
Reporter: Jakob Korherr Assignee: Unassigned
Resolution: Unresolved Votes: 2
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Status Whiteboard:

size_small importance_medium


 Description   

Currently JSF 2 provides #

{resource['libraryName:resourceName']}

to get the request path of the specified resource for the browser (e.g. /context-root/faces/javax.faces.resource/libraryName/resourceName). Thus #

{resource[...]}

is mostly used for css or js files.

Unfortunately there is no way to use the Resource API directly in EL to get the server path to internal resources, e.g. when using <ui:include src="..."> and referrencing a xhtml (facelet) page.

Of course, as a workaround, you can use this method in a managed bean:

public String getMyResourcePath()
{
FacesContext facesContext = FacesContext.getCurrentInstance();

Resource resource = facesContext.getApplication().getResourceHandler()
.createResource("myresource.xhtml", "mylibrary");
URL url = resource.getURL();

return url.toExternalForm();
}

However, this really only is a workaround.

I'd like to propose using #

{serverresource['...']}

or #

{internalresource['...']}

or #

{resoure['...'].serverPath}

(or something similar) to provide a convenient way for getting the server-path to the resource. This way users can use the facelets templating mechanism in combination with the Resource API, e.g.:

<ui:include src="#

{serverresource['templates:headInclude.xhtml']}

" />
<ui:component template="#

{serverresource['templates:componentTemplate.xhtml']}

">
...

See also the user-discussion from the MyFaces mailing list (showing that users are confused why #

{resource['']}

isn't working for facelets stuff): http://www.mail-archive.com/users@myfaces.apache.org/msg56907.html



 Comments   
Comment by Ed Burns [ 01/Aug/14 ]

Set priority to baseline ahead of JSF 2.3 triage. Priorities will be assigned accurately after this exercise.

Generated at Thu Jan 19 13:28:28 UTC 2017 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.