You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-user@tomcat.apache.org by Helios Alonso <ha...@atg.com.uy> on 2004/06/02 17:22:33 UTC

RE: [JSTL] Indexed array variable (and associations)

Well, c:set can set associations.

If the code I saw is fine, you can do this:

<c:set target="myAsoc" property="name" value="John"/>
to add an entry in myAsoc: Map
telling that "name" correspond to "John"

how do I do to access it?  ${myAsoc['name']}   ?

At 12:05 02/06/2004 -0300, you wrote:
>2 questions:
>
>1) At the moment, does EL allows bracket notation for accesing arrays?
>2) If the answer is yes, it works with associations? (Maps from -let's 
>say- strings, to beans)
>
>Sorry, I can't try now...



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


RE: [JSTL] Indexed array variable (and associations)

Posted by Helios Alonso <ha...@atg.com.uy>.
At 12:22 02/06/2004 -0300, you wrote:
>Well, c:set can set associations.
>
>If the code I saw is fine, you can do this:
>
><c:set target="myAsoc" property="name" value="John"/>
>to add an entry in myAsoc: Map
>telling that "name" correspond to "John"
>
>how do I do to access it?  ${myAsoc['name']}   ?

Thanks (I finally checked the code X-)

So, what is missing is setting.

For setting a complete array I'd use:

<c:set var="myArray">
         <array>
                 <item><array>
                         <item>Simon</item>
                         <item>75</item>
                         <item>70</item>
                 </array></item>
                 <item><array>
                         <item>Derek</item>
                         <item>75</item>
                         <item>70</item>
                 </array></item>
                 <item><array>
                         <item>Helios</item>
                         <item>75</item>
                         <item>70</item>
                 </array></item>
         </array>
</c:set>

Where array sets parent tag's value attribute (I hope set tag allow inner 
body processing).  Array would have a Vector for collecting items.  On 
doEndTag it would convert it to an array and set it to parent tag.

Item tag would look for an array parent tag and add a new value.  Its value 
would be by property, by body string, or letting an inner tag set it 
(<item><array> case).

We can use similar code to <choose><when> handlers.

But... it remembers me xml... maybe it's a better aproach (but I'm not sure 
about the capabilities)



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