ScottM
ScottM

Reputation: 109

Getting java.io.FileNotFoundException when template client is in subdirectory

I am trying to navigate to an administration page which has a sub directory under the webcontent folder and receiving an java.io.FileNotFoundException. Using Glassfish 3.1.1.

My

    war File:
         index.xhtml
         login.xhtml
         /admin/admin.xhtml

the link i am using is:

       <h:link value="Admin" outcome="admin/admin.xhtml"/>

I was hoping implicit naviagtion would be able to handle this?

Thanks in advance,

Scott

Upvotes: 2

Views: 1369

Answers (1)

BalusC
BalusC

Reputation: 1108842

Your <h:link> looks perfectly fine, although I would just trim off the .xhtml extension to minimize boilerplate and FacesServlet mapping ambiguity which JSF already takes care of for you.

You need to read the message of the FileNotFoundException which you got there. My cents on that it actually points to the template file which you're using in <ui:composition template> of admin/admin.xhtml. You'd like to specify an absolute path in there, i.e. starting with /, so that it's resolved relative to the root of the web content, otherwise it's resolved relative to the location of the current template client.

E.g. thus not so:

<ui:composition template="WEB-INF/admintemplate.xhtml">

which would search for /admin/WEB-INF/admintemplate.xhtml, but rather so:

<ui:composition template="/WEB-INF/admintemplate.xhtml">

Note that this is not related to implicit navigation. You would have exactly the same problem when opening the page directly.

Upvotes: 4

Related Questions