Issue Details (XML | Word | Printable)

Key: STR-2802
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: Oudot Christophe
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Struts 1

Validator validwhen cannot test between two different indices in array

Created: 18/Mar/06 12:54 AM   Updated: 05/Jun/08 06:18 AM
Return to search
Component/s: Core
Affects Version/s: 1.2.8
Fix Version/s: 1.3.10, 1.4.0

Environment:
Operating System: Windows 2000
Platform: PC

Bugzilla Id: 39020


 Description  « Hide
This code in the validator.xml fails with this error : "unexpected token adr.."

  
<field property="adr[0]" depends ="validwhen">
  <var>
      <var-name>test</var-name>
      <var-value>((*this*!=null) or (adr[1] != null ))</var-value>
  </var>
</field>


adr is an array of two adress lines. Only one of them needs tobe filled.
According to the document of the validator, it should work.

 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Niall Pemberton added a comment - 18/Mar/06 01:02 AM
Adding a link to the related thread on the user list:

http://www.mail-archive.com/user%40struts.apache.org/msg43177.html

I had a quick look at the source (ValidWhenParser.g) and I agree it looks like
it should cater for this. I also tried adding a test case (to
TestValidWhen.java) to and got the same result as Christophe.

Don Brown made changes - 23/Apr/06 04:52 AM
Field Original Value New Value
issue.field.bugzillaimportkey 39020 28093
Eric Rizzo added a comment - 21/Aug/06 05:05 PM
Is there any workaround for this bug? I have a similar requirement (need to check for presence of EITHER one field or at least one item in an array field (items selected from an HTML list), but have run into the same issue.
Is there any other way to configure the validator to do this kind of check, at least until this bug gets fixed?

Laird Nelson added a comment - 05/Mar/07 05:09 PM
It's now March 2007; I was wondering if any progress had been made on this bug. I am working on struts 1.3.5, and I encounter the same issue with the following code:

<var-value>((*this* != null) or ((govIDParts[0] == null) and (govIDParts[2] == null)))</var-value>

Niall Pemberton added a comment - 05/Mar/07 05:39 PM
I doubt anyones looking at this - It needs someone to come forward with a patch to fix it

Henri Yandell added a comment - 06/Mar/07 05:18 PM
Do you still have your test case Niall?

Repository Revision Date User Message
Struts #515237 Tue Mar 06 18:17:51 UTC 2007 niallp Add a test case to demonstrate Jira Isssue STR-2802
Files Changed
MODIFY /struts/struts1/trunk/core/src/test/java/org/apache/struts/validator/TestValidWhen.java
MODIFY /struts/struts1/trunk/core/src/test/java/org/apache/struts/validator/PojoBean.java

Niall Pemberton added a comment - 06/Mar/07 06:19 PM
I didn't (I changed machines since then) - but I've re-created one and committed it:

http://svn.apache.org/viewvc?view=rev&revision=515237

Henri Yandell added a comment - 15/Mar/07 10:01 PM

I suspect that the third of the array rules shouldn't have the LBRACKET on the end of it. The problem with both Niall's test and the original report is that neither of them match one of the 5 array rules.

ie:

Index: ValidWhenParser.g
===================================================================
--- ValidWhenParser.g (revision 518754)
+++ ValidWhenParser.g (working copy)
@@ -182,7 +182,7 @@
             Object i3 = argStack.pop();
             argStack.push(ValidatorUtils.getValueAsString(form, i3 + "[" + i4 + "]" + i5));
 }
-| identifier LBRACKET integer RBRACKET LBRACKET {
+| identifier LBRACKET integer RBRACKET {
             Object i7 = argStack.pop();
             Object i6 = argStack.pop();
             argStack.push(ValidatorUtils.getValueAsString(form, i6 + "[" + i7 + "]"));

Repository Revision Date User Message
Struts #520762 Wed Mar 21 05:53:44 UTC 2007 bayard Breaking the build by putting the unit test for STR-2802 fully in
Files Changed
MODIFY /struts/struts1/trunk/core/src/test/java/org/apache/struts/validator/TestValidWhen.java

Repository Revision Date User Message
Struts #520763 Wed Mar 21 05:57:10 UTC 2007 bayard Fixing STR-2802 by removing the unnecessary LBRACKET. Test now passes and I don't understand what the LBRACKET would have been there for so I think it was just an error that's been in there forever and ever.
Files Changed
MODIFY /struts/struts1/trunk/core/src/main/java/org/apache/struts/validator/validwhen/ValidWhenParser.java
MODIFY /struts/struts1/trunk/core/src/main/java/org/apache/struts/validator/validwhen/ValidWhenParser.g

Henri Yandell added a comment - 21/Mar/07 05:59 AM
 svn ci -m "Fixing STR-2802 by removing the unnecessary LBRACKET. Test now passes and I don't understan
d what the LBRACKET would have been there for so I think it was just an error that's been in there forever and ever. " src/
Sending src/main/java/org/apache/struts/validator/validwhen/ValidWhenParser.g
Sending src/main/java/org/apache/struts/validator/validwhen/ValidWhenParser.java
Transmitting file data ..
Committed revision 520763.

Henri Yandell made changes - 21/Mar/07 05:59 AM
Fix Version/s 1.4.0 [ 21795 ]
Status Open [ 1 ] Closed [ 6 ]
Resolution Fixed [ 1 ]
Assignee Struts Developers [ dev@struts.apache.org ]
Niall Pemberton added a comment - 10/Sep/07 10:41 PM
The fix for STR-3088 has also back-ported the fix for this issue into the 1.3 Branch - see revision 569606:

http://svn.apache.org/viewvc?view=rev&revision=569606

Niall Pemberton made changes - 10/Sep/07 10:41 PM
Fix Version/s 1.4.0 [ 21795 ]
Fix Version/s 1.3.10 [ 21840 ]
Paul Benedict made changes - 10/Sep/07 11:28 PM
Summary Validator validwhen :Cannot make dependance between two different index in an Array Validator validwhen cannot test between two different indices in array
Paul Benedict made changes - 05/Jun/08 06:18 AM
Fix Version/s 1.4.0 [ 21795 ]