<dependency> <groupId>org.webjars.bower</groupId> <artifactId>polymer</artifactId> </dependency> import com.vaadin.polymer.Polymer; import com.vaadin.polymer.PolymerWidget; import com.vaadin.polymer.elemental.Element; import import com.vaadin.polymer.elemental.HTMLElement; import com.vaadin.polymer.elemental.Template; @Tag("my-button") public class MyButton extends PolymerWidget { public MyButton() { setElement(createElement()); } private Element createElement() { Template template = Template.create("my-button.html"); Element buttonElement = (Element) template.getContent().querySelector("button"); return buttonElement; } @EventHandler private void handleClick(Event event) { } } @BindProperties({ @BindProperty(property = "disabled", value = "true", observer = "disabledChanged"), @BindProperty(property = "label") }) public class MyButton extends PolymerWidget { // ... @EventHandler("click") private void handleClick(Event event) { fireEvent(new ButtonClickEvent()); } // ... } public class MyButton extends PolymerWidget { @Property private String label; public MyButton() { setElement(createElement()); } private Element createElement() { Template template = Template.create("my-button.html"); Element buttonElement = (Element) template.getContent().querySelector("button"); bindProperty(buttonElement, "label", this, "label"); return buttonElement; } @Observe("label") private void handleLabelChange(String newLabel) { } }


上一篇:
下一篇:
切换中文