【问题标题】:How To Reload Page/Refresh Page After Dialog Close对话框关闭后如何重新加载页面/刷新页面
【发布时间】:2017-10-03 00:05:34
【问题描述】:

单击对话框内的“是”按钮后,我在重新加载页面时遇到了一些问题。当我单击是按钮(确认,以便可以删除该项目)后,我希望页面刷新/重新加载,以便我可以看到我当前的项目。

这是我的代码

<p:commandButton id="checkin" action="#{checkoutListBean.doCheckin(c.checkoutNumber)}"
   value="Checkin" >
<p:confirm header="Confirmation" message="Are you sure you delete this?" 
   icon="ui-icon-alert" />
</p:commandButton>
<p:confirmDialog global="true" showEffect="fade" hideEffect="fade">
<p:commandButton value="Yes" type="button" styleClass="ui-confirmdialog-yes" 
   icon="ui-icon-check" />
<p:commandButton value="No" type="button" styleClass="ui-confirmdialog-no" 
 icon="ui-icon-close" />
</p:confirmDialog>

这是我点击按钮时调用的java方法

public String doCheckin(long checki) {

    CheckoutDb.checkinBook(checki);
    getCheckoutList();

    return "checkoutList?facesRedirect=true";
}

public List getCheckoutList() {
    return checkoutList = CheckoutDb.selectCheckedOutBooks();
}

请帮忙

【问题讨论】:

  • 您在使用“facesRedirect”时出错
  • 首先你使用了错误的人脸重定向语法,它应该是?faces-redirect=true
  • 您通常会进行 AJAX 更新,而不是重新加载整个页面。

标签: primefaces jsf-2 jsf-2.2


【解决方案1】:

您必须更改重定向

  public String doCheckin(long checki) {

    CheckoutDb.checkinBook(checki);
    getCheckoutList();

    return "checkoutList?faces-redirect=true";
}

public List getCheckoutList() {
    return checkoutList = CheckoutDb.selectCheckedOutBooks();
}

【讨论】:

    【解决方案2】:

    您应该将一个动作附加到标有“是”的按钮上。

    类似:

    <p:commandButton action="#{checkoutListBean.reloadPage()}" value="Yes" type="button" styleClass="ui-confirmdialog-yes" 
       icon="ui-icon-check" />
    

    然后在 bean 中:

    public String reloadPage() {
        return "checkoutList?faces-redirect=true";
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多