简体   繁体   中英

JSF databatable selected row

This may sound quite strange, but checking whether any possibilities are there to get datatable selected row value if action is not in datatable row.

I have the following in JSF page

    <p:dataTable id="det" var="emp" lazy="true"
value="#{myMB.lazyModel}" paginator="true"
paginatorPosition="bottom" rows="10"
    rowKey="#{emp.employeeNumber}">

    <f:facet name="header">                  
        Employee Details    
    </f:facet>

If I add the following inside <p:column> </p:column> I am able to get the selectedDepartment row in ManagedBean, but if I add button above <p:column> </p:column> , ie not in datatable row, but on the heading, I am not able to get the selectedDepartment row because it is not in datatable row.

Are there any way I can get the selectedDepartment row if I add a button not in datatable row?

             <p:commandButton id="addEmployee" 
              icon="ui-icon-plus"                          
              oncomplete="newEmployeeDialog.show()" >
     <f:setPropertyActionListener value="#{emp}" 
     target="#{myMB.selectedDepartment}" />   
      </p:commandButton>

I don't think you can get the info like rowId if you dont put button inside the row. I suggest you first get an id from dataTable then take it into any hidden value to use it in commandButton.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM