2 Replies Latest reply on Mar 10, 2008 11:05 AM by mrbiggles

    Using <s:link...> in HtmlDataTable

    mrbiggles

      Hello,


      I would like to create a dynamic dataTable view using a HtmlDataTable Object. I know how to do that for tables containing static text or attribute bindings like

      #{user.name}

      . Problem is, that I also want to have a
      <s:link...>

      entry in the first column. For Example:



      
      <h:dataTable id="users" value="#{users}" var="user">
      
        <h:column>
      
         <f:facet name="header">Action</f:facet>
      
         <s:link id="editUser" value="Edit" action="#{userEdit.selectUser(user)}"/>
      
        </h:column>
      
        <h:column>
      
          <f:facet name="header">Login</f:facet>
      
          #{user.login}
      
        </h:column>
      
        <h:column>
      
        <f:facet name="header">Name</f:facet>
      
        #{user.name}
      
        </h:column>
      
      </h:dataTable>
      
      



      What I already have worked out is this:


      
              dataTable = new HtmlDataTable();
      
      
      
              String[] cols = "login, name".split(",");
      
      
              // Set columns.
      
              for (int i = 0; i < columns; i++) {
      
                  
      
                   String col = cols[i].trim();
      
                   
      
                  // Set header (optional).
      
                  UIOutput header = new UIOutput();
      
                  header.setValue(col);
      
      
                  // Set output.
      
                  UIOutput output = new UIOutput();
      
                  
      
                  ValueBinding myItem = FacesContext.getCurrentInstance().getApplication().createValueBinding("#{user." + col + "}");
      
                  output.setValueBinding("value", myItem);
      
      
                  // Set column.
      
                  UIColumn column = new UIColumn();
      
                  column.setHeader(header);
      
                  column.getChildren().add(output);
      
                  
      
                  // Add column.
      
                  dataTable.getChildren().add(column);
      
              }
      
      




      This works fine, but now I need a way to include a seam link:

      <s:link...>

      How can I do this?


      Regards, MrBiggles