Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
JSF引用错误的字段_Jsf - Fatal编程技术网

JSF引用错误的字段

JSF引用错误的字段,jsf,Jsf,我对JSF如何引用页面上的重复元素有一个问题。 在下面的代码块中,我尝试应用特定于区域的输入掩码 问题:当存储/输入两个或多个住宅时,所有邮政编码输入框都引用第一个国家/地区框,而不是它们自己的国家/地区框。因此,如果第一个是加拿大(值1013),那么所有邮政信箱都将采用加拿大格式掩码。不管第二个国家是什么 但是,update=“#{p:component('postalpcen')}”部分代码正确地指向正确的邮政编码框进行刷新 <p:outputPanel id="residp" sty

我对JSF如何引用页面上的重复元素有一个问题。 在下面的代码块中,我尝试应用特定于区域的输入掩码

问题:当存储/输入两个或多个住宅时,所有邮政编码输入框都引用第一个国家/地区框,而不是它们自己的国家/地区框。因此,如果第一个是加拿大(值1013),那么所有邮政信箱都将采用加拿大格式掩码。不管第二个国家是什么

但是,
update=“#{p:component('postalpcen')}”
部分代码正确地指向正确的邮政编码框进行刷新

<p:outputPanel id="residp" styleClass="f100p">
    <table class="c">
        <ui:repeat value="#{modelBean.residences}" var="address" varStatus="row">
            <tr>
                <td rowspan="2" class="bclgy b w20 cw tac" style="border-top:none;">#{row.index + 1}</td>
                <td style="border-top:none;"><p:outputLabel value="Address"/><br/>
                    <table class="f100p">
                        <tr>
                            <td style="border:none;"><p:outputLabel value="Unit no." for="un"/><br/>
                                <span class="if"><p:inputText id="un" value="#{address.aptNumber}" class=""><p:ajax/></p:inputText></span></td>
                            <td style="border:none;"><p:outputLabel value="Street no." for="snum"/><br/>
                                <span class="if"><p:inputText id="snum" value="#{address.streetNumber}" class=""><p:ajax/></p:inputText></span></td>
                            <td style="border:none;"><p:outputLabel value="Street name" for="sname"/><br/>
                                <span class="if"><p:inputText id="sname" value="#{address.streetName}" class=""><p:ajax/></p:inputText></span></td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td colspan="2" style="border-top:none;">
                    <table class="f100p">
                        <tr>
                            <td style="border:none;">
                                <p:outputLabel value="Country" for="ctry"/><br/>
                                <p:autoComplete id="ctry" value="#{address.country}" completeMethod="#{Controller.countryIds}"
                                        var="id"  itemValue="#{id}" itemLabel="#{Controller.getCountryLabel(id)}" forceSelection="true" class="">
                                    <p:ajax event="itemSelect" update="#{p:component('postalpcen')}"/>
                                    <p:ajax event="change" listener="#{Controller.countryEdited(row.index)}" update=""/>
                                </p:autoComplete>
                            </td>
                            <td style="border:none;">
                                <p:outputLabel value="Postal code or equivalent" for="pc"/><br/>
                                <p:outputPanel id="postalpcen" styleClass="f100p">
                                    <span class="pr l_5"><p:message for="pc" styleClass="err"/></span>
                                    <span class="if">   
                                        <c:choose>
                                            <c:when test="#{address.country eq '1013'}"><!-- Canada -->
                                                <p:inputMask id="pc" value="#{address.postalCode}" maxlength="10" mask="a9a 9a9" class="">
                                                <p:ajax/>
                                            </p:inputMask>
                                            </c:when>
                                            <c:otherwise><!-- Not Canada -->
                                                <p:inputMask id="pc" value="#{address.postalCode}" maxlength="10"  class="">
                                                <p:ajax/>
                                            </p:inputMask>
                                            </c:otherwise>
                                        </c:choose>
                                    </span>
                                </p:outputPanel>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </ui:repeat>
    </table>
</p:outputPanel>

#{row.index+1}







有一个类似的问题被问到,但这个问题涉及的值总是空的。我的不是空的,它是错误的。

检查您不能在
ui:repeat
中迭代并在jstl中使用它的var,但实际的副本是@Kukeltje是的,这两个链接都提供了代码中出现错误的答案。通常情况下,我可能没有编写此代码,但由我来修复它。@BalusC您是否可以更改副本链接到的问题,因为Kukeltje共享的问题实际上是此代码的更好示例。