我无法以其他形式更新数据表

时间:2012-11-23 09:06:13

标签: ajax jsf primefaces

我无法以其他形式更新datatable

javax.servlet.ServletException: Cannot find component with identifier "searchForm:dataTableId" referenced from "criteriaForm:j_idt13".
    javax.faces.webapp.FacesServlet.service(FacesServlet.java:321)
    com.opensymphony.sitemesh.webapp.SiteMeshFilter.obtainContent(SiteMeshFilter.java:129)
    com.opensymphony.sitemesh.webapp.SiteMeshFilter.doFilter(SiteMeshFilter.java:77)
    org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:113)
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)

我创建了两个表单,但我无法更新bean。 我正在使用;

<h:form id="criteriaForm">
        <p:panel>
            <h:panelGrid columns="3" cellpadding="2">
                <h:panelGrid columns="3" cellpadding="2">
                    <h:outputText value=start"></h:outputText>
                    <p:calendar required="false" id="date1"
                        value="#{searchBean.date1}">
                        <f:convertDateTime locale="en" pattern="dd/MM/yyyy" />
                    </p:calendar>
                </h:panelGrid>
                <h:panelGrid columns="3" cellpadding="2">
                    <h:outputText value="end"></h:outputText>
                    <p:calendar locale="en" required="false" id="date2"
                        value="#{searchBean.date2}">
                        <f:convertDateTime locale="en" pattern="dd/MM/yyyy" />
                    </p:calendar>
                </h:panelGrid>
                <p:commandButton icon="ui-icon-search" value="Search" type="submit"
                    actionListener="#{searchBean.commit()}"
                    style="width:110px;" update="searchForm:dataTableId"></p:commandButton>
            </h:panelGrid>
        </p:panel>
    </h:form>
    <br />
    <h:form id="searchForm">
        <p:dataTable var="item" id="dataTableId" widgetVar="dataTableWidget"
            paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
            rowIndexVar="index" value="#{searchBean.lazyModel}"
            lazy="true" paginator="true" resizableColumns="false" rows="15">
            <p:column headerText="TEST">
                <h:outputText value="#{item.customerName}"></h:outputText>
            </p:column>
            <p:column headerText="TEST">
                <h:outputText value="#{item.customerCode}"></h:outputText>
            </p:column>
            <p:column headerText="TEST">
                <h:outputText value="#{item.customerPhone}"></h:outputText>
            </p:column>
        </p:dataTable>
    </h:form>

我从页面来源复制了“searchForm:dataTableId

1 个答案:

答案 0 :(得分:1)

您需要在绝对客户端ID前加上您的案例:中的命名容器分隔符。因此,您应该使用update=":searchForm:dataTableId"代替。

<p:commandButton icon="ui-icon-search" value="Search" type="submit"
    actionListener="#{searchBean.commit()}"
    style="width:110px;" update=":searchForm:dataTableId">
</p:commandButton>

否则将相对于当前命名容器组件搜索它,这是第一个<h:form>本身。