struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ravi_eze <>
Subject Re: Type converters: convertToString not called
Date Thu, 31 Jan 2008 12:29:32 GMT


thanks for the reply. If the design had this behavior intended then probably
we cannot do any thing.... but in that case i would not agree with the
design. I read the post linked below and also the bug... but still unable to
understand the reason behind for such a design. 

i think i will now have to redesign my application.

thanks for all your help


jimski wrote:
> Hi Ravi-
> I think the problem here is how the struts2 tags were implemented.  As far
> as I can see from the code base the type converter definition you're
> referring to is used by the XWork API and not OGNL.  The XWork api is used
> by the Struts Tags which have the option to call the converter or not.  In
> the case of rendering content, the option chosen by the designers is not
> to call the converter and call toString() instead.  Check out this bug
> report for more details.
> I asked a question about this:
> (

> ...and it seems like a community generated patch is probably the only way
> forward at this point.  I started looking into it, but my day job has been
> way too busy to give me any time to actually code a patch.  There's also a
> question on my part as to whether or not the patch would even be accepted
> given that 2.0.6 supported type conversion at render time and the core
> struts2 dev team has explicitly chosen to remove this feature (as
> mentioned by Don Brown in the referenced bug report).  
> ravi_eze wrote:
>> hi,
>> We have Action class with Employee Object with setters and getters. The
>> Typeconverter was configured to be called when <EmployeeObject.empId> is
>> called by the jsp page. We found that convertFromString of type converter
>> is being called but convertToString is never called. Any idea why this is
>> happening? The details are as follows:
>> Type converter:
>> public class LongConverter extends StrutsTypeConverter {
>> 	public Object convertFromString(Map context, String[] values, Class
>> toClass) {
>>          ... ....
>> 	}
>> 	public String convertToString(Map context, Object o) {
>>         ... ....
>> 	}
>> }
>> in located along with the class file in
>> the same package:
>> employee.empId=com.comp.util.converter.LongConverter
>> After some debugging we found that we need to add a new file:
>> in the same package of Employee class with
>> entries: 
>> empId=com.comp.util.converter.LongConverter
>> and only then the convertToString would be called. I think we should have
>> only one conversion.prop file instead of 2. Any ideas why this is
>> happening this way? or am i missing any thing? please help. 
>> cheers,
>> ravi

View this message in context:
Sent from the Struts - User mailing list archive at

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message