0

Edited with additional info for clarity

We are migrating application from JBoss 5 to Tomee 7.0.1+. On Tomee we are using MyFaces 2.2.10 and RichFaces 4.2.0 (on Jboss we used Mojarra JSF instead of MyFaces).

We have a problem with f:ajax listener not triggering on value change in the radio button list. Here is our code:

 <h:selectOneRadio value="#{managedBean.paramsType}"
   layout="pageDirection">
   <f:selectItem itemValue="Item1" itemLabel="Item1" />
   <f:selectItem itemValue="Item2" itemLabel="Item2" />
   <f:ajax render="@form" execute="@form" listener="#{managedBean.checkSelection}" />
  </h:selectOneRadio>

<h:selectManyCheckbox value="#{managedBean.objectList}" layout="pageDirection">
   <f:selectItem itemValue="checkOption1" itemLabel="Option1" itemDisabled="#{managedBean.paramsType == 'Item3'}"/>
   <f:selectItem itemValue="checkOption2" itemLabel="Option2" itemDisabled="#{managedBean.paramsType == 'Item1'}"/>
   <f:selectItem itemValue="checkOption3" itemLabel="Option3" itemDisabled="#{managedBean.paramsType == 'Item2'}"/>
</h:selectManyCheckbox>

In managed bean the checkSelection method has the following signature:

public void checkSelection()
{
 //update objectList (select or deselect items) based on radio button selection
}

Check selection is never called when running the app on TomEE but the same worked on JBoss (identical code).

On TomEE, we tried adding AjaxBehaviorEvent as input parameter of checkSelection method, but the method is never called with or without this parameter. It looks like the listener attribute of f:ajax is not processing the event for some reason.

No errors are reported in the browser console or in application or server logs - the method is simply never called. Also, h:messages doesn't display any error.

Also, we tried with a4j:ajax and valueChangeListener. a4j:ajax behaves the same as f:ajax - method defined in managed bean is not called; valueChangeListener doesn't work for us because it is triggered by a different event than the f:ajax listener and we need a change of selection in radio buttons to affect the selection of a h:selectManyCheckbox component on the same form.

MWiesner
  • 8,868
  • 11
  • 36
  • 70
Stevan
  • 31
  • 2
  • 7
  • What is 'not working'? Do you see a network ajax call being send that does not reach your method? Is an ajax call not sent at all? Did you try adding an explicit `event` to the ajax tag? Do you have an h:messages in your page? Any errors in the browser console? When it worked on JBoss, was it 100% identical? A full [mcve] is the least you should post btw, meaning the easiest for others to use to reproduce – Kukeltje Oct 04 '16 at 15:27
  • Thanks for your kind input. I have edited the original question with more info. Hopefully it's now clear enough. – Stevan Oct 05 '16 at 08:47
  • Is this helpful as to debugging the problem? http://stackoverflow.com/q/2118656 – BalusC Oct 05 '16 at 09:23
  • Hi BalusC. Thanks for prompt response. I checked link you attached and passed through all items and debugging. Nothing happens. Whole program is in tag. Also, when I changed h:selectOneRadio to h:selectOneMenu or h:selectOneListbox, method is called and everything works fine. Also, tried with h:selectBooleanCheckbox and it works also. Only radio buttons are the problem. Do you know if there is some known issue with this? Thanks in advance – Stevan Oct 05 '16 at 11:54

1 Answers1

0

For newcomers: I had pretty much the same issue, practically exhausted the Internet, no solution.

Solved when migrated from jsf 2.2(.?) to 2.3.

By the way, @#$%!@#$*, 2 days lost in the other way, so take this as the hard way to learn/remember, when facing such problems, ALWAYS upgrade your libraries first...

Addendum: Don't blindly update your libraries.

As Jon Bates pinpointed, every change carries with it the potential of introduce new bugs into the system, and while the old vs new theme is by itself controversial, there is a general consensus that the good practice, when dealing with a already proved stable system, is to keep changes to the minimum, up to archiving the new desired goals. That's one of the reasons why good libraries usually have major, minor, and revision numbers, look at them.

  • Welcome! When answering, please make sure your answers are to the point, and remember it isn't always a good idea to blindly upgrade libraries.. – Jon Bates Apr 24 '18 at 18:00
  • Hi Jon! By your answer, I presume you have some level of experience doing this, thanks by sharing your point of view. But "when facing such problems" is the key point here, and sometimes it's not a matter of choice, so don't assume it's a blind one. In our field, to be afraid is something that comes after some time of practice and I believe it's a good thing, but don't push it to the point that you are afraid to do what you need to do. And by the way, more to the point than "solved when migrated from xx to yy"?? Regards. – Edson Freitas Apr 25 '18 at 14:27
  • Of course!. I solved an issue on my box today by upgrading a library. I also upgraded another library (just a version upgrade in SemVer semantics) had had to deal with totally bizarre unintended stupid issues. I'm afraid I still have to disagree on the advice, but I'll un-downvote the answer. When you get so many points on this site, you are able to moderate answers. I allowed a deliberately low-quality `test` answer slip through before seeing your answer, got told off for it and thought yours was another test. I can't change my score however unless you make an edit (site doesn't allow it) – Jon Bates Apr 26 '18 at 16:29
  • 1
    Hi Jon, I apologize for the way I answered to both, the question and you: after two days of misguided attempts, I was not in my best. I think I got what you saw wrong: the second part of the sentence, "ALWAYS.." is too strong, so I wrote a addendum. As to the un-downvote, I appreciate your intent and don't worry, as an old user of discussion lists, I now the way things can go when everyone can talk about everything without some kind of control, so I accept that one o other downvote is a minor price to pay to maintain a healthy ecosystem. – Edson Freitas May 03 '18 at 19:03
  • What explicit version and impl did you use where it was a problem? – Kukeltje May 03 '18 at 20:24