You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Sly_cardinal <co...@gmail.com> on 2007/05/16 09:15:41 UTC
Multiple (unwanted) valueChangeListener events
HI,
I am encountering strange behaviour with multiple, independent
valueChangeListeners being triggered from the same event.
I think that this problem might be related to what Julien Martin was
encountering in this thread, although reversed - I am getting too many
valueChange events:
http://www.nabble.com/MyFaces-and-valueChangeListener---t3267558.html
I have two inputText fields in a single form with separate
valueChangeListener methods defined for each:
<h:column>
<h:inputText id="fundToTransfer" value="#{cutoffItem.fundToTransfer}"
onchange="submit();"
immediate="false"
valueChangeListener="#{cutoffTransferForm.updateFundTransfer}" >
</h:inputText>
</h:column>
<h:column>
<h:inputText id="targetBalance"
value="#{cutoffItem.clientDetail.targetBalance}"
onchange="submit();"
immediate="false"
valueChangeListener="#{cutoffTransferForm.updateTargetBalance}" >
</h:inputText>
</h:column>
I have found that when the 'fundToTransfer' text field is changed and posts
back *both* updateFundTransfer and updateTargetBalance are triggered.
Originally I thought that changing the values of the backing bean properties
was causing the other listener to fire but I simplified the handlers down to
simple debugging messages that shows which UIComponent triggered the event:
public void updateFundTransfer(ValueChangeEvent event)
{
String sourceId = ((UIInput) event.getSource()).getId();
log.debug("updateFundTransfer: id=" + sourceId + ", value=" +
event.getNewValue());
}
public void updateTargetBalance(ValueChangeEvent event)
{
String sourceId = ((UIInput) event.getSource()).getId();
log.debug("updateTargetBalance: id=" + sourceId + ", value=" +
event.getNewValue());
}
The basic problem seems to be that a change to one of the text fields causes
the other field to trigger its own valueChangeListener, regardless of
whether its value changed or not.
I've added some more inputText fields for testing (targetBalance2 and
fundTransfer2) with the same valueChangeListener functions defined as the
original textfields.
Things get stranger:
- 'targetBalance2' and 'fundTransfer2' cause 'targetBalance' to trigger
'updateTargetBalance' prior to their own listeners.
- 'fundTransfer' causes 'targetBalance' to trigger 'updateTargetBalance'
*after* its own handler.
- When the value of 'targetBalance' is changed and posts back, only
'updateTargetBalance' listener is triggered (the behaviour I expect from the
rest of the cases).
Right now I am in the process of attempting to test this with the Java
Reference Implementation but I was wondering if this is a known MyFaces
issue or if someone has encountered something similar to this problem?
(I have also tried using the Sandbox 'valueChangeNotifier' component instead
of the 'valueChangeListener' with the same result.)
We are running JBoss 4.0.5 with MyFaces 1.1.5.
Thanks,
-Coridyn
--
View this message in context: http://www.nabble.com/Multiple-%28unwanted%29-valueChangeListener-events-tf3762940.html#a10636804
Sent from the MyFaces - Users mailing list archive at Nabble.com.
Re: Multiple (unwanted) valueChangeListener events
Posted by Sly_cardinal <co...@gmail.com>.
I have found that the problem was being caused by number converters that I
had attached to the inputText fields:
<h:inputText value="#{clientItem.deposit}"
valueChangeListener="#{creditTransferForm.updateDeposits}"
immediate="false"
onchange="submit();">
<f:convertNumber minFractionDigits="2" maxFractionDigits="2"
groupingUsed="true" />
<f:converter converterId="javax.faces.Double" />
</h:inputText>
Removing the convertNumber elements (but keeping the converters) solved the
problem.
Thanks,
-Coridyn.
Sly_cardinal wrote:
>
> HI,
>
> I am encountering strange behaviour with multiple, independent
> valueChangeListeners being triggered from the same event.
>
> ...
>
>
--
View this message in context: http://www.nabble.com/Multiple-%28unwanted%29-valueChangeListener-events-tf3762940.html#a10657759
Sent from the MyFaces - Users mailing list archive at Nabble.com.