TUTORIAL: ADF Faces (Part 2) Passing parameter values between JSF pages By: Dr. Ahmad Taufik Jamil, Pusat Teknologi Maklumat, HUKM This tutorial will show you how to pass parameter value originated from a JSF form and view them in another JSF page. The tutorial will show various ways to achieve the objectives. The entire tutorials will use JavaBeans and ADF Faces. Part 2 Using backing beans and managed beans 1. Creating new project folder. a. Using the same workspace in part 1 , create new project folder. Right click at workspace ADFJB, click New… b. In New Gallery dialog box, inside Categories column, expand General > Project, inside Items, click Empty Project, and then click OK.
13
Embed
Tutorial: ADF Faces: Passing parameter values between JSF pages-Part 2
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
TUTORIAL: ADF Faces (Part 2)
Passing parameter values between JSF pages By: Dr. Ahmad Taufik Jamil, Pusat Teknologi Maklumat, HUKM
This tutorial will show you how to pass parameter value originated from a JSF form and view them in another JSF page. The
tutorial will show various ways to achieve the objectives. The entire tutorials will use JavaBeans and ADF Faces.
Part 2
Using backing beans and managed beans
1. Creating new project folder.
a. Using the same workspace in part 1, create new project folder. Right click at workspace ADFJB, click New…
b. In New Gallery dialog box, inside Categories column, expand General > Project, inside Items, click Empty
Project, and then click OK.
c. In Create Project dialog box, enter view2 for Project Name :, and then click OK.
2. Creating page navigation using face-config.xml.
a. Right click at view2 project, click Project Properties…. In Project Properties dialog box, click Technology
Scope at left column; find and click JSF and JavaBeans at Available Technologies and move to right column
(Selected Technologies)-Java, JSP and Servlets is moved as well. Click OK.
b. Right click at view2 project, and click Open JSF navigation. File faces-config.xml is opened in Diagram view.
c. Click, drag & drop 2 JSF Page to design area of faces-config.xml and create JSF Navigation, just like in part
1 tutorial, follow steps 2(c) – 2(d) in part 1 tutorial.
3. Creating Managed Bean
a. Right click at view2 project, click New…
b. At New Gallery dialog box, expand General, find and click JavaBeans. Inside Items, click Bean and then click
OK.
c. At Create Bean dialog box, enter UserBean for Name:, view2 for Package:, and choose java.lang.Object for
Extends:, then click OK. Source editor for UserBean.java is now opened.
d. Add the following lines inside the UserBean class, immediately below UserBean constructor ( public
UserBean() { }). (****in part 1 tutorial, the following source code I put in backing bean. Now I separate
it into the managed bean (Userbean.java)).
private String nama; private String email; private String jantina; private String bangsa; //NAMA public String getNama(){ return nama; } public void setNama(String nama){ this.nama=nama; } //EMAIL public String getEmail(){ return email; } public void setEmail(String email){ this.email=email; } //JANTINA public String getJantina(){ return jantina; } public void setJantina(String jantina){ this.jantina=jantina; } //BANGSA public String getBangsa(){ return bangsa; } public void setBangsa(String bangsa){ this.bangsa=bangsa; }
e. Save all and compile.
4. Creating JSF form and backing beans.
a. Go back to faces-config.xml Diagram view.
b. Double click icon /untitled1.jsp. Enter borang.jsp for File name:. Click Next. Choose Automatically Expose
UI Components in a New managed Beans. Click Finish.
c. Follow step 3(c) until 3(l) of part 1 tutorial, BUT for step 3(d), change the title to ADF Faces: Passing value
using backing beans and managed beans. Make sure you get something like below:
d. Save All & compile.
5. Editing backing beans.
a. Double click button Hantar. At Bind Action Property dialog box, accept all values and click OK.
a. Now we are editing file Borang.java (backing bean). At line 37 (below variable declaration), add new variables: