Re: Overwrite a TypeConverter for a Map with Generics

2015-02-23 Thread Christoph Nenning
 Hello,
 how can i overwrite a TypeConverter for a Map?
  
 I defined the following global TypeConverter:
 java.lang.String=de..converter.StringTrimConverter
 (the converter removes blanks from the string)
  
 This converter is used for every String, even inside maps. That's fine.
  
 In one action i use the following map:
 MapString, String textfield = ...
 How can i use the default/another String converter for this property?
 Using a properties file for the action doesn't work. The Entry 
 Element_textfield is not used because i use Generics.
  
 Thanks
 Andreas
 
 -
 To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
 For additional commands, e-mail: user-h...@struts.apache.org
 



You can annotate the setter for that field, e.g.:


@TypeConversion(converter = my.package.TextfieldConverter)
public void setTextfield(MapString, String textfield)


and of course you have to implement your own converter:

public class TextfieldConverter extends StrutsTypeConverter


regards,
Christoph

This Email was scanned by Sophos Anti Virus


Re: Aw: Re: Overwrite a TypeConverter for a Map with Generics

2015-02-23 Thread Christoph Nenning
 Hello,
 thanks for your answer. Have you tried your solution and got it 
 working? I already tried that before, but it always picked up the 
 global converter de..converter.StringTrimConverter. But maybe i 
 did something wrong.
 
 I tried it with @TypeConversion(rule = ConversionRule.MAP, converter
 = de.converter...) (with annotations and also with a class-
 specific conversion-properties file).
 
 If a specify a class name that does not exists, i get an exception. 
 But if i use a class that exists, that class is not used for conversion.
 
 I tried to debug DefaultObjectTypeDeterminer: it's looking for an 
 @Element annotation. The class-specific properties file 
 (Element_textfield) will only be used if i don't use generics.
 
 Or do i need to implement a Map-Converter instead of a String-Converter?
 
 Thanks
 Andreas
  
  


Well, I did not use it for collection types. So you can try with a 
MapConverter. And I think those converters are used for saving only, not 
for rendering html. Try to annotate the getter, too.



Regards,
Christoph

This Email was scanned by Sophos Anti Virus


Aw: Re: Overwrite a TypeConverter for a Map with Generics

2015-02-23 Thread Andreas Sachs
Hello,
thanks for your answer. Have you tried your solution and got it working? I 
already tried that before, but it always picked up the global converter 
de..converter.StringTrimConverter. But maybe i did something wrong.

I tried it with @TypeConversion(rule = ConversionRule.MAP, converter = 
de.converter...) (with annotations and also with a class-specific 
conversion-properties file).

If a specify a class name that does not exists, i get an exception. But if i 
use a class that exists, that class is not used for conversion.

I tried to debug DefaultObjectTypeDeterminer: it's looking for an @Element 
annotation. The class-specific properties file (Element_textfield) will only be 
used if i don't use generics.

Or do i need to implement a Map-Converter instead of a String-Converter?

Thanks
Andreas
 
 

-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



Overwrite a TypeConverter for a Map with Generics

2015-02-22 Thread Andreas Sachs
Hello,
how can i overwrite a TypeConverter for a Map?
 
I defined the following global TypeConverter:
java.lang.String=de..converter.StringTrimConverter
(the converter removes blanks from the string)
 
This converter is used for every String, even inside maps. That's fine.
 
In one action i use the following map:
MapString, String textfield = ...
How can i use the default/another String converter for this property?
Using a properties file for the action doesn't work. The Entry 
Element_textfield is not used because i use Generics.
 
Thanks
Andreas

-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org