Form extends AbstractHtml { public String getIdBasedJsObject(final Collection<String> onlyForTagNames) { return getIdBasedJsObject("document.getElementById", onlyForTagNames); } Form(final AbstractHtml base,
            final AbstractAttribute... attributes); String getNameBasedJsObject(
            final Collection<String> onlyForTagNames); String getIdBasedJsObject(final Collection<String> onlyForTagNames); String getIdBasedJsObject(final String functionName,
            final Collection<String> onlyForTagNames); String getNameBasedJsObject(); String getIdBasedJsObject(); String getIdBasedJsObject(final String functionName); String getIdBasedJsObjectPlus(
            final Collection<String> additionalTagNames); String getIdBasedJsObjectPlus(final String functionName,
            final Collection<String> additionalTagNames);  }
@Test public void testGetIdBasedJsObject() { final Form form = new Form(null) { { new Input(this, new Id("name1")); new Div(this, new Id("excluded")){{new Input(this, new Id("name2"));}}; new Input(this, new Id("name3")); new Div(this){{new Input(this, new Id("name4"));}}; new Div(this){{new Input(this, new Id("name4"));}}; new Div(this){{new Input(this, new Id("name4"));}}; new Div(this){{new Input(this, new Id("name5"), new Type(Type.TEXT));}}; new Div(this){{new Input(this, new Id("name6"), new Type(Type.CHECKBOX));}}; new Div(this){{new Input(this, new Id("name7"), new Type(Type.RADIO));}}; new TextArea(this, new Id("included")); } }; final String jsObjectForNames = form.getIdBasedJsObject(); Assert.assertEquals("{name1:document.getElementById('name1').value,name3:document.getElementById('name3').value,included:document.getElementById('included').value,name7:document.getElementById('name7').checked,name6:document.getElementById('name6').checked,name5:document.getElementById('name5').value,name4:document.getElementById('name4').value,name2:document.getElementById('name2').value}", jsObjectForNames); }
@Test public void testGetJsObjectStringFunctionName() { final Form form = new Form(null) { { new Input(this, new Id("name1")); new Div(this, new Id("excluded")){{new Input(this, new Id("name2"));}}; new Input(this, new Id("name3")); new Div(this){{new Input(this, new Id("name4"));}}; new Div(this){{new Input(this, new Id("name4"));}}; new Div(this){{new Input(this, new Id("name4"));}}; new Div(this){{new Input(this, new Id("name5"), new Type(Type.TEXT));}}; new Div(this){{new Input(this, new Id("name6"), new Type(Type.CHECKBOX));}}; new Div(this){{new Input(this, new Id("name7"), new Type(Type.RADIO));}}; new TextArea(this, new Id("included")); } }; final String jsObjectForNames = form.getIdBasedJsObject("gebi"); Assert.assertEquals("{name1:gebi('name1').value,name3:gebi('name3').value,included:gebi('included').value,name7:gebi('name7').checked,name6:gebi('name6').checked,name5:gebi('name5').value,name4:gebi('name4').value,name2:gebi('name2').value}", jsObjectForNames); }