Todos Componentes

Podemos generar todos los componentes en un formulario,

Còdigo

@Test
public String allComponents() {
try {
List<Color> colorList = colorRepository.findAll();
Boolean found = unitTest.assertFalse("allComponents()", colorList.isEmpty());
if (found) {
/*
Dibuja la interfaz
*/
unitTest.form();
unitTest.formTitle("allComponents()");
unitTest.panel();
//-- Formulario
Color color = new Color();
color = colorList.get(0);
unitTest.panelAddInputText(Arrays.asList(new InputText("idcolor", color.getIdcolor()),
new InputText("activo", color.getActivo())));
//-- SelectOneMenu
List<Item> itemList = new ArrayList<>();
colorList.stream().map((c) -> new Item(c.getIdcolor(), c.getIdcolor(), c.getIdcolor())).forEachOrdered((item) -> {
itemList.add(item);
});
unitTest.panelAddSelectOneMenu(
Arrays.asList(new SelectOneMenu("color", itemList)));
//-- Tabla
unitTest.panelAddTableHeader("colores", Arrays.asList(new RowView("idcolor"), new RowView("activo")));
colorRepository.findAll().forEach((c) -> {
unitTest.panelAddTableCol(Arrays.asList(new ColView(c.getIdcolor()), new ColView(c.getActivo())));
});
unitView.panelAddTableClose();
unitTest.panelClose();
//-- Otra fila
unitTest.panel();
//-- Radio
unitTest.panelAddRadio(Arrays.asList(new Radio("sexo",
Arrays.asList(new Item("sexo", "Masculino", "Masculino"),
new Item("sexo", "Femenino", "Femenino")))));
//-- CheckBox
unitTest.panelAddCheckbox("sexo", Arrays.asList(new Checkbox("masculino", "Masculino", "Masculino"),
new Checkbox("femenino", "Femenino", "Femenino")));
unitTest.panelClose();
unitTest.formClose();
} else {
unitTest.errorMessage("No tiene registros");
}
} catch (Exception e) {
System.out.println(nameOfMethod()+" " + e.getLocalizedMessage());
}
return "";
}