如何在<p:datatable> </p:datatable>中设置Property ActionListener

时间:2014-03-10 09:17:27

标签: java jsf-2 primefaces

我使用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

2 个答案:

答案 0 :(得分:1)

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

答案 1 :(得分:1)

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

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