Hey Cosmin,

Sorry for not fully understanding what you were trying to achieve. Offhand, I
can't think of a way to get Stripes to bind to a setter with two parameters.
Your solution of binding to a Map and then iterating over the contents to
perform the additional logic doesn't sound bad. Implementing a Map to intercept
the values and performing the logic might work but you already said that you
didn't want to do that, and besides, it would essentially be the same code in a
different place - not a huge gain.

Freddy

- 
- Hey Freddy,
- 
- Thanks for the prompt and detailed reply.
- 
- I know about the map-related bindings as I have some extensive 
- Struts/Struts2 experience. However, I need to perform some logic when 
- binding this value. In other words, I need more than a map. As mentioned 
- earlier, I would like to bind to something like
- 
- setSomething(Gender gender, Double value)
- 
- When method setSomething is called I need to perform some additional 
- logic. I was just wondering if it's possible to bind to something like 
- this, as I don't want to implement a Map for such a small issue.
- 
- As I said, this is not an actual problem as I am using a Map already to 
- which I am binding and then calling setSomething(...) for each entry in 
- the Map. My question is if I have this "option" to improve my code.
- 
- Cosmin
- 
- - 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

Reply via email to