[Fwd: Map property validation and error messages]

View: New views
3 Messages — Rating Filter:   Alert me  

[Fwd: Map property validation and error messages]

by cosminaru :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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
Stripes-users@...
https://lists.sourceforge.net/lists/listinfo/stripes-users

Re: [Fwd: Map property validation and error messages]

by Poitras Christian :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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:cosminaru@...]
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
Stripes-users@...
https://lists.sourceforge.net/lists/listinfo/stripes-users

Re: [Fwd: Map property validation and error messages]

by cosminaru :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks for the reply.
I indeed implemented a validation method from the begining. Just wokndering if there's a better way. It seems not :)

Thanks,
Cosmin
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 [cosminaru@...]
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 Stripes-users@... https://lists.sourceforge.net/lists/listinfo/stripes-users


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
Stripes-users@...
https://lists.sourceforge.net/lists/listinfo/stripes-users
LightInTheBox - Buy quality products at wholesale price!