(1) You have an unused private static final VALUES
(2) You don't need to make an enum implement IsSerializable for GWT to
serialize it
(3) Why don't you pass an extra boolean argument to your enum
constructor that says whether it is windows?
(4) Why do you have separate enums for use in GWT and not in GWT? Why
not the same code?
(5) Is it possible your is windows property is getting lost because
nothing calls setWindows() on the enum instances that are used in the
GWT code? I believe enums are serialized by sending the enum name on the
wire and nothing else since enum instances are expected to be immutable.

HTH,
Paul

ped wrote:
> We are using GWT 1.5.2 and I'm having a problem with a Java 5 enum. In
> general, they have worked fine since we upgraded to 1.5.2, but I
> recently tried to add a property to one of my enume, and I do not see
> the correct value of the property in my GWT code.
> I have an enum (OperatingSystemType) that represents an OS with values
> like WinXP, Linux, etc... I have a GWT version of this enum called
> OperatingSystemTypeGWT. I generate the GWT version from the other
> version as the code below shows.
>
>         OperatingSystemTypeGWT osTypeGWT =
> OperatingSystemTypeGWT.valueOfDisplayValue(operatingSystemType.toString
> ());
>         osTypeGWT.setWindows(OperatingSystemType.isWindows
> (operatingSystemType));
>
> I log the value of the isWindows boolean before returning it to my GWT
> code, and as soon as I receive it in my GWT code. In every case, the
> value is correct before I return it, but it is always false (I believe
> that's the default value of a boolean) in my GWT code.
>
> I modified the container class that holds the reference to the enum in
> the same manner (adding an isWindows property and method) and that
> works fine - my GWT code sees the correct value of the boolean. This
> leads me to believe that the generated javascript is handling enums
> differently than concrete classes.
>
> Any help or insight is appreciated...
>
> Below is (essentially) the enum:
>
> public enum OperatingSystemTypeGWT
>       implements  com.google.gwt.user.client.rpc.IsSerializable
> {
>       UNKNOWN("Unknown"),
>       WINDOWS_XP("Windows XP"),
>       WINDOWS_VISTA("Windows Vista"),
>       LINUX("Linux");
>
>       private boolean propertyisWindows;
>
>       public boolean isWindows()
>       {
>               return propertyisWindows;
>       }
>
>       public void setWindows(boolean propertyisWindows)
>       {
>                this.propertyisWindows = propertyisWindows;
>       }
>
>       private String displayValue;
>       private OperatingSystemTypeGWT(String displayValue)
>       {
>               this.displayValue = displayValue;
>       }
>
>       @Override
>       public String toString()
>       {
>               return displayValue;
>       }
>
>       public static OperatingSystemTypeGWT valueOfDisplayValue(String
> displayValue)
>       {
>               for (OperatingSystemTypeGWT type : values())
>               {
>                       if (type.displayValue.equals(displayValue))
>                       {
>                               return type;
>                       }
>               }
>               return null;
>       }
>       private static final String[] VALUES = new String[]{UNKNOWN.toString
> (), WINDOWS_XP.toString(), WINDOWS_VISTA.toString(), LINUX.toString
> ()};
> }
>
> >
>
>   

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to Google-Web-Toolkit@googlegroups.com
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to