繁体   English   中英

如何在一个中设置一个PropertyActionListener <p:datatable>

[英]How to set a PropertyActionListener in a <p:datatable>

我使用PrimeFaces,我想在选定的行上设置一个动作列表器,以在对话框中显示他的一个列。

我的数据表看起来像这样:

<p:dataTable var="ligne" value="#{detailGrilleBean.lignes}">  
            <p:column headerText="Question">  
                <h:outputText value="#{ligne.questionBs}" />  
            </p:column>  
            <p:column headerText="Note">                     
                <p:rating value="#{ligne.reponse}" readonly="true" />  
            </p:column>  
            <p:column headerText="Justification">  
                <p:commandLink  oncomplete="nDialog.show();" title="View Detail" >  
                    <f:setPropertyActionListener value="#{ligne}"   
                       target="#{detailGrilleBean.selectligne}" />
                    <h:outputText styleClass="ui-icon ui-icon-search" style="margin:0 auto;" "/>  
                </p:commandLink> 
            </p:column>  
        </p:dataTable> 

对话框:

       <p:dialog   hideEffect="fade" width="600" height="100" id="dialogdesc"  widgetVar="nDialog" modal="true" showEffect="fade" closable="true" appendToBody="true">  
            <p:outputPanel id="nDetail" style="text-align:center;">  
                <h:panelGrid  columns="2" cellpadding="5">  
                    <h:outputText id="type" value="#{detailGrilleBean.selectligne.justification}" />  
                </h:panelGrid>  
            </p:outputPanel>  
        </p:dialog> 

Backingbean:

@ManagedBean
@RequestScoped
public class DetailGrilleBean implements Serializable {

Grille grille;
List<Lignegrille> lignes;
Lignegrille selectligne;
//Getters & Setters

在运行dilog时,它只是没有显示任何东西。 我试图在selectligne属性的setter和getter中添加一些日志记录,但我得到的只是lignes的输出日志最后一个元素;

PS:我正在使用PrimeFaces 3.5 / Tomcat EE 1.6

您必须更新对话框内容。 即在commandButton上设置update=":nDetail" (id取决于放置对话框的位置)。

现在你不要调用任何动作列表器,你只需要输入参数。 在您的情况下,您有两个选项:1。将您的dataTable设置为可选的dataTable,例如您在primefaces主页上找到的示例。 2.像这样准备你的commandLink(cource dataTable和对话框必须是格式):

<p:commandLink oncomplete="nDialog.show();" 
               title="View Detail"
               actionListener="#{detailGrilleBean.setSelectligne(ligne)}"
               process="@this"
               update="nDetail"/>

暂无
暂无

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

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