【问题标题】:How to update a datatable after submitting a dialog - JSF提交对话框后如何更新数据表 - JSF
【发布时间】:2016-10-08 13:37:16
【问题描述】:

经过这么多搜索,我在primeface的对话框中单击命令按钮后找不到更新数据表的方法。

我的 mainMenu.xhtml 有一个类似的数据表:

<section id="ownermanagement">

<h:form id="ownermanagementform">
    <p:commandButton class="btn icon-cart" actionListener="#{ownerControl.viewNewOwnerDialog()}" value="کارفرما جدید"/>
    <br></br><br></br>
    <p:growl id="growl" showDetail="true"/>
    <p:dataTable filterEvent="enter" id="ownerdatatable" value="#{ownerControl.ownerList}" var="owners" dir="rtl" emptyMessage="موردی با این مشخصات یافت نشد." style="border: 1px solid black;">
        <p:column filterBy="#{owners.id}" filterMatchMode="contains">
            <f:facet name="header">شناسه</f:facet>
                #{owners.id}
        </p:column>
        <p:column filterBy="#{owners.name}" filterMatchMode="contains">
            <f:facet name="header">نام</f:facet>
                #{owners.name}
        </p:column>

        <p:column>
            <f:facet name="header">عملیات</f:facet>
            <p:commandButton value="ویرایش کارفرما"
                             actionListener="#{ownerControl.viewEditOwnerDialog(owners)}" update="ownerdatatable"/> |
            <p:commandButton value="حذف کارفرما"
                             action="#{ownerControl.removeOwner(owners)}"
                             onclick="return confirm('آیا از حذف کارفرما اطمینان دارید؟')"
                             update="ownerdatatable"/> 
        </p:column>

    </p:dataTable>

</h:form>
</section>

我这样打开我的对话框:

<p:commandButton class="btn icon-cart" actionListener="#{ownerControl.viewNewOwnerDialog()}" value="کارفرما جدید"/>

viewNewOwnerDialog 方法是:

public void viewNewOwnerDialog() {
    Map<String, Object> options = new HashMap<String, Object>();
    //options.put("modal", true);
    options.put("resizable", false);
    resetInputs();
    RequestContext.getCurrentInstance().openDialog("createOwner", options, null);
}

这将在对话框中打开我的 createOwner 页面:

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:p="http://primefaces.org/ui">
    <h:head>
        <title>کارفرما جدید</title>
        <link rel="stylesheet" type="text/css" href="resources/style/elements.css" />
    </h:head>
    <h:body dir="rtl">
        <h:form id="newOwnerForm">
            <p:growl id="growl" showDetail="true" sticky="true"/>
            نام: <h:inputText class="InputField" value="#{ownerControl.owner.name}"/>
            <br></br><br></br>
            توضیحات: <p:inputTextarea class="textArea" value="#{ownerControl.owner.description}" rows="5" cols="100" counter="display" maxlength="500" counterTemplate="{0}" autoResize="false" />
            <h:outputText id="display" /><br></br>
            <p:commandButton class="btn icon-cart" value="ثبت" action="#{ownerControl.insertOwner()}"  process="@all"  update=":ownermanagementform:ownerdatatable"/>
        </h:form>
    </h:body>
</html>

如何更新咆哮以显示消息,然后更新 mainMenu 的数据表?

目前,我收到此错误:

Cannot find component with expression ":ownermanagementform:ownerdatatable" referenced from "newOwnerForm:j_idt10".

谢谢!

【问题讨论】:

  • 你有没有尝试添加section的id看看是不是问题?!?
  • @Yagami Light 是的,我也尝试过。仍然找不到我的组件。
  • 尝试将widgetvar 添加到您的数据表中
  • @YagamiLight 对不起老兄,但仍然是同样的错误
  • 更改咆哮的位置使其在表单之前并更新它

标签: jsf primefaces datatable


【解决方案1】:

我是这样解决的:

<p:commandButton value="Open Dialog" actionListener"...">
   <p:ajax event="dialogReturn" update="datatableID"/>
</p:commandButton>

【讨论】:

    猜你喜欢
    • 2014-07-23
    • 2017-07-22
    • 2012-09-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多