简体   繁体   English

Ajax更新不起作用

[英]Ajax update does not work

Why is the #{uImanager.select} never updated? 为什么#{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> 

It points to a private String Select; 它指向一个private String Select; with a getter and setter. 与吸气剂和二传手。 It's defined in a session scoped managed bean. 它是在会话范围内的托管bean中定义的。

Because your update attribute likely points to an invalid client ID. 因为您的update属性可能指向无效的客户端ID。 If you paid attention to the server logs, then you should have seen something like the following from PrimeFaces: 如果您关注服务器日志,那么您应该已经从PrimeFaces中看到了以下内容:

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

As the <p:panel> is inside the same UINamingContainer parent as the <p:commandButton> itself (at least, based on the code which you've posted so far), you can just specify its relative client ID: 由于<p:panel><p:commandButton>本身位于同一UINamingContainer父级中(至少根据到目前为止已发布的代码),因此只需指定其相对的客户端ID:

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

Or if you insist in specifying the absolute client ID, then you need to prefix it with : : 或者,如果你在指定的绝对委托人身份证坚持,那么你需要用前缀它:

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

Note that this only works if the <h:form> does by itself not have another UINamingContainer parent. 请注意,这仅在<h:form>本身没有另一个UINamingContainer父级的情况下有效。 Open the page in browser, rightclick and View Source to figure the generated HTML element ID. 在浏览器中打开页面,右键单击并查看源代码查看生成的HTML元素ID。 Finally you need to take that value, prefixed with : . 最后,你需要采取的值,前缀:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM