Hi,

Which type should I define in POJO Model to hold the value of the array of TextField/DropDownChoice when populated by ListView? Should I define it as String[] or ArrayList or something else?

I have attached the following example to explain my situation:


    public class DetailForm extends Form {
        private java.util.List ageList = Arrays.asList(new String[]{ "10", "20", "30" });
        public DetailForm(String string){

            super(string);
            DetailModel dm = new DetailModel();

            setModel(new CompoundPropertyModel(dm));

            ListView listView = new ListView("detailList", new PropertyModel(this, "detailData")){

                public void populateItem(final ListItem listItem){
                    final String detail = (String) listItem.getModelObject();
                    listItem.add(new Label("code",detail));
                    listItem.add(new DropDownChoice("age",ageList));
                    listItem.add(new TextField("name"));
                }
            };
            add(listView);

        }

        public List getDetailData(){
            java.util.List hm = new ArrayList();

            // Should get the data from DB, for simplicity I use hardcode value
            hm.add("aaaa");
            hm.add("bbbb");
            hm.add("cccc");
            return hm;
        }
    }


      & nbsp; // Model class
    public class DetailModel implements Serializable {

        private String[] age = new ArrayList();   // ???? Not sure about the type
        private String[] name;

        public String[] getAge(){
            return age;
        }

        public void setAge(String[] age){
            this.age = age;
        }

        public String[] getName(){
            return name;
        }

        public void setName(String[] name){
            this.name = name;
        }
    }

The idea behind String[] was my 'past time' with Struts  :)
Any suggestion?


Cheers,

Michael
 


Yahoo! Travel
Find great deals to the top 10 hottest destinations!

Reply via email to