[英]HTML 4 <button> in JSF 2.1
I would like to use the commands: 我想使用命令:
The JSF <h:commandButton>
generates an <input...>
but I would like that instead of generating the <input>
I would like that this generate a HTML 4 standard <button>
. JSF
<h:commandButton>
生成一个<input...>
但是我想这样做而不是生成<input>
我想生成一个HTML 4标准<button>
。
Closest what you can get with standard JSF component set is <input type="button">
which is generated by <h:button>
. 使用标准JSF组件集最接近的是
<input type="button">
,它由<h:button>
生成。
<h:button value="Button" />
which generates 产生
<input id="j_id_1" name="j_id_1" type="button" value="Button" onclick="window.location.href = '/context/currentpage.xhtml'" />
If you really insist in using <button>
for some unclear reason, then you have the following options: 如果您确实坚持使用
<button>
来解决某些原因,那么您有以下选择:
<p:button>
generates a <button>
. <p:button>
生成一个<button>
。 You should look into the Primefaces p:commandButton
. 您应该查看Primefaces
p:commandButton
。 This will render to a <button>
tag on the client. 这将呈现给客户端上的
<button>
标记。
http://www.primefaces.org/showcase/ui/commandButton.jsf http://www.primefaces.org/showcase/ui/commandButton.jsf
If you are using JSF 2.2, you can just use the <button>
tag with jsf namespace mixed. 如果您使用的是JSF 2.2,则可以使用带有jsf命名空间的
<button>
标记。 The secret here is the attribute process
from jsf
namespace, that post the form data, and the action
attribute. 这里的秘密是来自
jsf
命名空间的属性process
,它发布表单数据和action
属性。
<button type="submit" class="btn btn-primary"
jsf:action="#{profileController.updateProfile}"
jsf:process="@form">
<i class="fa fa-floppy-o" aria-hidden="true"></i>
#{bundle['button.store']}
</button>
In JSF 2.2 you can use any HTML tag mixing with JSF tags. 在JSF 2.2中,您可以使用与JSF标记混合的任何HTML标记。
It works for me by replacing <button>
with <h:commandLink>
, example: Replace 它通过用
<button>
<h:commandLink>
替换<button>
来为我工作,例如:替换
<button class="RUIFW-btn-primary pull-right"
type="submit"
name="action"
value="Find"
onClick="return submitPage(this);">
<span class="icon-search"></span>Find
</button>
with 同
<h:commandLink styleClass="RUIFW-btn-primary pull-right"
title="#{msg['view.button.Find']}"
action="#{anotherAccountController.doFind}"
onclick="return submitPage(this.form)">
<span class="icon-search"></span>#{msg['view.button.Find']}
</h:commandLink>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.