📄 modulemanagebean.java
字号:
/*$Id: ModuleManageBean.java,v 1.2 2008/11/24 02:34:31 libin Exp $ *-------------------------------------- * Apusic (Kingdee Middleware) *--------------------------------------- * Copyright By Apusic ,All right Reserved * author date comment * chenhongxin 2008-4-14 Created*/package org.operamasks.example.ejb.hr.litebean.module;import java.util.List;import java.util.UUID;import org.operamasks.example.ejb.hr.entity.Module;import org.operamasks.example.ejb.hr.service.ServiceBean;import org.operamasks.faces.annotation.Action;import org.operamasks.faces.annotation.Bind;import org.operamasks.faces.annotation.DataModel;import org.operamasks.faces.annotation.ManagedBean;import org.operamasks.faces.annotation.ManagedBeanScope;import org.operamasks.faces.annotation.ManagedProperty;import org.operamasks.faces.annotation.Required;import org.operamasks.faces.component.ajax.AjaxUpdater;import org.operamasks.faces.component.grid.impl.UIDataGrid;import org.operamasks.faces.component.layout.impl.UIWindow;/** * 主模块管理页面的托管Bean * @author chenhongxin */@ManagedBean(name="module.moduleManageBean", scope=ManagedBeanScope.SESSION)public class ModuleManageBean extends BeforeRenderBaseBean { /** * 操作记录标识 */ private Operation curModuleOperation = Operation.NOTHING; /** * 双击选中的主模块 */ private Module selectedModule; /** * 选中需要修改的主模块 */ private Module modifyModule; /** * 注入主模块管理页面托管Bean */ @ManagedProperty("#{serviceBean}") private ServiceBean service; /** * 绑定页面的DataGrid组件 */ @Bind(id="moduleDataGrid", attribute="binding") private UIDataGrid moduleDataGrid; /** * 绑定页面的明细Window组件 */ @Bind(id="detailModuleDialog", attribute="binding") private UIWindow detailModuleDialog; /** * 绑定页面的模块项Window组件 */ @Bind(id="itemsDialog", attribute="binding") private UIWindow itemsDialog; /** * 绑定明细编辑框里的主模块名称输入域,并指定Required验证失败的提示信息 */ @Bind(id="moduleName", attribute="value") @Required(message = "#{this.getMessages().get('required')}") private String moduleName; /** * 绑定明细编辑框里的主模块图标地址输入域,并指定Required验证失败的提示信息 */ @Bind(id="moduleIcon", attribute="value") private String moduleIcon; /** * DataGrid绑定数据的获取 * @return 绑定数据的List集合 */ @DataModel(id="moduleDataGrid") private List<Module> getModuleDataGridValues(){ return service.getModuleService().listModule(); } @Bind private AjaxUpdater itemsUpdater; /** * 绑定DataGrid的双击事件,记录选中的主模块 */ @Action(id = "moduleDataGrid", event = "ondblclick") public void moduleDataGrid_ondblclick() { Module selectedModule = (Module)moduleDataGrid.getSelectedRowData(); if(selectedModule != null) { this.selectedModule = selectedModule; } itemsUpdater.reload(); itemsDialog.show(); } /** * 获取双击选中的主模块对象 * @return 双击选中的主模块对象 */ Module getSelectedModule() { return this.selectedModule; } /** * 绑定添加按钮的点击击事件 */ @Action(id="add") public void add() { curModuleOperation = Operation.ADD; detailModuleDialog.show(); } /** * 绑定修改按钮的点击事件 */ @Action(id="modify") public void modify() { Module selectedModule = (Module)moduleDataGrid.getSelectedRowData(); if(selectedModule != null) { modifyModule = selectedModule; moduleName = selectedModule.getName(); moduleIcon = selectedModule.getIcon(); curModuleOperation = Operation.MODIFY; detailModuleDialog.show(); } } /** * 绑定删除按钮的点击事件 */ @Action(id="del") public void del() { Module selectedModule = (Module)moduleDataGrid.getSelectedRowData(); if(selectedModule != null) { service.getModuleService().removeModule(selectedModule); moduleDataGrid.reload(); } } /** * 绑定确定按钮的点击事件 */ @Action(id="ok") public void ok(){ if (curModuleOperation == Operation.ADD) { Module newOne = new Module(); newOne.setId(UUID.randomUUID().toString()); newOne.setName(moduleName); newOne.setIcon(moduleIcon); service.getModuleService().createModule(newOne); moduleDataGrid.reload(); } else if (curModuleOperation == Operation.MODIFY) { if(modifyModule != null) { modifyModule.setName(moduleName); modifyModule.setIcon(moduleIcon); service.getModuleService().modifyModule(modifyModule); moduleDataGrid.reload(); } } cancel(); } /** * 绑定取消按钮的点击事件,使用immediate=true跳过数据验证 */ @Action(id="cancel", immediate = true) public void cancel(){ curModuleOperation = Operation.NOTHING; moduleName = ""; moduleIcon = ""; modifyModule = null; detailModuleDialog.close(); } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -