2 Replies Latest reply on Oct 30, 2007 10:29 AM by Florian Duehring

    Problem when creating DataTable programmatically

    Florian Duehring Newbie

      Hi,
      I try to programmatically create a rich:dataTable programmatically.
      And adding a column with ajax-enabled commandLinks
      Here are some code-snippets

      this.dataTable = new HtmlDataTable();
      ...
      UIColumn column = new UIColumn();
      
      //create link
      HtmlCommandLink commandLink = new HtmlCommandLink();
      tmlAjaxSupport support = new HtmlAjaxSupport();
      support.setOnsubmit("alert('submit');");
      support.setOncomplete("checkAfterDelete();");
      commandLink.getChildren().add(support);
      
      //create method binding for action
      MethodBinding methodBinding =
       FacesContext.getCurrentInstance().getApplication().
       createMethodBinding(
       "#{sumShowItems.deleteSumItem}",
       null
       );
      commandLink.setAction(methodBinding);
      
      //create rendered
      HtmlPanelGrid grid = new HtmlPanelGrid();
      grid.setValueBinding(
       "rendered",
       FacesContext.getCurrentInstance().
       getApplication().
       createValueBinding(
       "#{item.timestmp == null}"
       )
      );
      //create text
      HtmlOutputText outputText = new HtmlOutputText();
      outputText.setValue("Loeschen");
      commandLink.getChildren().add(outputText);
      
      UIOutput header = new UIOutput();
      header.setValue("Delete");
      column.setHeader(header);
      
      grid.getChildren().add(commandLink);
      column.getChildren().add(grid);
      this.dataTable.getChildren().add(column);
      

      At first I wanted to use HtmlAjaxCommandLink, but theres no onsubmit-property for this element, so I decided to use the normal HtmlCommandLink with ajaxsupport.

      The Link is displayed, but neither the onsubmit-action not the normal action-method is called. Any idea how to do that?

      Thanks