I would like to have my GWT application use different constants when debugging or developing vs when deployed. What is the right way to do this? My web searches turn up a lot of pages about debugging GWT applications, which isn't what I'm looking for.
+1
A:
This looks like a job for deferred binding! ;)
It would look something like this (put this in your module XML file, I haven't actually tested it, but you should get the gist of it):
<define-property name="debug" values="true,false" />
<set-property name="debug" value="true" />
<replace-with class="package.Constants">
<when-type-is class="package.Constants"/>
</replace-with>
<replace-with class="package.ConstantsDebug">
<when-type-is class="package.Constants" />
<when-property-is name="debug" value="true"/>
</replace-with>
See the docs for more information on available parameters, rules and whatnot.
Igor Klimer
2010-05-30 23:55:03
Exactly what I wanted. Thanks.
Michael Donohue
2010-05-31 03:31:59
Just to add, GWT already has a debug flag - `gwt.enableDebugId` that controls the `ensureDebugId()` method. You can use that as a reference implementation, or better - can reuse the same flag.
sri
2010-05-31 05:11:08