tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David M. Holmes" <david_m_hol...@yahoo.com>
Subject RE: setProperty and arrays
Date Thu, 20 Jul 2000 20:19:05 GMT
1 is correct, the browser will basically submit an array of values for the same-named elements.
I
just verified this.

# HTML
<form action="test.jsp" method="post">
<input type="text" name="grade" value="" size="10"><Br>
<input type="text" name="grade" value="" size="10"><Br>
<input type="text" name="grade" value="" size="10"><Br>
<input type="text" name="grade" value="" size="10"><Br>
<input type="submit" name="submit" value="Submit">
</form>

# JSP
<jsp:useBean id="grades" class="test.Grades" scope="request">
	<jsp:setProperty name="grades" property="*"/>
</jsp:useBean>

<%

String[] theGrades = grades.getGrades();

for (int i = 0; i < theGrades.length; i++) {
	out.print( theGrades[i] + "<br>" );
}

%>

# Bean
package test;

public class Grades {
	String[] grades;
	
	public void setGrade(String[] grade) {
		this.grades = grade;
	}
	
	public String[] getGrades() {
		return grades;
	}

}


--- Bob Byron <bbyron@MailAndNews.com> wrote:
> Please forgive my naivete, but I am new to array
> processing in html and need 
> some of the pieces filled in.  If I have the
> following form:
> <jsp:useBean id="myBean" scope="session"
> class="mypackage.myclass">
> </jsp:useBean>
> <jsp:setProperty name="myBean" property="*">
> <form name="personalForm" method="POST"
> action="myPage.jsp">
> <table>
>   <tr><td>
>     <input name="Grade" type="text" value="<%=
> myBean.getGrade() %>">
>   </td></tr>
>   <tr><td>
>     <input name="Grade" type="text" value="<%=
> myBean.getGrade() %>">
>   </td></tr>
>   <tr><td>
>     <input name="Grade" type="text" value="<%=
> myBean.getGrade() %>">
>   </td></tr>
> </form>
> 
> 1) Is the above correct with the multiple listing of
> "Grade" as the name of 
> the input?  Wouldn't the browser only end up seeing
> one?
> 2) If you must use different names on each input,
> how do I force the three 
> differently named inputs to use "setGrade"?
> 3) Does tomcat automatically know that the object is
> an array instead of a 
> single string.
> 
> Thank you very much for your consideration,
> Bob Byron
> 
> >===== Original Message From "David M. Holmes"
> <david_m_holmes@yahoo.com> 
> =====
> >I don't use anything special, just setProperty
> >property="*". I use it with strings and numbers.
> >
> >int[] ages;
> >String[] names;
> >
> >public setAges(int[] ages) {
> >  this.ages = ages;
> >}
> >
> >public setNames(String[] names) {
> >  this.names = names;
> >}
> >
> 


__________________________________________________
Do You Yahoo!?
Get Yahoo! Mail  Free email you can access from anywhere!
http://mail.yahoo.com/

Mime
View raw message