I couldn't find anything in the mailing list. Actually I am new to this
group. Do you know any resources on the internet where using indexed
property and lazy intialization is explained.

Regards
Ritesh

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] 
Sent: Wednesday, March 26, 2003 6:06 PM
To: [EMAIL PROTECTED]
Subject: RE: Setting and Getting indexed property


U need to use lazy initialiszation.
Search the mail archive...I had replied some similar mail...

regards,
Shirish

-----Original Message-----
From: Ritesh Singhal [mailto:[EMAIL PROTECTED]
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


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


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

Reply via email to