导航:
动态导航: action="#{loginBean.login}"
loginBean
com.itanger.web.jsf.form.Master
request
跟 faces_config里面的manager-bean-name匹配来调用类的方法
eg:
public String login(){
String forward = "";
boolean flag = false;
MasterLogin master = new MasterLogin();
flag = master.login(this);
if(flag){
forward = "index";
}else{
forward = "error";
}
return forward;
}
/login.jsp
index
/index.jsp
error
/error.jsp
静态导航 : action="字符串" 来匹配
根据上面的进行跳转
事件: eg:
上面: (1)传参
(2)调用方法
studentBean
com.gayly.web.jsf.form.Student
request
----匹配
类的方法:
public void updateStudentInfoAction(ActionEvent event){
HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance ().getExternalContext().getRequest();
int id = Integer.parseInt(request.getParameter("id"));
studentmanage = new StudentManage();
Student stu = studentmanage.queryStudentByid(id);
request.setAttribute("studentBean", stu);
}
得到页面的ID在根据ID返回一个类的对象 然后再把那个类装到Request对象
注意:
对象: FacesContext.getCurrentInstance ().getExternalContext().getRequest()
他是事件驱动的灵魂
studentBean 一定要与那个Faces_Config中的那个名字相同
阅读(1016) | 评论(0) | 转发(0) |