Create a new bean name RequestDataComplex for this package.
Add a property for a password.
Add a property for a radio group.
Add a property for a checkbox group.
Add a property for a text area.
Add a property for a single select list.
Add a property for a multiple select list.
Copy the controller class from the Enhanced tutorial for Chapter
4. Refactor as necessary.
Copy the controller helper class from the Enhanced tutorial
for Chapter 4. Refactor as necessary.
Modify the controller helper.
Change all bean references to the bean for this package.
Change the location of the JSPs to this package.
Add an edit page to the package.
Add a password field.
Add a radio group.
Add a checkbox group.
Add a text area.
Add a single select list.
Add a multiple select list.
Add a confirm button.
Add a confirm page.
Echo all the data from the query string. Use an ordered list to organize
the data.
List all the options for the checkbox group and the multiple select list
in nested ordered lists.
Add edit and process buttons.
Add a process page.
Echo all the data from the query string. Use an ordered list to organize
the data.
List all the options for the checkbox group and the multiple select list
in nested ordered lists.
Add an edit button.
Edit the web.xml file.
Add a servlet definition for the controller.
Add a servlet mapping for the controller.
Modify the index.jsp file.
Modify the page by adding a hypertext link to the controller.
Do not link to the edit page; all accesses should be to the controller.
Run the project.
The index.jsp page will appear in the browser.
Enter data and see that it is displayed properly in the process and confirm
pages.
Notice that when you return to the edit page, all the data is lost.
Validate that all the JSP files contain valid HTML.
Whenevere a log file is used. you will need to shut down Tomcat in NetBeans
before doing a clean and build.
Click the Services tab in the NetBeans project.
Open the Servers folder.
Right-click Apache Tomcat.
Click Stop.
Now you can do a clean and build.
Complex Initialisation
Open the Source Packages folder.
Add the SetByAttribute class to the shared folder.
Copy the contents from the book's site.
Add the AttributeType class to the shared folder.
Copy the contents from the book's site.
Add the HelperBaseCh6 class to the shared folder.
Copy the contents from the book's site.
This class has member variables for the checked and
selected maps.
There are methods for accessing the maps and for adding to the maps.
It contains the method for setting the maps from the query string.
Create a new package named ch6.complexInit.
Copy the bean from the Complex Form tutorial. Rename it
RequestDataInit
Copy the controller class from the Post tutorial from Chapter
5. Refactor as necessary.
Copy the controller helper class from the Post tutorial from
Chapter 5. Refactor as necessary.
Copy the edit, confirm and process pages from the Complex Form
tutorial.
Modify the controller helper.
Extend it from HelperBaseCh6.
Change all bean references to the bean for this package.
Change the location of the JSPs to this package.
Add a method named resetNullable that does not have a return value. Call the setters
for extra, team and happines. Set the extra and team to null, set happiness to 0.
In the confirm method, call resetNullable before filling the bean from the request and call the setCheckedAndSelected method
after filling the bean from the request.
Copy the checked and selected maps from the session
in the copyFromSession method.
Modify the bean.
Modify the radio and checkbox properties with the attribute that indicates
that they are set using the word "checked".
Modify the select properties with the attribute that indicates that they
are set using the word "selected".
Modify the JSPs.
Modify the edit page.
Add initialisation for the password and text area fields.
Add initialisation for the radio and checkbox groups.
Add initialisation for the select lists.
The form should use the POST method.
Modify the confirm and process pages so that the forms use the POST method.
Edit the web.xml file.
Add a servlet definition for the controller.
Add a servlet mapping for the controller.
Modify the index.jsp file.
Modify the page by adding a hypertext link to the controller.
Do not link to the edit page; all accesses should be to the controller.
Run the project.
The index.jsp page will appear in the browser.
Enter data and see that it is displayed properly in the process and confirm
pages.
Notice that when you return to the edit page, the elements are all initialised
properly.
Validate that all the JSP files contain valid HTML.
Whenevere a log file is used. you will need to shut down Tomcat in NetBeans
before doing a clean and build.
Click the Services tab in the NetBeans project.
Open the Servers folder.
Right-click Apache Tomcat.
Click Stop.
Now you can do a clean and build.
Complex Validation and Persistence
The changes for the Complex Validation and Complex Persistent controllers have been combined in this tutorial.
Open the Source Packages folder.
Add a hibernate.cfg.xml file to the default package.
Add an empty file named hibernate.cfg.xml. Do not add it to a package, it will be added to the default package.
Copy the hibernate.cfg.xml file from the Examples page.
Edit the server, port, database and username.
Create a new package named ch6.complexPersistent.
Copy the controller class and the controller helper class from the Data
Persistence tutorial from Chapter 5. Refactor as necessary.
Copy the edit, confirm and process pages from the Complex Init
tutorial.
Copy the expired page from the Data Persistence tutorial from
Chapter 5
Copy the bean from the Complex Init tutorial. Rename it to
ComplexDataPersistent.
Modify the bean.
Add the class annotation that indicates that the class will have a separate
table in the database. Use the one from javax.persistence.
Extend the class from shared.PersistentBase. Alternatively,
you can add an id property, but don't do both.
Mark any properties that should not be saved in the database with the appropriate
annotation.
Marks the properties that return arrays so that a related table is created
in the database.
Add a NotNull annotation for the secret code.
Add a NotNull annotation for extra. Inlcude an appropriate message.
Add a size annotation for team. Include an appropriate message.
Modify the controller helper.
Change all bean references to the bean for this package.
Change the location of the JSPs to this package.
Add a method named resetNullable that clears the properties
for the buttons and lists.
Modify the confirm method so that it calls resetNullable before
filling the bean and setCheckedAndSelected after filling the
bean.
Modify the edit page.
Add EL for the error messages for secret code, extra and team.
Modify the process page.
Add the taglib for the JSTL, if it is not already in the page.
Add a forEach loop that displays all the data from the database.
Use EL to retrieve the data using the name that was used to add the data
to the request in the process method.
List all the data in a table.
Display a row of headings that contains the name of each property.
Display each row from the database in a separate row in the table
Each column in the table represents one property in the table.
For those properties that have multiple values, display them in an unordered
list in the table cell.
Edit the web.xml file.
Add a servlet definition for the controller.
Add an initialisation parameter named create.
Set the value to true when you want to create the table; otherwise,
leave it as false.
Add a servlet mapping for the controller.
Modify the index.jsp file.
Modify the page by adding a hypertext link to the controller.
Do not link to the edit page; all accesses should be to the controller.
Run the project.
The index.jsp page will appear in the browser.
Enter some data and navigate to the process page.
You will see a list of all the data that you have entered.
Click the Edit button.
Change the values and navigate to the process page.
You will see that the data for the last record was changed, instead of a
new record being added.
Click the New button.
Enter some new data and navigate to the process page.
You will see that a new record has been added to the database.
Be sure that the create parameter in the web.xml
file is set to false, so that your table will not lose all its
data when the servlet engine restarts.
Navigate to the confirm page.
In the browser, open a new tab and remove the cookie for JSESSIONID. Alternatively,
open the Tomcat manager application and reload the web application.
You should still be on the confirm page. Click process. You will be redirected
to the error page, since the session is no longer accessible and the data
is gone.
If there are errors, check your log file for more information.
Validate that all the JSP files contain valid HTML.
Whenevere a log file is used. you will need to shut down Tomcat in NetBeans
before doing a clean and build.