You have named your indexed property in the DynaActionForm "rows" - but on
your jsp you are using a var of "row"

Either change the property defined in the DynaActionForm to "row" or change
your jsp to refer to "rows"...

<c:forEach var="rows" items="${testForm.map.rows}"> <!-- was using
logic:iterator but tried this too -->

    Author: <c:out value="${rows.field1}"/>
    <html:text name="rows" property="field1" indexed="true" />
    <br>
    Pick from known affiliations
    <br>
    <html:select name="rows" property="field2" size="4" indexed="true">
        <html:option value="1"/>
        <html:option value="2"/>
        <html:option value="3"/>
        <html:option value="4"/>
        <html:option value="5"/>
    </html:select>

</c:forEach>

Niall

----- Original Message ----- 
From: "Mark Rehbein" <[EMAIL PROTECTED]>
Sent: Tuesday, July 05, 2005 4:18 AM


Hi,

I've been trying to get the values in my dynaaction form to update.

I have a "populator" Action that creates my TestRow[] object and adds it
to the form. The dynaaction also has a simple String property which I
also populate.
I then forward to my HTML form that has the row fields indexed. The form
is displayed with all the indexed text boxes and select boxes populated
as expected. I edit the values, including the non indexed field and
submit the form to the form processor action.

The form is retrieved and the non indexed field has the updated value,
BUT, the indexed fields still contain the original values!

I've triple checked everything, and looked around for answers but I
can't work out whats wrong. I've even done indexed forms successfully
before on a different project, so its very frustrating.

Even downloaded the lastest Struts 1.2.7/JSTL 1.1.2 libs and retried.

Any help greatly appreciated....Thanks Mark

Here's my code and config segments:

DynaActionForm definition from my struts-config.xml:


<form-bean name="testForm"
type="org.apache.struts.action.DynaActionForm">

            <form-property name="simple" type="java.lang.String"/>
            <form-property name="rows"
type="aims.app.support.library.pub.TestRow[]"/>

</form-bean>

and the action mappings

<action path="/do/testInit"
            type="aims.app.support.library.pub.action.TestInit"
            input="/do/gotoError.do"
            name="testForm"
            scope="session">
            <forward name="next" path="/do/gotoTestPage.do"/>
        </action>

        <action path="/do/testProcess"
            type="aims.app.support.library.pub.action.TestProcess"
            input="/do/gotoError.do"
            name="testForm"
            scope="session">
            <forward name="next" path="/do/gotoThankyou.do"/>
        </action>


My test page, which is included into my Tiles to form valid HTML and
mapped to /do/gotoTestPage.do :

<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="jstl/c" prefix="c" %>

<html:form action="/do/testProcess" >


<html:text property="simple" />

<c:forEach var="row" items="${testForm.map.rows}"> <!-- was using
logic:iterator but tried this too -->

    Author: <c:out value="${row.field1}"/>
    <html:text name="row" property="field1" indexed="true" />
    <br>
    Pick from known affiliations
    <br>
    <html:select name="row" property="field2" size="4" indexed="true">
        <html:option value="1"/>
        <html:option value="2"/>
        <html:option value="3"/>
        <html:option value="4"/>
        <html:option value="5"/>
    </html:select>



</c:forEach>

<p>
    <html:submit value="Continue" styleClass="addButton"/>
</p>


</html:form>

"Populator" action

public class TestInit extends Action {

    private static final String NEXT="next";

    public ActionForward execute(ActionMapping mapping,
                                 ActionForm form,
                                 HttpServletRequest request,
                                 HttpServletResponse response) throws
Exception {



        DynaActionForm testForm = (DynaActionForm) form;



        TestRow row1=new TestRow();
        row1.setField1("Mark");
        row1.setField2(2);

        TestRow row2=new TestRow();
        row2.setField1("Fred");
        row2.setField2(5);

        TestRow[] rows=new TestRow[2];
        rows[0]=row1;
        rows[1]=row2;

        testForm.set("rows", rows);
        testForm.set("simple", "hello");

        return mapping.findForward(NEXT);

    }
}

"Form processor" action

public class TestProcess extends Action {

    private static final String NEXT="next";


    public ActionForward execute(ActionMapping mapping,
                                 ActionForm form,
                                 HttpServletRequest request,
                                 HttpServletResponse response) throws
Exception {


        DynaActionForm testForm = (DynaActionForm) form;

        String simple=(String)testForm.get("simple");

        System.out.println("Simple: " + simple);


        TestRow[] rows=(TestRow[])testForm.get("rows");

        for (int i=0;i<rows.length;i++) {

            System.out.println("Name: " + rows[i].getField1());
            System.out.println("No: " + rows[i].getField2());

        }

        return mapping.findForward(NEXT);

    }
}

TestRow bean

public class TestRow {

    private String field1;
    private int field2;

    public String getField1() {
        return field1;
    }

    public void setField1(String field1) {
        this.field1 = field1;
    }

    public int getField2() {
        return field2;
    }

    public void setField2(int field2) {
        this.field2 = field2;
    }
}



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to