簡體   English   中英

在p:radioButton的for-Attribute中引用一個id

[英]Reference an id in the for-Attribute of p:radioButton

是否可以引用一個id來標識作為parents-parent-naming容器的子元素的組件?

例如:

<div class="browserDiv"
            id="browserObjects">
            <p:selectOneRadio id ="selectedFolder" value="${cc.attrs.value.selectedObjectPath}" layout="custom">
                <f:selectItems value="${cc.attrs.value.objectList}"
                                var="object" itmeValue="${object.path}" itemLabel=""/>
            </p:selectOneRadio>

            <table>
                <ui:repeat var="object" value="${cc.attrs.value.objectList}" id ="repeat" varStatus="status" >
                        <tr>
                            <td class="checkBoxCell">
                                <p:radioButton id="radioButton_${object.path}" for="selectedFolder" itemIndex="#{status.index}"/>
                            </td>
                        </tr>
                </ui:repeat>
            </table>

        </div>

我想從<p:radioButton>的for-attribute引用id selectedFolder 但是由於<ui:repeat>NamingContainer ,所以selectedFolder位於另一個NamingContainer ,我不知道該如何引用。 是否可以編寫類似for="../selectedFolder"

我不能使用絕對ID引用,因為這是復合組件的一部分。 我還嘗試在<ui:repeat>使用prependId="false" ,但這沒有用。

使用絕對客戶端ID而不是相對客戶端ID。

假設您有一個

<h:form id="form">
    <p:selectOneRadio id="radio" ...>
        ...
    </p:selectOneRadio>
</h:form>

那么其絕對客戶端ID將為form:radio 它就是您在生成的HTML源代碼中看到的值。 要從另一個命名容器中引用它,您需要在其前面加上(默認)命名容器分隔符: ,以使其成為:form:radio 因此,應該這樣做:

<p:radioButton for=":form:radio" ... />

具體問題無關 ,幾乎在所有地方都使用${}而不是#{} 盡管${}在僅顯示值中可以正常使用,但是無論何時提交表單,它都根本不起作用。 您確實需要#{}來代替。 它不僅get ,而且set ,而${}get 只需在所有JSF頁面上堅持#{}

也可以看看:


根據注釋進行更新 ,尚不清楚命名容器在組合中的所有位置,但是如果需要,您可以按以下方式動態解析組合的絕對客戶端ID:

<p:radioButton for=":#{cc.clientId}:radio" ... />

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM