Use an <f:event> tag to invoke a method for example on preRenderView lifecycle stage:
<f:event type="preRenderView" listener="#{controllerBeanName.methodName}"></f:event>

Articles, notes and random thoughts on Software Development and Technology
Use an <f:event> tag to invoke a method for example on preRenderView lifecycle stage:
<f:event type="preRenderView" listener="#{controllerBeanName.methodName}"></f:event>
To conditionally show a Twitter Bootstrap styled DIV with a list of error messages, use the rendered property on panelGroup to check whether messageList has messages to be displayed, and if so, render the enclosed content.
layout=”block” displays the output as a DIV, and row is one of the Bootstrap classes for row display.
<div class="span12 alert alert-danger"></div>
Set messages to display from your Backing Bean with:
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("your message");
Here’s the namespace declarations for the JSF 2.0 tags:
<!DOCTYPE HTML> <h:html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets">
For JSF 2.2 the URLs have changed. See post here.
Twitter Bootstrap adds ‘display:block’ to labels by default, which oddly affects the way radio buttons are displayed if renderd using JSF – the label drops down to the next line.
To work around this, add a class using styleClass to the <h:selectOneRadio> tag, and then use some additional CSS to set display back to ‘inline’ for labels within an element using the class you used on the selectOneRadio tag.
Here’s some example CSS:
.inlineRadioButtons {
}
.inlineRadioButtons label {
display: inline;
}
And here’s it used on some JSF generating radio buttons:
<h:form>
<h:panelGrid columns="2">
<h:outputText value="Color:" />
<h:selectOneRadio value="#{testBean.selectedColor}"
styleClass="inlineRadioButtons">
<f:selectItems value="#{testBean.colors}" var="#{item}"
itemValue="#{item}" itemLabel="#{item.desc}"></f:selectItems>
</h:selectOneRadio>
</h:panelGrid>
<h:commandButton action="#{testBean.save}" value="Save" styleClass="btn btn-primary"/>
</h:form>