Awesome. Thank you. @JsOverlay did the trick. Den torsdag den 3. december 2015 kl. 12.58.26 UTC+1 skrev Thomas Broyer: > > From > https://groups.google.com/d/msg/google-web-toolkit-contributors/q_GY4SxGQ7I/KrExmCQ9EgAJ > > I think you need to annotate those constant fields with @JsOverlay. > Or maybe you could declare them non-final and have them mapped to the > native constants ($wnd.Node.ELEMENT_NODE, etc.) > > On Thursday, December 3, 2015 at 11:49:23 AM UTC+1, rhmoller wrote: >> >> Hi >> >> How can I add constants to a native @JsType? >> >> I was trying to add support for constants to my WebIDL to JsInterop >> generator but I have a problem with constants. >> >> Here is a snippet of the definition of Node >> >> >> [Exposed=Window] >> interface Node : EventTarget { >> const unsigned short ELEMENT_NODE = 1; >> const unsigned short ATTRIBUTE_NODE = 2; // historical >> const unsigned short TEXT_NODE = 3; >> ... >> readonly attribute unsigned short nodeType; >> readonly attribute DOMString nodeName; >> >> >> And here is the corresponding Java that I generate >> >> >> @JsType(isNative = true, namespace = JsPackage.GLOBAL) >> public interface Node extends EventTarget { >> public static final short ELEMENT_NODE = 1; >> public static final short ATTRIBUTE_NODE = 2; >> public static final short TEXT_NODE = 3; >> ... >> @JsProperty(name = "nodeType") short getNodeType(); >> @JsProperty(name = "nodeName") String getNodeName(); >> >> >> But GWT complains about it >> >> [ERROR] Line 10: Native JsType field 'short Node.ELEMENT_NODE' cannot >> have initializer. >> >> I tried adding @JsIgnore to the fields but was also illegal >> >> Best regards >> Rene >> >
-- You received this message because you are subscribed to the Google Groups "GWT Users" 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/d/optout.
