This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Rust Web Development and have Bastian Gruber on-line!
See this thread for details.
Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Validator with 3 fields, 1 element required

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello and sorry for my english. I have an form with 3 field (type Multibox) where user can select or not select, but must select at least one in total

//Situaciones Juego Ataque
<html:multibox property="sjuegoa" value="1x0"/>1x0
<html:multibox property="sjuegoa" value="1x1"/>1x1
<html:multibox property="sjuegoa" value="1x2"/>1x2

//Situaciones Juego Defensa
<html:multibox property="sjuegod" value="1x0"/>1x0
<html:multibox property="sjuegod" value="1x1"/>1x1
<html:multibox property="sjuegod" value="1x2"/>1x2

//Situaciones Juego Mixto
<html:multibox property="sjuegom" value="1x0"/>1x0
<html:multibox property="sjuegom" value="1x1"/>1x1
<html:multibox property="sjuegom" value="1x2"/>1x2

I have seen Struts have the rule "validwhen" but my code don�t work fine. For example, i trying check at least Atack or Defend aren�t null:

<field property="sjuegoa" depends="validwhen">
<arg0 name="validwhen" key="campo.situaciones"/>
<var>
<var-name>test</var-name>
<var-value>(sjuegod == null) and (*this* == null)</var-value>
</var>
</field>

<field property="sjuegod">
<arg0 key="campo.sjuegod"/>
</field>

This code work semi-fine, the message i need appear but in console appear:

line 1:19: expecting EOF, found 'and'
at antlr.Parser.match(Parser.java:213)
at org.apache.struts.validator.validwhen.ValidWhenParser.expression(ValidWhenParser.java:370)

If i put brackets, the error don�t appear but the message that i need don�t appear:

<var-value>((sjuegod == null) and (*this* == null))</var-value>

�Any idea? I use Struts 1.2.4
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to put the arg/key tag within the tags that do the validating. You are putting it in a separate tag that does no validation.
 
Manuel Sanchez Iba�ez
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don�t understand your idea. Finally, i have written other validation in validation-rules.xml and i can verify well that 3 fields aren�t null.

Thanks for your interest.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic