0

Alright, so I have been trying for ages to solve this myself but it is impossible. I have a form with a radio button in my xhtml. The radio button included in the form is supposed to get a list of Objects use these as select items. These values are correctly retrieved and displayed in the options of the radio button. However, when I am actually trying to save one of these values by calling the equivalent setter nothing happens (i.e. the setter is never called). My form has the following structure:

...
<h:form id="xform">      
    <p:selectOneRadio id="supervisor" value="#{cntrl.demo}" layout="grid" columns="3">
        <f:selectItems value="#{cntrl.demos}" var="s" itemLabel="#{s}" itemValue="#{s}"/>
    </p:selectOneRadio>
    <p:commandButton value="submit" action="#{cntrl.register}" update="xform"/>
</h:form>

My Cntrl class contains the following methods:

@Named
@ViewScoped
public class Cntrl implements Serializable{

public void register() {
    //do some stuff
}

public void setDemo(Demo demo) {
    this.demo = demo;
}

public List<Demo> getDemos() {
    return demos;
}
///...more code
}

So the getDemos is properly called and the buttons are properly populated etc. However the setDemo never gets called

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Rakim
  • 1,087
  • 9
  • 21
  • 40
  • Any exceptions? How is the controller defined? – ujulu Apr 30 '16 at 10:52
  • no exceptions or anything. controller is defined as edited in the question – Rakim Apr 30 '16 at 11:08
  • Have you excluded everything from http://stackoverflow.com/q/2118656? – BalusC Apr 30 '16 at 11:11
  • Quickly going through them, I think that I don't have anything opposing to these points.. Is really weird. And on top of that, when I tried to display `selectItems` by using `s.someValue` I was getting an error saying that `s` is a String or something. Which is pretty weird taking into account that `getDemos` returns `List`. I don't know if that gives you any hint to what it can be but it sounds like a completely different issue to me – Rakim Apr 30 '16 at 11:36
  • Oh, and I forgot to mention that on form submission, the radio buttons go red. Which I think is implemented by PrimeFaces when a field is not passing validation. In this case that would be no selection of a radio button, although it appears to be – Rakim Apr 30 '16 at 11:41
  • And one last thing that might help is that on rendering of the page, gboth `getDemos` and `getDemo` are called. Isn't 'value="#{cntrl.demo}"` only supposed to call the setter? – Rakim Apr 30 '16 at 11:53
  • `getDemo()` will be called when the page is rendered, and `setDemo()` will be called when the page is submitted. – ujulu Apr 30 '16 at 12:03
  • So you already set project stage to development? So you already attached `` to check for any faces messages? Based on information provided so far, I'd guess you just have a conversion error. – BalusC Apr 30 '16 at 13:59
  • I got it displaying errors properly. I get something saying `Conversion Error setting value 'value' for 'null Converter'.` – Rakim Apr 30 '16 at 14:08
  • As I guessed. See the duplicate. – BalusC Apr 30 '16 at 14:39
  • ye I did just before. Is fixed now. Thanks for helping – Rakim Apr 30 '16 at 14:43

0 Answers0