uibinder - In GWT, How to use custom widget tag in an .ui.xml file with and without parameters for the tag in the same file -
i creating custom widget, "customwid" in uibinder. , in customwid.java file writing 2 constructors 1 0 args customwid(){....}
args customwid(string a,string b){......} so,now using custom widget in .ui.xml file,in .ui.xml file working fine when give <my:customwid/> alone, , fine when give <my:customwid a="srt1" b="str2"/> alone "my problem" whenever trying give both tags in 1 .ui.xml <my:customwid/> <my:customwid a="str1" b="str2"/> throwing error when using both types of tags in single .ui.xml mean how use custom widget tag prdefined tag? using @uiconstructor, showing error please developers... need answer possible
uibinder ever use single constructor given widget: either zero-arg constructor, or @uiconstructor (i'm surprised works when using either 1 or other call not both: 1 should fail in every case, , 1 should succeed in every case; if haven't annotated constructor @uiconstructor, <my:customwid/> should work , <my:customwid a="str1" b="str2"/> should fail)
there 2 solutions here:
- use setters
a,battributes (void seta(string a),void setb(string b))), , possibly check later (say, inonloadoronattach) have either none or both of , b, not 1 without other (if that's rule). - use
@uifield(provided = true)when need use other constructor (if choose have uibinder use zero-arg constructor –i.e. no@uiconstructor–, means you'll have movea="str1" b="str2"xml java code:@uifield(provided = true) customwid mycustomwid = new customwid("str1", "str2")).
the first option has preference.
Comments
Post a Comment