rleland     01/03/29 10:48:14

  Modified:    src/share/org/apache/struts/util package.html
  Log:
  Add small section on JavaBeans for Bean and Property Utils.
  Might need to be moved.
  
  Revision  Changes    Path
  1.5       +58 -1     jakarta-struts/src/share/org/apache/struts/util/package.html
  
  Index: package.html
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/util/package.html,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- package.html      2001/01/28 05:28:57     1.4
  +++ package.html      2001/03/29 18:48:13     1.5
  @@ -49,7 +49,64 @@
   <a name="doc.Beans"></a>
   <h3>Beans and Properties</h3>
   
  -<p>FIXME</p>
  +<p>FIXME</p>  <p>FIXME some parts of this might me moved to Taglibs</p>
  +<p> The <code>BeanUtils</code> and <code>PropertyUtils</code> utilities are
  +    used through out struts including the <code>IteratorTag, WriteTag</code>.
  +    Much of these utilities rely on and make use of Java reflection, to manipulate
  +    <a href='http://developer.java.sun.com/developer/onlineTraining/Beans/beans02/'>
  +    Java beans </a>.  Creating a <b>valid</b>  Java bean is essential !
  +    Briefly referring to the example class <code>ProductBean</code>
  +    below would follow these rules :
  +    <ul>
  +    <li> The class <b>must</b> a null constructor, or no constructor </li>
  +    <li> It's class declaration <b>must</b> be public </li>
  +    <li> The name for the property say 'value' would have a 'get' method of 
getValue()</li>
  +    <li> The 'get' and 'set' methods to be visible <b>must</b> be public.</li>
  +    <li> If desired the 'is' prefix can be used in place if 'get' for a 
boolean.</li>
  +    <li> Other requirements can be found
  +         <a 
href='http://developer.java.sun.com/developer/onlineTraining/Beans/beans02/'>
  +    here</a>.
  +    </ul>
  +    <pre>
  +        public class ProductBean() {
  +           private String value;
  +           public String getvalue() (return this.value}
  +           public void setvalue(String value) (this.value = value}
  +        }
  +    </pre>
  +    </p>
  +    <p> Observing these conventions will avoid unnecessary errors and save time.</p>
  +
  +   <p>
  +        This makes it possible to create a JSP page such as:
  +    <pre>
  +        &lt;logic:iterate id="product" name="receivedForm" 
property="receivedList"&gt;
  +              &lt;bean:write name="product" property="description" /&gt;
  +              &lt;bean:write name="product" property="value" /&gt;
  +        &lt;/logic:iterate&gt;
  +    </pre>
  +    In this case receiveForm is an ActionForm, with a definition such as
  +    <pre>
  +        public class ReceivedForm extends ActionForm  {
  +         private ProductList productList;
  +         public void setReceivedList(Enumeration enum) {
  +             productList = new ProductList(enum,Limits.ARRAY_SIZE_MIN);
  +         }
  +         /**
  +          * Defined so java.bean reflection will see getReceivedList
  +          * as a getter for receivedList
  +          */
  +         public void setReceivedList(ProductList productlist) {
  +
  +         }
  +
  +         /**
  +          * Returns an Array list of ProductBeans.
  +          */
  +         public ProductList getReceivedList() {
  +           return productList;
  +         };
  +       } //ReceiveForm
   
   <hr>
   
  
  
  

Reply via email to