Java Reference
In-Depth Information
Step 1. Right-click the project node jsf2demo to display a context menu as shown in
Figure 33.6. Choose
New
,
JSF Managed Bean
to display the New JSF Managed Bean
dialog box, as shown in Figure 33.7. (Note: if you don't see JSF Managed Bean in the
menu, choose
Other
to locate it in the JavaServer Faces category.)
Step 2. Enter and select the following fields, as shown in Figure 33.7:
Class Name:
TimeBean
Package:
jsf2demo
Name:
timeBean
Scope:
request
Click
Finish
to create TimeBean.java, as shown in Figure 33.8.
Step 3. Add the
getTime()
method to return the current time, as shown in Listing 33.2.
F
IGURE
33.6
Choose JSF Managed Bean to create a JavaBean for JSF.
L
ISTING
33.2
TimeBean.java
1
package
jsf2demo;
2
3
import
javax.inject.Named;
4
import
javax.enterprise.context.RequestScoped;
5
6 @Named
7 @RequestScoped
8
public class
TimeBean {
@Named
@RequestScoped
Search WWH ::
Custom Search