Monday, September 11, 2017

How do you create a custom HTML element?

GWT doesn't support some HTML tags, which is frustrating. So I'd like to create my own Composite to achieve semantically correct HTML.

What's the best way to go about doing something like this without having to use native javascript calls to create the elements? Is it even possible?

For example:

public class DataList extends Composite {

        public DataList(){
                createElement("myDataList", "myParentElement", data); 
        }

        public static native void createElement(String id, String parentId, List<String> data) /*-{

                var dl = $doc.createElement('datalist'); 
                dl.setAttribute('id',id); 

                  // code to populate the datalist

                  $doc.getElementById(parentId).appendChild(dl);
        }-*/;

}

There's got to be a better way to do this, right? Preferably some method that works with UiBinder?

--
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 google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment