}
public void update() {
// get original data
Tree objTree = (Tree) getFellow("objTree");
Treeitem selectedtem = objTree.getSelectedItem();
SimpleTreeNode selectedNode = (SimpleTreeNode) selectedtem.getValue();
BomForm form = (BomForm) selectedNode.getData();
if (form.getParentBomId() != null) {
Collection items = objTree.getItems();
Iterator it = items.iterator();
while (it.hasNext()) {
Treeitem item = (Treeitem) it.next();
SimpleTreeNode node = (SimpleTreeNode) item.getValue();
BomForm var = (BomForm) node.getData();
if (var.getBomId().equals(form.getParentBomId())) {
form.setParentBom(var);
}
}
}
// get new value from the view, then update to the database
Bom obj = (Bom) viewToObj(form);
BomDao dao = new BomDao();
dao.update(obj);
// refresh bom by building
selectBomByBuilding();
// set selected
Collection items = objTree.getItems();
Iterator it = items.iterator();
while (it.hasNext()) {
Treeitem item = (Treeitem) it.next();
SimpleTreeNode node = (SimpleTreeNode) item.getValue();
BomForm var = (BomForm) node.getData();
if (var.getBomId().equals(obj.getBomId())) {
objTree.setSelectedItem(item);
}
}
}