seinecle
seinecle

Reputation: 10778

which path for a file to appear in the xhtml of a jsf app

common.pde in the canvas tag is not found at runtime:

xhtml:

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html">
    <h:head>
        <title>test</title>
    </h:head>
    <h:body>
        <h:outputScript library="js" name="processing-1.4.1.js" />
        <canvas data-processing-sources="common.pde"></canvas>

    </h:body>
</html>

=> common.pde sits in the "Web pages" folder of my JSF 2.0 application. What is the correct method to specify its path?

Upvotes: 0

Views: 560

Answers (1)

BalusC
BalusC

Reputation: 1108722

Any relative paths (i.e. those not starting with http:// or /) in the HTML source code (as generated by JSF) are relative to the current request URI (as you see in browser's address bar).

So, if the current request URI is:

http://example.com/contextname/somefolder/page.xhtml

then the common.pde reference as you've there expects it to be in:

http://example.com/contextname/somefolder/common.pde

A leading / which brings you to domain root as in /common.pde would expect it to be in:

http://example.com/common.pde

Going one folder up ../ as in ../common.pde would expect it to be in:

http://example.com/contextname/common.pde

Being in a subfolder as in canvas/common.pde would expect it to be in:

http://example.com/contextname/somefolder/canvas/common.pde

I think it makes now sense? I guess that your concrete problem is caused because your JSF page is in a subfolder, or that you've mapped the FacesServlet on a prefix pattern such as /faces/* instead of a suffix pattern such as *.xhtml.

Upvotes: 1

Related Questions