Correct me if I wrong, I think in the bean it should be:
void setCategoryName(Map categoryName) and
Map getCategoryName()
-hemanth



-----Original Message-----
From: David Graham [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, September 11, 2002 3:54 PM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: Re: Dynamic number of form fields


I'm having some trouble getting this to work.  I get the error message
"javax.servlet.jsp.JspException: No getter method for property
categoryName(2) of bean org.apache.struts.taglib.html.BEAN"

I have a HashMap in my form called categoryNames and a getter/setter like
this:
public void setCategoryName(String key, Object name) {
     this.categoryNames.put(key, name);
}

public Object getCategoryName(String key) {
     return this.categoryNames.get(key);
}

I put a bunch of AccountCategory objects in the session and then the jsp
loops through to display the input boxes like this:

<c:forEach var="category" items="${sessionScope.accountCategories}">
    <html:text
      property="categoryCode(<%=
((AccountCategory)pageContext.getAttribute("category")).getAccountCategoryID
()
%>)"/>

</c:forEach>

Any ideas?  Do I need struts 1.1 for this (I'm using 1.0.2)?

Thanks,
Dave

>From: "Donald Ball" <[EMAIL PROTECTED]>
>Reply-To: [EMAIL PROTECTED]
>To: [EMAIL PROTECTED], [EMAIL PROTECTED]
>Subject: Re: Dynamic number of form fields
>Date: Wed, 11 Sep 2002 13:34:18 -0400
>
>On 9/11/2002 at 11:00 AM David Graham wrote:
>
> >I want to have a form with a variable number of input boxes.  For
> >example, a
> >simple edit person form that has a first name and last name input box for
> >each person in your db.  So the first set would be named firstName_12
> >lastName_12, the second set might be firstName_45623 and lastName_45623.
> >The number after the underscore is the personID from the db table.  When
> >the
> >form is submitted you loop over these fields and update the appropriate
> >row
> >in the database from the _ID info.
> >
> >I've read through the docs on DynaBeans and that seems like the way to go
> >but I'm still not sure how to go about this. When populating the
> >DynaFormBean, does struts just go through the request params and assign
> >them
> >to new form properties?  How would you validate this type of form?
>
>The Dyna beans don't exactly give you what you're looking for. The
>properties of a Dyna bean must be known at deployment time, do they're not
>directly suited for dynamic forms (the Dyna prefix is a bit misleading).
>What you probably want are map-backed ActionForm beans (which can be
>vanilla or Dyna, actually, with some caveats). There is no documentation in
>the user guide for them, but I've written a patch that adds some. Comments
>on it are greatly welcomed.
>
>- donald
><< patch >>
>--
>To unsubscribe, e-mail:
><mailto:[EMAIL PROTECTED]>
>For additional commands, e-mail:
><mailto:[EMAIL PROTECTED]>




_________________________________________________________________
MSN Photos is the easiest way to share and print your photos:
http://photos.msn.com/support/worldwide.aspx


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


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

Reply via email to