SlideShare a Scribd company logo
Tutorial 3: Accessing the Database
In this tutorial, you will learn how to access the database, retrieve data from one of its table and display the data
on a browser using Java EE in NetBeans IDE.
1. Open NetBeans.
2. Create a new Enterprise Application (refer to Tutorial 1 for the steps). If you have already created one,
then open it.
3. Create the database (refer to Tutorial 2 for the steps). If you have already created the database, then
make the connection by clicking the Services tab. Expand Databases until you come across the database
you have created previously, right-click the database then Connect.
4. At this point, your Enterprise Application Project should have the following files:
a. Entity class (<nameOfTable>.java)
b. Entity class session beans (AbstractFacade.java and <nameOfTableFacade.java)
If you still don't have these files at this point, then refer back to Tutorial 2 and create them.
5. Create the client interface.
a. Right-click the Web Application module (…war) then select Properties.
b. On the Project Properties dialog, click Frameworks from the Categories column, then click the
Add button.
c. In the Add a Framework dialog, select JavaServer Faces then click OK.
d. In the application's Web Application module, expand Web Pages directory and delete index.html
or index.jsp. Make sure that only index.xhtml is left.
6. Create the controller object.
a. In the application's Web Application module, right-click Source Packages -> New -> Java
Package. Type controller as package name then click Finish.
b. Right-click the controller package then select New -> JSF Managed Bean (if you don't find this,
click Other -> JavaServer Faces -> JSF Managed Bean.
c. Type the name of the JSF managed bean, then change the Scope value to Session then click Finish
At the point, your enterprise application should have the following files in its directory:
7. Clean and build the application by right-clicking the project then select Clean and Build from the pop up
menu. You should see a green message that says that clean and build is successful. If the message is in
red, then it means that there are errors in the application and you should correct these.
8. Once the build is successful, click the Run button from the standard toolbar to test the application.
You should read something about Facelets on the browser of your desktop, like as follows:
9. Retrieve data from the table and display the data on the browser.
a. Place a form on your JSF (index.xhtml).
b. From the JSF Palette, drag a JSF Data Table From Entity object. If the Palette window is not
displayed, Click Window -> Palette from the menu bar or Window -> IDE Tools -> Palette. This
Palette should be displayed on the right side of the IDE screen.
c. You should see some JSF tags embedded in the body section of your index.xhtml file. These tags
would read as follows:
Drag this object
towards index.xhtml
body section.
10. Add a new method in your controller that would display all records from the table.
a. Right-click the body of the controller class and select Insert Code -> Call Enterprise Bean.
b. Expand your ejb directory and select the appropriate …Façade file.
c. Add the method that would call the findAll() method from the session bean. Your controller code
should look like as follows:
Add this table attribute
if you want your table
to have borders.
d. Correct any errors (if there are any) by importing the necessary packages to gain access to the
library files you need – java.util.List and your entities package that contains your entity class.
e. Clean and Build, then run your program. You should see the following output on your browser.
Add this method to the controller
code. Make sure you use the correct
entity name (the one you have in
your entities package – in the ejb).
Your Project Directory
should have the following
files in it.

More Related Content

What's hot

How to debug a fast formula
How to debug a fast formulaHow to debug a fast formula
How to debug a fast formula
Feras Ahmad
 
Test case
Test caseTest case
Test case
alldesign
 
Visual studio ide componects dot net framwork
Visual studio ide componects dot net framworkVisual studio ide componects dot net framwork
Visual studio ide componects dot net framwork
Dipen Parmar
 
7200342 cognos-report-studio
7200342 cognos-report-studio7200342 cognos-report-studio
7200342 cognos-report-studiosarovar1
 
Setting up an odi agent
Setting up an odi agentSetting up an odi agent
Setting up an odi agent
Dharmaraj Borse
 
7 Methods to Solve "You don't have appropriate permission to perform this ope...
7 Methods to Solve "You don't have appropriate permission to perform this ope...7 Methods to Solve "You don't have appropriate permission to perform this ope...
7 Methods to Solve "You don't have appropriate permission to perform this ope...
DataNumen, Inc.
 
tPlan
tPlantPlan
Odi 11g master and work repository creation steps
Odi 11g master and work repository creation stepsOdi 11g master and work repository creation steps
Odi 11g master and work repository creation steps
Dharmaraj Borse
 
@Prompt
@Prompt@Prompt
@Prompt
sun93kum
 
Make a Password storage using Excel
Make a Password storage using ExcelMake a Password storage using Excel
Make a Password storage using Excel
Mahmudur Rahman
 
Selenium ide material (2)
Selenium ide material (2)Selenium ide material (2)
Selenium ide material (2)
Sriram Angajala
 
Chrome devtool
Chrome devtoolChrome devtool
Chrome devtool
Samundra khatri
 
External View Creation Guide
External View Creation GuideExternal View Creation Guide
External View Creation GuideAbhishek Agrawal
 
An invisible oracle bug
An invisible oracle bugAn invisible oracle bug
An invisible oracle bugsantosh challa
 
Attach
AttachAttach
Attach
Rajesh Ch
 

What's hot (15)

How to debug a fast formula
How to debug a fast formulaHow to debug a fast formula
How to debug a fast formula
 
Test case
Test caseTest case
Test case
 
Visual studio ide componects dot net framwork
Visual studio ide componects dot net framworkVisual studio ide componects dot net framwork
Visual studio ide componects dot net framwork
 
7200342 cognos-report-studio
7200342 cognos-report-studio7200342 cognos-report-studio
7200342 cognos-report-studio
 
Setting up an odi agent
Setting up an odi agentSetting up an odi agent
Setting up an odi agent
 
7 Methods to Solve "You don't have appropriate permission to perform this ope...
7 Methods to Solve "You don't have appropriate permission to perform this ope...7 Methods to Solve "You don't have appropriate permission to perform this ope...
7 Methods to Solve "You don't have appropriate permission to perform this ope...
 
tPlan
tPlantPlan
tPlan
 
Odi 11g master and work repository creation steps
Odi 11g master and work repository creation stepsOdi 11g master and work repository creation steps
Odi 11g master and work repository creation steps
 
@Prompt
@Prompt@Prompt
@Prompt
 
Make a Password storage using Excel
Make a Password storage using ExcelMake a Password storage using Excel
Make a Password storage using Excel
 
Selenium ide material (2)
Selenium ide material (2)Selenium ide material (2)
Selenium ide material (2)
 
Chrome devtool
Chrome devtoolChrome devtool
Chrome devtool
 
External View Creation Guide
External View Creation GuideExternal View Creation Guide
External View Creation Guide
 
An invisible oracle bug
An invisible oracle bugAn invisible oracle bug
An invisible oracle bug
 
Attach
AttachAttach
Attach
 

Similar to Tutorial 3 accessing the database

Components lab
Components labComponents lab
Components lab
Joanne Scouler
 
Components lab
Components labComponents lab
Components lab
IBM Rational software
 
Oracle ADF 11g Tutorial
Oracle ADF 11g TutorialOracle ADF 11g Tutorial
Oracle ADF 11g Tutorial
Rakesh Gujjarlapudi
 
Oracle ADF 11g Skinning Tutorial
Oracle ADF 11g Skinning TutorialOracle ADF 11g Skinning Tutorial
Oracle ADF 11g Skinning Tutorial
Rakesh Gujjarlapudi
 
Murach': HOW TO DEVELOP A DATA DRIVEN MVC WEB
Murach': HOW TO DEVELOP A DATA DRIVEN MVC WEB Murach': HOW TO DEVELOP A DATA DRIVEN MVC WEB
Murach': HOW TO DEVELOP A DATA DRIVEN MVC WEB
MahmoudOHassouna
 
Previous weeks work has been uploaded as well as any other pieces ne.docx
Previous weeks work has been uploaded as well as any other pieces ne.docxPrevious weeks work has been uploaded as well as any other pieces ne.docx
Previous weeks work has been uploaded as well as any other pieces ne.docx
keilenettie
 
Oracle EBS 12.1.3 : Integrate OA Framework BC4J components within java concur...
Oracle EBS 12.1.3 : Integrate OA Framework BC4J components within java concur...Oracle EBS 12.1.3 : Integrate OA Framework BC4J components within java concur...
Oracle EBS 12.1.3 : Integrate OA Framework BC4J components within java concur...
Amit Singh
 
Create software builds with jazz team build
Create software builds with jazz team buildCreate software builds with jazz team build
Create software builds with jazz team build
Bill Duncan
 
Cis407 a ilab 3 web application development devry university
Cis407 a ilab 3 web application development devry universityCis407 a ilab 3 web application development devry university
Cis407 a ilab 3 web application development devry universitylhkslkdh89009
 
Creating a dot netnuke
Creating a dot netnukeCreating a dot netnuke
Creating a dot netnuke
Nguyễn Anh
 
Metamorphosis from Forms to Java: A technical lead's perspective, part II
Metamorphosis from Forms to Java:  A technical lead's perspective, part IIMetamorphosis from Forms to Java:  A technical lead's perspective, part II
Metamorphosis from Forms to Java: A technical lead's perspective, part II
Michael Fons
 
Installation
InstallationInstallation
Installation
VenkataBolagani
 
GEIT 3341 DATABASE I LAB 2 GEIT 3341 Database I
GEIT 3341  DATABASE I  LAB 2  GEIT 3341 Database I  GEIT 3341  DATABASE I  LAB 2  GEIT 3341 Database I
GEIT 3341 DATABASE I LAB 2 GEIT 3341 Database I
MatthewTennant613
 
( 5 ) Office 2007 Create A Business Data Catolog
( 5 ) Office 2007   Create A Business Data Catolog( 5 ) Office 2007   Create A Business Data Catolog
( 5 ) Office 2007 Create A Business Data CatologLiquidHub
 
Developing RIA Web Applications with Oracle ADF.pdf
Developing RIA Web Applications with Oracle ADF.pdfDeveloping RIA Web Applications with Oracle ADF.pdf
Developing RIA Web Applications with Oracle ADF.pdf
sheriframadan18
 
Testing Options in Java
Testing Options in JavaTesting Options in Java
Testing Options in Java
Michael Fons
 
Applications lab
Applications lab Applications lab
Applications lab
IBM Rational software
 

Similar to Tutorial 3 accessing the database (20)

Components lab
Components labComponents lab
Components lab
 
Components lab
Components labComponents lab
Components lab
 
Oracle ADF 11g Tutorial
Oracle ADF 11g TutorialOracle ADF 11g Tutorial
Oracle ADF 11g Tutorial
 
Oracle ADF 11g Skinning Tutorial
Oracle ADF 11g Skinning TutorialOracle ADF 11g Skinning Tutorial
Oracle ADF 11g Skinning Tutorial
 
Murach': HOW TO DEVELOP A DATA DRIVEN MVC WEB
Murach': HOW TO DEVELOP A DATA DRIVEN MVC WEB Murach': HOW TO DEVELOP A DATA DRIVEN MVC WEB
Murach': HOW TO DEVELOP A DATA DRIVEN MVC WEB
 
Previous weeks work has been uploaded as well as any other pieces ne.docx
Previous weeks work has been uploaded as well as any other pieces ne.docxPrevious weeks work has been uploaded as well as any other pieces ne.docx
Previous weeks work has been uploaded as well as any other pieces ne.docx
 
Mca 504 dotnet_unit5
Mca 504 dotnet_unit5Mca 504 dotnet_unit5
Mca 504 dotnet_unit5
 
Oracle EBS 12.1.3 : Integrate OA Framework BC4J components within java concur...
Oracle EBS 12.1.3 : Integrate OA Framework BC4J components within java concur...Oracle EBS 12.1.3 : Integrate OA Framework BC4J components within java concur...
Oracle EBS 12.1.3 : Integrate OA Framework BC4J components within java concur...
 
Create software builds with jazz team build
Create software builds with jazz team buildCreate software builds with jazz team build
Create software builds with jazz team build
 
Cis407 a ilab 3 web application development devry university
Cis407 a ilab 3 web application development devry universityCis407 a ilab 3 web application development devry university
Cis407 a ilab 3 web application development devry university
 
Creating a dot netnuke
Creating a dot netnukeCreating a dot netnuke
Creating a dot netnuke
 
Metamorphosis from Forms to Java: A technical lead's perspective, part II
Metamorphosis from Forms to Java:  A technical lead's perspective, part IIMetamorphosis from Forms to Java:  A technical lead's perspective, part II
Metamorphosis from Forms to Java: A technical lead's perspective, part II
 
Installation
InstallationInstallation
Installation
 
GEIT 3341 DATABASE I LAB 2 GEIT 3341 Database I
GEIT 3341  DATABASE I  LAB 2  GEIT 3341 Database I  GEIT 3341  DATABASE I  LAB 2  GEIT 3341 Database I
GEIT 3341 DATABASE I LAB 2 GEIT 3341 Database I
 
( 5 ) Office 2007 Create A Business Data Catolog
( 5 ) Office 2007   Create A Business Data Catolog( 5 ) Office 2007   Create A Business Data Catolog
( 5 ) Office 2007 Create A Business Data Catolog
 
Lab3 RTC Source Control
Lab3 RTC Source ControlLab3 RTC Source Control
Lab3 RTC Source Control
 
Tutorial for netbeans
Tutorial for netbeansTutorial for netbeans
Tutorial for netbeans
 
Developing RIA Web Applications with Oracle ADF.pdf
Developing RIA Web Applications with Oracle ADF.pdfDeveloping RIA Web Applications with Oracle ADF.pdf
Developing RIA Web Applications with Oracle ADF.pdf
 
Testing Options in Java
Testing Options in JavaTesting Options in Java
Testing Options in Java
 
Applications lab
Applications lab Applications lab
Applications lab
 

Recently uploaded

The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
Steve Thomason
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
Celine George
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
bennyroshan06
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
GeoBlogs
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
PedroFerreira53928
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
AzmatAli747758
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 

Recently uploaded (20)

The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 

Tutorial 3 accessing the database

  • 1. Tutorial 3: Accessing the Database In this tutorial, you will learn how to access the database, retrieve data from one of its table and display the data on a browser using Java EE in NetBeans IDE. 1. Open NetBeans. 2. Create a new Enterprise Application (refer to Tutorial 1 for the steps). If you have already created one, then open it. 3. Create the database (refer to Tutorial 2 for the steps). If you have already created the database, then make the connection by clicking the Services tab. Expand Databases until you come across the database you have created previously, right-click the database then Connect. 4. At this point, your Enterprise Application Project should have the following files: a. Entity class (<nameOfTable>.java) b. Entity class session beans (AbstractFacade.java and <nameOfTableFacade.java) If you still don't have these files at this point, then refer back to Tutorial 2 and create them. 5. Create the client interface. a. Right-click the Web Application module (…war) then select Properties. b. On the Project Properties dialog, click Frameworks from the Categories column, then click the Add button.
  • 2. c. In the Add a Framework dialog, select JavaServer Faces then click OK. d. In the application's Web Application module, expand Web Pages directory and delete index.html or index.jsp. Make sure that only index.xhtml is left. 6. Create the controller object. a. In the application's Web Application module, right-click Source Packages -> New -> Java Package. Type controller as package name then click Finish. b. Right-click the controller package then select New -> JSF Managed Bean (if you don't find this, click Other -> JavaServer Faces -> JSF Managed Bean. c. Type the name of the JSF managed bean, then change the Scope value to Session then click Finish
  • 3. At the point, your enterprise application should have the following files in its directory: 7. Clean and build the application by right-clicking the project then select Clean and Build from the pop up menu. You should see a green message that says that clean and build is successful. If the message is in red, then it means that there are errors in the application and you should correct these. 8. Once the build is successful, click the Run button from the standard toolbar to test the application.
  • 4. You should read something about Facelets on the browser of your desktop, like as follows: 9. Retrieve data from the table and display the data on the browser. a. Place a form on your JSF (index.xhtml). b. From the JSF Palette, drag a JSF Data Table From Entity object. If the Palette window is not displayed, Click Window -> Palette from the menu bar or Window -> IDE Tools -> Palette. This Palette should be displayed on the right side of the IDE screen. c. You should see some JSF tags embedded in the body section of your index.xhtml file. These tags would read as follows: Drag this object towards index.xhtml body section.
  • 5. 10. Add a new method in your controller that would display all records from the table. a. Right-click the body of the controller class and select Insert Code -> Call Enterprise Bean. b. Expand your ejb directory and select the appropriate …Façade file. c. Add the method that would call the findAll() method from the session bean. Your controller code should look like as follows: Add this table attribute if you want your table to have borders.
  • 6. d. Correct any errors (if there are any) by importing the necessary packages to gain access to the library files you need – java.util.List and your entities package that contains your entity class. e. Clean and Build, then run your program. You should see the following output on your browser. Add this method to the controller code. Make sure you use the correct entity name (the one you have in your entities package – in the ejb). Your Project Directory should have the following files in it.