这个问题不是由bean的方法引起的,虽然bean是创建的,初始化后的其他字段是可见的。不调用用于获得列表的方法。谁遇到过这个问题? 豆:
public class UserBean {
@Autowired
private UserService service;
/**
* User Id.
*/
private Long id = -1l;
/**
* User login.
*/
private String login;
/**
* User password.
*/
private String password;
/**
* User email.
*/
private String email;
/**
* User email.
*/
private String firstName;
/**
* User lastname.
*/
private String lastName;
private Collection<User> list;
public UserBean(){
System.out.println("adsdasadsads");
this.login = "test";
}
public void setList(List<User> list) {
this.list = list;
}
public UserService getService() {
return service;
}
public void setService(UserService service) {
this.service = service;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getLogin() {
return login;
}
public void setLogin(String login) {
this.login = login;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public Collection<User> allUsers(){
System.out.println("wwwwwwwwwwwwwww");
for(User u : service.findAllUsers()){
System.out.println(u);
}
return (Collection<User>) service.findAllUsers();
}
public Collection<User> getList(){
System.out.println("aaaaaaaaaaaaa");
this.list = this.allUsers();
return this.list;
}
//add a new customer data into database
public String addUser(){
service.addUser(new User(8,this.login,this.password,this.email,this.firstName,this.lastName,new Date(90,5,12),new Role(2,"some")));
clearForm();
return "";
}
//clear form values
private void clearForm(){
setLogin("");
setPassword("");
setEmail("");
setFirstName("");
setLastName("");
}
}
面-配置。 XML
<el-resolver>
org.springframework.web.jsf.el.SpringBeanFacesELResolver
</el-resolver>
</application>
<managed-bean>
<managed-bean-name>user</managed-bean-name>
<managed-bean-class>bean.UserBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
<managed-bean>
<managed-bean-name>list</managed-bean-name>
<managed-bean-class>bean.ListBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
JSP:
<f:view>
<h:dataTable value="#{user.list}" var="loc">
....
</h:dataTable>
</f:view>
这不称为“#{user.list}”我在控制台调用上键入...此方法不会扩展,但会创建bean。因为信息很清楚。
众所周知,JSF 1.2.13
帮助,解决问题...