问题
I can use <replace-with>
tags to swap out different implementations of a class depending on the properties set in my GWT module file. That's great - I love it.
BUT: all that's different about my views between formfactor="mobile"
and formfactor="desktop"
are the ui.xml files I use - even the java files are identical. So, class swapping isn't sufficient - I don't want to have to duplicate the Java files to get different classes.
How can I use properties to affect which ui.xml file is loaded as a UiBinder template?
note: I'm currently using a workaround that calculates what the module properties should be in Java, and using the property in a switch statement that loads the appropriate ui.xml file. This is undesirable because:
- Code is duplicated - I have to calculate properties in the module file and in the java code
- Each permutation must compile every ui.xml file in order for the correct one to be chosen at runtime. I'd prefer a compile-time solution.
回答1:
I think, that You must write your own generator which will serve different ui binder templates. Probably you can overload method deduceTemplateFile() in UiBinderGenerator.
来源:https://stackoverflow.com/questions/10290978/using-different-uibinder-uitemplate-files-depending-on-module-property