What is the real conceptual difference between ui:decorate and ui:include?

The main difference between <ui:include> and <ui:decorate> is that the <ui:decorate> is intended to allow insertion of user-defined template components, while the <ui:include> is intended to include an existing and already-predefined template. This indeed means that the <ui:decorate> supports <ui:define> for user-defined template components in its body and can insert it at the <ui:insert> place … Read more

How can I remove HTML comments in my Facelets?

There are actually two ways: To remove ALL comments, add this to web.xml: <context-param> <param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name> <param-value>true</param-value> </context-param> or when you’re still on JSF 1.2 which doesn’t use Facelets as default view technology yet: <context-param> <param-name>facelets.SKIP_COMMENTS</param-name> <param-value>true</param-value> </context-param> To remove specific comments only, use <ui:remove>. <ui:remove><!– This is a HTML comment. –></ui:remove>

When to use f:view and f:subview

<f:view> The <f:view> is only useful if you want to explicitly specify/override any of the available attributes such as locale, encoding, contentType, etc or want to attach some phase listeners. E.g. <f:view locale=”#{user.locale}” encoding=”UTF-8″ contentType=”text/html”> If you don’t specify it, then the sane JSF defaults will just be used instead, which is respectively UIViewRoot#getLocale(), UTF-8 … Read more

Passing the backing bean as a parameter to a Facelet include

You can use <ui:param> for that. It needs to be nested in the <ui:include>. <ui:include src=”https://stackoverflow.com/questions/16842912/formView.xhtml”> <ui:param name=”ParameterBean” value=”#{Bean}” /> </ui:include> Unrelated to the concrete problem, standard Java Naming Conventions state that instance variable names must start with lower case. You should change your code in such way that respectively parameterBean and #{bean} will be … Read more

Reset input fields without executing validation

The <p:commandButton> processes indeed by default the entire form (process=”@form”), you can change this by specifying only the current component in the process attribute. <p:commandButton value=”Reset” … process=”@this” /> However, this will fail if the form is already been validated beforehand. The input fields which have been marked invalid won’t be updated with the new … Read more

Why is the getter called so many times by the rendered attribute?

EL (Expression Language, those #{} things) won’t cache the result of the calls or so. It just accesses the data straight in the bean. This does normally not harm if the getter just returns the data. The setter call is done by @ManagedProperty. It basically does the following: selector.setProfilePage(request.getParameter(“profilePage”)); The getter calls are all done … Read more

JSF and automatic reload of xhtml files

JRebel handles /WebContent folder changes. The problem is that Facelets do caching and do not reread changed files. To force reread specify the following parameters in web.xml. JSF 2 (Facelets 2.x): <!– Time in seconds that facelets should be checked for changes since last request. A value of -1 disables refresh checking. –> <context-param> <param-name>javax.faces.FACELETS_REFRESH_PERIOD</param-name> … Read more

JSF facelets template packaging

Facelets compositions (so, just plain *.xhtml pages, templates and include files) are resolved by ExternalContext#getResource() which delegates to ServletContext#getResource(). This requires a Servlet 3.x compatible container because /WEB-INF/lib/*.jar!/META-INF/resources resolving from is new since Servlet 3.0. If you aren’t on Servlet 3.x yet, or want to put those JARs on a different location for some reason, … Read more