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> 
1

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

3 Comments

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.
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.
This is just awesome. I was trying to find solution. Thanks

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.