Thanks for the code.. I started to build my code based on your replay as
shown below
<logic:iterate id="foo" indexId="i" name="addRateForm">
<html:text name="addRateForm" property='<%="firstName["+ i
+"].label"%>' />
</logic:iterate>
I added the get and set methods as u suggested. Also I did not
understand how the value of "i" will be incremented.
But then I got the following error message
Error Message: Cannot create iterator for this collection..
Could u help in explaining how this logic:iterate tag works..
Also I was trying to avaid using Struts-EL tag as it requires web
container supporting Servlet 2.3 specification.
Thanks
>>> [EMAIL PROTECTED] 06/06/03 12:05PM >>>
I hope that I am not too far out of touch with what you are attempting
to
accomplish, but I think I understand. There are a couple of things that
you
will have to do to get this working properly. In essence, what you want
to
do is use an indexed property. First, modify your Java bean as such:
private String[] firstName;
/*
// do the following in the constructor
// DEFAULT_SIZE should be whatever the maximum number of firstNames
are
allowed
firstName = new String[DEFAULT_SIZE];
*/
public String[] getFirstName(){
return FirstName;
}
public void setFirstName(String[] newName){
firstName = newName;
}
public String getFirstName(int i){
return firstName[i];
}
public void setFirstName(int i, String newName){
firstName[i] = newName;
}
You will have to initialize the array to some default size in the
constructor of the Java bean, otherwise the code below may throw a null
pointer exception. If you need the size of the array to be dynamically
resizable, perhaps you could use an ArrayList instead and have your Java
bean methods encapsulate this fact.
Then, in the JSP, you will have to iterate over every element in that
array
and use a tag of the following form:
<html-el:text property="firstName[${i}]" />
You will also have to modify any validation on this property for this
form.
See http://marc.theaimsgroup.com/?l=struts-user&m=104773695010730&w=2
for
details. I do not have much experience with this aspect of indexed
properties, but it seems like support for this in the validator is
limited
to statically declaring validation on a specific named element such as
firstName[1] or firstName[88].
This should also solve the repopulation problems that you were
experiencing.
I hope that this helps.
Larry
-----Original Message-----
From: Sashi Ravipati [mailto:[EMAIL PROTECTED]
Sent: Friday, June 06, 2003 10:34 AM
To: [EMAIL PROTECTED]
Subject: RE: Error - [Ljava.lang.String;@d23.
I do have multiple elements of the same name. I started to work with one
element and then I got this error.
So do I have to add any thing more to the tag?
Thanks
>>> [EMAIL PROTECTED] 06/06/03 10:29AM >>>
>[Ljava.lang.String;@d23.
Thats the default stringified version of your array. It looks like from
the
tag your using you just want to print a simple string, why are you
trying to
pass an array as the property?
-----Original Message-----
From: Sashi Ravipati [mailto:[EMAIL PROTECTED]
Sent: Friday, June 06, 2003 10:22 AM
To: [EMAIL PROTECTED]
Subject: Error - [Ljava.lang.String;@d23.
Hi
I get the following error when the jsp page is displayed after the
validation fails (Validation errros are all working fine)
[Ljava.lang.String;@d23.
This happens when I am passing values to a String Array. eg: .jsp I have
<html:text property="firstName" />
These are my set and get methods in my ActionForm
private String [] FirstName=null;
public String[] getfirstName(){
return FirstName;
}
public void setfirstName(String[] newName){
FirstName = newName;
}
It works fine when I use String but returns jusn when using String
array.
The values are being set correctly when I ran in debug mode.
Is this a bug??
Thanks
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
***************************************************************************
This electronic mail transmission contains confidential and/or
privileged
information intended only for the person(s) named. Any use,
distribution,
copying or disclosure by another person is strictly prohibited.
***************************************************************************
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]