3

I have the following problem, We have web content manager (WCM) running at remote host, which is responsible for generating header and footer HTML files. i.e. header.html, footer.html. The HTML files are not properly formatted syntax wise, WCM generated files have

  1. Space character ( ) ๐Ÿกข it is not allowed in XHTML.
  2. Non Closing break line (<br>) tags ๐Ÿกข it is invalid in XHTML.

So the WCM generated HTML pages might not be valid XHTML pages.

We are implementing some of our applications in JSF, where we need to include the WCM generated header and footer files. Can we include the non-formatted HTML files into our XHTML files?

commonTemplate.xhtml

<html>
<head>
..........;
</head>
<body>
<ui:include src="remote_host/header.html" />

<ui:insert name="commonBodyContent" />

<ui:include src="remote_host/footer.html" />
</body>
</html>
Jens Piegsa
  • 7,399
  • 5
  • 58
  • 106
uday
  • 315
  • 3
  • 7
  • 17

1 Answers1

6

I guess it is related to this question: Include non-Facelet content in a Facelet template

I do not recommend to mix XHTML with HTML, but most probably the browsers will not have any issues with the mentioned characters, hence you might try to directly render the file contenty, e.g. by

<h:outputText value="#{yourBean.headerCode}" escape="false" />

Whereas YourBean.getHeaderCode() would readout the header file's content and return it as String. YourBean should be ApplicationScoped.

Faster and better would be to get the WCM generating valid XHTML.

Community
  • 1
  • 1
Ingo
  • 429
  • 3
  • 7
  • Ohh i need to read the headerCode to a string variable ? , But our WCM will generate the header & footer content for every 4 hours, can't i simply include the remote html file. โ€“ uday Aug 08 '12 at 01:56
  • It must be valid XHTML since the component cannot be built otherwise. With the provided solution, JSF will not create a UIComponent for each HTML element of your header, but only for the outputText tag (actually this might make your whole request faster if you cache the results). In your application scoped bean you might set a timestamp everytime you cache the result and reset the cache after 4 hours. Plus, you could replace invalid characters in this code so that you have pure XHTML in the rendered output. โ€“ Ingo Aug 08 '12 at 08:40
  • This is just awesome. I was trying to find solution. Thanks โ€“ Makky Mar 17 '19 at 23:22