Monday, October 27, 2014

Re: Modify the property of an object via Deferred Binding

I was hoping for something other than a generator.  I only need to change one property after instantiation, and only sometimes, at this point and it seems like a lot of work to write a generator to do that.  I'd likely just create an override of the class at this point and update the rebind that already exists.

It would be awesome if the gwt compiler would support something along these lines:

<replace-with class="com.my.FavoriteImplementation">
<when-type-is class="com.SomeInterface"/>
                <set-object-property type="boolean" value="false" name="turnFeatureOn"/>
                <set-object-property type="string" value="MyPrimaryStyle" name="defaultStyle"/>
                <set-object-property name="complexProperty" provider="com.my.ComplexPropertyProvider"/>
</replace-with>

This might actually reduce the need for custom generators and make customization via GWT.create a bit more powerful.

On Sunday, October 26, 2014 3:06:15 PM UTC-7, Jens wrote:
Ignacio is right. Use a Generator that generates an implementation of your interface and implements the interface methods based on some property value (generators have access to properties). If your implementation is generally the same except some small changes then you can also create an abstract class that implements your interface and then generate a sub class which only implements the property specific changes.

Since properties only exist at compile time you need to generate property specific code. You can not do that at runtime.

-- J.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment