0

JSF 2.1 duplicates actionListener, valueChangeListener and validator calls many times while using binding for component and when backing bean is of View, Session or Application scope. Therefore each submit (partial or full) repeatedly call the same listeners many times. Each new request add +1 time in repeating listener calls. So the same listener is called repeatedly 1, 2, 3 and so on times.

If remove usage of binding for component then each listener is called once as expected. This bug makes bad perfomance and is potentially a reason of strange errors if the same listener is called repeatedly many times.

How to avoid listeners duplicated calls and keep on using binding?

  • the matter of my question is problem of using binding and View scope. The question you refer does not have this problem specified in summary and hence won't be found if look for "jsf repeated listener calls". And you suggest in your answer do not use binding and View scope. My question is how to allow use binding and View scope. Do you see a difference? – Oleksandr Tsurika Oct 03 '14 at 15:17
  • There is no mention about wrong usage of binding in View, Session or Application scope in jee jsf specification. And really it is **possible** to use binding for these scopes. And I know that many programmers do so and receive unexpected errors with duplicate listener calls. Thus I wanted to create clear description of this issue and suggest a solution. The solution how to avoid duplicate listener calls but still use binding and view scope (at least due to legacy of big old application). – Oleksandr Tsurika Oct 03 '14 at 15:48
  • >>(i.e. ask about the problem for which you incorrectly thought that using binding on a non-requestscoped bean would be the right solution). **My question** is concretely about why listener is triggered many times instead of once? What to do to avoid this? – Oleksandr Tsurika Oct 03 '14 at 15:58
  • I know that the bounded component is shared and restored among different requests to the same view. And I think the bug is in how it is restored - because exactly the same listeners are added. And the problem I stucked appeared in jsf2 - that bounded components listeners are duplicated. Thus perfomance of big application with hundreds boundings became worse. To refactor the application can take really much time. So easier to fix bug in jsf to do not duplicate listeners for bounded components. – Oleksandr Tsurika Oct 06 '14 at 08:03
  • this is your opinion or you found it in jsf specification that component has request scope? – Oleksandr Tsurika Oct 06 '14 at 08:06
  • In the specification is said that view backing bean can have different scopes. And that every view's component could be bounded. There are no limitations that bounding are possible only for "Request" scope but not for "View", "Session" or other scopes. You say it is wrong design, but I and many others who stucked with this unexpected behavior think this is bug in JSF implementation. [The similar issue posted as a bug on Icefaces](http://jira.icesoft.org/browse/ICE-7783) [Stackoverlow](http://stackoverflow.com/questions/8049572/actionlistener-is-called-multiple-times-bug-mojarra-2-1-3) – Oleksandr Tsurika Oct 06 '14 at 08:25

0 Answers0