📄 kkaction.java
字号:
package com.xm.cjgl.kkgl.action;
import java.util.List;
import net.sf.hibernate.HibernateException;
import com.hibernate.action.AbstractAction;
import com.opensymphony.xwork.ModelDriven;
import com.opensymphony.xwork.util.XWorkList;
import com.wygl.dmwh.service.DmListService;
import com.xm.cjgl.kkgl.condition.KkCondition;
import com.xm.cjgl.kkgl.domain.KkbEntity;
import com.xm.cjgl.kkgl.service.KkService;
public class KkAction extends AbstractAction implements ModelDriven {
private static final long serialVersionUID = -8865697900862435526L;
private KkService kkService ;
private KkCondition condition ;
private List kkList ;
private KkbEntity kkbEntity ;
private List selectedKcs = new XWorkList(String.class);
private List kslxList ;
private List kclxList ;
private String kkId ;
private DmListService dmListService ; //提取代码列表
public DmListService getDmListService() {
return dmListService;
}
public void setDmListService(DmListService dmListService) {
this.dmListService = dmListService;
}
public String getKkId() {
return kkId;
}
public void setKkId(String kkId) {
this.kkId = kkId;
}
public KkbEntity getKkbEntity() {
return kkbEntity;
}
public void setKkbEntity(KkbEntity kkbEntity) {
this.kkbEntity = kkbEntity;
}
public Object getModel() {
try{
condition = (KkCondition) get("condition");
}catch (Exception e){
condition = new KkCondition();
}
if(condition == null){
condition = new KkCondition();
}
return condition;
}
/**初始化服务*/
public void initService() {
if(kkService == null){
kkService = (KkService) this.getServiceBean("kkService");
}
if(dmListService == null){
dmListService = (DmListService) this.getServiceBean("dmListService");
}
}
/**查询列表信息*/
public String query() throws Exception {
try{
initService();
kkService.setCondition(condition);//传入condition条件
kkService.creatHquery();//构建hql
condition = (KkCondition) kkService.getCondition();//获得设置完的condition
kkList = kkService.queryList();
kclxList = dmListService.getxllb("Kclx");
set("condition",condition);
return "query";
}catch (HibernateException e) {
e.printStackTrace();
return ERROR;
}
}
/**转到添加页
* @throws Exception */
public String toAddPage() throws Exception
{
initService();
kslxList = dmListService.getxllb("Kslx");
kclxList = dmListService.getxllb("Kclx");
return "toAddPage";
}
/**添加课程信息*/
public String add()
{
initService();
kkService.add(kkbEntity);
return "add";
}
/**删除课程信息*/
public String delete()
{
initService();
String rtn =kkService.delete(selectedKcs);
if(rtn.equals("false")){
this.addActionError("没有可以删除的信息!");
return ERROR;
}else if (rtn.equals("error")){
this.addActionError("删除失败!");
return ERROR;
}
return "delete";
}
/**保存修改后的数据
* @throws Exception */
public String save() throws Exception
{
initService();
kkService.saveObject(kkbEntity);
return "update";
}
/**根据ID查询一条记录
* @throws Exception */
public String queryById() throws Exception
{
initService();
kslxList = dmListService.getxllb("Kslx");
kclxList = dmListService.getxllb("Kclx");
kkbEntity = (KkbEntity) kkService.queryById(kkId);
return "queryById";
}
public KkService getKkService() {
return kkService;
}
public void setKkService(KkService kkService) {
this.kkService = kkService;
}
public void setCondition(KkCondition condition) {
this.condition = condition;
}
public List getKkList() {
return kkList;
}
public void setKkList(List kkList) {
this.kkList = kkList;
}
public List getSelectedKcs() {
return selectedKcs;
}
public void setSelectedKcs(List selectedKcs) {
this.selectedKcs = selectedKcs;
}
public List getKslxList() {
return kslxList;
}
public void setKslxList(List kslxList) {
this.kslxList = kslxList;
}
public List getKclxList() {
return kclxList;
}
public void setKclxList(List kclxList) {
this.kclxList = kclxList;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -