Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

What is a Backing bean in JSF

What is a Backing bean in JSF

Backing bean in JSF is a subtype of managed Bean but contain properties of all or some of UI component in a JSF page. The Backing Bean is useful for UI component validations, conversion, event handling etc. In other words, backing bean properties binds to UI components In JSF page.

Below is the backing bean class of index.jsf . It has a custom method prints value of UI component on form submission 

package com.catgovind;

import javax.faces.bean.ManagedBean;
import javax.faces.component.UICommand;
import javax.faces.component.UIInput;
import javax.faces.component.UIOutput;

@ManagedBean
public class Index {
	
	private UIInput name;
	private UIOutput country;
	private UICommand button;
	
	public UIInput getName() {
		return name;
	}
	public void setName(UIInput name) {
		this.name = name;
	}
	public UIOutput getCountry() {
		return country;
	}
	public void setCountry(UIOutput country) {
		this.country = country;
	}
	public UICommand getButton() {
		return button;
	}
	public void setButton(UICommand button) {
		this.button = button;
	}
	
	public void printUI(){
		System.out.println(name.getValue());
		System.out.println(country.getValue());
	}
	
}

Below is the index.jsf page. Each UI component in JSF has a binding parameter binds to the backing bean class. 



	

JSF BackingBean Example






The JSF page displays like below in the browser 

Prints the following in the console when the Submit button is clicked 

Govindan Padmanaban
India

Download Backing Bean Project: BACKING_BEAN_EXAMPLE



This post first appeared on Oracle ADF, BPM, BI And Primavera P6 Tutorials, please read the originial post: here

Share the post

What is a Backing bean in JSF

×

Subscribe to Oracle Adf, Bpm, Bi And Primavera P6 Tutorials

Get updates delivered right to your inbox!

Thank you for your subscription

×