Erwin Dwight V. Ruiz wrote:
> thanks for the reply but i still have one more problem.
> i tried to set as what you've said as a
> String array but the values that i retrieved was null.
> here is my code:
>
> public void setName(String[] values){
>   String[] name=new String[values.length];
>   for(int i=0;i<values.length; i++){
>      name[i]=values[i];
>   }
> }
>
> public String[] getName(){ return name; }
>
> thanks. :)

First, there's no need to copy the array like you do in setName().
Second, you assign the value to a local variable named "name" in
setName() but you return the value of a variable named "name"
declared somewhere else in getName(). That's why it's empty; you
never set it. Try this instead:

   public class MyBean {
     private String[] name;
     public void setName(String[] value) {
       name = value;
     }
     public String[] getName() {
       return name;
     }
   }

Hans

> On Tue, 23 Jul 2002, Hans Bergsten wrote:
>
>
>>Erwin Dwight V. Ruiz wrote:
>>
>>>Hello I'm new to jsp and i'd like to know
>>>how multiple text boxes or form elements
>>>with the same name can be processed in a
>>>jsp application. if the names of the form elements
>>>are unique you could easily map the elements to a
>>>java bean through accessor and setter methods. what
>>>happens if the form elements name are not
>>>unique can we still map the elements to a
>>>java bean? if possible how do i do it?
>>
>>You can capture them in a bean with a setter method that takes an
>>array:
>>
>>   setMyProperty(String[] values)
>>
>>Hans
>>--
>>Hans Bergsten           [EMAIL PROTECTED]
>>Gefion Software         http://www.gefionsoftware.com
>>JavaServer Pages        http://TheJSPBook.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://archives.java.sun.com/jsp-interest.html
>> http://java.sun.com/products/jsp/faq.html
>> http://www.esperanto.org.nz/jsp/jspfaq.jsp
>> http://www.jguru.com/faq/index.jsp
>> http://www.jspinsider.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://archives.java.sun.com/jsp-interest.html
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.jsp
>  http://www.jguru.com/faq/index.jsp
>  http://www.jspinsider.com
>


--
Hans Bergsten           [EMAIL PROTECTED]
Gefion Software         http://www.gefionsoftware.com
JavaServer Pages        http://TheJSPBook.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://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

Reply via email to