Difference between revisions of "HowTo:Create a JSP Page and Java Controller"

From AgileApps Support Wiki
imported>Aeric
imported>Aeric
Line 1: Line 1:
<noinclude>
<noinclude>
{{Orientation|Developers|Intermediate|15}}
{{Orientation|Developers|Intermediate|15}}
</noinclude>This example describes how to use a [[Page]] to perform the following actions on records in the ''Directory'' object:
</noinclude>This example shows how a JSP [[Page]] and a Controller [[Class]] interact to let the user:
:*search for records based on specified criteria
:*add records to a Mailing List object
:*add records
:*do a SQL search for (one or more) records Β 
:*update records
:*update records


;Considerations:
The following files are used:
:It is important to create the Classes files first, then create the Pages. Five files are provided, including two Classes, and three Pages. The files should be created in this order:
:#Class [[AddUpdateController.java|AddUpdateController.java]]
#Class [[Directory.java|Directory.java]]
:#Page [[AddUpdate.jsp|AddUpdate.jsp]]
#Class [[DirectoryController.java|DirectoryController.java]]
Β 
#Page [[AddUpdate.jsp|AddUpdate.jsp]]
;Prerequisites:
#Page [[Directory.jsp|Directory.jsp]]
:* A "Mailing List" object must be created, with two fields: <tt>contact_name</tt> and <tt>contact_email</tt>
#Page [[SearchPage.jsp|SearchPage.jsp]]


To add the Pages and Classes:
To add the Pages and Classes:
#To create the (.java) Java pages, follow the instructions at [[Classes#Adding_a_Class|Add a Class]]
#To create the Java class:
#:Create the class Directory.java from: [[Directory.java|Directory.java]]
# Follow the instructions at [[Classes#Adding_a_Class|Add a Class]]
#::*Copy and paste the contents into the Class
# Copy and paste the contents of [[AddUpdateController.java]] into the Class
#::*Save the file as Directory.java
# Save the class
#:Create the class DirectoryController.java from: [[DirectoryController.java|DirectoryController.java]]
#:
#::*Copy and paste the contents into the Class
#To create the JSP Pages
#::*Save the file as DirectoryController.java
# Follow the instructions at [[Pages#Adding_a_Page|Add a Page]] to create <tt>AddUpdate.jsp</tt>
#To create the (.jsp) Java Server Pages, follow the instructions at [[Pages#Adding_a_Page|Add a Page]]
# Copy and paste the contents of [[AddUpdate.jsp]]
#:Create the page AddUpdate.jsp from: [[AddUpdate.jsp|AddUpdate.jsp]]
# Save the JSP page
#::*Copy and paste the contents into the Page
#:
#::*Save the file as AddUpdate.jsp
#:Create the page Directory.jsp from: [[Directory.jsp|Directory.jsp]]
#::*Copy and paste the contents into the Page
#::*Save the file as Directory.jsp
#:Create the page SearchPage.jsp from: [[SearchPage.jsp|SearchPage.jsp]]
#::*Copy and paste the contents into the Page
#::*Save the file as SearchPage.jsp
#To invoke the Directory page from the URL, copy and paste the following into a web browser. A valid username and password is required to log in to the platform.
#To invoke the Directory page from the URL, copy and paste the following into a web browser. A valid username and password is required to log in to the platform.
::<tt>{{platformURL}}/pages/Directory.jsp</tt>
::<tt>{{platformURL}}/pages/Directory.jsp</tt>

Revision as of 01:54, 28 July 2012

For:   Developers
Level: Intermediate
Time: 15 minutes

See more:
    ◾ HowTo Guides

This example shows how a JSP Page and a Controller Class interact to let the user:

  • add records to a Mailing List object
  • do a SQL search for (one or more) records
  • update records

The following files are used:

  1. Class AddUpdateController.java
  2. Page AddUpdate.jsp
Prerequisites
  • A "Mailing List" object must be created, with two fields: contact_name and contact_email

To add the Pages and Classes:

  1. To create the Java class:
  2. Follow the instructions at Add a Class
  3. Copy and paste the contents of AddUpdateController.java into the Class
  4. Save the class
  5. To create the JSP Pages
  6. Follow the instructions at Add a Page to create AddUpdate.jsp
  7. Copy and paste the contents of AddUpdate.jsp
  8. Save the JSP page
  9. To invoke the Directory page from the URL, copy and paste the following into a web browser. A valid username and password is required to log in to the platform.
https://{yourDomain}/networking/pages/Directory.jsp

After logging in, the user can perform these actions in the Directory object:

  • search for records based on specified criteria
  • add records
  • update records