ZolDRix
ZolDRix

Reputation: 31

I cannot update the datatable in another form

I cannot update the datatable in another form.

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)

I create two forms , but I can't update the bean . I'm using ;

<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>

I copied "searchForm:dataTableId" from the source of the page.

Upvotes: 3

Views: 496

Answers (1)

MaximG
MaximG

Reputation: 141

You need to prefix the absolute client ID with the naming container separator character which is in your case :. So, you should be using update=":searchForm:dataTableId" instead.

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

Otherwise it will be searched relative to the current naming container component, which is the first <h:form> itself.

Upvotes: 1

Related Questions