2012-04-22 113 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