Is there an ajax event being fired when an item has been added to a richfaces (4.3.1.Final) pickList
? I need to enable disable a button depending on if any items have been selected or not.
将项目添加到richfaces(4.3.1.Final)pickList时是否会触发ajax事件?我需要启用禁用按钮,具体取决于是否已选择任何项目。
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" />
. 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. 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.
我也试过
Is there an ajax event to listen for that fires after the target list (selectedItems
) has been updated? (and there must be a complete list of supported ajax events for this component somewhere, right?)
在目标列表(selectedItems)更新后,是否有一个ajax事件来侦听该触发器? (并且必须有一个完整的此组件支持的ajax事件列表,对吧?)
I also tried the change event, as suggested here, but it is not fired.
我也按照这里的建议尝试了更改事件,但它没有被触发。
2 个解决方案
#1
0
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://docs.jboss.org/richfaces/4.3.X/4.3.0.CR1/vdldoc/rich/pickList.html
#2
0
Try this:
<rich:pickList
var="item"
value="#{someBean.selectedItems}">
<a4j:ajax event="transfer" render="somePanelGroupWithTheButton" />
</rich:pickList>
#1
0
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://docs.jboss.org/richfaces/4.3.X/4.3.0.CR1/vdldoc/rich/pickList.html
#2
0
Try this:
<rich:pickList
var="item"
value="#{someBean.selectedItems}">
<a4j:ajax event="transfer" render="somePanelGroupWithTheButton" />
</rich:pickList>