Form extends AbstractHtml { public String getIdBasedJsObjectPlus( final Collection<String> additionalTagNames) { final Set<String> tagNames = new HashSet<>(); tagNames.addAll(additionalTagNames); tagNames.add(TagNameConstants.INPUT); tagNames.add(TagNameConstants.TEXTAREA); tagNames.add(TagNameConstants.SELECT); return getIdBasedJsObject(tagNames); } 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 testGetIdBasedJsObjectPlus() { final Form form = new Form(null) { { new Button(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.getIdBasedJsObjectPlus(Arrays.asList(TagNameConstants.BUTTON)); 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 testJsObjectPlusStringFunctionName() { final Form form = new Form(null) { { new Button(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.getIdBasedJsObjectPlus("gebi", Arrays.asList(TagNameConstants.BUTTON)); 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); }