Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.4k views
in Technique[技术] by (71.8m points)

jsf - ui:include can not include pages with different server context

In my tomcat I have defined two context.

One is my application URL, which is

http://localhost:8080/mysite/faces/abc.xhtml

another one is used to put all my static files which maybe used by other applications.

http://localhost:8080/files/myfile.html

In my application .xhtml file I want to include page from the other context, for example

<ui:include src="/files/myfile.html">

But I always get error

javax.faces.view.facelets.TagAttributeException:.....Invalid path : /files/myfile.html

It looks like ui:include is not appropriate to be used here because it only looks for context related path. What should I use then?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

There are several options:

  1. Use <iframe> instead.

  2. Refactor the shared files into a separate web fragment project which should end up as JAR in /WEB-INF/lib of both webapps. Put the Facelets resources in the /META-INF/resources folder of the separate web fragment project. It'll be available for <ui:include> the usual way: Structure for multiple JSF projects with shared code.

  3. When on JSF 1.x, use a custom com.sun.facelets.impl.DefaultResourceResolver: How to use Facelets composition with files from another context.

  4. When on JSF 2.x, use a custom javax.faces.view.facelets.ResourceResolver: how to share a jsf error page between multiple wars.

  5. When on JSF 2.2+, use a custom javax.faces.application.ResourceHandler: Obtaining Facelets templates/files from an external filesystem or database.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...