-
1. Re: Override internal Marshaller
ddadlani Feb 2, 2015 3:02 PM (in response to steeveb)Hello Steeve,
Have you looked at the documentation for custom marshallers? The link is http://docs.jboss.org/errai/3.1.1.Final/errai/reference/html_single/#sid-5931328_Marshalling-CustomMarshallers. Is this what you are trying to do?
Cheers,
Divya -
2. Re: Override internal Marshaller
steeveb Feb 2, 2015 4:43 PM (in response to ddadlani)Hello Divya,
I already had a look on the documentation, and I created a CustomMarshaller in that way. The problem I got is that there was an exception because I was trying to remap java.util.Date serialization. So I used my workaround to make it work, and I was just wondering if there was a builtin way to do this as I didn't find this in the documentation.
Regards,
Steeve
-
3. Re: Override internal Marshaller
werrenmi Feb 5, 2015 12:18 AM (in response to steeveb)Hello Steve
Can you please post the exception and your custom marshaller?
Regards
Michel
-
4. Re: Re: Override internal Marshaller
steeveb Feb 7, 2015 4:17 PM (in response to werrenmi)Hi Michel,
Here is the exception I got:
java.lang.IllegalStateException: Mapping definition collision for java.util.Date
[ERROR] Already have: MappingDefinition [mappingClass=java.util.Date, clientMarshallerClass=class org.jboss.errai.marshalling.client.marshallers.CustomDateMarshaller, serverMarshallerClass=null]
[ERROR] Attempted to add: MappingDefinition [mappingClass=java.util.Date, clientMarshallerClass=class org.jboss.errai.marshalling.client.marshallers.DateMarshaller, serverMarshallerClass=null]
And the class I created
package org.jboss.errai.marshalling.client.marshallers; import java.util.Date; import org.jboss.errai.marshalling.client.api.MarshallingSession; import org.jboss.errai.marshalling.client.api.annotations.ClientMarshaller; import org.jboss.errai.marshalling.client.api.annotations.ServerMarshaller; import org.jboss.errai.marshalling.client.api.json.EJValue; import org.jboss.errai.marshalling.client.marshallers.AbstractNullableMarshaller; import com.google.gwt.i18n.client.DateTimeFormat; @ServerMarshaller(Date.class) @ClientMarshaller(Date.class) public class CustomDateMarshaller extends AbstractNullableMarshaller<Date> { private DateTimeFormat format = DateTimeFormat.getFormat("yyyy-MM-dd'T'HH:mm:ssZ"); @Override public Date[] getEmptyArray() { return new Date[0]; } @Override public Date doNotNullDemarshall(EJValue o, MarshallingSession ctx) { if (o.isString() != null) { return format.parse(o.isString().stringValue()); } return null; } @Override public String doNotNullMarshall(Date o, MarshallingSession ctx) { return "\"" + format.format(o) +"\""; } }
I would like to replace the internal DateMarshaller by my implementation.
Regards,
Steeve
-
5. Re: Override internal Marshaller
randalmay May 27, 2016 11:00 AM (in response to steeveb)Were you able to override the default marshaller? I am trying to override the default Object Marshaller, so I am very interested in this.