[prev in list] [next in list] [prev in thread] [next in thread] 

List:       myfaces-user
Subject:    [Trinidad] valueChangeListener called too often?
From:       "Jessica Johnson" <jessica () internetmi ! com>
Date:       2007-11-30 21:53:12
Message-ID: 32b7d5c80711301353r87a7ac9oa35299e55f9c6005 () mail ! gmail ! com
[Download RAW message or body]

Hi all,

I'm seeing some strange behavior using PPC and SelectManyListBoxes.  I
have 3 select boxes: A, B, and C.  When a value in A is selected, the
values in B and C should change, and the value that is selected should
also change.  When a value is selected in B the values and selected
values in C should change.

The problem is that selecting an item in A is firing both of my
events.  First it fires the event for when A is changed which sets the
backing bean so that B and C have the desired values and a default
value is selected in B.  Then it fires the event for when B is
changed, with the values in the ValueChangeEvent are the values that
were submitted on the client side.  So the Bchanged event happily
overwrites the correct selected value that was set in Achanged.

It seems to me that selecting an item in A should trigger *only*
Achanged and selecting an item in B should trigger *only* Bchanged,
but selecting an item in either A or B triggers both events.  Is this
expected behavior?  Have I misunderstood how to set up the triggers?

I have been wracking my brain trying to think of a workaround for this
(instance variables to prevent double calls, using state, etc.) but
nothing has panned out so far.

Any ideas would be appreciated.


<tr:selectManyListbox id="selectA"
                      size="4"
                      binding="#{dataReportsLoader.selectA}"
                      converter="IntegerConverter"
                      contentStyle="width: 175px"
                      autoSubmit="true"
                      rendered="#{dataReportsLoader.renderFilters}"
                      valueChangeListener="#{dataReportsLoader.aChanged}"
                      valuePassThru="true"
                      value="#{dataReportsLoader.selectedAList}" >
    <f:selectItem itemLabel="-- All As --"
itemValue="#{dataReportsLoader.allValue}" />
    <f:selectItems value="#{dataReportsLoader.visibleAList}" />
</tr:selectManyListbox>

<tr:selectManyListbox id="selectB"
                      size="4"
                      binding="#{dataReportsLoader.selectB}"
                      contentStyle="width: 175px"
                      converter="IntegerConverter"
                      autoSubmit="true"
                      valueChangeListener="#{dataReportsLoader.bChanged}"
                      valuePassThru="true"
                      value="#{dataReportsLoader.selectedBList}"
                      partialTriggers="selectA"
                      rendered="#{dataReportsLoader.renderFilters}" >
    <f:selectItem itemLabel="-- All Ad Groups --"
itemValue="#{dataReportsLoader.allValue}" />
    <f:selectItems value="#{dataReportsLoader.visibleBList}" />

</tr:selectManyListbox>

<tr:selectManyListbox id="selectC"
                      size="4"
                      binding="#{dataReportsLoader.selectC}"
                      converter="IntegerConverter"
                      contentStyle="width: 175px"
                      valuePassThru="true"
                      value="#{dataReportsLoader.selectedCList}"
                      partialTriggers="selectB"
                      rendered="#{dataReportsLoader.renderFilters}" >
    <f:selectItem itemLabel="-- All Cs --"
itemValue="#{dataReportsLoader.allValue}" />
    <f:selectItems value="#{dataReportsLoader.visibleCList}" />
</tr:selectManyListbox>




aChanged() changes the values for visibleBList, visibleCList,
selectedAList based on the ValueChangedEvent's newValue
bChanged() changes the values for visibleCList and selectedCList based
on the values of ValueChangedEvent's newValue


I can post the code if anyone is interested.

Thanks,

jessica
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic