Portal Showcase


Since JSF 2.2, you can invoke an action or actionListener, passing through the JSF phases using f:viewAction.

General Usage

Its possible to choose this method to be executed during non-JSF request (GET) or in a postBack, using postBack attribute. Another useful attribute could be phase, as there you can specify which JSF PhaseId you want that method to be invoked on.

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">

		<f:viewAction action="#{viewMetadataBackingBean.viewAction}" phase="UPDATE_MODEL_VALUES"/>
	<h:outputText value="#{viewMetadataBackingBean.viewActionText}"/>

public class ViewMetadataBackingBean {

	private String viewActionText;
	private Country viewCountry;

	public String getViewActionText() {
		return viewActionText;

	public Country getViewCountry() {
		return viewCountry;

	public void setViewActionText(String viewActionText) {
		this.viewActionText = viewActionText;

	public void setViewCountry(Country viewCountry) {
		this.viewCountry = viewCountry;

	public String viewAction() {
		PhaseId phaseId = FacesContext.getCurrentInstance().getCurrentPhaseId();

		String phaseName = phaseId.toString();

		this.viewActionText = "View action was executed in phase " + phaseName;

		return null;
Liferay Faces Bridge Implementation 4.0.0 + Liferay Faces Portal 3.0.0 + Showcase Common 3.0.0 + Liferay Faces Util 3.0.0 + Mojarra 2.2.13