Yes, the EL can access array elements to, I believe, an arbitrary number of dimensions 
(please correct me if I'm wrong):

<%-- One dimensional array --%>
${myArray[index]}

<%-- Two dimensional array --%>
${myArray[index][index2]}

<%-- Three dimensional array --%>
${myArray[index][index2][index3]}

and so on.

Derek

> -----Original Message-----
> From: Helios Alonso [mailto:[EMAIL PROTECTED] 
> Sent: June 2, 2004 11:05 AM
> To: Tag Libraries Users List
> Subject: RE: [JSTL] Indexed array variable
> 
> 
> 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...
> 
> At 10:53 02/06/2004 -0400, you wrote:
> >Good question!  We can represent a multi-dimensional array as a 
> >recursive array of arrays.  For example, given tag <c:setArray>, we 
> >could both allocate and assign a two-dimensional array as follows:
> >
> ><%-- Create the first row, assign it values at index 0 and 1.
> ><%-- Assign the row to myArray at index 0. --%>
> ><c:setArray var="row" index="0" value="0"/>
> ><c:setArray var="row" index="1" value="1"/>
> ><c:setArray var="myArray" index="0" value="${row}"/>
> >
> ><%-- Create the second row, assign it values at index 2 and 3.
> ><%-- Assign the row to myArray at index 0. --%>
> ><c:setArray var="row" index="0" value="2"/>
> ><c:setArray var="row" index="1" value="3"/>
> ><c:setArray var="myArray" index="1" value="${row}"/>
> >
> >${myArray} now contains [[0,1], [2,3]].
> >
> >We can use the JSP Expression Language to access each array 
> element so 
> >that
> >
> ><c:out value="${myArray[0][0]}"/>
> ><c:out value="${myArray[0][1]}"/>
> ><c:out value="${myArray[1][1]}"/>
> ><c:out value="${myArray[1][2]}"/>
> >
> >outputs
> >
> >0 1 2 3
> >
> >Note that each index of 'myArray' refers to a row, each of 
> which is a 
> >one-dimensional array.  By induction, this model extends to 
> >multi-dimensional arrays where each element of an array may refer to 
> >another one-dimensional array whose elements may themselves 
> each refer 
> >to another one-dimensional array, and so on.
> >
> >What do you think?
> >
> >Derek
> >
> > > -----Original Message-----
> > > From: Simon Benzekri
> > > Sent: June 2, 2004 10:10 AM
> > > To: Tag Libraries Users List
> > > Subject: RE: [JSTL] Indexed array variable
> > >
> > >
> > > Good idea but how will multi-dimensional arrays be populated?
> > >
> > > Simon
> > >
> > > -----Original Message-----
> > > From: Helios Alonso [mailto:[EMAIL PROTECTED]
> > > Sent: Wednesday, June 02, 2004 9:48 AM
> > > To: Tag Libraries Users List
> > > Subject: RE: [JSTL] Indexed array variable
> > >
> > > It would be great.  I think it's very appropiate (very 
> common idea 
> > > even for non-programmers, easy to implement).
> > >
> > > By example (my case):  I want to make a calendar and 
> would like to 
> > > make it very generical.  If I could use associations with 
> taglibs, 
> > > I'd make something that gives me dates (or months, weeks, 
> and days),
> > > and another
> > > bean associating days to properties.  It helps mantaining the
> > > calendar code
> > > independent from the "properties" code.  And properties could be
> > > associations too:
> > >
> > > 'holiday' -> boolean
> > > 'holidayname' -> name
> > > 'itemscount' -> int
> > >
> > > and so on.
> > >
> > > The JSP would poduce HTML for the calendar, but guided by the 
> > > properties of each day (holidays in red, days with items with a 
> > > link, etc.)
> > >
> > > At 09:25 02/06/2004 -0400, you wrote:
> > > >I think you're right.  Just like no JSTL tag exists to create an 
> > > >associative array (a bean or a map indexed by string), 
> no JSTL tag 
> > > >exists that can explicitly allocate an indexed array.  
> > > ><jsp:useBean> can create both associative and indexed 
> arrays, and 
> > > ><c:set> can set associative array properties, but not 
> indexed array
> > > elements.  I think
> > > >the only solution, then, is to create my own tag handler 
> similar to 
> > > ><c:set> that can assign array elements.  Of course, this is 
> > > >non-standard, but will solve my problem.
> > > >
> > > >Will the next version of JSTL enhance <c:set> to permit the
> > > assignment
> > > >of array elements?
> > > >
> > > >Derek
> > > >
> > > > > -----Original Message-----
> > > > > From: Bill Siggelkow [mailto:[EMAIL PROTECTED]
> > > > > Sent: June 1, 2004 8:49 PM
> > > > > To: 'Tag Libraries Users List'
> > > > > Subject: RE: [JSTL] Indexed array variable
> > > > >
> > > > >
> > > > > I don't think that JSTL is going to be able to "create" array 
> > > > > elements. I think you will need to allocate the array
> > > ahead of time.
> > > > > Maybe someone else can clarify this a little more.
> > > > >
> > > > >
> > > > > Bill Siggelkow
> > > > > [EMAIL PROTECTED]
> > > > >
> > > > >
> > > > > -----Original Message-----
> > > > > From: Derek Mahar [mailto:[EMAIL PROTECTED]
> > > > > Sent: Tuesday, June 01, 2004 5:10 PM
> > > > > To: Tag Libraries Users List
> > > > > Subject: [JSTL] Indexed array variable
> > > > >
> > > > > How does one create and assign elements to an indexed
> > > array variable
> > > > > in JSTL or the Expression Language? <c:set> seems lacking in 
> > > > > this respect.
> > > > >
> > > > > Derek
> >NOTICE: This email contains privileged and confidential 
> information and 
> >is
> >intended only for the individual to whom it is addressed. If 
> you are not 
> >the named addressee, you should not disseminate, distribute 
> or copy this 
> >e-mail. Please notify the sender immediately by e-mail if you have 
> >received this transmission by mistake and delete this 
> communication from 
> >your system. E-mail transmission cannot be guaranteed to be 
> secured or 
> >error-free as information could be intercepted, corrupted, lost, 
> >destroyed, arrive late or incomplete, or contain viruses.
> >
> >AVIS: Le présent courriel contient des renseignements de nature
> >privilégiée et confidentielle et n'est destiné qu'à la 
> personne à qui il 
> >est adressé. Si vous n'êtes pas le destinataire prévu, vous 
> êtes par les 
> >présentes avisés que toute diffusion, distribution ou 
> reproduction de 
> >cette communication est strictement interdite.  Si vous avez reçu ce 
> >courriel par erreur, veuillez en aviser immédiatement 
> l'expéditeur et le 
> >supprimer de votre système. Notez que la transmission de 
> courriel ne peut 
> >en aucun cas être considéré comme inviolable ou exempt 
> d'erreur puisque 
> >les informations qu'il contient pourraient être interceptés, 
> corrompues, 
> >perdues, détruites, arrivées en retard ou incomplètes ou 
> contenir un virus.
> >
> >---------------------------------------------------------------------
> >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