0

I've been running Primefaces 3.0, no issues, and now am trying an upgrade to 3.4.x - I've tried 3.4, 3.4.1, and 3.4.2 and this problem occurs in all 3 - basically for the datatable with the selectionMode="single" option when I click on a row it remains selected no matter how many other rows I select. At the same time I'm quite sure the selection="#{databrowser.selectedData}" variable is not being set when I'm clicking on the rows. The table is fully populated and no 2 rows have the exact same data in all columns. Tested and this occurs in both Chrome and Firefox. I can't find any similar problem posted - wondering if anyone else has had this issue?

Apart from the element referencing this is the 3.0 code I've used:

<p:layoutUnit position="center" resizable="true" header="Data Set Details" styleClass="east_panel_header" >
        <h:form id="tblbrowser">  
            <p:dataTable id="dataTable" emptyMessage="No data sets found." style="width: 100%" var="datlis" resizableColumns="true" value="#{databrowser.selectedDataModel}" widgetVar="dataTable" selection="#{databrowser.selectedData}" selectionMode="single" >  

            <p:ajax event="rowSelect" update=":usercomments:commentsTable, :tblbrowser:dataTable" />

            <f:facet name="header" >
                <p:outputPanel>  
                <h:outputText value="Search all fields " />  
                <p:inputText id="globalFilter" onkeyup="dataTable.filter()"/>  
                </p:outputPanel>  
            </f:facet>  

            <p:column id="owner" filterBy="#{datlis.uname}" headerText="Added By" filterMatchMode="contains" >  
                <h:outputText value="#{datlis.uname}" />  
            </p:column>  

            <p:column id="name" filterBy="#{datlis.name}" headerText="Name" >  
                <h:outputText value="#{datlis.name}" />  
            </p:column>  

            <p:column id="description" filterBy="#{datlis.description}" headerText="Description" filterMatchMode="endsWith" >  
                <h:outputText value="#{datlis.description}" />  
            </p:column> 

            <p:column id="datatype" filterBy="#{datlis.data_type}" headerText="Data Type"  
                    filterOptions="#{databrowser.dataTypeOptions}" filterMatchMode="exact" >  
                <h:outputText value="#{datlis.data_type}" />  
            </p:column>  

            <p:column id="quality" filterBy="#{datlis.quality}" headerText="Source Type"  
                    filterOptions="#{databrowser.qualityOptions}" filterMatchMode="exact" >  
                <h:outputText value="#{datlis.quality}" />  
            </p:column>  

            <p:column id="added" headerText="Date Added" filterMatchMode="endsWith" >  
                <h:outputText value="#{datlis.added}" />  
            </p:column>  

            <p:column headerText="Metadata" style="width:40px" >  
                <p:commandButton id="selectButton" rendered="#{datlis.has_metadata}" icon="ui-icon-circle-arrow-s" title="View" ajax="false" >  
                    <f:param name="filepath" value="#{datlis.filepath}" />   
                    <p:fileDownload value="#{filedownloader.mfile}" /> 
                </p:commandButton>
            </p:column>

            <p:column headerText="Data File(s)" style="width:90px" >  
                <p:commandButton id="selectButton2" rendered="#{datlis.has_datafiles}" icon="ui-icon-circle-arrow-s" title="View" ajax="false" >  
                    <f:param name="datafiles" value="#{datlis.datafiles}" />   
                    <p:fileDownload value="#{filedownloader2.dfile}" /> 
                </p:commandButton>
                <h:outputText value=" " />  
                <h:outputText value="#{datlis.zipsize}" />  
            </p:column>   

            </p:dataTable>  
        </h:form>  
    </p:layoutUnit>

1 Answer 1

0

You are missing the rowKey attribute which should be the unique identifier of each row.

Example, if your selectedData object has a unique field id, your dataTable component should look like:

<p:dataTable id="dataTable" rowKey=#{datlis.id}
             value="#{databrowser.selectedDataModel}" var="datlis"
             selection="#{databrowser.selectedData}" selectionMode="single" >

No need to update the same table within p:ajax to see the selection, so you can probably remove the :tblbrowser:dataTable from the update target and have only:

<p:ajax event="rowSelect" update=":usercomments:commentsTable" />
1
  • k I've tried it like you've done above, seems to work now - it was the widgetvar that was holding it back maybe because it's the same name as the id..with rowkey and widgetvar like that it still broke, with rowkey and no widgetvar parameter it works.
    – Alaph432
    Nov 27, 2012 at 1:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.