Hi Cosmin,
You know the old saying: the only idiotic question is the one that you
have but do not ask. :)
With your property of type Map<SomeEnum, Double>, you can indeed bind
with something['enumValue']. In this case, 'enumValue' must be one of
the values that you defined in SomeEnum, case sensitive. Stripes will
convert 'enumValue' to SomeEnum using its EnumeratedTypeConverter
(you'll find it in the net.sourceforge.stripes.validation package) and
the value to Double with DoubleTypeConverter.
For example, if you have
public enum Gender {
Female,
Male
}
and a property:
private Map<Gender, Double> map;
public Map<Gender, Double> getSomething() { return map; }
public void setSomething(Map<Gender, Double> map) { this.map = map; }
You could bind with:
<s:text name="something['Female']"/>
The value entered would be converted to a Double and bound to the map
with key Female from the Gender enum.
Let me know if that helps.
Cheers,
Freddy
http://www.stripesbook.com
-
- Hello everyone,
-
- I first want to congratulate Tim Fennell and all Stripes contributors
- for the great work they've done. I started to migrate a Struts2
- application to Stripes and I must say: I'm impressed about the level of
- integration with the standards (a section at which Struts2 sucks) and
- also about the programming model. First impression is great. Great work.
-
- I came here though also to ask for a small (and idiotic) question. I am
- trying to bind a property with a non-basic type. For this I already have
- a method on my DTO
-
- public void setSomething(SomeEnum enumValue, Double someValue) {
- // create and store a type storing enum and value
- }
-
- In other words there is some logic that must be performed when setting
- such a Double. I am currently exposing a Map<SomeEnum, Double> and I am
- converting it manually inside the action. This works for me and the
- solution is "decent". However, I was wondering if Stripes has ways of
- binding to such methods. For example, if we have a getMap() we can bind
- to map['key']. I was wondering if for my above function I would be able
- to bind in a similar way: something['enumValue'].
-
- Thanks,
- Cosmin
-------------------------------------------------------------------------
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