I think the only way to acheive this is by using a validation method.

@ValidationMethod
public void validateMyMap() {
  for (Enum e : myEnum) {
    if (!myMap.contains(e)) {
      context.getValidationErrors().add("myMap[" + e + "]", new 
LocalizableError("<actionPath>.myMap." + e + ".invalidNumber"));
    }
  }
}


As far as I know, Stripes looks for <actionPath>.myMap.invalidNumber for error 
message... So you cannot customize it for each enum.

Christian

________________________________
From: Cosmin Marginean [mailto:[EMAIL PROTECTED]
Sent: Wednesday, October 08, 2008 2:57 AM
To: Stripes Users List
Subject: [Stripes-users] [Fwd: Map property validation and error messages]

Hi,

I am not sure if this slipped or I just didn't get any feedback. Anyways, just 
wanted to know if it's possible to force a required value for maps in the 
situation below

Thanks,
Cosmin

----
Hello all,

I am using a property on my action:

private Map<SomeEnum, Double> myMap;

that is rendered as an indexed property:

<stripes:text name="myMap['EnumValue1']"/>
<stripes:text name="myMap['EnumValue2']"/>
etc.

I would like to perform validation on the Double values in the map (so they are 
all required for each value in the enum) and I would also like to customize the 
error message when conversion or validation fails for each of the enum values 
separately (apparently <action_path>.myMap['EnumValue1'].invalidNumber is not 
beeing looked up at all).

Thanks in advance,
Cosmin


Cosmin Marginean

--
cosminaru.ro


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to