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.OrganizationGroupManager;
import com.pre.web.OptionBinder;
import com.pre.web.WebApplication;
import com.pre.web.base.renderers.OrganizationGroupRowRenderer;
public class OrganizationGroupWindow extends Window {
/**
*
*/
private static final long serialVersionUID = -475711030922211406L;
private OrganizationGroupManager ogManager;
private void _init(){
ogManager=(OrganizationGroupManager)WebApplication.lookup(OrganizationGroupManager.LocalJNDIName);
Grid groupsGrid=(Grid)getFellow("groupsGrid");
groupsGrid.setRowRenderer(new OrganizationGroupRowRenderer());
groupsGrid.setModel(new ListModelList());
}
public void onCreate(){
_init();
createMenubar();
feedGrid();
}
private void createMenubar() {
OptionBinder.bindStandardOptions(this, "groupsGrid", "details/OrganizationGroupDetails.zul");
}
public void onRefresh(){
refresh();
}
private void refresh(){
Grid groupsGrid=(Grid)getFellow("groupsGrid");
groupsGrid.removeChild(groupsGrid.getRows());
Rows newRows=new Rows();
groupsGrid.appendChild(newRows);
feedGrid();
}
private void feedGrid() {
Grid companiesGrid=(Grid)getFellow("groupsGrid");
ListModelList model=(ListModelList)companiesGrid.getModel();
model.clear();
model.addAll(ogManager.findAll());
}
}