How can I use java.util.Currency in GWT?
I'm working on a GWT application, and we introduced a Money class that contains a java.util.Currency. The only problem is that GWT doesn't seem to support this class.
I did a google search and found开发者_JS百科 this code in the GWT source code, but I'm not quite sure what the "jat numberformat-r2942" library is, or how to inherit it into my project. Has anybody successfully been able to use this GWT library? If not, what is the best way to deal with currencies in a GWT application?
Should I just capture the currency as a String on the client side, then create a Currency object on the server side? We're trying to use the GWT-dispatch library, so I'd like to use the same bean on the client and server side.
You can use <super-source>
to replace all non-translatable classes with your version.
Take a look at http://code.google.com/webtoolkit/doc/1.6/DevGuideOrganizingProjects.html, look for "Overriding one package implementation with another".
OTOH, if you only need to transfer this object through GWT-RPC, then use the new RequestFactory that solves this issue altogether - there are no common classes on server and client, proxies are used instead.
jat/numberformat-r2942
is not a separate library that can be included via a JAR file. It looks like the changes
directory in the GWT source repository may be a place to hold individual user's branches containing possible future additions to the mainline GWT source.
If you want to use that implementation of Currency (which may be buggy and/or incomplete) your best bet is to copy it to your source tree (changing the packages for all of the necessary classes) and use <super-source>
as Peter suggests.
精彩评论