Re: Indexed Grid Representation on a Form
I ended up getting it to work thru this hack below. I'd be curious if someone was able to do this dynamic grid entry gracefully using struts!!! % int i = 0; % logic:iterate id="customerContact" name="adminUpdateProfileForm" property="customerContacts" tr tdinput type='text' name="customerContact[%= i++ %].contactName" value="%= ((com.mydomain.project.CustomerContact)customerContact).getContactName() %"/td /tr /logic:iterate - Original Message - From: Jeff Trent To: [EMAIL PROTECTED] Sent: Thursday, May 17, 2001 10:12 PM Subject: Re: Indexed Grid Representation on a Form No, this still generates an exception. If I substitute i for 0 in your below example it works but that doesn't help me for the iteration. Thanks, jeff. - Original Message - From: Nanduri, Amarnath To: '[EMAIL PROTECTED]' Sent: Thursday, May 17, 2001 5:39 PM Subject: RE: Indexed Grid Representation on a Form % int i = 0; % logic:iterate id="list" name="adminUpdateProfileForm" property="customerContacts" tr % i++ ; % tdhtml:text property="customerContact[i].contactName"//td /tr /logic:iterate -Original Message-From: Jeff Trent [mailto:[EMAIL PROTECTED]]Sent: Thursday, May 17, 2001 3:58 PMTo: [EMAIL PROTECTED]Subject: Indexed Grid Representation on a Form I think this should work (but obviously it doesn't). Can anyone tell me why? % int i = 0; % logic:iterate id="list" name="adminUpdateProfileForm" property="customerContacts" tr tdhtml:text property="customerContact[%=i++%].contactName"//td /tr /logic:iterate Where getCustomerContacts() returns a vector of CustomerContact objects getCustomerConact(int offset) returns an CustomerContact element from that vector. thanks, jeff
Re: Indexed Grid Representation on a Form
What really is needed is a new html tag called grid or something that handles this more gracefully. Using the iterate tag seems to be a waste since I'm not really using it for anything other than a counter placeholder. I know its a departure from standard HTML form types but who the hell cares. This would be really useful addition instead of mixing html tags in with iterate tag to accomplish something that should be simple. Maybe I'll write a taglib for this... So reading your comments, Jim, it sounds like your using code analagous to this but your implementation uses a map instead (?) BTW, now that I'm using html field names like customerContactName[0].title, I find that conventional javascript to set focus doesn't work - I get javascript errors. Any ideas how to reference these fields? thanks, jeff - Original Message - From: Jim Richards [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Thursday, May 17, 2001 10:24 PM Subject: Re: Indexed Grid Representation on a Form It should be: % int i = 0; % logic:iterate id=list name=adminUpdateProfileForm property=customerContacts tr % i++ ; % tdhtml:text property=%= \customerContact[\ + i \].contactName\ %//td /tr /logic:iterate You need to replace the whole string. The exception would have been from the BeanUtils not able to understand what the [i] would have meant. If you have an iterator in a scriptlet, then you need to always use a scriptlet to access it. Usually. Mostly. I had a feeling there was a change made to iterate recently to give you an index value, but I can't remember what it was. I usually use a Map and have the key as the integer value in the index for the entry. Works well when you don't have liner numbering in the list of key/value pairs.