/** * Creates a {@link Select} element with the specified {@link Select#name(String)} attribute and child nodes. * * @param name The {@link Select#name(String)} attribute. * @param children The child nodes. * @return The new element. */ public static final Select select(String name, Object...children) { return select().name(name).children(children); }
/** * Creates an empty {@link Select} element. * * @return The new element. */ public static final Select select() { return new Select(); }
/** * {@doc HTML5.forms#attr-select-multiple multiple} attribute. * * <p> * Whether to allow multiple values. * * @param multiple * The new value for this attribute. * Typically a {@link Boolean} or {@link String}. * @return This object (for method chaining). */ public final Select multiple(Object multiple) { attr("multiple", deminimize(multiple, "multiple")); return this; }
th("Species:"), td( select().name("species").children( option("cat"), option("dog"), option("bird"), option("fish"), option("mouse"), option("rabbit"), option("snake") ).choose(pet.getSpecies()) ), td(new Tooltip("❓", "The kind of animal.")) th("Status:"), td( select().name("status").children( option("AVAILABLE"), option("PENDING"), option("SOLD") ).choose(pet.getStatus()) ), td(new Tooltip("❓", "The current status of the animal."))
/** * {@doc HTML5.forms#attr-fae-form form} attribute. * * <p> * Associates the control with a form element. * * @param form The new value for this attribute. * @return This object (for method chaining). */ public final Select form(String form) { attr("form", form); return this; }
private Div examplesDiv(ObjectMap m) { if (m.isEmpty()) return null; Select select = null; if (m.size() > 1) { select = (Select)select().onchange("selectExample(this)")._class("example-select"); } Div div = div(select)._class("examples"); if (select != null) select.child(option("model","model")); div.child(div(m.remove("model"))._class("model active").attr("data-name", "model")); for (Map.Entry<String,Object> e : m.entrySet()) { if (select != null) select.child(option(e.getKey(), e.getKey())); div.child(div(e.getValue().toString().replaceAll("\\n", "\n"))._class("example").attr("data-name", e.getKey())); } return div; }
@Override /* Widget */ public Object getContent(RestRequest req) throws Exception { return div( form().id("form").action("servlet:/store/order").method(POST).children( table( tr( th("Pet:"), td( select().id("addPet_names").name("petId") ), td(new Tooltip("❓", "The pet to purchase.")) ), tr( th("Ship date:"), td(input().name("shipDate").type("date")), td(new Tooltip("❓", "The requested ship date.")) ), tr( td().colspan(2).style("text-align:right").children( button("reset", "Reset"), button("submit", "Submit") ) ) ).style("white-space:nowrap") ) ); } }
/** * Convenience method for selecting a child {@link Option} after the options have already been populated. * * @param optionValue The option value. * @return This object (for method chaining). */ public Select choose(Object optionValue) { if (optionValue != null) { for (Object o : getChildren()) { if (o instanceof Option) { Option o2 = (Option)o; if (StringUtils.isEquals(optionValue.toString(), o2.getAttr(String.class, "value"))) o2.selected(true); } } } return this; }
th("Species:"), td( select().name("species").children( option("cat"), option("dog"), option("bird"), option("fish"), option("mouse"), option("rabbit"), option("snake") ).choose(pet.getSpecies()) ), td(new Tooltip("❓", "The kind of animal.")) th("Status:"), td( select().name("status").children( option("AVAILABLE"), option("PENDING"), option("SOLD") ).choose(pet.getStatus()) ), td(new Tooltip("❓", "The current status of the animal."))
/** * {@doc HTML5.forms#attr-fe-name name} attribute. * * <p> * Name of form control to use for form submission and in the form.elements API. * * @param name The new value for this attribute. * @return This object (for method chaining). */ public final Select name(String name) { attr("name", name); return this; }
private Div examplesDiv(ObjectMap m) { if (m.isEmpty()) return null; Select select = null; if (m.size() > 1) { select = (Select)select().onchange("selectExample(this)")._class("example-select"); } Div div = div(select)._class("examples"); if (select != null) select.child(option("model","model")); div.child(div(m.remove("model"))._class("model active").attr("data-name", "model")); for (Map.Entry<String,Object> e : m.entrySet()) { if (select != null) select.child(option(e.getKey(), e.getKey())); div.child(div(e.getValue().toString().replaceAll("\\n", "\n"))._class("example").attr("data-name", e.getKey())); } return div; }
@Override /* Widget */ public Object getContent(RestRequest req) throws Exception { return div( form().id("form").action("servlet:/store/order").method(POST).children( table( tr( th("Pet:"), td( select().id("addPet_names").name("petId") ), td(new Tooltip("❓", "The pet to purchase.")) ), tr( th("Ship date:"), td(input().name("shipDate").type("date")), td(new Tooltip("❓", "The requested ship date.")) ), tr( td().colspan(2).style("text-align:right").children( button("reset", "Reset"), button("submit", "Submit") ) ) ).style("white-space:nowrap") ) ); } }
/** * Convenience method for selecting a child {@link Option} after the options have already been populated. * * @param optionValue The option value. * @return This object (for method chaining). */ public Select choose(Object optionValue) { if (optionValue != null) { for (Object o : getChildren()) { if (o instanceof Option) { Option o2 = (Option)o; if (StringUtils.isEquals(optionValue.toString(), o2.getAttr(String.class, "value"))) o2.selected(true); } } } return this; }
/** * Creates a {@link Select} element with the specified {@link Select#name(String)} attribute and child nodes. * * @param name The {@link Select#name(String)} attribute. * @param children The child nodes. * @return The new element. */ public static final Select select(String name, Object...children) { return select().name(name).children(children); }
/** * {@doc HTML5.forms#attr-fe-disabled disabled} attribute. * * <p> * Whether the form control is disabled. * * @param disabled * The new value for this attribute. * Typically a {@link Boolean} or {@link String}. * @return This object (for method chaining). */ public final Select disabled(Object disabled) { attr("disabled", deminimize(disabled, "disabled")); return this; }
/** * {@doc HTML5.forms#attr-fae-form form} attribute. * * <p> * Associates the control with a form element. * * @param form The new value for this attribute. * @return This object (for method chaining). */ public final Select form(String form) { attr("form", form); return this; }
private Div examplesDiv(ObjectMap m) { if (m.isEmpty()) return null; Select select = null; if (m.size() > 1) { select = (Select)select().onchange("selectExample(this)")._class("example-select"); } Div div = div(select)._class("examples"); if (select != null) select.child(option("model","model")); div.child(div(m.remove("model"))._class("model active").attr("data-name", "model")); for (Map.Entry<String,Object> e : m.entrySet()) { if (select != null) select.child(option(e.getKey(), e.getKey())); div.child(div(e.getValue().toString().replaceAll("\\n", "\n"))._class("example").attr("data-name", e.getKey())); } return div; }
/** * Creates an empty {@link Select} element. * * @return The new element. */ public static final Select select() { return new Select(); }
/** * Convenience method for selecting a child {@link Option} after the options have already been populated. * * @param optionValue The option value. * @return This object (for method chaining). */ public Select choose(Object optionValue) { if (optionValue != null) { for (Object o : getChildren()) { if (o instanceof Option) { Option o2 = (Option)o; if (StringUtils.isEquals(optionValue.toString(), o2.getAttr(String.class, "value"))) o2.selected(true); } } } return this; }
/** * Creates a {@link Select} element with the specified {@link Select#name(String)} attribute and child nodes. * * @param name The {@link Select#name(String)} attribute. * @param children The child nodes. * @return The new element. */ public static final Select select(String name, Object...children) { return select().name(name).children(children); }