我们使用外部提供的HTML5资源(响应性设计)。我们面临的挑战是使用Java添加逻辑,同时保持精确的HTML呈现。
我发现JSF通过在这种情况下是有帮助的。
但是我不能让单选按钮工作。我不知道如何使用托管bean中的属性(示例中的“stringAttribute”)进行连接。在POST数据中,我看到了所选单选按钮的值,但是JSF没有在托管bean中设置它。
有人看到我在这里的企图出了什么问题吗?
还是根本不支持?(type=“收音机”没有出现在Oracle中的表8-4如何呈现HTML5元素中)。
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:jsf="http://xmlns.jcp.org/jsf"
xmlns:pt="http://xmlns.jcp.org/jsf/passthrough">
<h:form>
<input jsf:value="#{myBean.stringAttribute}" pt:value="firstChoice" pt:name="the-radio-group" type="radio"/>
<input jsf:value="#{myBean.stringAttribute}" pt:value="secondChoice" pt:name="the-radio-group" type="radio"/>
<h:commandButton type="submit" value="Submit" action="#{myBean.submit}"/>
</h:form>或者你会怎么处理这个?请记住,我有相当复杂的HTML,必须准确地使用JSF来呈现。为了给您一个想法,下面是我想要生成的HTML:
<div class="form-group">
<div class="col-sm-12 mod-formelem">
<input data-enslaved-group="radio" data-enslaved-master="radio-1" id="___radio204_01___" name="___radio204___" type="radio"/>
<label class="mod-formelem--icon mod-icon icon-checkbox_checkmark_16" for="___radio204_01___"/>
<label class="mod-formelem--text" for="___radio204_01___">Option 1</label>
</div>
<div class="col-sm-12 mod-formelem">
<input data-enslaved-group="radio" data-enslaved-master="radio-2" id="___radio204_02___" name="___radio204___" type="radio"/>
<label class="mod-formelem--icon mod-icon icon-checkbox_checkmark_16" for="___radio204_02___"/>
<label class="mod-formelem--text" for="___radio204_02___">Option 2</label>
</div>
</div>发布于 2016-07-17 19:17:05
这个问题已经存在两年了,但问题仍然存在,所以回答这个问题是值得的,这样其他面临同样问题的开发人员就会从中受益。
使用JSF传递变量似乎不可能实现单选按钮。但是,CSS框架(如Bootstrap )要求您使用与JSF生成的HTML代码不同的代码。在这种情况下,您可以像这就是答案中描述的那样模拟单选按钮。这个例子尤其使用了Bootstrap和BootsFaces,但是这个想法也可以推广到其他框架中。
发布于 2017-03-21 01:42:15
我认为这不是不可能的。您可以尝试此解决方案:
JSF2.2中使用h:selectOneRadio的自定义布局
https://stackoverflow.com/questions/24302402
复制相似问题