struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ritesh Singhal" <>
Subject Setting and Getting indexed property
Date Wed, 26 Mar 2003 12:03:30 GMT
Hi All,

I am having problem setting and getting indexed property of a form bean.
I have a form bean:

public class ExampleForm extends ActionForm {
    private String id[];
    private String name[];
    private String address[];

    public String getIdIndexed( int index )
        return ( id[index] );

    public void setIdIndexed(int index, String value)
        id[index] = value;
    ..... And so on

With appropriate getter and setter methods.

Now in my jsp page I am trying to access these fields and display them
in a table format. Something like this:

<logic:iterate id="foo" name="exampleForm" property="id" indexId="ctr">
        <tr align="center" valign="middle">
            <td><html:text name="exampleForm" property='<%= "idIndexed["
+ ctr + "]"%>'/></td>
            <td><html:text name="exampleForm" property='<%=
"nameIndexed[" + ctr + "]"%>'/></td>
            <td><html:text name="exampleForm" property='<%=
"addressIndexed[" + ctr + "]"%>'/></td>

I want to have the same form bean for create and edit page of the
entity. So in create page I will have a table with blank fields and in
edit page I will have prepopulated fields. Also in edit page I shud be
able add more rows for the table. Now I don't know what property name to
give in create page of the entity. Above code works fine when form bean
is already populated, but problem comes when you want to create the
entity. Do I need to initialize the array? And of what size? As I want
it to be dynamic. Also in create page I want some default number of rows
with blank pages. What shud be the property name for those text fields?

Please help me. I am stuck coz of this problem.

Thanks and Regards

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message