无法将行从数据表绑定到托管bean

我在将某个配置文件从数据表绑定到ManagedBean进行编辑时遇到问题,我将仅在代码中显示一列以使其易于阅读!

adminIndex.xhtml

<!DOCTYPE html>

   <h:form>
<h:dataTable value = "#{profil.getProfils()}" var = "profil">

 <h:column>                 
   <f:facet name = "header">Login</f:facet>                 
    <h:inputText value = "#{profil.login}" size = "10" rendered = 
        "#{edit.id eq profil.login}" />
        <h:outputText value = "#{profil.login}" rendered = "#{edit.id 
        ne profil.login}" />
    </h:column>
    <h:column>
       <f:facet name ="header">Edit</f:facet>
       <h:commandButton value ="Edit" 
              action = "#{edit.setId(profil.id)}" 
              rendered = "#{edit.id ne profil.login}"> 
           </h:commandButton>
      </h:column>
</h:dataTable>
<h:commandButton id="save" value ="Save" 
              action = "#{profil.saveProfil()}" > 
</h:commandButton>
</h:form>
    </h:body>
</html>

Profil.java:

@Entity
@Table(name="profil")
@ManagedBean(name="profil")
@SessionScoped
public class Profil implements Serializable {

private static final long serialVersionUID = 1L;
@Id
private String login;

public void saveProfil() {
    EditBean eb = new EditBean();
    eb.setId(null);
    ProfilDao dao = new ProfilDao();
    dao.saveProfile(this);
 }

  public List<Profil> getProfils(){
    ProfilDao dao = new ProfilDao();
    return dao.profils();
}
}

EditBean.java:

@ManagedBean(name="edit")
public class EditBean {
private static String id;

    public void setId(String id) {
    this.id = id;
}
}

toString方法显示该对象为null,我需要将该对象绑定到managedBean

wzhm123456 回答:无法将行从数据表绑定到托管bean

谢谢大家,我解决了它,与save相关的命令按钮不在数据表中!

本文链接:https://www.f2er.com/3134898.html

大家都在问