簡體   English   中英

Ajax更新不起作用

[英]Ajax update does not work

為什么#{uImanager.select}從未更新?

<p:panel id="EditDetailsPanel" header="Edit Details">
    <h:panelGrid columns="2" cellpadding="5">
        <h:outputLabel value="Simple :" />
        <h:selectOneMenu value="#{uImanager.select}">
            <f:selectItem itemValue="val1" itemLabel="Coffee1" />
            <f:selectItem itemValue="val2" itemLabel="Coffee2" />
            <f:selectItem itemValue="val3" itemLabel="Coffee3" />                                  
        </h:selectOneMenu>
    </h:panelGrid>
    <p:commandButton value="Submit" update="EditDetailsForm:EditDetailsPanel"/>
    #{uImanager.select}
</p:panel> 

它指向一個private String Select; 與吸氣劑和二傳手。 它是在會話范圍內的托管bean中定義的。

因為您的update屬性可能指向無效的客戶端ID。 如果您關注服務器日志,那么您應該已經從PrimeFaces中看到了以下內容:

INFO: Cannot find component with identifier "EditDetailsForm:EditDetailsPanel" in view.

由於<p:panel><p:commandButton>本身位於同一UINamingContainer父級中(至少根據到目前為止已發布的代碼),因此只需指定其相對的客戶端ID:

<p:commandButton value="Submit" update="EditDetailsPanel"/>

或者,如果你在指定的絕對委托人身份證堅持,那么你需要用前綴它:

<p:commandButton value="Submit" update=":EditDetailsForm:EditDetailsPanel"/>

請注意,這僅在<h:form>本身沒有另一個UINamingContainer父級的情況下有效。 在瀏覽器中打開頁面,右鍵單擊並查看源代碼查看生成的HTML元素ID。 最后,你需要采取的值,前綴:

暫無
暫無

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

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