You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Reinhard Nägele <re...@mgm-edv.de> on 2004/12/21 16:06:04 UTC

validwhen expression parsing anomaly

I set up the following expression for a validwhen validation rule, which 
produces the exception below:

<![CDATA[((*this* >= 1) and (*this* <= 6) and (*this* != null))]]>

Inserting parentheses that should not be necessary solves the issue:

<![CDATA[(((*this* >= 1) and (*this* <= 6)) and (*this* != null))]]>

I do actually consider this a bug. Should I enter one into the bug database?

I'm using Struts 1.2.4 final.

BTW, the last validwhen example in the validator guide doesn't put the 
expression in CDATA. Could someone please correct this?

Thanks,
Reinhard


line 1:34: expecting RPAREN, found 'and'
at antlr.Parser.match(Parser.java:213)
at 
org.apache.struts.validator.validwhen.ValidWhenParser.expr(ValidWhenParser.java:384)
at 
org.apache.struts.validator.validwhen.ValidWhenParser.expression(ValidWhenParser.java:369)
at 
org.apache.struts.validator.validwhen.ValidWhen.validateValidWhen(ValidWhen.java:114)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at 
org.apache.commons.validator.ValidatorAction.executeValidationMethod(ValidatorAction.java:567)
at org.apache.commons.validator.Field.validateForRule(Field.java:811)
at org.apache.commons.validator.Field.validate(Field.java:890)
at org.apache.commons.validator.Form.validate(Form.java:174)
at org.apache.commons.validator.Validator.validate(Validator.java:367)
at 
org.apache.struts.validator.DynaValidatorForm.validate(DynaValidatorForm.java:112)
at 
org.apache.struts.action.RequestProcessor.processValidate(RequestProcessor.java:921)
<snip />






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


Re: validwhen expression parsing anomaly

Posted by Reinhard Nägele <re...@mgm-edv.de>.
See inline.

Matt Bathje wrote:

> Reinhard Nägele wrote:
>
>> I set up the following expression for a validwhen validation rule, 
>> which produces the exception below:
>>
>> <![CDATA[((*this* >= 1) and (*this* <= 6) and (*this* != null))]]>
>>
>> Inserting parentheses that should not be necessary solves the issue:
>>
>> <![CDATA[(((*this* >= 1) and (*this* <= 6)) and (*this* != null))]]>
>>
>> I do actually consider this a bug. Should I enter one into the bug 
>> database?
>>
>> I'm using Struts 1.2.4 final.
>
>
>
> This is a "feature", not a bug - see that second to last bullet point 
> in the validwhen section of:
> http://struts.apache.org/userGuide/dev_validator.html
>
> which says:
> - Only two items may be joined with and or or
>
>
> Very weird, but it is also the documented behavior of validwhen.


I must have overlooked this. Sorry about that. However, I'm kind of 
curious why this is. Could anyone shed some light please?

>>
>> BTW, the last validwhen example in the validator guide doesn't put 
>> the expression in CDATA. Could someone please correct this?
>>
>
> I don't see any of the validwhen examples enclosed in CDATA tags. Am I 
> missing something? I am referencing the same page as above.


Yes, you don't see them because they are not there where they should be. ;-)

Wrong (as in the guide), because of the ">"):

|<var-value>((heightInInches >= 60) or (*this* == null))</var-value>


Correct:

||<var-value>|<![CDATA[|((heightInInches >= 60) or (*this* == null))]]></var-value>|


Reinhard


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


Re: validwhen expression parsing anomaly

Posted by Matt Bathje <mp...@ntsource.com>.
Reinhard Nägele wrote:
> I set up the following expression for a validwhen validation rule, which 
> produces the exception below:
> 
> <![CDATA[((*this* >= 1) and (*this* <= 6) and (*this* != null))]]>
> 
> Inserting parentheses that should not be necessary solves the issue:
> 
> <![CDATA[(((*this* >= 1) and (*this* <= 6)) and (*this* != null))]]>
> 
> I do actually consider this a bug. Should I enter one into the bug 
> database?
> 
> I'm using Struts 1.2.4 final.


This is a "feature", not a bug - see that second to last bullet point in 
the validwhen section of:
http://struts.apache.org/userGuide/dev_validator.html

which says:
- Only two items may be joined with and or or


Very weird, but it is also the documented behavior of validwhen.



> 
> BTW, the last validwhen example in the validator guide doesn't put the 
> expression in CDATA. Could someone please correct this?
> 

I don't see any of the validwhen examples enclosed in CDATA tags. Am I 
missing something? I am referencing the same page as above.


Matt

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