Raible's Wiki

Raible Designs
Wiki Home
News
Recent Changes

AppFuse

Homepage
  - Korean
  - Chinese
  - Italian
  - Japanese

QuickStart Guide
  - Chinese
  - French
  - German
  - Italian
  - Korean
  - Portuguese
  - Spanish
  - Japanese

User Guide
  - Korean
  - Chinese

Tutorials
  - Chinese
  - German
  - Italian
  - Korean
  - Portuguese
  - Spanish

FAQ
  - Korean

Latest Downloads

Other Applications

Struts Resume
Security Example
Struts Menu

Set your name in
UserPreferences


Referenced by
Articles
Articles_pt
CreateActions_zh
CreateManager
CreateManager_es
SpringControllers_ko
ValidationAndList




JSPWiki v2.2.33

[RSS]


Hide Menu

CreateActions


This is version 1. It is not the current version, and thus it cannot be edited.
[Back to current version]   [Restore this version]


Coming Soon! Here's a quick and dirty rough draft in the meantime.

Here's a quick-n-dirty how to. We're creating a new Action/JSP for the "Position" entity in this example:

  • Generate your Struts' ActionForms by executing "ant ejbdoclet" from the command-line
  • Generate a skeleton JSP using the strutsgen tool in the tools folder:
    • From the command-line, navigate to "tools/strutsgen"
    • Execute "ant gen -Dform.name=PositionForm" to generate two files in tools/strutsgen/build: PositionForm.properties (labels for your form elements) and PositionForm.jsp (skeleton JSP file)
    • Copy the contents of PositionForm.properties into web/WEB-INF/classes/ApplicationResources.properties.
    • Copy PositionForm.jsp to web/positionForm.jsp
  • Create a new Struts Action in src/web. We called it PositionAction.java. Look in ResumeAction.java for the XDoclet javadocs at the beginning of the class. Use these as an example to create a /savePosition action-mapping.
  • Delete all methods in PositionAction.java (if you used ResumeAction.java as a template). Find and replace Rresume with Pposition.
  • Override the execute method and put a debugging statement into the method body to verify we're hitting it. Something like: System.out.println("entering execute method");
  • Edit web/positionForm.jsp so the form's action="savePosition"
  • Run "ant deploy" to deploy the updated application to Tomcat.
  • Start Tomcat and go to http://localhost:8080/apptracker/positionForm.jsp.
  • This should bring up the JSP, with a simple form in it. Click the button and you should see "entering execute method" in your Tomcat console. If so - nice work!

Next up - integrating positionForm.jsp with Tiles, putting some meat into the Action's execute method, creating an ActionTest, replacing execute with different CRUD methods (add, edit, search), customizing the JSP so it looks good and finally - write a WebTest to test the JSPs functionality (or doing it via the browser).


Attachments:


Go to top   More info...   Attach file...
This particular version was published on 06-Nov-2006 13:52:29 MST by MattRaible.