Groups | Search | Server Info | Keyboard shortcuts | Login | Register


Groups > comp.lang.java.programmer > #4637

Re: Is JavaBeans able to store an array?

From byhesed <byhesed@gmail.com>
Newsgroups comp.lang.java.programmer
Subject Re: Is JavaBeans able to store an array?
Date 2011-05-26 22:11 -0700
Organization http://groups.google.com
Message-ID <970d7ab8-dc74-4d7c-a486-b934fb3b5d3b@22g2000prx.googlegroups.com> (permalink)
References <5ec5c70e-03e1-46ae-8ed4-b79ddfef70a0@35g2000prp.googlegroups.com> <irivd5$fjj$1@news.albasani.net>

Show all headers | View raw


On 5월25일, 오후10시15분, Lew <no...@lewscanon.com> wrote:
> On 05/24/2011 09:15 PM, byhesed wrote:
>
>
>
>
>
>
>
>
>
> > Can I handle array values using JavaBeans?
> > I could'n find the way to pass an array to JavaBeans.
>
> > Below is my situation.
>
> > There are four checkboxes.
> > I want to handle those values in JavaBeans.
>
> > --------------------------------------------------------------------------- -------------------------
> > 1. TestBeanForm.jsp
> > --------------------------------------------------------------------------- -------------------------
> > <form action="TestBean.jsp" method="post">
> >      <input type="checkbox" name="books">  Java for Student<br>
> >      <input type="checkbox" name="books">  Compiler Construction<br>
> >      <input type="checkbox" name="books">  Software Engineering<br>
> >      <input type="checkbox" name="books">  Core Servlet and JSP<br>
> >      <p>
> >      <input type="submit" value="Submit">
> > </form>
> > --------------------------------------------------------------------------- -------------------------
>
> > Here, I use JavaBeans.
> > --------------------------------------------------------------------------- -------------------------
> > 2. TestBean.jsp
> > --------------------------------------------------------------------------- -------------------------
> > <%@page import="test.TestBean"%>
>
> > <jsp:useBean id="testBean" class="test.TestBean">
> >    <jsp:setProperty name="testBean" property="*"/>
> > </jsp:useBean>
> > <jsp:getProperty name="testBean" property="books"/>
> > --------------------------------------------------------------------------- -------------------------
>
> > When dealing with thoes values using JavaBeans,
> > Only the first books element is passed to JavaBeans.
> > Here is my javaBean [sic].
>
> > --------------------------------------------------------------------------- -------------------------
> > 3. TestBean.java
> > --------------------------------------------------------------------------- -------------------------
> > package test;
>
> > public class TestBean {
> >    private String books;
>
> >    public void setBooks(String books) { this.books = books; }
> >    public String getBooks() { return books; }
> > }
> > --------------------------------------------------------------------------- -------------------------
>
> Where's the array in your bean?
>
> --
> Lew
> Honi soit qui mal y pense.http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg

I got rid of the code about array.
Original code is here.

---------------------------------------------------------------------------
-------------------------
3. TestBean.java
---------------------------------------------------------------------------
-------------------------
   package test;

   public class TestBean {
   private String[] books;
   public void setBooks(String[] books) { this.books = books; }
   public String[] getBooks() { return books; }
}
---------------------------------------------------------------------------
-------------------------

However, when I pass multiple check box values,
A browser only can receive just first one value in checkboxes.
Do you know how to handle array values in JavaBean?

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Is JavaBeans able to store an array? byhesed <byhesed@gmail.com> - 2011-05-24 18:15 -0700
  Re: Is JavaBeans able to store an array? Lew <noone@lewscanon.com> - 2011-05-25 09:15 -0400
    Re: Is JavaBeans able to store an array? byhesed <byhesed@gmail.com> - 2011-05-26 22:11 -0700
      Re: Is JavaBeans able to store an array? Lew <noone@lewscanon.com> - 2011-05-27 01:38 -0400
        Re: Is JavaBeans able to store an array? byhesed <byhesed@gmail.com> - 2011-05-27 03:54 -0700
          Re: Is JavaBeans able to store an array? Lew <noone@lewscanon.com> - 2011-05-27 10:25 -0400
            Re: Is JavaBeans able to store an array? byhesed <byhesed@gmail.com> - 2011-05-29 17:26 -0700

csiph-web