The Enum Converter is not enabled by default. It converts Java5 Enums into JavaScript strings and back again. This converter is not enabled by default because DWR makes sure that is has permission before it touches any of your code.
You can enable the enum converter for a single class using the following:
<convert converter="enum" match="your.full.package.EnumName"/>
A quick example may help. Suppose you have the following Java code:
public class Remoted { public void setStatus(Status p) { // ... } } enum Status { PASS, FAIL, }
If Remoted
was configured as a Creator, and Status
is convertable using the EnumConverter, then you can call the Java code from Javascript as follows:
Remoted.setStatus("PASS");
If no match is found in the given enum, then an exception will be thrown.