Stephen:
The following code works just perfect:
JSP page:
<...>
<form>
<input type="..." name="same_name" value="valueA">
<input type="..." name="same_name" value="valueB">
<input type="..." name="same_name" value="valueC">
</form>
</...>
ON POST:
<jsp:setProperty name="id" property="..."
param="same_name" />
What this code does is take all the parameters named
'same_name', make an array of them and send it to the
method on the bean. Then you can get the array from
the bean and loop through it.
The bean:
private String property[] = new String[] {};
public String[] get...() { return this.property; }
public void set...(String b[]) { this.property = b; }
If you don't want to use beans you can do the
following:
JSP page:
<...>
<form>
<input type="..." name="same_name" value="valueA">
<input type="..." name="same_name" value="valueB">
<input type="..." name="same_name" value="valueC">
</form>
</...>
ON POST:
<%
Enumeration e =
request.getParameterValues("same_name");
while (e.hasMoreElements()) {
...
}
%>
You have to check if the last method and names are
correct because I don't remember totally.
Hope this help
Atilio
--- "Stephen T. Dziuban" <[EMAIL PROTECTED]> wrote:
> Suppose: an html form has an array of similar
> fields, and on posting we
> want to send their parameter values to a bean using
> <jsp:setProperty
> name="fieldArrayBean" property="*" /> (with little
> or no code added).
>
> Case 1: Let's say the form fields are named
> "field0", "field1", ... Then
> "public void setField0(String input)", "public void
> setField1(String
> input)", ... could be used even if not the most
> elegant.
>
> Case 2: Let's say the form fields are named
> "field[0]", "field[1]", ...
> What would the declaration be for the set-parameter
> method in the bean?
> "public void setField(int field, String input)" is
> the closest I could
> guess, but it doesn't seem to work.
>
> Anybody solved this one?
>
> Steve Dz.
>
>
===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with
> body: "signoff JSP-INTEREST".
> For digest: mailto [EMAIL PROTECTED] with body:
> "set JSP-INTEREST DIGEST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.html
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
>
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
=====
Ing. Atilio Ranzuglia Buteler
[EMAIL PROTECTED]
__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets