struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Gainty <mgai...@hotmail.com>
Subject RE: OGNL - Multi-dimensional Array
Date Tue, 20 Oct 2009 17:44:56 GMT


a few years back we had a similar scenario of something called a WKT (wellKnownText class)
which is a class containing an array of values (in this case LAT/LONG )
List WKTArray<WKT> = new Array(12);
then inside the loop..

for(int i=0;i<WKTArray.size();i++)
{
 wkt=WKTArray.next();
 Longitude=wkt[0]
 Latitude=wkt[1];
}

my understanding of arrays represented by [][] is that is a flat array  
any supplied index uses array arithmetic to determine the correct index into the array e.g.
assume this declaration and this population scenario
int [][]foo;
foo[0][0]; //would resolve to 0th entry
foo[0][1]; //would resolve to 1 entry
foo[0][2]; //would resolve to 2 entry 
foo[1][0]; //would resolve to 1*3+0 entry

foo[1][2]; //would resolve to 1*3+2 entry or the 5th entry

the same principal applies to OGNLStack which is a stack of n number of elements pushed onto
the stack

does this conform to your understanding?
Martin Gainty 
______________________________________________ 
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
 
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten
wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist
unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet
keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen
wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire
prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe
quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information
seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les
email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune
responsabilité pour le contenu fourni.




> Date: Tue, 20 Oct 2009 11:04:33 -0600
> Subject: OGNL - Multi-dimensional Array
> From: dan.stephenson@gmail.com
> To: user@struts.apache.org
> 
> Hello everyone,
> 
> I had a question regarding multi-dimensional arrays and how they are handled
> by OGNL (struts2).
> 
> I have the following snippet in my JSP:
> 
> ...
> <input type="text" name="dataCollection[0][0]" id="data00" class="..."
> maxLength="1" size="1"/>
> <input type="text" name="dataCollection[0][1]" id="data01" class="..."
> maxLength="1" size="1"/>
> ...
> 
> On the Action side I have a class variable declared at the top with a
> corresponding setter:
> 
> ...
> private String[][] dataCollection;
> ...
> public void setDataCollection(String[][] dataCollection)
> {
>    this.dataCollection = dataCollection;
> }
> ...
> 
> I haven't had much difficulty handling the output of a two-dimensional array
> such as this, but am unable to figure out the right way of handling this as
> input.  I am using struts 2.0.14.
> 
> Thanks for your assistance.
> 
> Daniel Stephenson
> dan.stephenson@gmail.com
 		 	   		  
_________________________________________________________________
Your E-mail and More On-the-Go. Get Windows Live Hotmail Free.
http://clk.atdmt.com/GBL/go/171222985/direct/01/
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message