Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
指定输入类型=”时,名称属性被覆盖;电台;作为JSF passthrough元素_Jsf_Radio Button_Jsf 2.2_Passthrough Elements - Fatal编程技术网

指定输入类型=”时,名称属性被覆盖;电台;作为JSF passthrough元素

指定输入类型=”时,名称属性被覆盖;电台;作为JSF passthrough元素,jsf,radio-button,jsf-2.2,passthrough-elements,Jsf,Radio Button,Jsf 2.2,Passthrough Elements,当使用jsf 2.2中添加的jsf:attributes将普通HTML单选按钮绑定到bean时,我遇到了一个问题,即生成的单选输入名称不匹配: <label> <input type="radio" value="foo" name="a-radio" jsf:id="fooOption" jsf:value="#{fooBean.value} /> </label> <label> <input type="radio"

当使用jsf 2.2中添加的jsf:attributes将普通HTML单选按钮绑定到bean时,我遇到了一个问题,即生成的单选输入名称不匹配:

<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>


但是,当呈现页面时,输入的name属性变成“[some:jsf:id]:fooption”和“[some:jsf:id]:barOption”,这意味着选中一个不会取消选中另一个!这是一个bug,还是jsf:attribute名称空间不支持单选按钮?

您可以更好地使用
h:selectOneRadio
组件,该组件随后包含一系列
s:selectItem
s

<h:selectOneRadio value="#{fooBean.value}">
    <f:selectItem itemValue="foo" itemLabel="foo" />
    <f:selectItem itemValue="bar" itemLabel="bar" />
</h:selectOneRadio>


有关更完整的示例,请参见将
名称指定为。它将覆盖隐式属性

<html ... xmlns:a="http://xmlns.jcp.org/jsf/passthrough">

<label>
    <input type="radio" value="foo" a:name="a-radio" jsf:id="fooOption" />
</label>
<label>
    <input type="radio" value="bar" a:name="a-radio" jsf:id="barOption" />
</label>


您只需将其重新声明为
,或手动从请求参数映射中获取提交的值。

OP想要自定义默认单选按钮呈现,这在
中是不可能的(默认情况下会生成HTML