0

I can not get an f:ajax listener working on a simplest JSF 2.2 page. Values are assigned, but the listener is deaf. Strangely, the very same code is working perfectly fine if I replace h:selectOneRadio with h:selectOneMenu. Here is the html:

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:h="http://xmlns.jcp.org/jsf/html">

<h:head>
  <title>Test</title>
</h:head>
<h:body>
  <h:form id="f" >
    <h:selectOneRadio id="r" value="#{test.mode}">
      <f:selectItem itemValue="One"/>
      <f:selectItem itemValue="Two"/>
      <f:selectItem itemValue="Three"/>
      <f:ajax render="@form" execute="@form" listener="#{test.listener2()}"/>
    </h:selectOneRadio>
    <br/>
    <h:outputText id="out" value="#{test.mode}"/>
  </h:form>
</h:body>
</html>

and the bean:

@Named
@SessionScoped
public class Test implements Serializable {

  private final static Logger LOG = Logger.getLogger(Test.class.getName());

  private String mode;

  public String getMode() {
    return mode;
  }

  public void setMode(String mode) {
    this.mode = mode;
    LOG.info("Mode setter: " + mode);
  }

  public void listener1(AjaxBehaviorEvent event) throws AbortProcessingException {
    LOG.info("Mode listener 1: " + mode);
  }

  public void listener2()  {
    LOG.info("Mode listener 2: " + mode);
  }

}

Neither of the listener method types are fired for h:selectOneRadio. Making the bean as @ManagedBean and using different ajax event types were to no help either.

The issue appeared after upgrading of Apache Tomee to version 7.0.1 (MyFaces 2.2.10, JSF 2.2). Same problem with MyFaces to 2.2.11.

The web app is bundled inside an ear, no other JSF libraries are loaded, no Primefaces and similar, no servlet filters, no nothing at all - a pure JSF 2.2 application.

Any ideas?

MWiesner
  • 8,868
  • 11
  • 36
  • 70
andbi
  • 4,426
  • 5
  • 45
  • 70
  • try adding an explicit event to the `f:ajax` – Kukeltje Nov 20 '16 at 21:14
  • @Kukeltje makes no difference, tested most of them. – andbi Nov 20 '16 at 21:22
  • Oops, I missed that you already mentioned that... Sorry... So If I understand correctly, calling listener1 also does not work (without brackets in the xhtml)? Any info when you add an `h:messages`? And what when you run the app in development mode? – Kukeltje Nov 20 '16 at 22:13
  • @Kukeltje, the same, no logs or errors, it looks like listeners are being skipped or not resolved. Just filed the bug, this is a real stopper. – andbi Nov 21 '16 at 08:30

1 Answers1

2

There's a bug in MyFaces, will be fixed in MyFaces 2.2.12. Should you need an immediate solution, use MyFaces snapshots, they seem to be working fine, just drop them in Tomee's lib folder instead of the stock versions of myfaces-api-* and myfaces-impl-*.

https://issues.apache.org/jira/browse/MYFACES-4068

andbi
  • 4,426
  • 5
  • 45
  • 70