In this lesson, you replace the existing Contact
Us JSP page with a new JSP page, called MyContactUsDisplay.jsp. The
MyContactUsDisplay.jsp page contains an HTML form and replaces the
default Contact Us page of the Madisons starter store, ContactDisplay.jsp.
You create a dynamic action form to hold the HTML form data in the
MyContactUsDisplay.jsp page which collects user input to be processed
by the logic you enabled in the previous lesson.
About this task
The MyContactUsDisplay.jsp file contains a form as its main
element. The form is defined with the Struts html:form tag. The action attribute
of the html:form element specifies the
action to which the form is submitted. The action is identified by
the path attribute of its action configuration
element. The action element can also be used to establish the appropriate
action form and scope for your HTML form. The form comprises two text
input fields, one text-area input field, and a submit button, rendered
with Struts html:text
, html:textarea
,
and html:submit
tags. The form also includes three
hidden fields, defined with the Struts html:hidden tag, which are
used to pass along WebSphere Commerce context parameters.
Procedure
- The struts-config-ext.xml file should
still be open for editing in the Struts Configuration File Editor.
If not, expand Stores/WebContent/WEB-INF. Right-click
the struts-config-ext.xml file, and select .
- Click the Form Beans tab. In the
Form Beans section, click Add to create a Form
Bean. Replace the default bean name with the name MyContactUsForm.
- In the Form Bean Attributes section,
for the Type, enter org.apache.struts.action.DynaActionForm.
- In the Form Beans tab, click the Form
Properties tab.
- In the DynaBeans section, select MyContactUsForm.
- Create the properties for the MyContactUsForm form:
- In the Form Properties section
click Add to create the name property
for the
MyContactUsForm
form.
- For the Name field, enter name.
- Select the name property, and in the Form
Property Attributes section, for the Type field, enter java.lang.String
- In the Form Properties section
click Add to create the email property
for the
MyContactUsForm
form.
- For the Name field, enter email.
- Select the name property, and in the Form
Property Attributes section, for the Type field, enter java.lang.String
- In the Form Properties section
click Add to create the comment property
for the
MyContactUsForm
form.
- For the Name field, enter comment.
- Select the name property, and in the Form
Property Attributes section, for the Type field, enter java.lang.String
- In the Form Properties section
click Add to create the storeId property
for the
MyContactUsForm
form.
- For the Name field, enter storeId.
- Select the name property, and in the Form
Property Attributes section, for the Type field, enter java.lang.String
- In the Form Properties section
click Add to create the langId property
for the
MyContactUsForm
form.
- For the Name field, enter langId.
- Select the name property, and in the Form
Property Attributes section, for the Type field, enter java.lang.String
- In the Form Properties section
click Add to create the catalogId property
for the
MyContactUsForm
form.
- For the Name field, enter catalogId.
- Select the name property, and in the Form
Property Attributes section, for the Type field, enter java.lang.String
- Save your changes. You have created the properties for
JSP page dynamic form.
- Click the Action Mappings tab. In
the Action Mappings section, select MyContactUsCmd.
- In the Form Bean Specification section
associate the Form Bean with the MyContactUsForm form:
- In the Form Bean Name field enter the name MyContactUsForm
- In the Scope field, select request.
- Ensure the Validate check box
is not selected.
- Switch to the Source view and verify
that the MyContactUsCmd action definition now looks as follows:
<action path="/MyContactUsCmd"
type="com.ibm.commerce.struts.BaseAction"
parameter="com.ibm.commerce.sample.commands.MyContactUsCmd"
name="MyContactUsForm"
scope="request"
validate="false">
</action>
- Save your changes and leave the Struts Configuration File
Editor open.