Collection Converters

The final 2 default converters are for maps and collections:

<convert converter="collection" match="java.util.Collection"/>


<convert converter="map" match="java.util.Map"/>

Generally speaking these converters will be able to recursively convert their contents.

There is a catch for these 2 however:

There is no way of knowing the underlying type of the collection just using reflection. So the 2 converters above can convert from any collection to something meaningful in JavaScript, however there is no way to know what sort of Collection to convert to going the other way.

Since we can't work it out automatically we may need to use the special signatures syntax in the dwr.xml file to allow us to hint types to the conversion process.

Maps and null keys

Javascript does not support non string keys. Because of this a null key in a Map will not be converted. DWR allows you to specify a String you would like to use when a null key is encountered. To configure this you will need to override the default map converter in the allow section of your applications dwr.xml.

<convert converter="map" match="java.util.Map">
  <param name="nullKey" value="null"/>