0

I tried to extend a JSF application by including xhtml files from a directory which is not in the context root:

Point of inclusion:

<form>
    <ui:repeat value="#{calcBean.resolveIncludes()}" var="curInc">
        <ui:include src="#{curInc}" />
    </ui:repeat>    
</h:form>

CalcBean delivers:

public List<String> resolveIncludes()
{
    final List<String> ret = new ArrayList<>();
    ret.add("D:/extensionDir/inc1.xhtml");
    ret.add("D:/extensionDir/inc2.xhtml");

    return ret;
}

The content of the xhtml files is not included because the path must be relative the origin xhtml according documentation. Is there a way to achieve this? The aim is to extend a JSF application by adding a set of files to a defined extension directory without redeploy.

opfau
  • 731
  • 9
  • 37
  • Use a resource resolver: See http://stackoverflow.com/questions/5379995/how-to-share-a-jsf-error-page-between-multiple-wars/5380452#5380452 – Kukeltje Nov 13 '15 at 11:00
  • I have read this, but `ResourceLoader` is deprecated. Is there another possibilty? – opfau Nov 13 '15 at 11:06
  • 1
    See http://jdevelopment.nl/jsf-22/?utm_medium=referral&utm_source=zeef.io%2Fblock%2F227&utm_campaign=ZEEF#809. And please next time mention what you tried, read, etc... http://www.catb.org/esr/faqs/smart-questions.html#beprecise and http://stackoverflow.com/help/how-to-ask. – Kukeltje Nov 13 '15 at 11:14

1 Answers1

0

Ok it works. But unfortunately the path is validated before the ResourceHandler is invoked. To identify the resource as "external dynamic" I had to prefix it for instance with "extension_". In the origin example:

public List<String> resolveIncludes()
{
    final List<String> ret = new ArrayList<>();
    ret.add("/extension_inc1.xhtml");
    ret.add("/extension_inc2.xhtml");

    return ret;
}

And I had to use c:forEach instead of ui:repeat:

<c:forEach items="#{calcBean.resolveIncludes()}" var="curInc">
    <ui:include src="#{curInc}" />
</c:forEach>
opfau
  • 731
  • 9
  • 37