Primefaces:对话框隐藏时不会更新文本字段

时间:2013-01-23 12:16:36

标签: primefaces

我试图从对话框更新文本字段。文本字段位于父组件中。但它没有发生。如果我在更新命令按钮时给出文本字段的id。我遇到了错误: javax.faces.FacesException:找不到标题为“customerCode”的组件,引用自“tabView:lkpSltRec”

因为它无法找到组件ID。我用过替代品。我已经取了隐藏字段。点击命令按钮后,隐藏字段得到更新,通过简单的javascript函数更新父组件的文本字段。从对话框中的命令按钮的完成调用javascript函数。因为,根据项目要求,我必须通过primefaces实现它,而不是通过javascript。 Plz,建议我使用primefaces的方法。以下是代码段:

这里ecap:lookup是自定义组件。

    Selected Customer <p:inputText id="customerCode"
        value="#{sixthTabBBean.customerName}" label="Selected Adddress"></p:inputText>
    Selected Customer City <p:inputText id="selectedCity"   value="#{sixthTabBBean.customerCity}"  ></p:inputText>
    <ecap:lookup lookupId="LOV0072" inputId="customerCode" clickStatus="city"
        defaultDDValueIndex="0" title="CustomerCode"></ecap:lookup>

        New LOV <ecap:lookup lookupId="LOV0092" inputId="customerCode" clickStatus="none"
        defaultDDValueIndex="0" title="CustomerCode"></ecap:lookup>

    City<p:inputText id="custCity" value="#{sixthTabBBean.customerCity}"
        disabled="true" label="City"></p:inputText>
    Selected Customer <p:inputText id="customerCode1"
        value="#{sixthTabBBean.customerName}" label="Selected Adddress" ></p:inputText>
    Selected Customer City <p:inputText id="selectedCity1"  value="#{sixthTabBBean.customerCity}"  ></p:inputText>
    Selected Customer State <p:inputText id="selectedSate1"     value="#{sixthTabBBean.customerState}"  ></p:inputText>
    <ecap:lookup lookupId="LOV0098" inputId="customerCode" clickStatus="state"
        defaultDDValueIndex="0" title="CustomerCode"></ecap:lookup>
    <p:dialog id="lkpDialog" widgetVar="lpDialogVar" header="Lookup"
        modal="true" width="1000" height="600"
        rendered="#{lookupSearch.popupRender}"  >
        <h:form  rendered="#{lookupSearch.popupRender}"  prependId="false">
            <h:panelGrid cellpadding="10" id="diaFrmId">
                <p:dataTable id="newfdt" var="flxSearch"
                    value="#{lookupSearch.lkpSearchCriteriaList}">

                    <p:column id="newwhc">
                        <f:facet name="header">
                            <h:outputLabel value="Search Fields"></h:outputLabel>
                        </f:facet>
                        <p:selectOneMenu styleClass="fdd180" id="newwdd"
                            value="#{flxSearch.searchCriterion.whereClause}">
                            <f:selectItems value="#{flxSearch.whrClausDropdown}" />
                        </p:selectOneMenu>
                    </p:column>

                    <p:column id="newcoc">
                        <f:facet name="header">
                            <h:outputLabel value="Conditions"></h:outputLabel>

                        </f:facet>
                        <p:selectOneMenu id="newco" styleClass="fdd95"
                            value="#{flxSearch.searchCriterion.operator}">
                            <f:selectItems id="newcriOperatorItms"
                                value="#{flxSearch.operatorDropdown}" />
                        </p:selectOneMenu>
                    </p:column>

                    <p:column id="newcic">
                        <f:facet name="header">
                            <h:outputLabel value="Value"></h:outputLabel>

                        </f:facet>
                        <p:inputText id="newcriInpNm"
                            rendered="#{!flxSearch.inputDate and !flxSearch.boolValue and !flxSearch.required}"
                            styleClass="285 ftb" deferChangeEvent="true"
                            value="#{flxSearch.searchCriterion.value}"
                            maxlength="#{flxSearch.maxLength}"
                            disabled="#{flxSearch.disableInput}" partialSubmit="true"
                            labelValue="#{flxSearch.searchCriterion.label}"
                            required="#{flxSearch.required}">
                        </p:inputText>

                        <p:inputText id="newcriInpM"
                            rendered="#{!flxSearch.inputDate and !flxSearch.boolValue and flxSearch.required }"
                            value="#{flxSearch.searchCriterion.value}"
                            maxlength="#{flxSearch.maxLength}"
                            disabled="#{flxSearch.disableInput}"
                            labelValue="#{flxSearch.searchCriterion.label}"
                            required="#{flxSearch.required}">

                        </p:inputText>

                        <p:selectOneMenu styleClass="fdd" id="newbldd"
                            value="#{flxSearch.searchCriterion.value}"
                            disabled="#{flxSearch.disableInput}"
                            rendered="#{flxSearch.boolValue }">
                            <f:selectItems value="#{flxSearch.booleanDropdown}" />
                        </p:selectOneMenu>

                        <p:calendar id="newcriDtNm" size="9"
                            rendered="#{flxSearch.inputDate and !flxSearch.boolValue and !flxSearch.required }"
                            disabled="#{flxSearch.disableInput}" showOn="button"
                            value="#{flxSearch.searchCriterion.value}"
                            labelValue="#{flxSearch.searchCriterion.label}">
                        </p:calendar>

                        <p:calendar id="newcriDtM" size="9"
                            rendered="#{flxSearch.inputDate and !flxSearch.boolValue and flxSearch.required }"
                            disabled="#{flxSearch.disableInput}"
                            value="#{flxSearch.searchCriterion.value}"
                            enableChangeDetector="false" partialSubmit="true"
                            labelValue="#{flxSearch.searchCriterion.label}"
                            required="#{flxSearch.required}" showOn="button">
                        </p:calendar>

                    </p:column>
                </p:dataTable>
                <!-- hidden text used to update values in the parent component -->
                <p:inputText  type="hidden" id="hiddencustomerCode"  
                    value="#{sixthTabBBean.customerName}"   ></p:inputText>
                <p:inputText  type="hidden" id="hiddencustCity"  
                    value="#{sixthTabBBean.customerCity}"   ></p:inputText>
                <p:inputText  type="hidden" id="hiddencustState"  
                value="#{sixthTabBBean.customerState}"   ></p:inputText>

                <p:fieldset legend="Combined By">
                    <h:panelGrid columns="2" cellpadding="10">
                        <p:selectOneRadio id="newSlctDrk"
                            valueChangeListener="#{lookupSearch.getSelectedLogOpr}"
                            value="#{lookupSearch.selLogOpr}"
                            title="Combine all search criteria with AND or OR">
                            <f:selectItems id="newSlctDrkItms"
                                value="#{lookupSearch.logicalOperators}" />
                        </p:selectOneRadio>
                    </h:panelGrid>
                </p:fieldset>
                <h:panelGrid columns="3">
                    <p:commandButton value="Find" id="lkpfndDg" update="resultFldSet"
                        actionListener="#{lookupSearch.search}">
                    </p:commandButton>
                    <p:commandButton value="Clear" id="lkpClearDg"
                        actionListener="#{lookupSearch.clear}" />
                </h:panelGrid>
                <p:fieldset legend="Result" id="resultFldSet">
                        <p:dataTable binding="#{lookupSearch.lkpResultDataTable}"
                            value="#{lookupSearch.searchResultsForPage}"></p:dataTable>
                </p:fieldset>
                <p:commandButton value="Select" id="lkpSltRec" update="customerCode"
                    oncomplete="lpDialogVar.hide();insertSelectedValue();"
                    actionListener="#{lookupSearch.selectValue}" />
            </h:panelGrid>
        </h:form>
    </p:dialog>

</h:panelGrid>

这里ecap:lookup是自定义组件。

1 个答案:

答案 0 :(得分:0)

最后,我得到了解决方案。我遇到的例外是因为表单标签。从对话框触发的ajax事件无法在表单外找到组件。在这种情况下使用: :#{P:组分( 'COMPONENTID')}

在这里,它不仅会在表单中搜索id,还会在其外部搜索。