1 Reply Latest reply on Jan 9, 2008 7:24 PM by dkarr

    How to model non-scalar columns in dataTable/subTable?

    dkarr

      JSF 1.1, RichFaces 3.1.3, WebLogic 9.2.2.

      I asked about this a couple days ago, but I'm still struggling with this.

      For background, I'm trying to model a list of "Project" objects, where each project has a name and department, and also a list of Server objects for each project. The number of servers per project is variable, but it's reasonable to assume it's at least one.

      I'll need full editing capabilities, including the ability to add/delete/edit projects and servers.

      I can only find one example of "rich:subTable", and I can't figure out how to get that to work in my situation.

      Can anyone give me any suggestions on how to model this?

        • 1. Re: How to model non-scalar columns in dataTable/subTable?
          dkarr

          If anyone is thinking about this, I'm sort of getting close, but it still isn't quite right. I've kludged this with one header with the text "Host Name / CPU Count / Platform", but that's obviously not optimal. I can't figure out how to have proper headers for the nested table, but with all headers in the table in the headers for the main table.

          The following is my current page:

          <%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
          <%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>
          <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
          <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
          <% System.out.println("Got here."); %>
          <html>
          <head>
          <title>WebLogic License Manager</title>
          </head>
          <body>
          <f:view>
           <a4j:form>
           <a4j:commandLink id="save" reRender="projectsTable" value="Save"/>
           <a4j:commandLink id="add" action="#{projectManager.addProject}" reRender="projectsTable" value="Add"/>
           <rich:dataTable id="projectsTable" value="#{projectManager.projects}" title="Projects" var="project"
           frame="border" rules="all" rowKeyVar="rowNum"
           onRowMouseOver="this.style.backgroundColor='#F1F1F1'"
           onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'">
           <f:facet name="caption">
           <h:outputText value="Projectse"/>
           </f:facet>
           <rich:column>
           <f:facet name="header">
           <h:outputText value="Name"/>
           </f:facet>
           <h:inputText value="#{project.name}" size="#{projectManager.maxNameLength}"/>
           </rich:column>
           <rich:column>
           <f:facet name="header">
           <h:outputText value="Department"/>
           </f:facet>
           <h:inputText value="#{project.department}" size="#{projectManager.maxDepartmentLength}"/>
           </rich:column>
           <rich:column colspan="3">
           <f:facet name="header">
           <h:outputText value="Host Name / CPU Count / Platform"/>
           </f:facet>
           <rich:dataTable value="#{project.servers}" title="Servers"
           var="server">
           <rich:column>
           <h:inputText value="#{server.hostName}"/>
           </rich:column>
           <rich:column>
           <h:inputText value="#{server.cpuCount}"/>
           </rich:column>
           <rich:column>
           <h:inputText value="#{server.platform}"/>
           </rich:column>
           </rich:dataTable>
           </rich:column>
           <rich:column>
           <f:facet name="header">
           <h:outputText value="Ops"/>
           </f:facet>
           <a4j:commandLink action="#{projectManager.addAboveProject}" reRender="projectsTable" value="[Add Above]">
           <f:param name="rowNum" value="#{rowNum}"/>
           </a4j:commandLink>
           <a4j:commandLink action="#{projectManager.addBelowProject}" reRender="projectsTable" value="[Add Below]">
           <f:param name="rowNum" value="#{rowNum}"/>
           </a4j:commandLink>
           <a4j:commandLink action="#{projectManager.deleteProject}" reRender="projectsTable" value="[Delete]">
           <f:param name="rowNum" value="#{rowNum}"/>
           </a4j:commandLink>
           </rich:column>
           </rich:dataTable>
           </a4j:form>
          </f:view>
          </body>
          </html>