【问题标题】:Page hangs after commandbutton action inside datatable [duplicate]数据表内的命令按钮操作后页面挂起[重复]
【发布时间】:2017-03-06 13:25:26
【问题描述】:

我正在使用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")));
	}
	
	
	
	
}

【问题讨论】:

    标签: jsf icefaces icefaces-3


    【解决方案1】:
    <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 使用调试来验证您没有重复的 id。每行都应该有一个唯一的id 我通常将行号添加到id

    【讨论】:

    • 谢谢你的回答,我照你说的做了,改了身份证,但不幸的是我还是有同样的问题
    猜你喜欢
    • 2012-05-13
    • 2012-11-18
    • 2018-03-19
    • 1970-01-01
    • 2018-01-24
    • 1970-01-01
    • 2019-07-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多