Aldo Suwandi
Aldo Suwandi

Reputation: 392

How to include JSF template in different folder

i've been searching in all section of this forum and still don't get an answer about my problem.

My problem is how to include JSF template that located in different folder. Here's my folder structure and file list.

/WEB-INF
login.xhtml
/template
-----layout.xhtml
/home
-----homefile.xhtml
-----/user
----------userfile.xhtml

What im trying to do is to using template under /template folder on homefile.xhtml and userfile.xhtml. I already try this following code

<ui:composition template="template/layout.xhtml">
</ui:compostion>

But its not working. I got error that "can't find resources "template/layout.xhtml">. If i use that code in login.xhtml its working fine.

Any idea how to do it ? One of the solution is make another /template/layout.xhtml inside home folder, but i think its not the best solution.

Upvotes: 0

Views: 2560

Answers (1)

chkal
chkal

Reputation: 5668

Add a slash in front of your template location like this:

<ui:composition template="/template/layout.xhtml">
</ui:compostion>

This should work. The location template/layout.xhtml is relative to the "current folder", which will mean JSF will try to load /home/template/layout.xhtml.

Upvotes: 1

Related Questions