Using different UiBinder @UiTemplate files depending on module property

末鹿安然 提交于 2019-12-11 03:37:48

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!