【问题标题】:Update p:commandButton in p:column on complete of actionListener在 actionListener 完成时更新 p:column 中的 p:commandButton
【发布时间】:2014-09-05 11:41:45
【问题描述】:

我正在尝试一种停用方法,它将在命令按钮上显示帐户的状态(“已停用”、“已激活”),当我单击命令按钮时,它将激活或停用基于帐户的帐户关于目前的状态。一旦我确认,commandButton 将立即更新为其当前状态。

我有以下代码,我想在“confirmDeactivateDialog”或“confirmActivateDialog”中完成我的 actionlistener 后更新我的 commandButton。我尝试在这两个confirmDialog 标记处使用update="a,b",但它不起作用。有什么建议么?

<p:column headerText="Status" style="text-align: center">  
    <p:commandButton id='a' rendered="#{bean.isActivated(account_status)==true}" oncomplete="PF('deactivateDialog').show();" value="Activated">
       <f:setPropertyActionListener value="#{searchEmployeeResultList}" target="#{bean.selectedEmployee}"/>
    </p:commandButton>

    <p:confirmDialog id="confirmDeactivateDialog" header="Confirm Deactivation" widgetVar="deactivateDialog">
       <p:commandButton id="Deactivate" value="Ok" oncomplete="PF('deactivateDialog').hide();" actionListener="#{AccountManagedBean.deactivate}"/>
    </p:confirmDialog>

    <p:commandButton id="b" rendered="#{bean.isActivated(account_status)==false}" oncomplete="PF('activateDialog').show();" value="Deactivate">
       <f:setPropertyActionListener value="#{searchEmployeeResultList}" target="#{bean.selectedEmployee}"/>
    </p:commandButton>

    <p:confirmDialog id="confirmActivateDialog" header="Confirm Activation" widgetVar="activateDialog">
       <p:commandButton id="Activate" value="Ok" oncomplete="PF('activateDialog').hide();" actionListener="#{AccountManagedBean.activate}"/>
    </p:confirmDialog>

</p:column> 

【问题讨论】:

  • “它不起作用?” - 究竟是什么不起作用?有任何错误信息吗?也许像“找不到组件'a'”?
  • @Manuel: 提示:OP 在列中声明了对话框。
  • 对。那么p:commandButton的生成id就不会只是a或者b。检查生成的 JSF 的 HTML 源代码。 JSF 将为数据表中的每一行生成一个唯一 ID,此 ID 将是您的 a 元素的前缀。对ab 使用相对更新路径。
  • @Manuel 没有错误;(只是commandButton不会更新。
  • @Manuel 那么你的意思是 update= ":
    :a, :
    :b" 吗?

标签: jsf primefaces dialog commandbutton


【解决方案1】:

试试 update="a b"

它们之间没有逗号

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-10-15
    • 2015-01-22
    • 1970-01-01
    • 1970-01-01
    • 2011-05-31
    • 2013-10-22
    • 1970-01-01
    相关资源
    最近更新 更多