1

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.

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:

<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?)

I also tried the change event, as suggested here, but it is not fired.

Community
  • 1
  • 1
Magnilex
  • 11,584
  • 9
  • 62
  • 84
  • Can you try stock JSF events, maybe the ``? – kolossus Jun 11 '13 at 05:25
  • 1
    For future reference, the list of supported events is in the [official docs](http://docs.jboss.org/richfaces/4.3.X/4.3.0.CR1/vdldoc/rich/pickList.html) – Makhiel Jun 11 '13 at 11:06
  • Thanks, adding to my answer. They really should include stuff like this in the downloadable pdf though. – Magnilex Jun 11 '13 at 11:19

2 Answers2

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.

This is a defect that was solved in 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

Magnilex
  • 11,584
  • 9
  • 62
  • 84
0

Try this:

<rich:pickList 
        var="item"
        value="#{someBean.selectedItems}">
    <a4j:ajax event="transfer" render="somePanelGroupWithTheButton" />
</rich:pickList>
  • 2
    Please don't provide code-only answers. Explain in a bit more detail what's going on, and why your answer could solve the problem. – jlindenbaum Apr 22 '15 at 19:27