tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kevin HaleBoyes <kcbo...@yahoo.com>
Subject useBean, setProperty, and repeating form fields
Date Tue, 22 May 2001 14:53:49 GMT
In order to set my bean properties based on an incoming (POST'ed) HTML form, 
I'm using the following construct in a JSP page:

<jsp:useBean id="ord" class="ord.OrderBean" scope="request">
  <jsp:setProperty name="ord" property="*"/>
</jsp:useBean>

It works fine except now I want to process something a little different.  I'm 
working on an Order entry system and the Order Items are a repeating group of 
fields.  In my HTML form I have <input> fields named like "partNumber0, 
quantity0, price0" and "partNumber1, quantity1, price1" that repeat for each
potential item in an order.

Is there any way to use the <jsp:setProperty> construct to automatically set 
the properties in an OrderItems bean.  I'm guessing it might have something to
do with indexed properties but I really can't see how this would work.  If I
have my bean as

public class OrderItemBean
{
   String[] partNumber;
   ...

   public void setPartNumber( int index, String value ) {...}
   ...
}

Is the JSP runtime going to be able to take the partNumber0 field and be able
to call my indexed-property setter method with the correct index.  What if I
use the version

   public void setPartNumber( String[] value );

as my setter method?

Any and all help would be appreciated.
Thanks,
Kevin


____________________________________________________________
Do You Yahoo!?
Get your free @yahoo.co.uk address at http://mail.yahoo.co.uk
or your free @yahoo.ie address at http://mail.yahoo.ie

Mime
View raw message