在数据表

时间:2017-03-06 13:25:27

标签: jsf icefaces icefaces-3

我正在使用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">
			<ace:dataTable id="cptTable" value="#{compte.allComptes}"
				var="cpt" paginator="true" paginatorPosition="bottom" rows="10">
				
				...
				
				<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>
			</ace:dataTable>
		</h:form>
		</f:view>
		</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{

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

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

	public int getId_compte() {
		return id_compte;
	}

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

	public int getId_agence() {
		return id_agence;
	}

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

	public int getId_client() {
		return id_client;
	}

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

	public String getNum_compte() {
		return num_compte;
	}

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

	public double getSolde() {
		return solde;
	}

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

	public String getDate_creation_compte() {
		return date_creation_compte;
	}

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

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

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

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

1 个答案:

答案 0 :(得分: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 =&#34; id&#34;在渲染时它会创建一个重复的id使用debug来验证tou没有重复的id。每行应该有一个唯一的ID我通常将行号添加到id