2017-03-06 49 views
0

我正在使用icefaces api項目工作,我遇到了一個問題我在dataTable裏面使用了一個commandButton刪除行中的對象,但是當我點擊它時,服務器掛起並保持加載時不顯示控制檯中的任何錯誤。頁面在命令按鈕操作後在數據表中掛起

使用Apache,Tomcat的7.0.75

我的html代碼:

<ui:composition template="./WEB-INF/template/template.xhtml"> 
 
     <ui:param name="titre" value="Liste de Comptes"/> 
 
     <ui:define name="content"> 
 
     <f:view> 
 
      <h:form id="form"> 
 
\t \t \t <ace:dataTable id="cptTable" value="#{compte.allComptes}" 
 
\t \t \t \t var="cpt" paginator="true" paginatorPosition="bottom" rows="10"> 
 
\t \t \t \t 
 
\t \t \t \t ... 
 
\t \t \t \t 
 
\t \t \t \t <ace:column width="10"> 
 
       <f:facet name="header"> 
 
        <h:outputText value="Opérations"/> 
 
       </f:facet> 
 
       <h:commandLink id="dlt" actionListener="#{compte.deletCompte}" title="Supprimer" > 
 
        <f:param name="idcpt" value="#{cpt.id_compte}"/> 
 
        <ace:ajax execute="dlt" render="form"/> 
 
        <br/> 
 
       </h:commandLink> 
 
       <h:link outcome="modifierCompte" value="Modifier le compte" > 
 
        <f:param name="id" value="#{cpt.id_compte}"/> 
 
       </h:link> 
 
       <ice:outputText value=" | "/> 
 
       <h:link outcome="operation" value="Operation sur le compte" > 
 
        <f:param name="id" value="#{cpt.id_compte}"/> 
 
       </h:link> 
 
        
 
       </ace:column> 
 
\t \t \t </ace:dataTable> 
 
\t \t </h:form> 
 
\t \t </f:view> 
 
\t \t </ui:define> 
 
    </ui:composition>

我的豆:

package jee.model; 
 

 
import java.io.Serializable; 
 
import java.util.ArrayList; 
 
import java.util.Map; 
 

 
import javax.annotation.PostConstruct; 
 
import javax.faces.bean.ManagedBean; 
 
import javax.faces.bean.SessionScoped; 
 
import javax.faces.context.ExternalContext; 
 
import javax.faces.context.FacesContext; 
 
import javax.servlet.http.HttpSession; 
 

 
import jee.dao.dao; 
 

 
@ManagedBean 
 
@SessionScoped 
 
public class Compte implements Serializable{ 
 

 
\t /** 
 
\t * 
 
\t */ 
 
\t private static final long serialVersionUID = -7177239517089845251L; 
 
\t 
 
\t private int id_compte; 
 
\t private int id_agence; 
 
\t private int id_client; 
 
\t private String num_compte; 
 
\t private double solde; 
 
\t private String date_creation_compte; 
 
\t public ArrayList<Compte> comptes; 
 
\t 
 
\t public Compte() { 
 
\t \t super(); 
 
\t \t this.id_agence=1; 
 
\t \t // TODO Auto-generated constructor stub 
 
\t } 
 

 
\t public Compte(int id_compte, int id_agence, int id_client, 
 
\t \t \t String num_compte, double solde, String date_creation_compte, 
 
\t \t \t ArrayList<Compte> comptes) { 
 
\t \t super(); 
 
\t \t this.id_compte = id_compte; 
 
\t \t this.id_agence = id_agence; 
 
\t \t this.id_client = id_client; 
 
\t \t this.num_compte = num_compte; 
 
\t \t this.solde = solde; 
 
\t \t this.date_creation_compte = date_creation_compte; 
 
\t } 
 
\t 
 
\t 
 

 
\t public int getId_compte() { 
 
\t \t return id_compte; 
 
\t } 
 

 
\t public void setId_compte(int id_compte) { 
 
\t \t this.id_compte = id_compte; 
 
\t } 
 

 
\t public int getId_agence() { 
 
\t \t return id_agence; 
 
\t } 
 

 
\t public void setId_agence(int id_agence) { 
 
\t \t this.id_agence = id_agence; 
 
\t } 
 

 
\t public int getId_client() { 
 
\t \t return id_client; 
 
\t } 
 

 
\t public void setId_client(int id_client) { 
 
\t \t this.id_client = id_client; 
 
\t } 
 

 
\t public String getNum_compte() { 
 
\t \t return num_compte; 
 
\t } 
 

 
\t public void setNum_compte(String num_compte) { 
 
\t \t this.num_compte = num_compte; 
 
\t } 
 

 
\t public double getSolde() { 
 
\t \t return solde; 
 
\t } 
 

 
\t public void setSolde(double solde) { 
 
\t \t this.solde = solde; 
 
\t } 
 

 
\t public String getDate_creation_compte() { 
 
\t \t return date_creation_compte; 
 
\t } 
 

 
\t public void setDate_creation_compte(String date_creation_compte) { 
 
\t \t this.date_creation_compte = date_creation_compte; 
 
\t } 
 

 
\t 
 
\t public void setComptes(ArrayList<Compte> comptes) { 
 
\t \t this.comptes = comptes; 
 
\t } 
 

 
\t public ArrayList<Compte> getComptes() { 
 
\t \t dao d = new dao(); 
 
\t \t ExternalContext ec = 
 
\t \t \t \t FacesContext.getCurrentInstance().getExternalContext(); 
 
\t \t HttpSession session = (HttpSession) ec.getSession(false); 
 
\t \t comptes=d.getComptes((String)session.getAttribute("login")); 
 

 
\t \t return comptes; 
 
\t } 
 
\t 
 
\t public void deletCompte(){ 
 
\t \t dao d = new dao(); 
 
\t \t ExternalContext ec = 
 
\t \t \t \t FacesContext.getCurrentInstance().getExternalContext(); 
 
\t \t Map<String,String> params = ec.getRequestParameterMap(); 
 
\t \t 
 
\t \t d.supprimerCompte(Integer.parseInt(params.get("idcpt"))); 
 
\t } 
 
\t 
 
\t 
 
\t 
 
\t 
 
}

回答

0
<h:link outcome="modifierCompte" value="Modifier le compte" > 
       <f:param name="id" value="#{cpt.id_compte}"/> 
      </h:link> 
      <ice:outputText value=" | "/> 
      <h:link outcome="operation" value="Operation sur le compte" > 
       <f:param name="id" value="#{cpt.id_compte}"/> 
      </h:link> 

重複的id可以導致這種情況。你在這裏有重複的名字f:param name =「id」當呈現時它創建一個重複的id使用debug來驗證tou沒有重複的id。每行都應該有一個唯一的ID我通常添加行號到ID

+0

謝謝你的回答,我做了你所說的,並改變了ID的,但不幸的是,我仍然有同樣的問題 –