Tutorials > Program model > Use Struts tags, action forms, and validation

< Previous | Next >


Prepare the workspace

In this step, we will import sample code into the WebSphere Commerce workspace. This sample code is the starting point for the tutorial.


Procedure

  1. Open WebSphere Commerce Developer.

  2. Ensure the consumer direct sample store (ConsumerDirect.sar) is published:

    If you published the store, refresh the Stores project after the publishing completes successfully:

    1. Open WebSphere Commerce Developer.

    2. Open the Enterprise Explorer view.

    3. Right-click Stores and select Refresh.

  3. Unzip the sample code for this tutorial:

    1. Locate the WC7StrutsSample.zip file that you downloaded to the file system.

    2. Unzip the files into a temporary directory on the file system, for example, C:\temp.

  4. Import the controller command Java code into the workspace:

    1. Navigate to WebSphereCommerceServerExtensionsLogic.

    2. Right-click the src folder and select Import. The Import wizard opens.

    3. From the Select an import source list, select General > File System and click Next.

    4. Click Browse (beside the From directory field) and navigate to Javafiles directory in the temporary directory, for example C:\temp\startercode\Javafiles.

    5. Click Select All to select all the files under the Javafiles directory.

    6. In the Folder field, the WebSphereCommerceServerExtensionsLogic/src folder is already specified. Keep this value and all other default values.

    7. Click Finish.

  5. Import the response JSP page for this tutorial:

    1. In the Enterprise Explorer view, expand Stores > WebContent > ConsumerDirect_name > > StoreInfoArea, where ConsumerDirect_name is the name of the store.

    2. Right-click the StoreInfoArea directory and select Import.

    3. From the Select an import source list, select General > File System and click Next.

    4. Click Browse (beside the From directory field) and navigate to the storeassets directory code in the temporary directory, for example C:\temp\startercode\storeassets.

    5. Click Deselect All, then select the MyContactUsDisplay.jsp and MyContactUsAckDisplay.jsp files.

    6. In the Folder field, the Stores/WebContent/ ConsumerDirect_name/ StoreInfoArea folder is already specified. Keep this value.

    7. Click Finish.

  6. Import the US English properties file for the tutorial into the appropriate directory:

    1. In the Enterprise Explorer view, expand Stores > Java Resources: src > ConsumerDirect_name .

    2. Right-click the ConsumerDirect_name directory and select Import.

    3. From the Select an import source list, select General > File System and click Next.

    4. Click Browse (beside the From directory field) and navigate to the storeassets directory in the temporary directory, for example C:\temp\startercode\storeassets.

    5. Click Deselect All, then select the StrutsTutorialNLS_en_US.properties file.

    6. In the Folder field, the Stores/src/ ConsumerDirect_name folder is already specified. Keep this value.

    7. Click Finish.

  7. Create the default properties file, to be used when a locale-specific properties file is not found:

    1. In the Enterprise Explorer view, expand Stores > Java Resources: src > ConsumerDirect_name .

    2. Right-click StrutsTutorialNLS_en_US.properties and select Copy.

    3. Right-click it again and select Paste.

    4. In the Name Conflict window, type StrutsTutorialNLS.properties and click OK.

  8. Copy the following files from drive:yourTempDir\startercode\ACpolicies to WC_EAR\xml\policies\xml:

    • MyContactUsAckViewACPolicy.xml

    • MyContactUsCmdACPolicy.xml

  9. Due to a restriction in the application classloader, there are certain TLD files that cannot be loaded by a web module, such as the Struts TLD files packaged in struts.jar located in the WebSphere Commerce EAR lib directory. As a workaround to this restriction, copy the struts.jar from the EAR /lib directory into the Stores WEB-INF/lib directory.

    1. In the Enterprise Explorer view, expand WC > lib.

    2. Right-click struts.jar and select Copy.

    3. Expand Stores > WebContent > WEB-INF > lib.

    4. Right-click lib and select Paste.

  10. Import the validation rules for this tutorial:

    1. In the Enterprise Explorer view, expand Stores > WebContent > WEB-INF.

    2. Right-click the WEB-INF directory and select Import.

    3. From the Select an import source list, select General > File System and click Next.

    4. Click Browse and navigate to the storeassets directory code in the temporary directory. For example, C:\temp\startercode\storeassets.

    5. Click Deselect All, and select the validation.xml and validator-rules.xml files.

    6. In the Folder field, the Stores/WebContent/WEB-INF folder is already specified. Keep this value, as it is correct.

    7. Click Finish.

Test the environment to ensure you are ready to start the tutorials:

  1. In WebSphere Commerce Developer, switch to the Server view.

  2. Right-click WebSphere Commerce Test Server and select Start if the server is stopped or Restart > Start if the server is running.

  3. After the server has started, we will see information similar to the following in the Console view of WebSphere Commerce Developer:

    A WSVR0001I: Server server1 open for e-business
    

    You can scroll up to examine the log of the startup process. Alternatively, you can monitor the server status as it starts by examining the WCDE_INSTALL/\wasprofiles\logs\server1\trace.log file.

  4. In the Enterprise Explorer view, expand Stores > WebContent > ConsumerDirect > _name .

  5. Right-click the index.jsp file and select Run As > Run on Server. If the Server Selection window displays, select Choose an existing server and click Finish.

  6. Alternatively, to directly launch the index.jsp, you can enter the following URL directly in the Web browser:

    http://localhost/webapp/wcs/stores/servlet/ConsumerDirect/index.jsp
    

  7. On the store locale selection page that is displayed in the Web browser, click United States English.

  8. At the bottom of the store United States English home page that is displayed, click Contact Us.

  9. Observe the default Contact Us page, which should look similar to the following:

You are now ready to proceed with the tutorial.

< Previous | Next >


+

Search Tips   |   Advanced Search