我是一个看似简单的jsf问题的jsf新手。我工作了几个小时没有运气。这是控制台的例外,后面是代码(提前谢谢):
04-Apr-2018 17:19:31.368 SEVERE [http-nio-8080-exec-10] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [Faces Servlet] in context with path [/crm1] threw exception [javax.el.PropertyNotWritableException: /Reclamation.xhtml @17,115 value="#{CliBean.clientSelect}": Property [clientSelect] not writable on type [com.crm1.presentation.ClientBean]] with root cause
javax.el.PropertyNotWritableException: Property [clientSelect] not writable on type [com.crm1.presentation.ClientBean]
我的bean定义:
@ManagedBean(name="CliBean")
@RequestScoped
public class ClientBean {
public Client selectedClient;
private List<SelectItem> clientSelect;
ClientDAO dao = new ClientDAOImpl();
public Client cli = new Client();
private String logcli;
public Client getCli() {
return cli;
}
public void setCli(Client cli) {
this.cli = cli;
}
public Client getSelectedClient() {
return selectedClient;
}
public void setSelectedClient(Client selectedClient) {
this.selectedClient = selectedClient;
}
/*public List<Client> lister(){
return dao.findAll();
}*/
public String LoginCheck(){
Session ses = HibernateUtil.getSession();
SessionFactory fac = HibernateUtil.getSessionFactory();
ses.getTransaction();
List<Client> list = ses.createSQLQuery("select * from client where login_cli='" + cli.getLoginCli() + "' and pwd_cli='" + cli.getPwdCli() + "'").list();
if (list.size() > 0) {
//servlet session part
logcli = cli.getLoginCli();
HttpSession hs = sessionUtil.getSession();
hs.setAttribute("logcli",logcli);
//servlet session part
//BootFaces
FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "", "Congratulations! You've successfully logged in.");
FacesContext.getCurrentInstance().addMessage("loginForm:password", msg);
//BootFaces
return "/success.xhtml?faces-redirect=true";
} else {
//FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_WARN, "client not found", ""));
//BootFaces
FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "", "client not found !");
FacesContext.getCurrentInstance().addMessage("loginForm:password", msg);
//BootFaces
}
try {
ses.getTransaction().commit();
} catch (Exception e) {
}
ses.close();
return null;
}
public String afflogin(){
return logcli;
}
public String doLogout(){
HttpSession hs = sessionUtil.getSession();
hs.invalidate();
return "/index.xhtml";
}
public List<SelectItem> getClientSelect() {
if (clientSelect == null){
clientSelect = new ArrayList<SelectItem>();
ClientServicesImpl clientServicesImpl = new ClientServicesImpl();
List<Client> listClients = clientServicesImpl.findAll();
if(listClients != null && !listClients.isEmpty()){
SelectItem item;
for (Client clientlist : listClients) {
item = new SelectItem(clientlist , clientlist.getNomCli());
clientSelect.add(item);
}
}
}
return clientSelect;
}
}
JSF代码:
<h:selectOneMenu id="client" value="#{CliBean.clientSelect}" converter="#{clientConverter}" >
<f:selectItems value="#{CliBean.clientSelect}" itemValue="#{CliBean.cli.idCli}"/>
</h:selectOneMenu>
selectedClient有公共吸气剂&amp;二传手 谁能告诉我哪里出错了?如果你愿意,请随意解释,因为我本身不是一个小人物。谢谢。