opfau
opfau

Reputation: 761

Extend JSF 2.2 application by adding xhtml files from external directory

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.

Upvotes: 0

Views: 147

Answers (1)

opfau
opfau

Reputation: 761

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>

Upvotes: 0

Related Questions