Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a JSF web app that allows users to sign and view a guestbook. Use the Gue

ID: 668303 • Letter: C

Question

Create a JSF web app that allows users to sign and view a guestbook.
Use the Guestbook database to store guestbook entries. [Note: A SQL script to create the
Guestbook database is provided in the examples directory for this chapter.] The Guestbook database
has a single table, Messages, which has four columns: Date, Name, Email and Message. The database
already contains a few sample entries. Using the AddressBook app in Section 30.2 as your guide, create
two Facelets pages and a managed bean. The index.xhtml page should show the Guestbook entries
in tabular format and should provide a button to add an entry to the Guestbook. When the
user clicks this button, display an addentry.xhtml page. Provide h:inputText elements for the user’s
name and email address, an h:inputTextarea for the message and a Sign Guestbook button to submit
the form. When the form is submitted, you should store in the Guestbook database a new entry
containing the user’s input and the date of the entry.

Explanation / Answer

Table Name: Messages

Database Name: Guestbook

Field Name

Data Type

Date

Date

Name

Varchar(15)

Email

Varchar(50)

Message

varchar(255)

SQL Script to create table:

CREATE TABLE ‘Messages’ (
‘Name’ Varchar(15) NOT NULL,
‘Email’ varchar(50) NOT NULL,
‘Date’ Date NOT NULL,
‘Message’ varchar(255) NOT NULL,
PRIMARY KEY (‘Name’)
) ENGINE= Guestbook DEFAULT CHARSET=latin1 CHECKSUM=1 ROW_FORMAT=DYNAMIC

Example Data in the table:

Name

Email

Date

Message

Raul

Raul.g@htmail.com

11/09/2015

Test message sending by raul

Steev

Steev@htmai.com

11/09/2015

Applying for leave request on Easter

You have to run this script in the SQL developer

index.xhtml

Message.Java

Guestbook.Java

addentry.xhtml

web.xml

The Index page will be looks like with the data of

Name

Email

Date

Message

Raul

Raul.g@htmail.com

11/09/2015

Test message sending by raul

Steev

Steev@htmai.com

11/09/2015

Applying for leave request on Easter

àAdd Button

And the add page will be displayed like below

Enter name :  

Enter Email :

Enter Your Message :

Enter Date :

Add Message button

Field Name

Data Type

Date

Date

Name

Varchar(15)

Email

Varchar(50)

Message

varchar(255)