Date: 2004-04-13T22:44:25
   Editor: 195.127.68.50 <>
   Wiki: Apache Struts Wiki
   Page: StrutsCatalogVariableScreenFields
   URL: http://wiki.apache.org/struts/StrutsCatalogVariableScreenFields

   no comment

Change Log:

------------------------------------------------------------------------------
@@ -1,20 +1,20 @@
 It is a quite common that you come across a screen whose common requirement is to 
layout a part or whole of the screen dynamically based on the runtime decisions made 
by the user. A typical example is of screen used for submission of report process. 
Screen for such a functionality is made of two blocks, in the first block user inputs 
report process name and presses a “Search” button on the basis of report name 
specified a list of arguments appears in the lower block, against which the user is 
supposed to provide values.
 
-In general against every field in JSP, { { { ActionForm } } } bean has to have a pair 
of accessor and mutator methods (getter and setter methods). In this scenario since 
the number of fields varies there could be a problem if some fields does not have a 
corresponding accessor and mutator method.
+In general against every field in JSP, {{{ ActionForm }}} bean has to have a pair of 
accessor and mutator methods (getter and setter methods). In this scenario since the 
number of fields varies there could be a problem if some fields does not have a 
corresponding accessor and mutator method.
 Best practices
 There are three possible solutions to this problem
 
  1. Name all the fields in specific pattern like field1, field2, field3 etc and 
provide their accessor and mutator methods in the FormBean. In this approach there is 
a maximum limit on number of fields that can appear on screen.
- 1. The purpose of { { { FormBean } } } is to reduce the overhead of doing 
getParameter () in the Servlet. We always have the option of not using a { { { 
FormBean } } } and doing the getParameter in Action class.
+ 1. The purpose of {{{ FormBean }}} is to reduce the overhead of doing getParameter 
() in the Servlet. We always have the option of not using a {{{ FormBean }}} and doing 
the getParameter in Action class.
  1. Third option is to utilize the setProperty ()/getProperty () methods provided by 
Struts especially for this type of problem.
 
 In case we have a small and fixed number of fields on screen, it is not a bad idea to 
go for the first approach described above, but in general it has been found that the 
last approach is the best one. 
 
-To use this, define two methods in your { { { ActionForm } } } bean class. These 
methods may in turn be written to store the values into a { { { HashMap } } }.  
Populate all the required fields in the form Action Class or any Helper class.
+To use this, define two methods in your {{{ ActionForm }}} bean class. These methods 
may in turn be written to store the values into a {{{ HashMap }}}.  Populate all the 
required fields in the form Action Class or any Helper class.
 {{{ 
 public class testVarForm extends ActionForm 
 {
-{{{  private HashMap hMap = new HashMap(); 
+  private HashMap hMap = new HashMap(); 
 
   public testVarForm()   {  } 
 
@@ -32,7 +32,7 @@
   public void setHashMap(HashMap newHMap) 
   { 
     this.hMap =newHMap; 
-  } }}}
+  }
 }
  }}}
 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to