struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Allen, Daniel" <Daniel.Al...@kbcfp.com>
Subject RE: 2 Dimensional arrays?
Date Fri, 09 May 2008 17:35:58 GMT
Hmm. I don't know of a way to make Struts 2 give back 2-D array
properties in the auto-magical way that it will do 1-D arrays (doesn't
mean there's not one: I keep finding out that a lot of things I want to
do can be done by magic if you know the correct XML incantation) but
perhaps you could sidestep this with JSON? I'm not particularly familiar
with AJAX stuff, but my understanding is that JSON can encode any
arbitrary object possible in JavaScript. That could potentially entail a
large number of changes, though... 

Or, another JavaScript solution, one that doesn't entail switching to
any kind of AJAX, would be to have a script that concatenates all of one
row's values into a single string, and then have a single-dimensional
array property. Sort of wasteful in that processing time is spent
composing and then parsing back to the original state, but I think it
would serve your purpose.

HTH,
~DVA

-----Original Message-----
From: Michael Gagnon [mailto:mgagnon@genome.med.harvard.edu] 
Sent: Friday, May 09, 2008 11:36 AM
To: user@struts.apache.org
Subject: 2 Dimensional arrays?

Is it possible to get back 2D arrays from a form?

 

I want to be able to have a table with some number of rows. Each row has
a
'grouping' field which the user can enter a number in. Each row will
also
have a dynamic 'foo' column which will have a button to add additional
'foo'
values. Some javascript will drop in new 'foo' textfields on a given row
whenever that row's button is clicked.

 

I want to be able to collect an int[] grouping array, which is straight
forward. Iterating over a collection to create textfields will let me
get an
int[] in my action which will be the list of groupings indexed by row
(so
grouping[0] yields the entered value for the first row, grouping[3]
yields
the entered value for the fourth row, etc.)

 

I also want to be able to collect an int[][] foo array. This should be
an
int[] array of foo values indexed by row. This is less straightforward
and
I'm not sure how to approach this. Are there any sorts of similar
examples
to this floating around?


-- 
This message may contain confidential, proprietary, or legally privileged information. No
confidentiality or privilege is waived by any transmission to an unintended recipient. If
you are not an intended recipient, please notify the sender and delete this message immediately.
Any views expressed in this message are those of the sender, not those of any entity within
the KBC Financial Products group of companies (together referred to as "KBC FP"). 

This message does not create any obligation, contractual or otherwise, on the part of KBC
FP. It is not an offer (or solicitation of an offer) of, or a recommendation to buy or sell,
any financial product. Any prices or other values included in this message are indicative
only, and do not necessarily represent current market prices, prices at which KBC FP would
enter into a transaction, or prices at which similar transactions may be carried on KBC FP's
own books. The information contained in this message is provided "as is", without representations
or warranties, express or implied, of any kind. Past performance is not indicative of future
returns.


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


Mime
View raw message