2
<h:form>
    <h:messages />
        <h:selectOneRadio value="#{bean.selectedValue}" id="selectId"
            layout="pageDirection">
            <f:selectItems value="#{bean.values}" var="value"
                itemLabel="#{value.text}" itemValue="{value}" />
        </h:selectOneRadio>
        <h:commandButton value="Press Me" >
            <f:ajax listener="#{bean.btn_action}" execute="@form"/>
        </h:commandButton>
</h:form>

Below are code details.

  • Bean is backing bean in @ViewScope.
  • bean.values is list of another managed bean which is in @RequestScope.
  • Radio button value is binded to above @RequestScope managed bean in backing bean. #{bean.selectedValue}
  • selectedValue is reference to object in backing bean having getter/setter.

Issues. - When execute=@form is added to ajax tag, listener is not even called. - After execute-@form, listener is getting called however radio button selected value is not updated in backing bean. - When i debug getter is always called for selectedValue never the setter.

Any help will be appreciated. Thanks.

Anish D
  • 21
  • 1
  • 3

1 Answers1

3

Assuming that itemValue="{value}" is just a careless typo and that you never paid attention to the server logs, then this construct will silently fail if #{value} represents a non-standard type and you don't have a Converter for that type or didn't implement the type's equals() method properly.

First step would be adding render="@form" to <f:ajax>, so that <h:messages> get updated as well, so that you don't need to look into server logs for conversion/validation errors.

<f:ajax execute="@form" listener="#{bean.btn_action}" render="@form" />

Second step would be fixing the problem based on the shown conversion/validation error. Most likely you've a conversion error "null converter" or maybe you already have one, but you're getting a validation error "value is not valid" instead.

Both potential problems are answered in detail in the following answers:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555