You can specify attributes as constructor arguments, but you can't pass in an arbitrary value.
http://castor.codehaus.org/xml-mapping.html#7.3-Mapping-constructor-arguments
--Keith
Bryan LaPlante wrote:
Never mind, I just put a call to super(EventObject.class) into an no argument constructor so that it could be marshaled and still satisfy the EventObject contract. It would be nice if I could handle this in the mapping file or a custom FieldHandler so that I don't have to find another way to enforce my contracts for the application.
Bryan
----- Original Message ----- From: "Bryan LaPlante" <[EMAIL PROTECTED]> To: <[email protected]> Sent: Wednesday, February 09, 2005 7:24 AM Subject: [castor-user] mapping question
I have a class that extends EventObject, the mandatory constructor must
take
an Object. Is there any way to provide a constructor argument in the class tag of the mapping file. Here is the mapping and the class. I get the following error when trying to marshal this class.
Nested error: org.exolab.castor.mapping.MappingException: The Java class org.xoscript.server.event.ServerEvent is not constructable -- it does not contain a default public constructor
public class ServerEvent extends EventObject{
public String target = null;
public ServerEvent (Object source, String targ){ super(source); this.setTarget(targ); }
getter and setters...... }
I want to ignore source in the output xml, that is way it is missing. <class name="org.xoscript.server.event.ServerEvent">
<field name="target" type="java.lang.String" direct="false">
<bind-xml name="target" node="attribute"/>
</field>
</class>
Bryan LaPlante
----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to [EMAIL PROTECTED] with a subject of: unsubscribe castor-user
----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-user
----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-user
