22
TUTORIAL: ADF Faces (Part 3) 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 3 Using Managed Beans & Data Control 1. Creating 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.

Tutorial: ADF Faces: Passing parameter values between JSF ... · PDF fileTUTORIAL: ADF Faces (Part 3) Passing parameter values between JSF pages By: Dr. Ahmad Taufik Jamil, Pusat Teknologi

  • Upload
    buinhu

  • View
    226

  • Download
    2

Embed Size (px)

Citation preview

Page 1: Tutorial: ADF Faces: Passing parameter values between JSF ... · PDF fileTUTORIAL: ADF Faces (Part 3) Passing parameter values between JSF pages By: Dr. Ahmad Taufik Jamil, Pusat Teknologi

TUTORIAL: ADF Faces (Part 3)

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 3

Using Managed Beans & Data Control

1. Creating 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.

Page 2: Tutorial: ADF Faces: Passing parameter values between JSF ... · PDF fileTUTORIAL: ADF Faces (Part 3) Passing parameter values between JSF pages By: Dr. Ahmad Taufik Jamil, Pusat Teknologi

c. In Create Project dialog box, enter view3 for Project Name :, and then click OK.

2. Creating managed beans.

a. Follow steps 3(a) – 3(e) in part 2 tutorial. But for steps 3(a) and 3(c), please change view2 to view3.

Page 3: Tutorial: ADF Faces: Passing parameter values between JSF ... · PDF fileTUTORIAL: ADF Faces (Part 3) Passing parameter values between JSF pages By: Dr. Ahmad Taufik Jamil, Pusat Teknologi

3. Creating data control.

a. At Applications Navigator tab, expand project view3, Application Sources, view3, until you see file

UserBean.java.

b. Right click at UserBean.java, and click Create Data Control.

Page 4: Tutorial: ADF Faces: Passing parameter values between JSF ... · PDF fileTUTORIAL: ADF Faces (Part 3) Passing parameter values between JSF pages By: Dr. Ahmad Taufik Jamil, Pusat Teknologi

c. New files will created; DataControl.dxt and UserBean.xml under folder view3.

d. Click Save All.

4. Creating page navigation using face-config.xml

a. Right click at view3 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.

Page 5: Tutorial: ADF Faces: Passing parameter values between JSF ... · PDF fileTUTORIAL: ADF Faces (Part 3) Passing parameter values between JSF pages By: Dr. Ahmad Taufik Jamil, Pusat Teknologi

b. Right click at view3 project, and click Open JSF navigation. File faces-config.xml is opened in Diagram

view.

Page 6: Tutorial: ADF Faces: Passing parameter values between JSF ... · PDF fileTUTORIAL: ADF Faces (Part 3) Passing parameter values between JSF pages By: Dr. Ahmad Taufik Jamil, Pusat Teknologi

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, until you get something like below:

5. Creating JSF form

d. Go to faces-config.xml Diagram view.

Page 7: Tutorial: ADF Faces: Passing parameter values between JSF ... · PDF fileTUTORIAL: ADF Faces (Part 3) Passing parameter values between JSF pages By: Dr. Ahmad Taufik Jamil, Pusat Teknologi

e. Double click icon /untitled1.jsp. Enter borang.jsp for File name:. Click Next. Choose Do Not

Automatically Expose UI Components in a Managed Beans. Click Finish.

Page 8: Tutorial: ADF Faces: Passing parameter values between JSF ... · PDF fileTUTORIAL: ADF Faces (Part 3) Passing parameter values between JSF pages By: Dr. Ahmad Taufik Jamil, Pusat Teknologi

f. You will create new file borang.jsp without backing beans.

g. From Components Palette, using ADF Faces Core, click, drag & drop PanelPage to file borang.jsp Design

area. Change the Title 1 to ADF Faces: Passing parameter value using Managed Beans and Data

Control.

Page 9: Tutorial: ADF Faces: Passing parameter values between JSF ... · PDF fileTUTORIAL: ADF Faces (Part 3) Passing parameter values between JSF pages By: Dr. Ahmad Taufik Jamil, Pusat Teknologi

h. Insert PanelGrid (using JSF HTML component), inside PanelPage, and enter 1 for No of Columns. Click

Finish. (Follow step 3(e)-3(f) in tutorial part 1 ).

i. Go to Data Controls tab, expand UserBeanDataControl and Operations.

Page 10: Tutorial: ADF Faces: Passing parameter values between JSF ... · PDF fileTUTORIAL: ADF Faces (Part 3) Passing parameter values between JSF pages By: Dr. Ahmad Taufik Jamil, Pusat Teknologi

j. Click, drag & drop nama to Panel Grid, choose Texts and click ADF Input Text w/ Label. Do the same for

email.

k. Make sure you get this:

l. Click at the first input text to mark it, go to Property Inspector, change the Label to Nama :.

Page 11: Tutorial: ADF Faces: Passing parameter values between JSF ... · PDF fileTUTORIAL: ADF Faces (Part 3) Passing parameter values between JSF pages By: Dr. Ahmad Taufik Jamil, Pusat Teknologi

m. Do the same for second input text, and change the Label to E-Mail: at the Property Inspector.

n. Now, click, drag & drop jantina, behind E-Mail input text, choose Single Selection and click ADF Select

One Radio…

Page 12: Tutorial: ADF Faces: Passing parameter values between JSF ... · PDF fileTUTORIAL: ADF Faces (Part 3) Passing parameter values between JSF pages By: Dr. Ahmad Taufik Jamil, Pusat Teknologi

o. At List Binding Editor dialog box, choose Fixed List. For Base Data Source Attribute, select jantina. For

Set Values: , enter Lelaki and Perempuan. Lastly choose Selection Required for “No Selection” Item:.

Then click OK.

Page 13: Tutorial: ADF Faces: Passing parameter values between JSF ... · PDF fileTUTORIAL: ADF Faces (Part 3) Passing parameter values between JSF pages By: Dr. Ahmad Taufik Jamil, Pusat Teknologi

p. Click on the radio button you made just now to mark it, at the Property Inspector, change Label to

Jantina : , then press Enter.

q. Click, drag & drop bangsa from Data Control tab, to Panel Grid, behind the radio button. Choose Single

Selection, and then click ADF Select One Choice…

r. At List Binding Editor dialog box, choose Fixed List. For Base Data Source Attribute, select jantina. For

Set Values: , enter Melayu, Cina, India and Lain-lain. Lastly choose Selection Required for “No

Selection” Item:. Then click OK.

Page 14: Tutorial: ADF Faces: Passing parameter values between JSF ... · PDF fileTUTORIAL: ADF Faces (Part 3) Passing parameter values between JSF pages By: Dr. Ahmad Taufik Jamil, Pusat Teknologi

s. Click at the Select One Choice component you have just made just now to mark it, at Property Inspector,

change Label to Bangsa : , then press Enter.

t. From Data Control tab, click, drag & drop commit to Panel Grid, behind Bangsa (One Choice component).

Page 15: Tutorial: ADF Faces: Passing parameter values between JSF ... · PDF fileTUTORIAL: ADF Faces (Part 3) Passing parameter values between JSF pages By: Dr. Ahmad Taufik Jamil, Pusat Teknologi

u. Click ADF Command Button.

v. Click button Commit to mark it. At the Property Inspector, change Text to Hantar, and at Disabled, delete

exclamation mark (!) (from #{!bindings.Commit.enabled} to #{bindings.Commit.enabled}). At Action,

enter submit. Press Enter.

Page 16: Tutorial: ADF Faces: Passing parameter values between JSF ... · PDF fileTUTORIAL: ADF Faces (Part 3) Passing parameter values between JSF pages By: Dr. Ahmad Taufik Jamil, Pusat Teknologi

w. Save all and compile.

6. Creating JSF page to view parameter value.

a. Use instruction from tutorial part 1 from 5(a) – 5(c).

b. Using JSF HTML component, Click, drag and drop Panel Grid inside the PanelPage at design area, and

Enter 1 for Number of Column, then click Finish.

Page 17: Tutorial: ADF Faces: Passing parameter values between JSF ... · PDF fileTUTORIAL: ADF Faces (Part 3) Passing parameter values between JSF pages By: Dr. Ahmad Taufik Jamil, Pusat Teknologi

c. Go to Data Control tab, click, drag and drop nama to Panel Grid. Choose Texts, and then click ADF Output

Text w/ Label.

Page 18: Tutorial: ADF Faces: Passing parameter values between JSF ... · PDF fileTUTORIAL: ADF Faces (Part 3) Passing parameter values between JSF pages By: Dr. Ahmad Taufik Jamil, Pusat Teknologi

d. Repeat the same for email, jantina and bangsa.

e. Go back to Components Palette tab, using ADF Faces Core, click, drag and drop CommandButton, behind

the last inputValue component.

f. While the CommandButton is still marked, at Property Inspector, change Text to Kembali. Press Enter.

Page 19: Tutorial: ADF Faces: Passing parameter values between JSF ... · PDF fileTUTORIAL: ADF Faces (Part 3) Passing parameter values between JSF pages By: Dr. Ahmad Taufik Jamil, Pusat Teknologi

g. At papar.jsp – Structure, find and click af:panelLabelAndMessage - #{bindings.nama.label} to mark it.

(under h:panelGrid).

h. Go to Property Inspector, change Label from #{bindings.nama.label} to Nama : , then press Enter.

Page 20: Tutorial: ADF Faces: Passing parameter values between JSF ... · PDF fileTUTORIAL: ADF Faces (Part 3) Passing parameter values between JSF pages By: Dr. Ahmad Taufik Jamil, Pusat Teknologi

i. Repeat step 6(g) & 6(h) for email, jantina and bangsa, and enter E-Mail : , Jantina : and Bangsa :

respectively for Label in Property Inspector.

j. Click button Kembali to mark it. At Property Inspector, set Action to back.

Page 21: Tutorial: ADF Faces: Passing parameter values between JSF ... · PDF fileTUTORIAL: ADF Faces (Part 3) Passing parameter values between JSF pages By: Dr. Ahmad Taufik Jamil, Pusat Teknologi

k. Click Save All & compile.

l. Run file borang.jsp, and enter values for each field and click button Hantar.

m. See the result.

Page 22: Tutorial: ADF Faces: Passing parameter values between JSF ... · PDF fileTUTORIAL: ADF Faces (Part 3) Passing parameter values between JSF pages By: Dr. Ahmad Taufik Jamil, Pusat Teknologi

n. Finally, click button Kembali.