2012-04-22 83 views
0

我有啊:數據表與複選框:缺少的屬性:selectBooleanCheckbox

<div id="settingsHashMap" style="width:750px; height:400px; position:absolute; background-color:r; top:20px; left:1px"> 

        <h:form id="form"> 

         <!-- The sortable data table --> 
         <h:dataTable id="dataTable" value="#{SessionsController.dataList}" var="item"> 
          <!-- Check box --> 
          <h:column> 
           <f:facet name="header"> 
            <h:outputText value="Select" /> 
           </f:facet> 
           <h:selectBooleanCheckbox onclick="highlight(this)" value="#{SessionsController.selectedIds[dataItem.id]}" /> 
          </h:column> 
          <h:column> 
           <f:facet name="header"> 
            <h:commandLink value="Account Session ID" actionListener="#{SessionsController.sort}"> 
             <f:attribute name="sortField" value="Account Session ID" /> 
            </h:commandLink> 
           </f:facet> 
           <h:outputText value="#{item.aSessionID}" /> 
          </h:column> 
          <h:column> 
           <f:facet name="header"> 
            <h:commandLink value="User ID" actionListener="#{SessionsController.sort}"> 
             <f:attribute name="sortField" value="User ID" /> 
            </h:commandLink> 
           </f:facet> 
           <h:outputText value="#{item.userID}" /> 
          </h:column> 
          <h:column> 
           <f:facet name="header"> 
            <h:commandLink value="Activity Start Time" actionListener="#{SessionsController.sort}"> 
             <f:attribute name="sortField" value="Activity Start Time" /> 
            </h:commandLink> 
           </f:facet> 
           <h:outputText value="#{item.activityStart}" /> 
          </h:column> 
          <h:column> 
           <f:facet name="header"> 
            <h:commandLink value="Activity End Time" actionListener="#{SessionsController.sort}"> 
             <f:attribute name="sortField" value="Activity End Time" /> 
            </h:commandLink> 
           </f:facet> 
           <h:outputText value="#{item.activityEnd}" /> 
          </h:column> 
          <h:column> 
           <f:facet name="header"> 
            <h:commandLink value="Activity" actionListener="#{SessionsController.sort}"> 
             <f:attribute name="sortField" value="Activity" /> 
            </h:commandLink> 
           </f:facet> 
           <h:outputText value="#{item.activity}" /> 
          </h:column> 
         </h:dataTable> 

         <!-- The paging buttons --> 
         <h:commandButton value="first" action="#{SessionsController.pageFirst}" 
             disabled="#{SessionsController.firstRow == 0}" /> 
         <h:commandButton value="prev" action="#{SessionsController.pagePrevious}" 
             disabled="#{SessionsController.firstRow == 0}" /> 
         <h:commandButton value="next" action="#{SessionsController.pageNext}" 
             disabled="#{SessionsController.firstRow + SessionsController.rowsPerPage >= SessionsController.totalRows}" /> 
         <h:commandButton value="last" action="#{SessionsController.pageLast}" 
             disabled="#{SessionsController.firstRow + SessionsController.rowsPerPage >= SessionsController.totalRows}" /> 
         <h:outputText value="Page #{SessionsController.currentPage}/#{SessionsController.totalPages}" /> 
         <br /> 

         <!-- The paging links --> 
         <ui:repeat value="#{SessionsController.pages}" var="page"> 
          <h:commandLink value="#{page}" actionListener="#{SessionsController.page}" 
              rendered="#{page != SessionsController.currentPage}" /> 
          <h:outputText value="#{page}" escape="false" 
              rendered="#{page == SessionsController.currentPage}" /> 
         </ui:repeat> 
         <br /> 

         <!-- Set rows per page --> 
         <h:outputLabel for="rowsPerPage" value="Rows per page" /> 
         <h:inputText id="rowsPerPage" value="#{SessionsController.rowsPerPage}" size="3" maxlength="3" /> 
         <h:commandButton value="Set" action="#{SessionsController.pageFirst}" /> 
         <h:message for="rowsPerPage" errorStyle="color: red;" /> 

        </h:form>     

       </div> 

原來,當我從第一次拼版工作不加載JSF數據表和行不突出顯示。我刪除了這段代碼:

      <h:column> 
           <f:facet name="header"> 
            <h:outputText value="Select" /> 
           </f:facet> 
           <h:selectBooleanCheckbox onclick="highlight(this)" value="#{SessionsController.selectedIds[dataItem.id]}" /> 
          </h:column> 

而且一切正常。

你能告訴我這個標籤h:selectBooleanCheckbox中是否有任何缺失的屬性。 我該如何糾正這個問題?

回答

1

是不是它應該是item.id,而不是dataItem.id

value="#{SessionsController.selectedIds[item.id]}" 

,而不是

value="#{SessionsController.selectedIds[dataItem.id]}" 
+0

沒有變化。還是有同樣的問題。 – 2012-04-22 13:01:35

+0

沒有item對象有getter/setter的id屬性嗎?以及它的SessionsController中是否存在selectedIds?它不是空的? – Daniel 2012-04-22 13:10:46