18 package org.turro.jpa.grid;
20 import org.turro.jpa.Dao;
21 import org.turro.zkoss.grid.EditableGrid;
22 import org.zkoss.zk.ui.Component;
23 import org.zkoss.zk.ui.ext.AfterCompose;
24 import org.zkoss.zul.Row;
25 import org.zkoss.zul.Rows;
35 private boolean autoSave =
true;
37 public JpaGrid(
Dao dao, String query,
boolean autoSave) {
41 this.autoSave = autoSave;
49 this.autoSave = autoSave;
69 for(Component row :
getRows().getChildren()) {
70 if(
isValid((V) ((Row)row).getValue())) {
71 ((Row)row).setValue(dao.saveObject(((Row)row).getValue()));
84 if(autoSave && row.getValue() !=
null &&
isValid((V) row.getValue())) {
85 row.setValue(dao.saveObject(row.getValue()));
92 if(autoSave && row.getValue() !=
null) {
93 dao.deleteObject(row.getValue());
99 private void addTableRows() {
101 appendChild(
new Rows());
103 for(Object o : dao.getResultList(query)) {
111 row.setSclass(
"invalid");
void setQuery(String query)
boolean deleteRow(Row row)
JpaGrid(Dao dao, String query, boolean autoSave)
void setAutoSave(boolean autoSave)
boolean isAllowInsertions()
abstract void initiateRow(Row row, V value)
abstract boolean isValid(V v)
Rows getRows(boolean create)