【问题标题】:p:autocomplete updating other parts of the page when complete-method calledp:autocomplete 调用完成方法时更新页面的其他部分
【发布时间】:2014-03-18 13:14:30
【问题描述】:

也许我遗漏了一些非常基本的东西。

我有一个带有 p:ajax event="itemSelect" 子和 forceSelection="true" 属性的 p:autocomplete。 当用户从列表中选择一个值时,我可以从 itemSelect 事件更新部分页面。这一切都很好。 现在,当用户在字段中键入内容时,我还想要一个页面更新。 我想将此作为取消选择处理。 不幸的是,当调用完整方法时,我看不到更新的方法。 甚至像

这样的东西
final RequestContext requestContext = RequestContext.getCurrentInstance();
requestContext.update("content_form:table");

在完整方法中没有帮助。

有什么想法吗?我希望我能以全面的方式表达自己。

【问题讨论】:

    标签: primefaces


    【解决方案1】:

    您可以使用 key 事件之一,例如 onkeyup、onkeydown 等

            <h:panelGrid id="components2update">
                <ui:param name="teststuff" value="#{areasBean.someValueThatgotUpdated}" />
                <p:outputLabel value="#{teststuff}" />
            </h:panelGrid>
    
            <p:autoComplete id="acSimple" value="#{someBean.someValue}"
                completeMethod="#{someBean.autoCompMethod}"
                .... >
                <p:ajax event="keyup" oncomplete="alert('ddd')"
                    update=":#{p:component('components2update')}" />
    
            </p:autoComplete>
    

    【讨论】:

    • 如果您想根据autoCompMethod 的结果更新某些内容,这不起作用。 keyUp 事件在 autoCompMethod 被调用之前就被触发了。
    • @MonkeySupersonic,听起来你想有条件地更新你的组件,所以你最好在支持 bean 上处理该逻辑,并让它调用更新,stackoverflow.com/questions/11365094/…
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-30
    • 1970-01-01
    • 2014-05-21
    • 2021-12-17
    • 2012-09-12
    相关资源
    最近更新 更多