简体   繁体   English

添加/删除项目时,Richfaces pickList ajax事件

[英]Richfaces pickList ajax event when item has been added/removed

Is there an ajax event being fired when an item has been added to a richfaces (4.3.1.Final) pickList ? 将项目添加到Richfaces(4.3.1.Final) pickList时,是否会引发ajax事件? I need to enable disable a button depending on if any items have been selected or not. 我需要启用禁用按钮,具体取决于是否选择了任何项目。

The developer guide does not mention this at all, but I found this when googling. 开发人员指南根本没有提到这一点,但是我在谷歌搜索时发现了这一点 Using the suggested solution, I used the following ajax events: 使用建议的解决方案,我使用了以下ajax事件:

<rich:pickList 
        var="item"
        value="#{someBean.selectedItems}">
    <a4j:ajax event="sourceblur" render="somePanelGroupWithTheButton" />
    <a4j:ajax event="targetblur" render="somePanelGroupWithTheButton" />
</rich:pickList>

This works. 这可行。 However, the event is fired each time the source or target list is blurred, which is too frequently for my needs. 但是,每次源或目标列表模糊时都会触发该事件,这对于我的需求而言太频繁了。

I also tried <a4j:ajax event="additems" /> and <a4j:ajax event="removeitems" /> . 我还尝试了<a4j:ajax event="additems" /><a4j:ajax event="removeitems" /> In this case, the event is fired only on removal or adding items, exactly like I want. 在这种情况下,仅在删除或添加项目时才触发该事件,完全与我想要的一样。 However, selectedItems isn't populated with the new item until after the event has been fired. 但是,直到事件被触发后, selectedItems才会填充新项目。 This means I cannot use it to re-render the button, since the list will be empty after adding the first item, and having size one after adding the second element. 这意味着我不能用它来重新渲染按钮,因为添加第一个项目后列表将为空,添加第二个元素后列表将为1。

Is there an ajax event to listen for that fires after the target list ( selectedItems ) has been updated? 在目标列表( selectedItems )更新之后,是否有ajax事件来监听该事件? ( and there must be a complete list of supported ajax events for this component somewhere, right? ) 并且某处必须有此组件的受支持的ajax事件的完整列表,对吗?

I also tried the change event, as suggested here , but it is not fired. 我也试过改变事件,如建议在这里 ,但它没有被解雇。

Just tried the change event again, and suddenly it worked. 只是再次尝试了变更事件,突然就起作用了。 Possibly a typo from me when I first tried it. 当我第一次尝试时可能是我的错字。 This is the way to go: 这是要走的路:

<rich:pickList 
        var="item"
        value="#{someBean.selectedItems}">
    <a4j:ajax event="change" render="somePanelGroupWithTheButton" />
</rich:pickList>

When the event is triggered and somePanelGroupWithTheButton is re-rendered, someBean.selectedItems has been populated with the correct items. 当触发事件和somePanelGroupWithTheButton进行重新渲染, someBean.selectedItems已经填入了正确的项目。

This is a defect that was solved in 4.3.0.M2: https://issues.jboss.org/browse/RF-12360 . 这是在4.3.0.M2中解决的缺陷: https ://issues.jboss.org/browse/RF-12360。

And the supported events for pickList can be found here: http://docs.jboss.org/richfaces/4.3.X/4.3.0.CR1/vdldoc/rich/pickList.html 可以在以下位置找到pickList的受支持事件: http : pickList

Try this: 尝试这个:

<rich:pickList 
        var="item"
        value="#{someBean.selectedItems}">
    <a4j:ajax event="transfer" render="somePanelGroupWithTheButton" />
</rich:pickList>

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

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