我正在尝试在我的用户列表页面中按名字进行搜索。在将搜索选项放入用户列表页面之前,用户列表页面工作正常。在 list.xhtml 中添加代码以进行搜索后,页面显示以下错误,请求处理期间出现异常:由 javax.servlet.ServletException 引起,消息为:“/secure/admin/user/customer/customerList.xhtml @70,70 value ="#{userByFirstNameAction.firstName}":在类型 org.javassist.tmp.java.lang.Object_$$_javassist_seam_25 上找不到属性“firstName”
我的列表页面是:customerList.xhtml
<h:form class="input-list" id="searchUser" style="width:100%;"
name="searchUser">
<div class="search_button">
SEARCH BY FIRST NAME :
<h:inputText tabindex="1" id="firstName" type="text"
value="#{userByFirstNameAction.firstName}" required="true">
<f:validateLength minimum="3" maximum="20" />
</h:inputText>
</div>
<h:commandButton value="Search" tabindex="2"
action="#{userByFirstNameAction.retrieveCustomersByFirstName}">
</h:commandButton>
</h:form>
userByFirstNameAction.java :
@Name("userByFirstNameAction")
@Stateless
@AutoCreate
public class UserByFirstNameActionImpl implements UserByFirstNameAction {
private UserTypeEnum userType;
@In
private UserService userService;
//@In(value = "firstName", scope = ScopeType.CONVERSATION, required = false)
private String firstName;
/**
*
*/
private static final long serialVersionUID = 8282995226262125676L;
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
@Override
public List<User> retrieveCustomersByFirstName(String firstName) {
//this.userType = UserTypeEnum.CUSTOMER;
return userService.findByFirst(firstName);
}
}
@Jan 谢谢你的时间..
我已将 Get/Set for firstname 放在 bean 类中...
这里供您参考
界面:
package com.ermms.clrp.user;
import java.io.Serializable;
import java.util.List;
import javax.ejb.Local;
import com.ermms.clrp.dto.user.CLRPUser;
import com.ermms.clrp.dto.user.User;
@Local
public interface UserByFirstNameAction extends Serializable {
public String initEmployee();
public String initCustomer();
public List<User> getEmployeesByFirstName();
public List<User> getCustomersByFirstName();
public List<User> retrieveEmployeesByFirstName();
// public List<User> retrieveCustomersByFirstName();
public List<User> retrieveCustomersByFirstName(String firstName);
}
班级 :
package com.ermms.clrp.user;
import java.util.List;
import javax.ejb.Stateless;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.AutoCreate;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Out;
import com.ermms.clrp.common.enumeration.UserTypeEnum;
import com.ermms.clrp.dto.user.CLRPUser;
import com.ermms.clrp.dto.user.User;
import com.ermms.clrp.service.UserService;
@Name("userByFirstNameAction")
@Stateless
@AutoCreate
public class UserByFirstNameActionImpl implements UserByFirstNameAction {
private UserTypeEnum userType;
@In
private UserService userService;
//@In(value = "firstName", scope = ScopeType.CONVERSATION, required = false)
private String firstName;
/**
*
*/
private static final long serialVersionUID = 8282995226262125676L;
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
@Override
public List<User> getEmployeesByFirstName() {
this.userType = UserTypeEnum.EMPLOYEE;
return userService.findByFirstName(firstName, userType);
}
@Override
public List<User> getCustomersByFirstName() {
this.userType = UserTypeEnum.CUSTOMER;
return userService.findByFirstName(firstName, userType);
}
@Override
public List<User> retrieveEmployeesByFirstName() {
this.userType = UserTypeEnum.EMPLOYEE;
return userService.findByFirstName(firstName, userType);
}
@Override
public List<User> retrieveCustomersByFirstName(String firstName) {
//this.userType = UserTypeEnum.CUSTOMER;
return userService.findByFirst(firstName);
}
public String initEmployee() {
return "/secure/admin/user/customer/customerListByFirstName.xhtml";
}
public String initCustomer() {
this.userType = UserTypeEnum.CUSTOMER;
return "/secure/admin/user/customer/customerListByFirstName.xhtml";
}
public UserTypeEnum getUserType() {
return userType;
}
public void setUserType(UserTypeEnum userType) {
this.userType = userType;
}
}
提前致谢