1

Can someone help? I am really new to JSF. I just want to know how to Display my Html in the JSF page. My Html file is in the String Format. Say for example

     str="<html>.........<h1> display this portion </h1>........</html>";

Can i Use Javascript to display this in my JSF?

1
  • What did you try and what error are you getting? If the xml parsing is causing trouble due to some special characters then put your javascript code in a separate file. Commented Jan 6, 2012 at 5:45

1 Answer 1

2

I can think of 2 options:

  1. <h:outputText value="#{mrBean.htmlString}" escape="false" />
  2. Or else, just make sure that all the tags in your HTML files are closed properly and all of them must have root tags. Then you can include your file with:

    <ui:include src="myFile.html" />
    
Sign up to request clarification or add additional context in comments.

3 Comments

The <f:verbatim> is unnecessary. Even more, it's deprecated in JSF2 because it's a leftover from JSF 1.0/1.1 ages. You can just inline HTML unchanged in the view since JSF 1.2 and for sure also in Facelets.
@BalusC in certain cases, I think <f:verbatim> is still useful. If I'm now wrong, <ui:include> expect the included page to be a well-formed XML page. If my included page does not have a root tag that covers the whole page, I will get a FaceletException.
You already have the <html> root tag (which should actually be <ui:composition>, but that aside). Otherwise, there's always the <ui:fragment>.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.