1

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

由于它无法找到组件 id 。我已经使用了替代方法。我已经采取了隐藏字段。单击命令按钮后,隐藏字段得到更新,并通过简单的javascript函数即时更新父组件的文本字段。javascript函数从对话框中命令按钮的oncomplete调用。因为,根据项目要求,我必须通过 primefaces 而不是通过 javascript 来实现它。请建议我在 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 是自定义组件。

4

1 回答 1

0

最后,我得到了解决方案。我遇到的异常是由于表单标签。从对话框触发的 ajax 事件无法在表单之外找到组件。在这种情况下,请使用::#{p:component('componentId')}

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

于 2013-01-24T06:26:19.310 回答