tags:

views:

240

answers:

1

I have a form with (at the moment) two fields and submit the following:

capture.id = 213
capture.description = DescriptionText

The target object 'capture' is immutable and I would like to provide a type converter to take both values and call the constructor. What I cannot seem to do is get by TypeConverter to be invoked.

If the input is simply:

capture = foo

Then the type converter is called, but obviously this isn't much use, is there away to make a ognl delegate the rest of the rest of the type conversation to me, perhaps passing in a Map of the parameters?

Any ideas? Is this even possible in struts2

versions: struts 2.0.14 & ognl 2.6.11

EDIT: I've done a bit of reading on this and my next attempt seemed to me to be a good plan. My theory was that using the Map syntax would make Ognl convert the values to a map and then call my converter with that map to convert it to my value.

capture[id] = 213
capture[description] = DescriptionText

Nope that doesn't seem make any difference at all.

A: 

It seems the that the answer is no you can't do that with struts2.

I've posted this question on the struts2 mailing list and it seems that it just isn't possible to have multiple fields be presented to a TypeConverter.

The alternative solution suggested is to have mutable object with setters and then have some form of 'petify' method to prevent any future changes.

For my project I've actually implemented another struts Interceptor to implement my custom parameter binding behaviour.

Gareth Davis