JSF Showcase


HtmlForm is a UIForm component that renders a <form> element.

General Usage

In order to submit a form via Ajax, it is necessary to specify an f:ajax child tag inside of h:commandButton or h:commandLink.

Source Code

<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://xmlns.jcp.org/jsf/core"
	xmlns:h="http://xmlns.jcp.org/jsf/html"	xmlns:ui="http://xmlns.jcp.org/jsf/facelets">

		<h:messages globalOnly="true" layout="table" />
		<h:commandButton actionListener="#{formBackingBean.submit}"
			<f:ajax execute="@form" render="@form" />

public class FormBackingBean {

	public void submit() {

		FacesContext facesContext = FacesContext.getCurrentInstance();
		FacesMessage facesMessage = null;

		if (facesContext.getPartialViewContext().isAjaxRequest()) {
			facesMessage = new FacesMessage("The form was submitted via Ajax and re-rendered with updates to the DOM.");
		else {
			facesMessage = new FacesMessage(
					"The form was submitted as a full page postback and the entire page was re-rendered.");

		facesContext.addMessage(null, facesMessage);
Liferay Faces Bridge Implementation 4.0.0 + Showcase Common 3.0.0 + Liferay Faces Util 3.0.1-SNAPSHOT + Mojarra 2.2.13