📄 studentaction.java
字号:
package com.xm.xjgl.xslr.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.wygl.xtgl.service.DeptService;
import com.xm.xjgl.classmanage.service.ClassService;
import com.xm.xjgl.majormanage.service.MajorService;
import com.xm.xjgl.xslr.condition.StudentCondition;
import com.xm.xjgl.xslr.domain.StudentEntity;
import com.xm.xjgl.xslr.service.StudentService;
public class StudentAction extends AbstractAction implements ModelDriven{
private static final long serialVersionUID = 1L;
private StudentService studentService ;
private DeptService deptService ;
private DmListService dmListService ; //提取代码列表
private MajorService majorService ;
private ClassService classService ;
private StudentCondition condition ;
private List studentList ;
private List deptList ; //存放部门信息
private List mzList ; //民族列表
private List majorList ;
private List classList ;
private List xzList ; //学制集合
private List zzmmList ; //政治面貌集合
private List xbList ; //性别集合
private List ztList ; //状态集合
private List pyfsList ; //培养方式
private List selectedStudents = new XWorkList(String.class);
private StudentEntity studentEntity ;
private String studentId ;
public String getStudentId() {
return studentId;
}
public void setStudentId(String studentId) {
this.studentId = studentId;
}
public Object getModel() {
try{
condition = (StudentCondition) get("condition");
}catch (Exception e){
condition = new StudentCondition();
}
if(condition == null){
condition = new StudentCondition();
}
return condition;
}
/**初始化服务*/
public void initService() {
if(studentService == null){
studentService = (StudentService) this.getServiceBean("studentService");
}
if(deptService == null){
deptService = (DeptService) this.getServiceBean("deptService");
}
if(dmListService == null){
dmListService = (DmListService) this.getServiceBean("dmListService");
}
if(majorService == null){
majorService = (MajorService) this.getServiceBean("majorService");
}
if(classService == null){
classService = (ClassService) this.getServiceBean("classService");
}
}
/**查询列表信息*/
public String query() throws Exception {
try{
initService();
studentService.setCondition(condition);//传入condition条件
studentService.creatHquery();//构建hql
condition = (StudentCondition) studentService.getCondition();//获得设置完的condition
studentList = studentService.queryList();//查询结果集
deptList = deptService.queryList();
set("condition",condition);
return "query";
}catch (HibernateException e) {
e.printStackTrace();
return ERROR;
}
}
public String query2() throws Exception {
try{
initService();
studentService.setCondition(condition);//传入condition条件
studentService.creatHquery();//构建hql
condition = (StudentCondition) studentService.getCondition();//获得设置完的condition
studentList = studentService.queryList();//查询结果集
deptList = deptService.queryList();
set("condition",condition);
return "query2";
}catch (HibernateException e) {
e.printStackTrace();
return ERROR;
}
}
/**删除学生信息*/
public String delete()
{
initService();
String rtn =studentService.delete(selectedStudents);
if(rtn.equals("false")){
this.addActionError("没有可以删除的信息!");
return ERROR;
}else if (rtn.equals("error")){
this.addActionError("删除失败!");
return ERROR;
}
return "delete";
}
/**转到添加页
* @throws Exception */
public String toAddPage() throws Exception
{
initService();
mzList = dmListService.getMzList();
deptList = deptService.queryList();
majorList = majorService.queryList();
classList = classService.queryList();
xbList = dmListService.getxllb("SexCode");
xzList = dmListService.getxllb("XueZhi");
zzmmList = dmListService.getxllb("Zzmm");
ztList = dmListService.getxllb("State");
pyfsList = dmListService.getxllb("Pyfs");
return "toAddPage";
}
/**添加学生信息*/
public String add()
{
initService();
studentService.add(studentEntity);
return "add";
}
/**查询一条记录
* @throws Exception */
public String queryById() throws Exception
{
initService();
mzList = dmListService.getMzList();
deptList = deptService.queryList();
majorList = majorService.queryList();
classList = classService.queryList();
xbList = dmListService.getxllb("SexCode");
xzList = dmListService.getxllb("XueZhi");
zzmmList = dmListService.getxllb("Zzmm");
ztList = dmListService.getxllb("State");
pyfsList = dmListService.getxllb("Pyfs");
studentEntity = (StudentEntity) studentService.queryById(studentId);
return "queryById";
}
public String queryById2() throws Exception
{
initService();
studentEntity = (StudentEntity) studentService.queryById(studentId);
return "queryById2";
}
/**保存记录
* @throws Exception */
public String save() throws Exception
{
initService();
studentService.saveObject(studentEntity);
return "update";
}
public StudentService getStudentService() {
return studentService;
}
public void setStudentService(StudentService studentService) {
this.studentService = studentService;
}
public void setCondition(StudentCondition condition) {
this.condition = condition;
}
public List getStudentList() {
return studentList;
}
public void setStudentList(List studentList) {
this.studentList = studentList;
}
public DeptService getDeptService() {
return deptService;
}
public void setDeptService(DeptService deptService) {
this.deptService = deptService;
}
public List getDeptList() {
return deptList;
}
public void setDeptList(List deptList) {
this.deptList = deptList;
}
public List getSelectedStudents() {
return selectedStudents;
}
public void setSelectedStudents(List selectedStudents) {
this.selectedStudents = selectedStudents;
}
public StudentEntity getStudentEntity() {
return studentEntity;
}
public void setStudentEntity(StudentEntity studentEntity) {
this.studentEntity = studentEntity;
}
public DmListService getDmListService() {
return dmListService;
}
public void setDmListService(DmListService dmListService) {
this.dmListService = dmListService;
}
public MajorService getMajorService() {
return majorService;
}
public void setMajorService(MajorService majorService) {
this.majorService = majorService;
}
public List getMzList() {
return mzList;
}
public void setMzList(List mzList) {
this.mzList = mzList;
}
public ClassService getClassService() {
return classService;
}
public void setClassService(ClassService classService) {
this.classService = classService;
}
public List getMajorList() {
return majorList;
}
public void setMajorList(List majorList) {
this.majorList = majorList;
}
public List getClassList() {
return classList;
}
public void setClassList(List classList) {
this.classList = classList;
}
public List getXzList() {
return xzList;
}
public void setXzList(List xzList) {
this.xzList = xzList;
}
public List getZzmmList() {
return zzmmList;
}
public void setZzmmList(List zzmmList) {
this.zzmmList = zzmmList;
}
public List getXbList() {
return xbList;
}
public void setXbList(List xbList) {
this.xbList = xbList;
}
public List getZtList() {
return ztList;
}
public void setZtList(List ztList) {
this.ztList = ztList;
}
public List getPyfsList() {
return pyfsList;
}
public void setPyfsList(List pyfsList) {
this.pyfsList = pyfsList;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -