# The Converters

There are a number of converters that are defined and initialized for you. They are defined as follows:

<converter id="null"
<converter id="primitive"
<converter id="bignumber"
<converter id="string"
<converter id="date"

<converter id="array"
<converter id="map"
<converter id="collection"

<converter id="bean"
<converter id="hibernate"

<converter id="dom"
<converter id="dom4j"
<converter id="jdom"
<converter id="xom"

<converter id="servlet"


The converters are merely defined here and are put into use with <convert ...> elements. There are 2 attributes in any convert element, a reference to a converter definition and a match line that defines the class(s) that it can convert.

For example the simplest converter is the null converter that converts void and null values to javascript null and undefined vales. This creator is the simplest of all. It assumes that you will be calling static methods only, so no object creation is needed.

By default DWR marshalls Java void values into Javascript nulls using the following: <convert converter="null" match="void"/>. There are times when a java.lang.Void needs to be converted as well so the same converter is used for those too: <convert converter="null" match="java.lang.Void"/>. There is no danger in passing nulls from Java to Javascript so these definitions are made by default - you don't need to put them in the <allow> section yourself.

The primitive converter converts boolean, byte, char, etc as well as their Class based alternatives Boolean etc. The default setup includes 16 entries in the allow section for all primitive types along the following lines: <convert converter="primitive" match="java.lang.Long"/> and <convert converter="primitive" match="long"/>.

The string and date converters are also setup by default. We have not found any way to subvert Strings, Dates or basic numeric types so they are all turned on by default.

• 评论

• 上一篇
• 下一篇