JSF ajax的命令没有更新primefaces选择列表 [英] JSF ajax commandbutton not updating primefaces picklist

查看:165
本文介绍了JSF ajax的命令没有更新primefaces选择列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是在code:

<h:form id="articleForm" >
    <p:commandButton value="Select tags" ajax="true" >
        <f:ajax execute="@form" render="@form :articleForm:tags" />
    </p:commandButton>

    <p:pickList id="tags" value="#{articleController.dualListModelForTags}" var="tag" itemLabel="#{tag.tag}" itemValue="#{tag}" converter="distinctTagConverter">
        <f:facet name="sourceCaption">Distinct tags</f:facet>  
        <f:facet name="targetCaption">Connected tags</f:facet>
    </p:pickList>
</h:form>

在命令被点击时,getDualListModelForTags()的支持bean调用并执行。在getDualListModelForTags()我做了一些修改,所以我想领料单进行更新。不过选择列表(ID =标签)没有再次呈现。只有当我刷新页面,被修改的领料单进行。

When the commandbutton is clicked, the getDualListModelForTags() in the backing bean is called and executed. In getDualListModelForTags() I make some modifications so I want the picklist to be updated. But the picklist(id=tags) is not rendered again. Only when I refresh the page, are the modifications made to the picklist.

推荐答案

在PrimeFaces &LT;电话号码:的commandButton&GT; 组件不与合作&LT; F:AJAX&GT; 。您需要使用该按钮自身的AJAX针对性的属性来代替。相反,&LT的; F:AJAX执行&GT; 你应该使用&LT;电话号码:的commandButton处理&gt; 。但是,这已经默认为 @form ,这样你就可以忽略它。相反,&LT的; F:AJAX渲染&GT; 你应该使用&LT;电话号码:的commandButton更新&GT; 。指定这些已涵盖了 @form 客户端ID是不必要的,所以只要 @form 就足够了。另外,阿贾克斯=真正的属性是不必要的,因为这就是默认了。

The PrimeFaces <p:commandButton> component doesn't work together with <f:ajax>. You need to use the button's own ajax-targeted attributes instead. Instead of the <f:ajax execute> you should use <p:commandButton process>. But this already defaults to @form, so you can omit it. Instead of the <f:ajax render> you should use <p:commandButton update>. Specifying client IDs which are already covered by @form is unnecessary, so just @form is sufficient. Also the ajax="true" attribute is unnecessary as that's the default already.

因此​​,只要这个应该做的:

So just this should do:

<p:commandButton value="Select tags" update="@form" />


无关的具体问题,你正在做内部的getter方法​​的业务工作。这是一个坏主意。做到这一点,在按钮的动作方法来代替。您也似乎可以用一个会话范围的bean的视图范围的数据。这是一个坏主意。把豆在视图范围来代替。


Unrelated to the concrete problem, you're doing the business job inside a getter method. This is a bad idea. Do it in the button's action method instead. You also seem to be using a session scoped bean for view scoped data. This is a bad idea. Put the bean in the view scope instead.

这篇关于JSF ajax的命令没有更新primefaces选择列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆