简体   繁体   English

JSF可数据竞争的选定行

[英]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 我在JSF页面中有以下内容

    <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. 如果在<p:column> </p:column>内添加以下内容,则可以在ManagedBean中获得selectedDepartment行,但是如果在<p:column> </p:column>上方添加按钮,即不在datatable中行,但是在标题上,我无法获得selectedDepartment行,因为它不在datatable行中。

Are there any way I can get the selectedDepartment row if I add a button not in datatable row? 如果我不在数据表行中添加按钮,有什么方法可以获取selectedDepartment行?

             <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. 如果您不将按钮放在行内,我认为您不会获得像rowId这样的信息。 I suggest you first get an id from dataTable then take it into any hidden value to use it in commandButton. 我建议您首先从dataTable中获取一个ID,然后将其带入任何隐藏值以在commandButton中使用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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