You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Frank Ling <st...@hotmail.com> on 2001/07/10 21:16:52 UTC

Sorry, another question for Iterate Tag

Good Morning:

I have a question for the iterate property update with indexed tag.

Normally I use my own tag to show the real name of the iterate property for
update purpose, then just read them out from the HTTPRequest on my action
class, that works well until recently I have to add a upload feature to one
of my page which have Iterate tags. Since there aren't any HTTPRequest left
in my action class to read due to the multipart issue. Then I try to using
the ActionForm to handle the Iterate property for update.

I go through couple thread on this mailing list regarding for the indexed
tag on iterate tag for update purpose, and follow all the steps, still can't
get this thing works, please help me out.
Here are the step I did.

1) I get a object call InflowAttributes have three field, all have the
getters and setters.
    a. String name
    b. String type
    c. String value

2) I get form-bean call UserForm and have one of the field.
    a. InFlowAttribute[] attributes.
    have three method for the field.
    a.
    public InFlowAttribute[] getAttributes() {
        return this.attributes;
    }
    b.
    public void setAttributes(InFlowAttributes[] attributes) {
        this.attributes = attributes;
    }
    c.
    public InFlowAttribute getAttribute(int index) {
        return this.attributes[index];
    }
    3) I get jsp for the editing a userform, have couple thing made for this
indexed Iterate & Text tag.
    a) I get Dave Hay's indexed package install on top of the struts 1.0
release, both java and tld.
    b) I have struts-html.tld and struts-logic.tld define on top of my JSP
page.
    c) Here is my implementation for the iterate.
    <logic:iterate id="attribute" name="userForm" property="attributes">
        <tr>
        <td><struts:htmpProperty name="attribute" property="name"/><.td>
        <td><html:text name="attribute" property="value"
indexed="true"/></td>
        </tr>
    </logic:iterate>
    d) I have all the attribute[0..n].value set up properlly without any
problem.

    4) This JSP for editing userform will trigged a saveUser action. Here is
my problem, I can get all the other field from userform without problem
except attributes field is null, no matter whatever I do.

I know some thing I did wrong to cause the array attributes didn't get set
back to my userform, but just couldn't figure out why, If some people out
there can help me out, there will be really appreciated. Basically I try to
understand how the HTML form request get populate back to form bean.
especially how the "attribute[0..n].value" can get set back to array
"attributes" on my form.

By the way, until to this point, I still didn't put
enctype="multipart/form-data" on my form yet, so this will be pure Iterate
tag update issue.

Thanks in advance for the help.

Regards

FL