When the Apache My Faces JSF 1.2 Implementation renders an HTML page behind the scenes , is it even possible to set/code something which will display a pure HTML Table / DIV (NOT the jsf component ) conditionally. When I searched , I saw that , using h:panelGroup is a solution, but I haven’t tried yet, posting here for any better methods or approaches.
Its almost like wanting to say – writing a javascript code in java and inject it when the HTML is rendered – is it possible?
Thanks,
Several ways.
Use
<h:panelGroup layout="block">. It renders a HTML<div>element.Wrap the HTML
<div>element inside a<h:panelGroup>. Without any client-side attributes likeid,styleClass,onclick, etc, the<h:panelGroup>won’t render anything. With them it would however render a<span>element (or<div>iflayoutis set toblock).Wrap the HTML
<div>element inside a<f:verbatim>.It’s by the way not so special that MyFaces generates HTML. The Mojarra JSF implementation also does that. The competitors Struts2, Spring MVC, Wicket, Tapestry, etc..etc.. also. Microsoft ASP.NET MVC also. PHP also. All server side languages in fact. Simply because of the fact that the webbrowser doesn’t understand them. It only understands HTML/CSS/JS 😉
As to mixing JavaScript with Java/JSP/JSF, you may find this article useful.