0
votes

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.

1
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 minimal reproducible example is the least you should post btw, meaning the easiest for others to use to reproduceKukeltje
Thanks for your kind input. I have edited the original question with more info. Hopefully it's now clear enough.Stevan
Is this helpful as to debugging the problem? stackoverflow.com/q/2118656BalusC
Hi BalusC. Thanks for prompt response. I checked link you attached and passed through all items and debugging. Nothing happens. Whole program is in <h:form> 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 advanceStevan

1 Answers

0
votes

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.