Solution
I think the best way to solve this is to name every file only with lower case letters and the references will be converted to lower case.
First create a class that will include a toLowerCase(String)
method.
public final class Functions {
private Functions() {
// Hide constructor.
}
public static String toLowerCase(String s) {
return s.toLowerCase();
}
}
Then you have to define a functions.taglib.xml
(functions
is an example how to name it).
<?xml version="1.0" encoding="UTF-8"?>
<facelet-taglib
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facelettaglibrary_2_0.xsd"
version="2.0">
<namespace>http://example.com/functions</namespace>
<function>
<function-name>contains</function-name>
<function-class>com.example.Functions</function-class>
<function-signature>boolean contains(java.util.Collection, java.lang.Object)</function-signature>
</function>
</facelet-taglib>
The last step is to register the taglib in your web.xml
.
<context-param>
<param-name>javax.faces.FACELETS_LIBRARIES</param-name>
<param-value>/WEB-INF/functions.taglib.xml</param-value>
</context-param>
Now you're ready to use it:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:fn="http://example.com/functions">
<ui:include src="fn:toLowerCase('xyz/Abc.xhtml')}"/>
</html>
Explanation
Basically this example will convert the source reference to lower case. This only works if you're files are also all named with lower case characters.
If defining a custom tag library is too time-consuming for you, you can also use a @ApplicationScoped
bean and add the method there (see Utility methods in application scoped bean)
Of course, capatalizing the first letter of the filename works as well as lower case filenames. You just have to use a capitalize()
method (I can add that on request or see How to capitalize the first letter of a String in Java?).
There may be other approaches but they will be a lot harder than this.
See Also
How to create a custom EL function to invoke a static method? (credit for the function definition)
Why are files case (in)sensitive on Linux and Windows?