gpt4 book ai didi

jsf 命令按钮在值中使用标签

转载 作者:行者123 更新时间:2023-12-04 21:15:04 27 4
gpt4 key购买 nike

不确定是否可能,但我在学校的大部分项目中都使用 Bootstrap 。我通常在管理面板中使用的一个设计属性是图标的使用(编辑 = 铅笔,删除 = 十字,添加 = 加号,...)。

因此,为了呈现这些简单的按钮,我使用了以下代码:

<a href="#" class="btn"><i class="icon-pencil"></i></a>

在与 JSF 一起使用时,我尝试使用:

<h:commandButton value="<i class='icon-delete icon-white'></i>" class="btn-danger" action="#{horseController.delete(item.id)}" />

但似乎不允许使用此错误消息中所述的“<”:

Error Parsing /admin/horses.xhtml: Error Traced[line: 27] The value of attribute "value" associated with an element type "null" must not contain the '<' character.

所以我的问题是:如何在 commandButton 中使用标签,在本例中是使用图标?

最佳答案

<h:commandButton>是错误的标签。它生成一个 HTML <input type="submit">元素,而你需要一个 HTML <a>元素。你需要一个<h:commandLink>相反。

<h:commandLink class="btn-danger" action="#{horseController.delete(item.id)}">
<i class="icon-delete icon-white" />
</h:commandLink>

关于jsf 命令按钮在值中使用标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14369698/

27 4 0