Java Reference
In-Depth Information
Automatic Generation of Getter and Setter Methods
Netbeans can automatically generate getter and setter methods for our
properties. We simply need to click the keyboard shortcut for "insert
code", which defaults to Alt+Insert in Windows and Linux, then select
Getters and Setters .
package com.ensode.jsf.managedbeans;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
@ManagedBean
@RequestScoped
public class RegistrationBean {
/** Creates a new instance of RegistrationBean */
public RegistrationBean() {
}
private String salutation;
private String firstName;
private String lastName;
private Integer age;
private String email;
//getters and setters omitted for brevity }
Notice that the names of all of the bean's properties (instance variables) match the
names we used in the page's value binding expressions. These names must match so
that JSF knows how to map the bean's properties to the value binding expressions.
Implementing the confirmation page
Once our user fills out the data on the input page and submits the form, we want to
show a confirmation page displaying the values that the user entered. Since we used
value binding expressions on every input field on the input page, the corresponding
fields on the managed bean will be populated with user-entered data. Therefore all
we need to do in our confirmation page is display the data on the managed bean via
a series of <h:outputText> JSF tags.
Search WWH ::




Custom Search