Ouch. Any chance you could log this as a bug ?
I've got some crazy plans I keep debating wrt to ognl enhancements so
this would probably be a good place for them.
On 12/15/06, Jim Steinberger <[EMAIL PROTECTED]> wrote:
Just wanted to give a heads up on a gotcha I ran into.
The "index" value of the "foreach" tag is stored as a String, not an
integer, so be careful when using it to, say, index into an array.
e.g. If you have a two-dimensional array stored in the input-symbol
"matrix", the following will work fine:
${matrix[0].length}
But the following, where "matrixIndex" is the symbol used for a
surrounding "foreach"-tag's "index" value, will throw an error:
${matrix[matrixIndex].length}
The error will tell you that "matrix" does not have the property: 0.
i.e. since matrixIndex is a String, it's looking for a property of the
array-object named "0".
This issue hadn't hit me before because OGNL casts it automatically when
used in expressions like: "${matrixIndex > 0}". But since a
String-input is valid as a [] parameter in OGNL, it doesn't know to cast
it.
I used the workaround:
[EMAIL PROTECTED]@parseInt(matrixIndex)].length}
Jim
--
Jesse Kuhnert
Tapestry/Dojo team member/developer
Open source based consulting work centered around
dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]