struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <shirishchandra.sakh...@ubs.com>
Subject RE: Setting and Getting indexed property
Date Wed, 26 Mar 2003 12:36:27 GMT
U need to use lazy initialiszation.
Search the mail archive...I had replied some similar mail...

regards,
Shirish

-----Original Message-----
From: Ritesh Singhal [mailto:ritesh_singhal@infosys.com]
Sent: Wednesday, March 26, 2003 1:04 PM
To: Struts Users Mailing List
Subject: Setting and Getting indexed property


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>
        </tr>
</logic:iterate>

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
Ritesh

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


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


Mime
View raw message