osdir.com
mailing list archive

Subject: Re: Creating templates in jar files - msg#00075

List: java.facelets.user

Date: Prev Next Index Thread: Prev Next Index

I would like to create custom taglibs with the help of facelets in
separate jars.
Is it possible to load the xhtml files with ui:include from the
classpath?

I mean something like this:
<ui:include source="classpath://com/x/y/datascroller.xhtml">

Would be nice to use something similar when I create taglibs in the
source xml element.


Yes. Use a custom resource resolver. Like this one:

public class ClassletsResourceResolver extends DefaultResourceResolver {

public ClassletsResourceResolver() {
super();
}

private static final String PREFIX = "/classlets/";

public String getPrefix() {
return PREFIX;
}

public URL resolveUrl(String path) {
final String prefix = getPrefix();
if (path != null && path.startsWith(prefix)) {
final String resource = path.substring(prefix.length());
final URL url = getClass().getClassLoader().getResource(resource);
return url;
} else

{
return super.resolveUrl(path);
}
}
}

I have something similar in my Seamless utility library, except it checks the classpath only if the template isn't found on the filesystem:

http://seamless.ninthavenue.com.au/xref/seamless/util/FaceletsJarResolver.html
http://www.ninthavenue.com.au/extras/seamless

To change the facelets resolver you need to set a context parameter in your web.xml, like this:

<!-- allows facelets to be in jars -->
<context-param>
<param-name>facelets.RESOURCE_RESOLVER</param-name>
<param-value>seamless.util.FaceletsJarResolver</param-value>
</context-param>

As somebody mentioned in this thread, you don't need to do this for custom tags as they are already resolved relative to the taglib file, even if this is in a jar.

Roger


--
----------------------------------------
Ninth Avenue Software
p: +61 7 3137 1351 (UTC +10)
f: +61 7 3102 9141
w: http://www.ninthavenue.com.au
e: info@xxxxxxxxxxxxxxxxxx
----------------------------------------


Was this page helpful?
Yes No
Thread at a glance:

Previous Message by Date: click to view message preview

Possible to use Facelets 1.1.12 with Tomcat 5.5?

Hello everybody,Do you know if it's possible? If yes, could you please tell me how? Regards.PS: sorry for the topic hijacking thing. Could you tell me (show me where on the Internet) how to use Facelets 1.1.12 with Tomcat 5.5, Alexander?----- Original Message ----From: Jesse Alexander (KSFD 121) <alexander.jesse@xxxxxxxxxxxxxxxxx>To: users@xxxxxxxxxxxxxxxxxxxxxSent: Friday, June 8, 2007 3:16:40 PMSubject: RE: Possible to use Facelets 1.1.12 with Tomcat 5.5? Sure...   hth Alexander   PS: it would be better to initiate a new thread for a new topic... the topic highjacking is nasty for those that check the threaded messages Fussy? Opinionated? Impossible to please? Perfect. Join Yahoo!'s user panel and lay it on us.

Next Message by Date: click to view message preview

Re: Possible to use Facelets 1.1.12 with Tomcat 5.5?

Hi,there is no problem with using facelets 1.1.12 with tomcat 5.5 that I'm aware of.If you have a problem could you please post some more detailed information.- Mike On 08/06/07, Thai Dang Vu <dxxvi@xxxxxxxxx> wrote: Hello everybody,Do you know if it's possible? If yes, could you please tell me how? Regards.PS: sorry for the topic hijacking thing. Could you tell me (show me where on the Internet) how to use Facelets 1.1.12 with Tomcat 5.5, Alexander? ----- Original Message ----From: Jesse Alexander (KSFD 121) <alexander.jesse@xxxxxxxxxxxxxxxxx >To: users@xxxxxxxxxxxxxxxxxxxxxSent: Friday, June 8, 2007 3:16:40 PMSubject: RE: Possible to use Facelets 1.1.12 with Tomcat 5.5? Sure...   hth Alexander   PS: it would be better to initiate a new thread for a new topic... the topic highjacking is nasty for those that check the threaded messages Fussy? Opinionated? Impossible to please? Perfect. Join Yahoo!'s user panel and lay it on us.

Previous Message by Thread: click to view message preview

Re: Re: Creating templates in jar files

Hi. Can't you do that with weblets? https://weblets.dev.java.net/ "The Weblets project was born during our book research for an easy way of loading resources directly out of JAR"   I tried it with loading css files.. That worked fine. So maybe you can use it as well for loading xhtml files..No, Weblets are not suitable for this task (although it would be great to adapt Weblets for this task as well).Weblets serve only servlet requests to resources. When Facelets load templates, this doesn't go via servlet requests ( i.e. no HTTP request is sent) therefor Weblets can't help here.Bye./lexi 

Next Message by Thread: click to view message preview

RE: Creating templates in jar files

My experience is: this is done automatically done for tag-sources...   The tag-sources are referenced relatively to the taglib-file.   If you want that the user can use ui:include to include your stuff, I propose to use weblets. separates the problems and you do not need another phaselistener, but a servlet.. OR write a tag that does the include...   hth Alexander From: Zsoldos Balázs [mailto:zs_b@xxxxxxxxxxx] Sent: Friday, June 08, 2007 11:41 AMTo: users@xxxxxxxxxxxxxxxxxxxxxSubject: Creating templates in jar files Hi!I would like to create custom taglibs with the help of facelets in separate jars.Is it possible to load the xhtml files with ui:include from the classpath?I mean something like this:    <ui:include source="classpath://com/x/y/datascroller.xhtml">Would be nice to use something similar when I create taglibs in the source xml element.Regards,Balazs________________________________________________________Foglalja le nyaralását online! Horvátországi ajánlatok. Repülőjegyek.
Loading Comments...
Home | News | Patents | Sitemap | FAQ | advertise

Advertising by