Return-Path: Delivered-To: apmail-jakarta-struts-dev-archive@apache.org Received: (qmail 9845 invoked from network); 5 Feb 2003 04:09:59 -0000 Received: from exchange.sun.com (192.18.33.10) by daedalus.apache.org with SMTP; 5 Feb 2003 04:09:59 -0000 Received: (qmail 25995 invoked by uid 97); 5 Feb 2003 04:11:26 -0000 Delivered-To: qmlist-jakarta-archive-struts-dev@nagoya.betaversion.org Received: (qmail 25988 invoked from network); 5 Feb 2003 04:11:25 -0000 Received: from daedalus.apache.org (HELO apache.org) (208.185.179.12) by nagoya.betaversion.org with SMTP; 5 Feb 2003 04:11:25 -0000 Received: (qmail 9175 invoked by uid 500); 5 Feb 2003 04:09:54 -0000 Mailing-List: contact struts-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Struts Developers List" Reply-To: "Struts Developers List" Delivered-To: mailing list struts-dev@jakarta.apache.org Received: (qmail 9163 invoked by uid 500); 5 Feb 2003 04:09:54 -0000 Received: (qmail 9158 invoked from network); 5 Feb 2003 04:09:54 -0000 Received: from icarus.apache.org (208.185.179.13) by daedalus.apache.org with SMTP; 5 Feb 2003 04:09:54 -0000 Received: (qmail 3132 invoked by uid 1059); 5 Feb 2003 04:03:14 -0000 Date: 5 Feb 2003 04:03:14 -0000 Message-ID: <20030205040314.3131.qmail@icarus.apache.org> From: craigmcc@apache.org To: jakarta-struts-cvs@apache.org Subject: cvs commit: jakarta-struts/doc/faqs newbie.xml X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N craigmcc 2003/02/04 20:03:14 Modified: doc/faqs newbie.xml Log: Another good newbie FAQ answer. PR: Bugzilla #16065 Submitted by: Edgar Dollin Revision Changes Path 1.11 +54 -2 jakarta-struts/doc/faqs/newbie.xml Index: newbie.xml =================================================================== RCS file: /home/cvs/jakarta-struts/doc/faqs/newbie.xml,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- newbie.xml 5 Feb 2003 03:31:24 -0000 1.10 +++ newbie.xml 5 Feb 2003 04:03:14 -0000 1.11 @@ -101,6 +101,11 @@ Do ActionForms have to be true JavaBeans? +
  • + Do I have to have a separate ActionForm bean + for every HTML form? +
  • +

    @@ -565,6 +570,55 @@ +

    + +

    This is an interesting question. As a newbie, it is a good + practice to create a new ActionForm for each action + sequence. You can use DynaActionForms to help reduce + the effort required, or use the code generation facilities of your + IDE.

    + +

    Some issues to keep in mind regarding reuse of form beans + are as follows:

    +
      +
    • Validation - You might need to use different + validation rules depending upon the action that is currently + being executed.
    • +
    • Persistence - Be careful that a form populated in + one action is not unexpectedly reused in a + different action. Multiple <form-bean> + entries in struts-config.xml for the same + ActionForm subclass can help (especially if you + store your form beans in session scope). Alternatively, + storing form beans in request scope can avoid unexpected + interactions (as well as reduce the memory footprint of your + application, because no server-side objects will need to be + saved in between requests.
    • +
    • Checkboxes - If you do as recommended and reset + your boolean properties (for fields presented as checkboxes), + and the page you are currently displaying does not have a + checkbox for every boolean property on the form bean, the + undisplayed boolean properties will always appear to have a + false value.
    • +
    • Workflow - The most common need for form bean + reuse is workflow. Out of the box, Struts has limited support + for workflow, but a common pattern is to use a single form bean + with all of the properties for all of the pages of a workflow. + You will need a good understanding of the + environment (ActionForms, Actions, + etc.) prior to being able to put together a smooth workflow + environment using a single form bean.
    • +
    + +

    As you get more comfortable, there are a few shortcuts you can + take in order to reuse your ActionForm beans. Most of + these shortcuts depend on how you have chosen to implement your + Action / ActionForm combinations.

    + +
    + +
  • Why is ActionForm a base class rather than an interface?
  • - -
  • Do I have to have a separate ActionForm bean for every HTML form?
  • Can I use other beans or hashmaps with ActionForms?
  • --------------------------------------------------------------------- To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: struts-dev-help@jakarta.apache.org