I ran into a very interesting issue. Here is my scenario:
My Goal
- Use a SelectManyCheckbox with a nested tooltip.
- Use SelectManyCheckbox onHide event to fire an Ajax (ActionListener) call and update the
- SelectManyCheckbox label and nested tooltip text.
My Approach
- Use a remoteCommand and tie it to the SelectManyCheckbox onHide event
XHTML
<p:selectCheckboxMenu id="sourceFilter"
onHide="sourceFilterCommand();"
value="#{viewRevenueBean.sourceSelectManyMenu.selectedValues}"
label="#{viewRevenueBean.sourceSelectManyMenu.label}"
filter="true" filterMatchMode="contains"
validator="#{viewRevenueBean.sourceSelectManyMenu.validate}"
widgetVar="srcFilterDropDown">
<f:selectItems id="sourceItems"
value="#{viewRevenueBean.sourceSelectManyMenu.availableItems}"
var="source" itemLabel="#{source.label}" itemValue="#{source.value}" />
<f:convertNumber type="number" />
<p:tooltip id="srcToolTip"
for="sourceFilter"
value="#{viewRevenueBean.sourceSelectManyMenu.tooltipText}"
showEffect="fade"
hideEffect="fade"/>
<p:remoteCommand name="sourceFilterCommand" update="sourceFilter"
actionListener=#{viewRevenueBean.sourceSelectManyMenu.defaultEventHandler}"/>
</p:selectCheckboxMenu>
My Results
- Ajax (Action Listener) gets fired and SelectManyCheckbox label and nested tooltip are updated (expected behavior).
- In Firebug, I noticed that each onHide event Ajax call is multiplying the preceding number of server side requests by two (unexpected behavior).
e.g
1st onHide event = 1 Request
2nd onHide event = 2 Requests
3rd onHide event = 4 Requests
4th onHide event = 8 Requests
5th onHide event = 16 Requests
etc.....
This is obviously not desired and leads to a big slow down after just a couple onHide events.
Experiments I tried
I created a p:command button which accomplished the desired Ajax call and correct element updates (without the multiplied request issue) . I then proceeded to steal it's Ajax JavaScript call via Firebug and placed it in my own JavaScript function, which I then used as my onHide callback. Again, I experience the same unwanted result, the label and tooltip are updated, but the requests start to multiply.
I tried placing the remoteCommand in different locations (outside the menu, inside it's own form etc). It doesn't make a difference. The problem is still encountered.
I tried simplifying the SelectManyCheckbox scenario (remove tooltip, coverter, tweak various attributes etc) to eliminate other possibilities. No difference.
I tried a p:ajax instead of p:remoteCommand using onchange. The Ajax requests work fine but obviously it's not what I am after. I need to trigger it onHide.
Instead of a SelectCheckboxMenu , i tried using a SelectManyCheckbox (no label) with onchange and keeping everything else the same. The remoteCommand works fine, the Ajax call gets called once and everything is nice and dandy. [/list] [list] * I tried the PrimeFaces 3.5-SNAPSHOT as well. No difference. Issue is still manifested.
Haven't found any clues on the forum or the net thus far in regards to this issue. Does this sound like a bug or programmer clumsiness :roll: ? Of course any insight and/or suggestions are highly appreciated.