On Jan 22, 5:32 am, nina <[email protected]> wrote: > Hi all > > I have my own convenient composite which is a HorizontalPanel with a > Label and TextBoxBase, called FormEntry. I have 4 different > constructors for this composite, where some take just a label text > string and others also take a default value and a boolean determining > if the TextboxBase should be PasswordTextBox or a TextBox. > > Now, I am trying to convert my project to use the new UiBinder > feature. I figured based > onhttp://code.google.com/webtoolkit/doc/latest/DevGuideUiBinder.html#Us... > that I could annotate all my constructors with @UiConstructor and then > in the ui.xml use the name/or number of constructor arguments to match > it to the right constructor. > > So for example in the ui.xml I have > > <my:FormEntry ui:field="username" labelText="Username" > defaultValue="nina" /> > <my:FormEntry ui:field="password" labelText="Password" > defaultValue="pass123" password="true"/> > > and in the FormEntry.java I have > > @UiConstructor > public FormEntry(String labelText, String defaultValue){ > this(labelText, defaultValue, false); > > } > > @UiConstructor > public FormEntry(String labelText, String defaultValue, boolean > password){ > // code... > > } > > The error message I get is "FormEntry has more than one constructor > annotated with @UiConstructor". > > I've looked for more info on how this @UiConstructor works but haven't > found anything. So the question are: > - do I have the right approach here?
IMO, you'd rather have a single @UiConstructor with the required "fields" (could be the no-arg ctor if you only have optional fields) and setters for optional ones. > - why can't I have more than one constructor marked with > UiConstructor? > - does the binding happen with the help of the constructor arg names > or numbers or types or what? The names. -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
