首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

JSF 相关有关问题 按钮不能执行,还没有报错

2012-01-06 
JSF相关问题按钮不能执行,还没有报错下面是页面:%@taglib urihttp://java.sun.com/jsf/core prefixf

JSF 相关问题 按钮不能执行,还没有报错
下面是页面:
<%@taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.tongtech.tongintegrator.monitorcenter.view.bean.*"%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>编辑用户</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<link rel="stylesheet" type="text/css" href="../css/css.css">
</head>
<body>
<f:view>
<table border="0" width="100%" cellspacing="0" cellpadding="3"
class="small">
<tr>
<td align="left">
<h:graphicImage id="node_user" value="../images/node_user.gif"></h:graphicImage>
<h:outputText value="编辑用户" id="opt1"></h:outputText>
</td>
</tr>
</table>
<h:form>
<table border="0" cellspacing="1" width="90%" cellpadding="3"
align="center">
<tr>
<td style="width: 122px; height: 30px">
<h:outputLabel for="userName">
<h:outputText value="用户名: " id="outputText11"></h:outputText>
</h:outputLabel>
</td>
<td>
<h:inputText id="userName" required="true"
value="#{userBean.userName}"></h:inputText>

<h:message for="userName" id="usernameMsg"></h:message>
<h:inputHidden value="#{userBean.user_id}" id="user_id"></h:inputHidden>

</td>
</tr>
<tr>
<td>
<h:outputLabel for="password">
<h:outputText value="密码:" id="outputText8"></h:outputText>
</h:outputLabel>
</td>
<td>
<h:inputSecret id="password" required="true"
value="#{userBean.password}" redisplay="true"></h:inputSecret>
</td>
</tr>
<tr>
<td>
<h:outputLabel for="repassword">
<h:outputText value="确认密码:" id="outputText3"></h:outputText>
</h:outputLabel>
</td>
<td>
<h:inputSecret id="repassword" value="#{userBean.repassword}"
required="true" redisplay="true">
</h:inputSecret>
<h:message for="repassword" id="passwordMsg"></h:message>
</td>
</tr>
<tr>
<td>
<h:outputLabel for="department">
<h:outputText value="部门:" id="outputText44"></h:outputText>
</h:outputLabel>
</td>
<td>
<h:selectOneMenu id="department">


<f:selectItems value="#{userInfoBean.department}" />
</h:selectOneMenu>
</td>
</tr>
<tr>
<td>
<h:outputLabel for="roleEdit">
<h:outputText value="角色: " id="outputText66"></h:outputText>
</h:outputLabel>
</td>
<td>
<h:selectManyCheckbox layout="lineDirection" id="roleEdit">
<f:selectItems value="#{userInfoBean.roles}" />
</h:selectManyCheckbox>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<h:commandButton value="修改" id="bt1" type="submit"
action="#{userBean.modify}"
onclick="parent.userTree.location.reload();" />
<h:commandButton value="删除" id="bt2" type="submit"
action="#{userBean.delete}"
onclick="parent.userTree.location.reload();" />
</td>
</tr>

</table>
</h:form>
</f:view>
</body>
</html>


下面是userBean:
public class UserBean extends BaseBean {
private String userName;
private String password;
private String repassword;
private String dpt;// 新加用户时,存放用户的部门 
//private List <SelectItem> department;//在编辑用户时,选择用户所在的部门
private String phone;
//private boolean[] role;
//private List groupAll;
private MonitorUser userInfo;
private String user_id;
private MonitorUser user;
//private List<MonitorGroup> allGroup;

public UserBean() {
super();
//department = new ArrayList<SelectItem>();
MonitorUserService monitorUserService = (MonitorUserService) getServiceBean("monitorUserService");
//allGroup = monitorUserService.findGroupAll();
String userid = FacesUtils.getRequestParameter("userid");
/*for(int i = 0;i<allGroup.size();i++){
MonitorGroup group = (MonitorGroup)allGroup.get(i);
this.department.add(new SelectItem(group.getGroupId(),group.getGroupName()));
}*/
if (userid != null) {
Integer id = Integer.valueOf(FacesUtils
.getRequestParameter("userid"));
userInfo = monitorUserService.findUserByUserID(id);
userName = userInfo.getUsername();
user_id = String.valueOf(userInfo.getUserid());
password = userInfo.getPassword();
repassword = password;
}
}

public String modify() {
MonitorUserService monitorUserService = (MonitorUserService) getServiceBean("monitorUserService");
if (user_id != null) {
Integer userId = Integer.valueOf(user_id);
userInfo = monitorUserService.findUserByUserID(userId);
userInfo.setUsername(userName);
userInfo.setPassword(password);
monitorUserService.updateUser(userInfo);
return "modify success";
}
return " modify false";
}

public String delete() {
MonitorUserService monitorUserService = (MonitorUserService) getServiceBean("monitorUserService");
if (user_id != null) {
Integer userId = Integer.valueOf(user_id);
user = monitorUserService.findUserByUserID(userId);
monitorUserService.deleteUser(user);
return "delete success";
}
return "delete false";
}

}

下面是userInfoBean:
public UserInfoBean(){
super();
department = new ArrayList<SelectItem>();
roles = new ArrayList<SelectItem>();
MonitorUserService monitorUserService = (MonitorUserService) getServiceBean("monitorUserService");


allGroup = monitorUserService.findGroupAll();
allRole = monitorUserService.findRoleAll();
//String userid = FacesUtils.getRequestParameter("userid");
for(int i = 0;i<allGroup.size();i++){
MonitorGroup group = (MonitorGroup)allGroup.get(i);
this.department.add(new SelectItem(group.getGroupId(),group.getGroupName()));
}
for(int i = 0;i<allRole.size();i++){
MonitorRole role = (MonitorRole)allRole.get(i);
this.roles.add(new SelectItem(role.getRoleId(),role.getRoleName()));
}
}
当页面中没有
<h:selectOneMenu id="department">
  <f:selectItems value="#{userInfoBean.department}" />
</h:selectOneMenu>
和 
<h:selectManyCheckbox layout="lineDirection" id="roleEdit">
  <f:selectItems value="#{userInfoBean.roles}" />
</h:selectManyCheckbox>
时 修改和删除按钮都可以执行,加上后,两个按钮就失效了,还不报错


[解决办法]
如:
<h:selectOneMenu value="#{userInfoBean.depart}" > 
<f:selectItems value="#{userInfoBean.department}" / > 
</h:selectOneMenu > 

热点排行