1 Reply Latest reply on Aug 16, 2007 12:40 PM by mrohad

    DataModal and a4j:support

    mrohad

      I've a rich:dataTable and onRowClick I am calling an actionListener in a back bean(using a4j:support) , now I would like to get the row I clicked

      my back bean extends EntityQuery
      on the actionlistener I call the method getDataModelSelection() but I always get the first row...
      how can I fix it?

        • 1. Re: DataModal and a4j:support
          mrohad

          I've 2 problems
          1)when I'm calling selectCustomerFromTable i am always getting the first row
          2) when I calling the update method updatecustomer is empty...

          any idea?

          @Scope(ScopeType.CONVERSATION)
          @Name("customerList")
          public class CustomerList extends EntityQuery {
          
           private static final String[] RESTRICTIONS = {
           "lower(customer.name) like concat(lower(#{customerList.customer.name}),'%')",
           "lower(customer.shortName) like concat(lower(#{customerList.customer.shortName}),'%')",
           "lower(customer.address) like concat(lower(#{customerList.customer.address}),'%')",
           "lower(customer.address2) like concat(lower(#{customerList.customer.address2}),'%')",
           "lower(customer.phoneNumber) like concat(lower(#{customerList.customer.phoneNumber}),'%')",
           "lower(customer.phoneNumber2) like concat(lower(#{customerList.customer.phoneNumber2}),'%')",
           "lower(customer.fax) like concat(lower(#{customerList.customer.fax}),'%')",};
          
           private Customer customer = new Customer();
           @DataModel
           List<Customer> customers = null;
           public List<Customer> getCustomers(){
           customers = (List<Customer>) getResultList();
           return customers;
           }
          
           private Customer updateCustomer = new Customer();
           @Override
           public String getEjbql() {
           return "select customer from Customer customer";
           }
          
           @Override
           public Integer getMaxResults() {
           return 25;
           }
          
           public Customer getCustomer() {
           return customer;
           }
          
           @Override
           public List<String> getRestrictions() {
           return Arrays.asList(RESTRICTIONS);
           }
           public void selectCustomerFromTable(ActionEvent event){
           int x = 1;
           updateCustomer = (Customer) getDataModelSelection();
           }
          
          
           public Customer getUpdateCustomer() {
           return updateCustomer;
           }
           public void update(ActionEvent event){
           getEntityManager().persist(updateCustomer);
           getEntityManager().flush();
           }
          
          
          }