Richfaces 4数据表rowclick没有达到侦听器方法

时间:2011-03-29 15:55:53

标签: ajax jsf datatable richfaces

我正在从richfaces 3到4迁移应用程序。我被困在数据表中。

rowclick向服务器发送请求并呈现响应,但不调用侦听器方法。它甚至没有评估方法。我试过提供一个不存在的方法名称,它仍然不会在运行时抱怨。我正在使用Richfaces 4.0.0 CR1库。

任何人都有线索,请帮助我。

这是我的数据表代码。

<rich:dataTable id="customersTable"
    value="#{customerBean.customerList}" 
        var="customer" 
        rowKeyVar="rowKey">
            <a4j:ajax event="rowclick" 
                    listener="#{customerBean.makeRowEditable}">
             </a4j:ajax>
        <rich:column>
            <f:facet name="header">Id</f:facet>
            #{customer.id}
        </rich:column>

        <rich:column>
            <f:facet name="header">Name</f:facet>
            #{customer.name}
        </rich:column>
</rich:dataTable>

支持豆

package myapp;


import java.util.ArrayList;
import java.util.List;

import javax.faces.event.AjaxBehaviorEvent;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class CustomerBean {

    protected Log log = LogFactory.getLog(this.getClass());
    private List<Customer> customerList;
    private Customer selectedCustomer;

    public CustomerBean() {
        log.warn("CustomeBean is instantiated." + this);

        this.customerList = new ArrayList<CustomerBean.Customer>();
        customerList.add(new Customer(1, "One"));
        customerList.add(new Customer(2, "Two"));
        customerList.add(new Customer(3, "Three"));
        customerList.add(new Customer(1, "Four"));
    }

    public List<Customer> getCustomerList() {
        return customerList;
    }

    public void setCustomerList(List<Customer> customerList) {
        this.customerList = customerList;
    }

    public Customer getSelectedCustomer() {
        return selectedCustomer;
    }

    public void setSelectedCustomer(Customer selectedCustomer) {
        this.selectedCustomer = selectedCustomer;
    }

    public void makeRowEditable(AjaxBehaviorEvent event) {
        log.warn("CustomerBean. makeRowEditable: ");
    }

    public void selectCustomer(Customer customer) {
        this.selectedCustomer = customer;
        log.warn("CustomerBean. selectCustomer: customer = " + customer);
    }


    public void unselectCustomer() {
        log.warn("CustomerBean. unselectCustomer: ");
        this.selectedCustomer = null;
    }


    public class Customer {
        private int id;
        private String name;

        public Customer() {
        }

        public Customer(int id, String name) {
            this.id = id;
            this.name = name;
        }

        public int getId() {
            return id;
        }

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

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }
    }
}

感谢任何帮助:)

1 个答案:

答案 0 :(得分:1)

删除它 <a4j:ajax event="rowclick" listener="#{customerBean.makeRowEditable}"> </a4j:ajax> 如果你使用richfaces 4!