Srinivas,

This has come up a little while ago and I've added to the nested 
extension to allow for it. The problem is, is that if you have other 
nested tags inside an iterate tag or similar, they will work on a 
property returned from that object from the list etc. What was needed 
was to access the object itself. This was just not possible in the 
original tags or otherwise.

To allow this I've added the ability to access the current object from a 
parent. Using "./" or "this/" as the child tag's property, you will 
access the parent object itself. So if it's a string, you can write it 
out, make it an input field etc.

For example...
<nested:iterate property="stringList">
<nested:text property="this/" />
</nested:iterate>
...will loop through an array of Strings and make text inputs for them.

There is one specific detail to get this working properly. In your bean, 
you have to provide the more literal form of indexed setter property, 
rather than the collection form used for the getter.
Example where I'm setting the value back to my ArrayList...

public void setStringList(int index, String str) {
myList.set(index, str);
}


My getter remains unchanged as the collection form...

public ArrayList getStringList() {
return myList;
}

This is all because the system which sets it wont be pulling out the 
collection, making the modifications, and then returning it altered. It 
will leave everything up to you. This is still good however.

This functionality is in the nightly build from the 23rd of Jan, or you 
can download an updated jar from the site.
http://www.keyboardmonkey.com/struts

As a small disclaimer, the ArrayList getter shown above is only possible 
with a nightly build. Users of Struts 1.0/1.01 will need to return an 
Object array as in "arrayList.toArray()".

Hope this does what you're after.


Arron.


srinivas wrote:

>hi Arron,
>
>Thank you very much for the advice. It fits to our problem but i am faced
>with another one.
>
>I d'ont no how to generate input fields(text or select) when the bean
>return's an array of Strings.
>I did not get the idea how i can iterate through the array of Strings and
>generate an input field
>with value equal to the contents of the String.
>
>i d'ont have control over the action beans as they are generated from XML
>Schema. I use castor source generation to
>generate a java class out of XML schema and then use it in ActionForm.
>
>Thank u once again.
>
>Srinivas
>-----Original Message-----
>From: Arron Bates [mailto:[EMAIL PROTECTED]]
>Sent: Monday, January 28, 2002 5:43 AM
>To: Struts Users Mailing List
>Subject: Re: how to use strus HTML tags when i have a collection of
>items to be displayed
>
>
>The nested extension.
>
>Go here to learn how...
>http://www.keyboardmonkey.com/struts
>
>It's in the nightly build or you can pick up the library from the page
>above. Will be in Struts 1.1
>
>
>Arron.
>


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

Reply via email to