package com.pre.web.base;
import org.zkoss.zul.Grid;
import org.zkoss.zul.ListModelList;
import org.zkoss.zul.Rows;
import org.zkoss.zul.Window;
import com.pre.session.base.WarehouseManager;
import com.pre.web.OptionBinder;
import com.pre.web.WebApplication;
import com.pre.web.base.renderers.WarehouseRowRenderer;
public class WarehouseWindow extends Window {
/**
*
*/
private static final long serialVersionUID = -7780620655416254624L;
private WarehouseManager manager;
public void onCreate(){
_init();
createMenubar();
feedGrid();
}
private void _init(){
manager=(WarehouseManager)WebApplication.lookup(WarehouseManager.LocalJNDIName);
Grid warehousesGrid=(Grid)getFellow("warehousesGrid");
warehousesGrid.setRowRenderer(new WarehouseRowRenderer());
warehousesGrid.setModel(new ListModelList());
}
private void createMenubar() {
OptionBinder.bindStandardOptions(this, "warehousesGrid", "details/WarehouseDetails.zul");
}
private void refresh(){
Grid warehousesGrid=(Grid)getFellow("warehousesGrid");
warehousesGrid.removeChild(warehousesGrid.getRows());
Rows newRows=new Rows();
warehousesGrid.appendChild(newRows);
feedGrid();
}
private void feedGrid() {
Grid warehousesGrid=(Grid)getFellow("warehousesGrid");
ListModelList model=(ListModelList)warehousesGrid.getModel();
model.clear();
model.addAll(manager.findAll());
}
}