private void buildDivFieldsFromEntity(ComposerController<?> composer) { // AnnotateDataBinder binder = new AnnotateDataBinder(crudFormWindow); // binder.bindBean("controller2", composer); if (divFields.getChildren().size() == 0) { List<Component> list = new ArrayList<Component>(divFields.getChildren()); for (Component c : list) { c.detach(); } d = new Div(); g = new Grid(); d.appendChild(g); binder = new AnnotateDataBinder(g); binder.bindBean("controller2", composer); Columns c = new Columns(); Column col1 = new Column(); col1.setWidth("120px"); Column col2 = new Column(); col2.setAlign("left"); c.appendChild(col1); c.appendChild(col2); Rows r = new Rows(); Textbox t; Checkbox checkbox; for (ManagedBeanField field : composer.getListColumns()) { if (field.isVisible()) { Row row = new Row(); row.appendChild(new Label(Labels.getLabel(field.getFieldCaption()))); String fieldName = "controller2." + field.getFieldName() + ""; if (field.getFieldType().equalsIgnoreCase("boolean")) { checkbox = new Checkbox(); binder.addBinding(checkbox, "checked", fieldName); row.appendChild(checkbox); } else { t = new Textbox(); t.setWidth("98%"); binder.addBinding(t, "value", fieldName); row.appendChild(t); } r.appendChild(row); } } g.appendChild(r); d.setParent(this.divFields); // binder.loadAll(); } binder.loadComponent(g); // binder.saveAll(); }
/** * Metodo que constroi o Listheader baseado nos campos da Entity * * @param composer composer para construir a lista de campos */ private void builderListHeaderFromEntity(ComposerController<?> composer) { if (this.divListhead.getChildren().size() == 1) { Listheader oper = (Listheader) this.divListhead.getChildren().get(0); this.divListhead.removeChild(oper); for (ManagedBeanField field : composer.getListColumns()) { if (field.isVisible()) { Listheader l = new Listheader(Labels.getLabel(field.getFieldCaption())); l.setSort("auto(" + field.getKey() + ")"); this.divListhead.appendChild(l); } } this.divListhead.appendChild(oper); } }
@Override public void render(Listitem listItem, Object data, int paramInt) throws Exception { Entity entityItem = (Entity) data; listItem.setValue(entityItem); for (ManagedBeanField field : composer.getListColumns()) { if (field.isVisible()) { Listcell l = new Listcell(); l.setLabel(String.valueOf(Reflection.getFieldValue(entityItem, field.getKey()))); l.setParent(listItem); } } ((Button) cellOper.getChildren().get(0)).setId(null); ((Button) cellOper.getChildren().get(1)).setId(null); Listcell vOper = ((Listcell) cellOper.clone()); vOper.setParent(listItem); // this.divListBox.appendChild(cellOper); // new Listcell(prod.getName()).setParent(listItem); // new Listcell(""+prod.getPrice()).setParent(listItem); // new Listcell(""+cartItem.getAmount()).setParent(listItem); }