struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jacky Shih" <jacky.s...@gmail.com>
Subject Struts2 can't populate array property to form beans
Date Sun, 01 Jun 2008 19:16:53 GMT
Hi all,

I meet a problem on populating array properties...
here is the detail description:

public class User {
       String [] phone;
       public String[] getPhone(){
             return phone;
       }
       public void setPhone(String[] phone) {
             this.phone=phone;
       }
}

public class UserAction {
        private User user=new User();

        public User getUser(){ return user;}
        public void setUser(User user) { this.user=user;}

        public String execute() {
                  // user.getPhone() always return null...
        }

}


And i have a jsp which will submit a list of phone to the action class


<form name=xxx action=xxx>
      <input type=text name="user.phone" />
      <input type=text name="user.phone" />
      <input type=text name="user.phone" />
       <input type=submit name=submit value=submit/>
</form>


after the form is submitted... the action class is called, however the list
of phone can't be populated to the user object in the UserAction class...
i have tried if the phone is not a array type.. the property is populated to
the user object ...
any suggestion for the issue?
thx alot!

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message