When using plain HTML radio buttons bound to a bean using the jsf: attributes added in JSF 2.2, I run into an issue where the generated names of the radio inputs don't match:
<label>
<input type="radio" value="foo" name="a-radio" jsf:id="fooOption" jsf:value="#{fooBean.value} />
</label>
<label>
<input type="radio" value="bar" name="a-radio" jsf:id="barOption" jsf:value="#{fooBean.value} />
</label>
However, when the page is rendered, the name attributes of the inputs become "[some:jsf:id]:fooOption" and "[some:jsf:id]:barOption", meaning that checking one doesn't uncheck the other! Is this a bug, or does the jsf: attribute namespace not support radio buttons?
Specify the
name
as passthrough attribute instead. It will override the implicit attribute.You only need to redeclare it as
<f:viewParam name="a-radio" value="#{fooBean.value}">
, or to manually grab the submitted value from the request parameter map.