PDA

View Full Version : Valang bug when accessing list element?


imilina
Jun 16th, 2006, 04:59 AM
I've posted similar thread few months ago, but got no reply...

Has anyone successfully made valang access list elements? Documentation says that this can be done using syntax like:

users[0].name = 'Steven'

but when I try to implement this I get parse exception: Encountered "[0]" at line 7, column 79.

I'm using valang from spring modules 0.4

uboness
Jun 18th, 2006, 02:41 PM
Hi,

Thanks for the input... I just fixed this issue and it will be availabe in 0.5.

cheers,

Uri

marvi
Jun 21st, 2006, 01:03 AM
I have the same issue with Map access. Is that also covered by the fix?

marvi
Jun 21st, 2006, 04:13 AM
I get an error on this expression with latest code from CVS:
{ currentPage : validatedParameters[Test1] == 'test1-value' : 'Should be equal' }

java.lang.RuntimeException: org.springmodules.validation.valang.parser.ParseEx ception: Encountered "[Test1]" at line 1, column 36.
Was expecting one of:
<BETWEEN> ...

Costin Leau
Jun 21st, 2006, 08:00 AM
Please raise an issue on JIRA (http://opensource.atlassian.com/projects/spring/browse/MOD) as it is easier to keep track of it. thanks.

uboness
Jun 21st, 2006, 04:36 PM
hi marvi,

I cannot seem to be able to reproduce the parse error you get. In fact, I shouldn't be able to do so since the map access should be working in release 0.4. Can you be even more specific about your test/setting? perhaps you have an old valang jar in you classpath?

cheers,

Uri

marvi
Jun 25th, 2006, 12:48 PM
Hi Uri!

I checked out the new testcase and it works for me too. But if I copy and paste my expression into your testcase and rerun the test I get a ParseException.

If I take your test expression and copies that into my code it parses without error, and I get the expected NotReadablePropertyException.

I have tried to see if there is some strange character inside my expression, but it looks good. What happens if you try this test case:


public void testParser57MapAccess() {
String text = "{currentPage : validatedParameters[Test1] EQUALS 'test1-value' : 'Should be equal'}";
assertTrue(validate(new Person(10, "Uri"), text));
}

uboness
Jun 25th, 2006, 07:43 PM
well... I figured out the problem. It seems that the valang parser was originally configured to only allow keys that start with a lower case or an underscore letter. This is the reason for the parse exception in your example where the key is 'Test1' with a capital 'T'. I'll try to fix it so it will be possible to set any value as the key (I'll first need to make sure this change won't break anything ;)).

Thanks for the input,

Uri

marvi
Jun 25th, 2006, 10:25 PM
Thanks for looking into this, Uri!