jsf html标签里面的值 [英] jsf html tag inside value

查看:85
本文介绍了jsf html标签里面的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 < h:commandButton id 

我有这个commandButton,我需要使用Bootstrap 3添加一个图标。 =logoutButtonaction =#{loginController.logout()}class =btn btn-primarystyle =margin-top:10px; margin-left:10px; value =注销>< / h:commandButton>

这个图标在引导程序的span标记中有3个原因,所以我试着将它添加到在命令按钮中的value属性如下所示:

 < h:commandButton id =logoutButtonaction =#{loginController .logout()}class =btn btn-primarystyle =margin-top:10px; margin-left:10px;值=< span class =glyphicon glyphicon-log-out>< / span>注销>< / h:commandButton> 

我有错误,我想我不能在值属性中添加html标签,有没有简单的方法来做到这一点?

解决方案

您不能将标记放在值中JSF组件的属性。您应该像标准HTML一样将标记放在标记体中。但是,这不被< h:commandButton> 支持(原因很简单,因为它会生成< input> 元素和任何子元素将以无效HTML结束)。它会在生成的< input> 元素之后呈现



< h:commandLink> 代替。虽然它会生成< a> 元素,但Bootstrap CSS也只是支持以及 btn 样式类。

 < h:commandLink id =logoutButtonaction =#{loginController.logout}styleClass =btn btn-primary> 
< span class =glyphicon glyphicon-log-out>< / span>注销
< / h:commandLink>

(注意我修正了错误的 class 属性为 styleClass

I've this commandButton, and I need to add a icon using Bootstrap 3.

<h:commandButton  id="logoutButton" action="#{loginController.logout()}" class="btn btn-primary" style="margin-top: 10px;margin-left: 10px;" value="Log Out"></h:commandButton>

the icon is in a span tag for bootstrap 3 reasons, so I've tried to add it to the value property in the command button like this:

<h:commandButton  id="logoutButton" action="#{loginController.logout()}" class="btn btn-primary" style="margin-top: 10px;margin-left: 10px;" value="<span class="glyphicon glyphicon-log-out"></span>Log Out"></h:commandButton>

I've got an error, I suppose that I can't add html tags inside the value property, is there an easy way to do this?

解决方案

You can't put markup in the value attribute of a JSF component. You should put markup in the tag body like as in normal HTML. However, this is not supported by the <h:commandButton> (for the very simple reason because it generates an <input> element and any children would end up in invalid HTML). It would be rendered after the generated <input> element.

Just use <h:commandLink> instead. Whilst it generates an <a> element, the Bootstrap CSS also just supports it as well as to the btn style class.

<h:commandLink id="logoutButton" action="#{loginController.logout}" styleClass="btn btn-primary">
    <span class="glyphicon glyphicon-log-out"></span>Log Out
</h:commandLink>

(note that I fixed the wrong class attribute to be styleClass)

这篇关于jsf html标签里面的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆