Asleson, Ryan wrote:
Hello, I am new to Struts 2, so please bear with me. I am looking at implementing a custom StrutsTypeConverter. I want it to
be a "global" converter (no just specific to an Action).  If I'm
understanding it correctly, to implement this I create an
xwork-conversion.properties file, and the format of this file is like
this:
com.domain.SomeCustomType=com.domain.SomeCustomTypeConverter where SomeCustomTypeConverter implements StrutsTypeConverter. First
question:  Is this correct?
Yes. I added some new notes to that page today stating exactly that: http://struts.apache.org/2.x/docs/type-conversion.html

Next question:  How well does this handle subclassing?  Here's what I
mean:
Suppose I have an abstract com.domain.SomeAbstractClass type that has
many subclasses, and it's these subclasses that I actually need to
convert.  I want to have an entry like this in
xwork-conversion.properties:
com.domain.SomeAbstractClass=com.domain.SomeAbstractClassConverter Where SomeAbstractClassConverter is smart enough to convert any instance
of SomeAbstractClass.  For this to happen, the Class that is sent to the
convertFromString method must be the class of the actual
SomeAbstractClass subclass, not the SomeAbstractClass. Is this what happens at runtime? Is the class that is sent to
convertFromString the actual class that is being converted, or the class
that is listed in the .properties file?  Will Struts2 use the
SomeAbstractClass converter for a subclass of SomeAbstractClass even if
it's not explicity defined in the .properties file?
Thank you!!
Yes. From the javadoc:
* Looks for converter mappings for the specified class, traversing up its class hierarchy and interfaces and adding * any additional mappings it may find. Mappings lower in the hierarchy have priority over those higher in the
* hierarcy.




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to