Re: Mapping multiple enums to a nested object

2007-09-25 Thread Guillaume Bilodeau
Ok that clears things up. I'll sit down and try to write this down now. Thanks for all the help guys! GB cilquirm wrote: > > Doesn't seem that way. > One converts a single string value to an enum, and the other converts a > String[] to a List > > I just checked it over and it's not directly

Re: Mapping multiple enums to a nested object

2007-09-25 Thread cilquirm
Doesn't seem that way. One converts a single string value to an enum, and the other converts a String[] to a List I just checked it over and it's not directly useable because it's a type converter for a specific enum ( OperationsEnum ), but the principles apply. The long and the short of is that

Re: Mapping multiple enums to a nested object

2007-09-25 Thread Dave Newton
--- Guillaume Bilodeau <[EMAIL PROTECTED]> wrote: > So you're saying that the showcase EnumTypeConverter > isn't the same as the one provided in XWork2? The showcase converter specifically handles conversions to/from Lists; the XWork converter converts to/from Strings. It is poorly named, perhaps,

Re: Mapping multiple enums to a nested object

2007-09-25 Thread Guillaume Bilodeau
So you're saying that the showcase EnumTypeConverter isn't the same as the one provided in XWork2? cilquirm wrote: > > Indeed, the problem is that EnumTypeConverter, as provided by Struts2 > only works for single values. > > Can you make selectedNutrients a List? > > If so, you might be able

Re: Mapping multiple enums to a nested object

2007-09-25 Thread cilquirm
Indeed, the problem is that EnumTypeConverter, as provided by Struts2 only works for single values. Can you make selectedNutrients a List? If so, you might be able to use the EnumTypeConverter from the showcase app, or roll your own based off it, which isn't that hard at all. org.apache.struts

Re: Mapping multiple enums to a nested object

2007-09-25 Thread Guillaume Bilodeau
Yes I tried that, with no success unfortunately. Somehow we need to specify that: 1- selectedNutrients[] will need to be mapped to an array of Nutrients 2- each element of selectedNutrients[] must be mapped using EnumTypeConverter cilquirm wrote: > > Are enums type-converted automatically now?

Re: Mapping multiple enums to a nested object

2007-09-25 Thread cilquirm
Are enums type-converted automatically now? I recall early on I had to specify http://struts.apache.org/2.0.9/struts2-core/apidocs/com/opensymphony/xwork2/util/EnumTypeConverter.html Have you tried specifying that? with Element_selectedNutrients = com.opensymphony.xwork2.util.EnumTypeConvert

Re: Mapping multiple enums to a nested object

2007-09-25 Thread Guillaume Bilodeau
I've done some further debugging and here's what I now know: 1. I was able to bind TypeConverters to the model.group and model.selectedNutrients properties by creating a SimpleFoodCreationRequest-conversion.properties with the following lines: group=com.opensymphony.xwork2.util.EnumTypeConverter

Re: Mapping multiple enums to a nested object

2007-09-24 Thread Guillaume Bilodeau
Hey no problem, I'm kind of sluggish also :) It's true that I could use a different method name to expose the nested object, it does bring some confusion. Somehow the group converter seems to work fine, so I don't understand why the nutrients doesn't. I'm knee-deep in OGNL code to see exactly wh

Re: Mapping multiple enums to a nested object

2007-09-24 Thread Dave Newton
Whoops! Guillaume Bilodeau wrote: > 1- I'm using "food.name" as the text field key - not > as its name - so a localized label will be shown next > to it. You're right; I didn't even see that. > 2- I thought the action itself was pushed on the > value stack and that one could reference and bind

Re: Mapping multiple enums to a nested object

2007-09-24 Thread Guillaume Bilodeau
Ok, as I said I'm new to Struts2 so maybe I made some wrong assumptions. Please correct me if I'm wrong: 1- I'm using "food.name" as the text field key - not as its name - so a localized label will be shown next to it. 2- I thought the action itself was pushed on the value stack and that one coul

Re: Mapping multiple enums to a nested object

2007-09-24 Thread Dave Newton
--- Guillaume Bilodeau <[EMAIL PROTECTED]> wrote: > Yes it was deliberate. I'm not sure I see the > advantages of flattening my action *and* my request > object, for now I'd rather keep this nested as it > currently is. Of course I'll change my mind if > given the right counter-arguments :) The

Re: Mapping multiple enums to a nested object

2007-09-24 Thread Guillaume Bilodeau
Yes it was deliberate. I'm not sure I see the advantages of flattening my action *and* my request object, for now I'd rather keep this nested as it currently is. Of course I'll change my mind if given the right counter-arguments :) newton.dave wrote: > > --- Guillaume Bilodeau <[EMAIL PROTECTE

Re: Mapping multiple enums to a nested object

2007-09-24 Thread Dave Newton
--- Guillaume Bilodeau <[EMAIL PROTECTED]> wrote: > The action has a SimpleFoodCreationRequest getModel() > method which should expose the request object to > the JSP. The Action code you posted does not implement ModelDriven; was that a deliberate omission? > Action: > public class CreateSimpleF

Re: Mapping multiple enums to a nested object

2007-09-24 Thread Guillaume Bilodeau
Hi Adam, The action has a SimpleFoodCreationRequest getModel() method which should expose the request object to the JSP. However you are right that it doesn't have any setter, but is it really necessary since all bindings are done on the nested request object? Thanks, GB Adam Hardy-3 wrote:

Re: Mapping multiple enums to a nested object

2007-09-24 Thread Adam Hardy
Guillaume, I don't see a Food getter and setter on your action. Guillaume Bilodeau on 23/09/07 18:48, wrote: Hi all, I'm quite new to Struts2 and so far I love what I see. Currently I'm having a problem trying to map a checkboxlist based on a set of enums to a model object nested in my action

Re: Mapping multiple enums to a nested object

2007-09-23 Thread Guillaume Bilodeau
Looks like the JSP code doesn't show. Here it is: [s:form action="createSimpleFood.go" method="post" namespace="/nutrition"] [s:textfield key="food.name" name="model.name" /][br/] [s:select key="food.group" name="model.group" list="availableGroups" /]