I've been trying to get the Indexed List example from the Type Conversion 
documentation 
(http://struts.apache.org/2.0.14/docs/type-conversion.html#TypeConversion-AnadvancedexampleforindexedListsandMaps)
 to work without success.  

The action is as follows (note I initialize the List with some TestData 
instances):

package gmi.action.test;

import java.util.ArrayList;
import java.util.List;
import com.opensymphony.xwork2.Action;

/*This is a test!*/

public class TestAction implements Action {

    private List beanList = new ArrayList();


    public List getBeanList() {
        return beanList;
    }

    public void setBeanList(List beanList) {
        this.beanList = beanList;
    }

    public String execute() throws Exception {
        beanList.add(new TestData(1l, "one"));
        beanList.add(new TestData(2l, "two"));
        beanList.add(new TestData(3l, "three"));
        return SUCCESS;
    }
}

The data class is the same as in the example:

package gmi.action.test;

import java.io.Serializable;

public class TestData implements Serializable { 

            private Long id;
            private String name;
            
            public TestData(Long i, String n){
                id = i;
                name = n;
            }

            public Long getId() {
                return id;
            }

            public void setId(Long id) {
                this.id = id;
            }

            public String getName() {
                return name;
            }

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


            public String toString() {
                return "TestData{" +
                        "id=" + id +
                        ", name='" + name + '\'' +
                        '}';
            }
        }

I have a TestAction-conversion.properties file like so:

KeyProperty_beanList=id
Element_beanList=TestData
CreateIfNull_beanList=true

and my struts.xml file contains:

        <action name="prepTest" method="execute" 
class="gmi.action.test.TestAction">
            <result name="success">/test.jsp</result>
        </action>


If I browse to the prepTest url, I get 3 text boxes, so the iterator is 
working, but the boxes are empty.  Has anyone else had success with this 
example or accessing List elements by the List element ID's rather than using 
something like status.id?
Thanks,
Joe



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Reply via email to