On Sunday, February 16, 2014 4:26:37 AM UTC+1, Magnus wrote: > > Hi, > > I have subclassed MenuItem: > > class MyMenuItem extends MenuItem > > > And I would like to use it in an UIBinder specification: > > <g:MenuBar ui:field="menuBar"> > <g:MyMenuItem ui:field="myItem" text="Label" customField="test"> > ... > > > Where do I specify, which attributes are allowed in the UIBinder > specification and how they are passed to the MyMenuItem class? >
MenuItem is a bit special as it's not a Widget and is processed in a special way by the parent-MenuBar-specific parser. The general rule otherwise is documented in http://www.gwtproject.org/javadoc/latest/com/google/gwt/user/client/ui/UIObject.html …and/or you can use a @UiConstructor or a @UiFactory. I cannot believe that it is sufficient to have a constructor with the same > fields like this: > > MyMenuItem (String text,String customField) > > > (In a constructor, the order of the parameters matters, in an XML element > it does not.) > GWT works as the source level, so it'll match arguments and attributes by name; but only on @UiConstructor-annotated constructors or @UiFactory methods. The MenuItem-specific parser requires subclasses to have a zero-arg constructor though. > Can I only pass strings, or can I also pass other things, e. g. enums? > Most simple value types can be used, including enums, and GWT will do its best to parse them to the correct type. Beware of overloads though: https://code.google.com/p/google-web-toolkit/issues/detail?id=7744 -- 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/google-web-toolkit. For more options, visit https://groups.google.com/groups/opt_out.
