Primefaces update from inside another form

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-13 18:14:21

问题


I'm not sure what's wrong with my HTML code. From what I read, it should work. I even tried using prependId="false" which didn't resolve the problem of not finding the UI Component.

<p:tabView>
        <p:tab title="Tab1" id="tab1">
            <h:form id="form1" prependId="false">
                <p:panelGrid columns="2" id="grid1">

                    <h:outputLabel for="minDraw" value="Starting draw number:" />
                    <p:inputText id="minDraw" value="#{LottoMaxBacking.minDraw}" />
                    <p:commandButton value="Get Frequency From Begining"
                        actionListener="#{LottoMaxBacking.loadAllDrawFreq}"
                        update=":form2:freqTable" />
                </p:panelGrid>
            </h:form>
            <h:form id="form2" prependId="false">
                <p:dataTable var="entry" value="#{LottoMaxBacking.drawFreqList}"
                    id="freqTable">
                    <f:facet name="header">
                        <h:outputText value="#{LottoMaxBacking.tableHeader}" />
                    </f:facet>
                    <p:column sortBy="#{entry.key}" headerText="Ball Number">

                        <h:outputText value="#{entry.key}" />

                    </p:column>
                    <p:column sortBy="#{entry.value}" headerText="Frequency">

                        <h:outputText value="#{entry.value}" />

                    </p:column>

                </p:dataTable>
            </h:form>
        </p:tab>
        <p:tab title="Tab 2"></p:tab>
    </p:tabView>

I tried ":tab1:form2:freqTable", ":freqTable", and "freqTable" but none of them work. When I put both forms together as a single form, it would find the freqTable fine.


回答1:


OK I finally figured it out after looking at the error message again.

Cannot find component with identifier ":form2:freqTable" referenced from "j_idt54:j_idt56"

idt54 refers to the TabView and idt56 refers to the command button. So it turns out that my button's AJAX update string didn't go far enough original and all my other attempts referred to the wrong parent container. I added an id to p:tabView and changed the update String and it worked.

<p:commandButton value="Get Frequency From Begining" 
    actionListener="#{LottoMaxBacking.loadAllDrawFreq}"
    update="tv:form2:freqTable" />


来源:https://stackoverflow.com/questions/15018533/primefaces-update-from-inside-another-form

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!