• 大小: 11.49MB
    文件类型: .rar
    金币: 2
    下载: 1 次
    发布日期: 2023-07-29
  • 语言: 其他
  • 标签: jsf  

资源简介

jsf实现的增删改查小示范,大家共同学习进步

资源截图

代码片段和文件信息

package com.demo.bean;

import java.util.ArrayList;
import java.util.List;

import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;

import com.demo.dao.StudentDAO;
import com.demo.entity.Student;

public class StuOptBean
{
 private Integer stuId;
     private String stuName = ““;
     private Integer stuAge;
     private String stuAddress = ““;
 private StudentDAO stuDAO = new StudentDAO();
 private List stuList = new ArrayList();
 
public StudentDAO getStuDAO()
{
return stuDAO;
}

public void setStuDAO(StudentDAO stuDAO)
{
this.stuDAO = stuDAO;
}


public String getStuAddress()
{
return stuAddress;
}

public void setStuAddress(String stuAddress)
{
this.stuAddress = stuAddress;
}

public Integer getStuAge()
{
return stuAge;
}

public void setStuAge(Integer stuAge)
{
this.stuAge = stuAge;
}


public Integer getStuId()
{
return stuId;
}

public void setStuId(Integer stuId)
{
this.stuId = stuId;
}

public String getStuName()
{
return stuName;
}

public void setStuName(String stuName)
{
this.stuName = stuName;
}

public List getStuList()
{
stuList = stuDAO.findAll();
return stuList;
}

public void setStuList(List stuList)
{
this.stuList = stuList;
}



//查询单条记录方法
public String selById()
{
try
{
FacesContext ctx = FacesContext.getCurrentInstance();
String stuId = (String)ctx.getExternalContext().getRequestParameterMap().get(“stuId“);

Student student = stuDAO.findById(Integer.parseInt(stuId));
if (student != null)
{
this.setStuId(student.getStuId());
this.setStuName(student.getStuName());
this.setStuAge(student.getStuAge());
this.setStuAddress(student.getStuAddress());
}
}
catch (Exception e)
{
return “error“;
}

return “update“;
}

//插入数据方法
public String insert()
{
try
{
Student student = new Student();
student.setStuId(this.getStuId());
student.setStuName(this.getStuName());
student.setStuAge(this.getStuAge());
student.setStuAddress(this.getStuAddress());
stuDAO.save(student);
}
catch(Exception e)
{
return “error“;
}
return “main“;
}

//更新数据方法
public String update()
{
try
{
Student student = new Student();
student.setStuId(this.getStuId());
student.setStuName(this.getStuName());
student.setStuAge(this.getStuAge());
student.setStuAddress(this.getStuAddress());
int i = stuDAO.update(student);
}
catch(Exception e)
{
return “error“;
}
return “main“;
}

//删除数据方法
public String delete()
{
try
{
FacesContext ctx = FacesContext.getCurrentInstance();
String stuId = (String)ctx.getExternalContext().getRequestParameterMap().get(“stuId“);
int i = stuDAO.delete(Integer.parseInt(stuId));
}
catch(Exception e)
{
return “error“;
}
return “main“;
}

}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       3178  2008-09-28 14:09  DemoByWukewei\.classpath

     文件        487  2008-09-28 14:09  DemoByWukewei\.myhibernatedata

     文件        312  2008-09-28 14:09  DemoByWukewei\.mymetadata

     文件       1616  2008-09-28 14:09  DemoByWukewei\.project

     文件       7165  2008-09-28 14:09  DemoByWukewei\build.xml

     文件     512707  2008-09-28 14:09  DemoByWukewei\DemoByWukewei\WebRoot\WEB-INF\lib\mysql.jar

     文件        508  2008-09-28 14:09  DemoByWukewei\mysql.sql

     文件       3028  2008-09-28 14:09  DemoByWukewei\src\com\demo\bean\StuOptBean.java

     文件       2350  2008-09-28 14:09  DemoByWukewei\src\com\demo\dao\StudentDAO.java

     文件        924  2008-09-28 14:09  DemoByWukewei\src\com\demo\entity\Student.hbm.xml

     文件       1140  2008-09-28 14:09  DemoByWukewei\src\com\demo\entity\Student.java

     文件       3072  2008-09-28 14:09  DemoByWukewei\src\com\demo\hibernate\HibernateSessionFactory.java

     文件        910  2008-09-28 14:09  DemoByWukewei\src\hibernate.cfg.xml

     文件        308  2008-09-28 14:09  DemoByWukewei\WebRoot\error.jsp

     文件        216  2008-09-28 14:09  DemoByWukewei\WebRoot\index.jsp

     文件       1191  2008-09-28 14:09  DemoByWukewei\WebRoot\insert.jsp

     文件       1779  2008-09-28 14:09  DemoByWukewei\WebRoot\main.jsp

     文件         39  2008-09-28 14:09  DemoByWukewei\WebRoot\meta-INF\MANIFEST.MF

     文件       1388  2008-09-28 14:09  DemoByWukewei\WebRoot\update.jsp

     文件       1797  2008-09-28 14:09  DemoByWukewei\WebRoot\WEB-INF\.faces-config.mex

     文件      10763  2008-09-28 14:09  DemoByWukewei\WebRoot\WEB-INF\c-1_0-rt.tld

     文件      11310  2008-09-28 14:09  DemoByWukewei\WebRoot\WEB-INF\c-1_0.tld

     文件      15999  2008-09-28 14:09  DemoByWukewei\WebRoot\WEB-INF\c.tld

     文件       3674  2008-09-28 14:09  DemoByWukewei\WebRoot\WEB-INF\classes\com\demo\bean\StuOptBean.class

     文件       3378  2008-09-28 14:09  DemoByWukewei\WebRoot\WEB-INF\classes\com\demo\dao\StudentDAO.class

     文件       1396  2008-09-28 14:09  DemoByWukewei\WebRoot\WEB-INF\classes\com\demo\entity\Student.class

     文件        924  2008-09-28 14:09  DemoByWukewei\WebRoot\WEB-INF\classes\com\demo\entity\Student.hbm.xml

     文件       2406  2008-09-28 14:09  DemoByWukewei\WebRoot\WEB-INF\classes\com\demo\hibernate\HibernateSessionFactory.class

     文件        910  2008-09-28 14:09  DemoByWukewei\WebRoot\WEB-INF\classes\hibernate.cfg.xml

     文件       1618  2008-09-28 14:09  DemoByWukewei\WebRoot\WEB-INF\faces-config.xml

............此处省略80个文件信息

评论

共有 条评论