I'm working with JSF 2.
For one of the pages, it needs to include a page along the lines of:
domain/subdomain/cms/[userspecified_code].html
I used the ui:include tag to get this file. It works fine for files that exists, but for files that doesn't exist, it throws in FileNotFoundException the renders the whole page as an error page.
Is there an alternate solution to the ui:include tag that skips/logs the file error, and just displays a empty section? Such that it minimises the disturbance to the user (the included file is only a small section of the page, if there's no matching file, I'll rather not show anything). One way I can think of is to have the section ajax loaded, so if there's an error, it'll be a javascript error rather than a sever error, but is there a more elegant/easier way of doing it?
Here the xhtml that I currently have:
<!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:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html">
Lots of other html....
<ui:include src="domain/subdomain/cms/#{userspecified_code}.html"/>
Lots of other html....
</html>
Edit
Thanks for all the answers. I am looking for a solution that doesn't need me to add all the file checking logic in myself.