@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") ) ); } }
@Override /* MenuItemWidget */ public Div getContent(RestRequest req) throws Exception { Div div = div(); for (String s : BUILT_IN_STYLES) { java.net.URI uri = req.getUri(true, new AMap<String,String>().append("stylesheet", "htdocs/themes/"+s+".css")); div.children(a(uri, s), br()); } return div; } }
/** * The swap method. * * <p> * Converts this bean into a div tag with contents. * * @param session The bean session. * @return The swapped contents of this bean. */ public Div swap(BeanSession session) { return div( small(display), span()._class("tooltiptext").children(content) )._class("tooltip"); } }
"A-1", A.class, a("http://foo", "bar"), "A-2", A.class, a("http://foo", "bar", btag, "baz"), "A-3", A.class, a("http://foo", ""), "A-4", A.class, a("http://foo", " "), "A-5", A.class, a("http://foo"), "Abbr-1", Abbr.class, abbr().children("foo"), "Abbr-2", Abbr.class, abbr("foo", "bar", btag, "baz"), "Address-1",
private Div headers(Session s, ResponseInfo ri) { if (! ri.hasHeaders()) return null; Table sectionTable = table(tr(th("Name"),th("Description"),th("Schema")))._class("section-table"); Div headers = div( div("Headers:")._class("section-name"), sectionTable )._class("headers"); for (Map.Entry<String,HeaderInfo> e : ri.getHeaders().entrySet()) { String name = e.getKey(); HeaderInfo hi = e.getValue(); sectionTable.child( tr( td(name)._class("name"), td(toBRL(hi.getDescription()))._class("description"), td(hi.asMap().keepAll("type","format","items","collectionFormat","default","maximum","exclusiveMaximum","minimum","exclusiveMinimum","maxLength","minLength","pattern","maxItems","minItems","uniqueItems","enum","multipleOf")) ) ); } return headers; }
@RestMethod( name=GET, path="/edit", summary="Render form entry page for editing config file", description="Renders a form entry page for editing the raw text of a config file." ) public Form getConfigEditForm() { return form().id("form").action("servlet:/").method("POST").enctype("application/x-www-form-urlencoded").children( div()._class("data").children( table( tr(td().style("text-align:right").children(button("submit","Submit"),button("reset","Reset"))), tr(th().child("Contents")), tr(th().child( textarea().name("contents").rows(40).cols(120).style("white-space:pre;word-wrap:normal;overflow-x:scroll;font-family:monospace;") .text(getServletConfig().getConfig().toString())) ) ) ) ); }
private Table header(Session s) { Table table = table()._class("header"); table.child(tr(th("Description:"),td(toBRL(info.getDescription())))); table.child(tr(th("Version:"),td(info.getVersion()))); Table t2 = table(); t2.child(tr(th("Name:"),td(c.getName()))); if (c.hasUrl()) t2.child(tr(th("URL:"),td(a(c.getUrl(), c.getUrl())))); if (c.hasEmail()) t2.child(tr(th("Email:"),td(a("mailto:"+ c.getEmail(), c.getEmail())))); table.child(tr(th("Contact:"),td(t2))); Object child = l.hasUrl() ? a(l.getUrl(), l.hasName() ? l.getName() : l.getUrl()) : l.getName(); table.child(tr(th("License:"),td(child))); Object child = ed.hasUrl() ? a(ed.getUrl(), ed.hasDescription() ? ed.getDescription() : ed.getUrl()) : ed.getDescription(); table.child(tr(th("Docs:"),td(child))); Object child = StringUtils.isUri(tos) ? a(tos, tos) : tos; table.child(tr(th("Terms of Service:"),td(child)));
@Test public void testToString() { Form f = form("bar", fieldset( legend("foo:"), "Name:", input("text"), br(), "Email:", input("text"), br(), "X:", keygen().name("X"), label("label")._for("Name") ) ); String r = f.toString(); assertEquals("<form action='bar'><fieldset><legend>foo:</legend>Name:<input type='text'/><br/>Email:<input type='text'/><br/>X:<keygen name='X'/><label for='Name'>label</label></fieldset></form>", r); } }
private HtmlElement opBlockSummary(String path, String opName, Operation op) { return div()._class("op-block-summary").children( span(opName.toUpperCase())._class("method-button"), span(path)._class("path"), op.hasSummary() ? span(op.getSummary())._class("summary") : null ).onclick("toggleOpBlock(this)"); }
/** * Creates a {@link Div} element with the specified child nodes. * * @param children The child nodes. * @return The new element. */ public static final Div div(Object...children) { return div().children(children); }
private HtmlElement tagBlockSummary(Tag t) { ExternalDocumentation ed = t.getExternalDocs(); return div()._class("tag-block-summary").children( span(t.getName())._class("name"), span(toBRL(t.getDescription()))._class("description"), ed == null ? null : span(a(ed.getUrl(), ed.hasDescription() ? ed.getDescription() : ed.getUrl()))._class("extdocs") ).onclick("toggleTagBlock(this)"); }
/** * Creates a {@link Button} element with the specified {@link Button#type(String)} attribute. * * @param type The {@link Button#type(String)} attribute. * @return The new element. */ public static final Button button(String type) { return button().type(type); }
/** * Creates a {@link Form} element with the specified {@link Form#action(String)} attribute. * * @param action The {@link Form#action(String)} attribute. * @return The new element. */ public static final Form form(String action) { return form().action(action); }
/** * Creates a {@link Tr} element with the specified child nodes. * * @param children The child nodes. * @return The new element. */ public static final Tr tr(Object...children) { return tr().children(children); }
/** * Creates a {@link Th} element with the specified child nodes. * * @param children The child nodes. * @return The new element. */ public static final Th th(Object...children) { return th().children(children); }
/** * Creates a {@link Td} element with the specified child nodes. * * @param children The child nodes. * @return The new element. */ public static final Td td(Object...children) { return td().children(children); }
/** * Creates a {@link Table} element with the specified child nodes. * * @param children The child nodes. * @return The new element. */ public static final Table table(Object...children) { return table().children(children); }
/** * Creates an {@link Input} element with the specified {@link Input#type(String)} attribute. * * @param type The {@link Input#type(String)} attribute. * @return The new element. */ public static final Input input(String type) { return input().type(type); }
/** * Creates a {@link Textarea} element with the specified {@link Textarea#name(String)} attribute and * {@link Textarea#text(Object)} node. * * @param name The {@link Textarea#name(String)} attribute. * @param text The {@link Textarea#text(Object)} node. * @return The new element. */ public static final Textarea textarea(String name, String text) { return textarea().name(name).text(text); }