You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Daniel Stephenson <da...@gmail.com> on 2009/10/20 19:04:33 UTC

OGNL - Multi-dimensional Array

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

Re: Live data update coming from a server

Posted by Paweł Wielgus <po...@gmail.com>.
Hi Zied,
if that's just one and only thing that this app will be doing i
wouldn't choose struts for this task,
i would use swing or swt. And that's because struts is based on http
protocol which is made for downloading data from server only when
client wants it, i'm not claiming that this can't be done, with ajax
or so called comet but i would use swing or swt for this task.
Of course if your app have more to do or to conform with it might be
reasonable to use struts.

Best greetings,
Paweł Wielgus.


2009/10/20 bejaoui zied <be...@hotmail.com>:
>
> Hi guys,
>
>
>
> I have a general enquiry and hope that you will be able to help me.
>
> I would like to build an application that receive date from a server and update it in the users interface, data will be sent frequentley and has to be updated in real time.
>
> Is it ok ti use struts for this application?
>
> And any idea about a genral method for implemeting this.
>
> ZIED BEJAOUI
> Tel: 0044(0)7506628905
>
>
>
>
>
>
>
> _________________________________________________________________
> A la recherche de bons plans pour une rentrée pas chère ? Bing ! Trouvez !
> http://www.bing.com/search?q=bons+plans+rentr%C3%A9e&form=MVDE6

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


Live data update coming from a server

Posted by bejaoui zied <be...@hotmail.com>.
Hi guys,

 

I have a general enquiry and hope that you will be able to help me.

I would like to build an application that receive date from a server and update it in the users interface, data will be sent frequentley and has to be updated in real time.

Is it ok ti use struts for this application?

And any idea about a genral method for implemeting this. 

ZIED BEJAOUI
Tel: 0044(0)7506628905





 
 		 	   		  
_________________________________________________________________
A la recherche de bons plans pour une rentrée pas chère ? Bing ! Trouvez !
http://www.bing.com/search?q=bons+plans+rentr%C3%A9e&form=MVDE6

RE: OGNL - Multi-dimensional Array

Posted by Martin Gainty <mg...@hotmail.com>.

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/

Re: OGNL - Multi-dimensional Array

Posted by Daniel Stephenson <da...@gmail.com>.
Thanks for both of the replies.  I got caught up working on some other stuff
and was just barely able to come back to this issue.  The original error I
was receiving was the following:

...
2009-10-20 14:55:33,745 ERROR
com.opensymphony.xwork2.util.InstantiatingNullHandler - Could not create
and/or set value back on to object
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name '[[Ljava.lang.String;': Could not resolve matching constructor
...

It took me about 5 seconds to figure out what I was doing wrong :)  I was
not initializing the two-dimensional array so when it went to set the values
on the array it was blowing up with the above error.  So, just to test this
out, I created the class variable as follows:

...
private String[][] dataCollection = new String[100][100];
...

Hopefully it won't be a stretch for me to figure out how to initialize this
dynamically so that I get the proper-sized array!

Thanks again for help from both you.

Daniel Stephenson
dan.stephenson@gmail.com
208.284.9637 - Cell
208.375.3888 - Office
208.498.2033 - Fax

On Tue, Oct 20, 2009 at 12:42 PM, Musachy Barroso <mu...@gmail.com> wrote:

> what kind of problem are you having? Is it not calling
> "setDataCollection" at all? or are you not getting the expected values
> in the array?
>
> musachy
>
> On Tue, Oct 20, 2009 at 10:04 AM, Daniel Stephenson
> <da...@gmail.com> wrote:
> > 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
> >
>
>
>
> --
> Screw John Galt, who is Martin Gainty?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: OGNL - Multi-dimensional Array

Posted by Musachy Barroso <mu...@gmail.com>.
what kind of problem are you having? Is it not calling
"setDataCollection" at all? or are you not getting the expected values
in the array?

musachy

On Tue, Oct 20, 2009 at 10:04 AM, Daniel Stephenson
<da...@gmail.com> wrote:
> 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
>



-- 
Screw John Galt, who is Martin Gainty?

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