0

I want to do some crazy grouping with SelectOneRadio, so I decide to create my own custom component that allow me to specify the name attribute of the <input> tag (as you know, same name means the radio buttons are in the same group). The renderer is correct, so I have a <input> that used to render like this

<input name="myForm:test1" id="myForm:test1:0" value="0" type="radio">

now render like this

<input name="foo" id="myForm:test1:0" value="0" type="radio">

However, EL stop working when I submit a form (same for h:commandButton and p:commandButton). So if I have this

<xxx:selectOneRadio id="test1" value="#{myBean.selectedFood}">

then EL work, selectedFood print out the corrected value, but if I put in

<xxx:selectOneRadio id="test1" value="#{myBean.selectedFood}" groupId="foo"> 

which will make the name=foo in the <input> tag. Then EL binding stop working. selectedFood is null.

More interestingly, If I put in this

<xxx:selectOneRadio id="test1" value="#{myBean.selectedFood}" groupId="myForm:test1">

which myForm:test1 is the correct client Id, then EL binding work again, so it does not look like it is my code that make the binding stop working. Does JSF require the name attribute of the input tag to the client id?

Thang Pham
  • 38,125
  • 75
  • 201
  • 285

1 Answers1

2

The name becomes the HTTP request parameter name and this has to be used to collect submitted HTTP request parameter values. This defaults to the JSF component client ID and the collecting happens in the decode() method of the Renderer (or the UIComponent itself). You need to override/implement the decode() of the Renderer as well to change the way how you get request parameter values.

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