3 Replies Latest reply on Jan 17, 2008 10:50 AM by Justin Cobb

    a4j:support inside rich:dataTable

    Justin Cobb Newbie

      Is it possible to add an a4j:support tag within a rich:dataTable to look for event "onRowClick" I have tried over and over to get this to work and I dont know if I am just doing something wrong. I had the same problem getting an a4j:support to work in a rich:listshuttle component. Can you add a4j:support to a rich component or not since the richfaces component is already ajaxed?

        • 1. Re: a4j:support inside rich:dataTable
          Justin Cobb Newbie

          So here is what I am trying to do. I have a dataTable generated dynamically. And I want to add support for an onRowClick event. I have tried using an actionListener and the action event. I have no problem populating the data table, I just can't get any onRowClick actions to fire. Here is some example code

          
          HtmlPanelGrid grid = new HtmlPanelGrid();
           grid.setStyle("width:100%;");
           grid.setColumns(1);
          
           HtmlDatascroller myScroll = new HtmlDatascroller();
           myScroll.setId("dynamicdatascroller");
           myScroll.setStyle("width:100%;");
           myScroll.setTableStyle("width:100%;");
           myScroll.setAlign("center");
           myScroll.setFor("dynamicsearchtable");
           myScroll.setMaxPages(20);
           grid.getChildren().add(myScroll);
          
           HtmlSpacer mySpacer = new HtmlSpacer();
           mySpacer.setHeight("10");
           grid.getChildren().add(mySpacer);
          
           // Create datatable.
           HtmlDataTable dynamicDataTable = new HtmlDataTable();
           dynamicDataTable.setId("dynamicsearchtable");
           dynamicDataTable.setOnRowMouseOver("this.style.backgroundColor='#F1F1F1'");
           dynamicDataTable.setOnRowMouseOut("this.style.backgroundColor='#FFFFFF'");
           dynamicDataTable.setRows(8);
           dynamicDataTable.setStyle("width:100%;");
           dynamicDataTable.setValueExpression("value", createValueExpression("#{SearchBean.dynamicList}", List.class));
           dynamicDataTable.setVar("dynamicItem");
          
           HtmlAjaxSupport support = new HtmlAjaxSupport();
           support.setAjaxSingle(true);
           support.setEvent("onRowClick");
           support.setId("ajaxrowclick");
          
          //Try and use an action event
           support.setActionExpression(createActionExpression("#{SearchBean.rowClickAction}", String.class));
          
          // This is where i tried and use an actionlistener
          // RowClickEvent evt = new RowClickEvent();
          // support.addActionListener(evt);
           dynamicDataTable.getChildren().add(support);
          
           grid.getChildren().add(dynamicDataTable);
          
          
          
          
          
          
          private MethodExpression createActionExpression(String actionExpression, Class<?> returnType) {
           FacesContext facesContext = FacesContext.getCurrentInstance();
           return facesContext.getApplication().getExpressionFactory().createMethodExpression(
           facesContext.getELContext(), actionExpression, returnType, new Class[0]);
           }
          


          • 2. Re: a4j:support inside rich:dataTable
            Ilya Shaikovsky Master

            you should add it as facet instead of as component.

            • 3. Re: a4j:support inside rich:dataTable
              Justin Cobb Newbie

              I'll try adding the a4j:support using the facet tag. I wasn't aware it had to be done this way