gpt4 book ai didi

jsf - 防止 h :Commandbutton from submitting form

转载 作者:行者123 更新时间:2023-12-04 02:33:11 25 4
gpt4 key购买 nike

我有一个表单和两个嵌入其中的命令按钮,如图所示。

<h:commandButton label="Submit" type="button" 
image="resources/images/Save4.jpg"
actionListener="#{userController.createNewUser()}" />

<h:commandButton label="Home"
image="resources/images/Save4.jpg"
action="/index.jsf?faces-redirect=true" />

点击主页按钮应该重定向到 index.jsf 但它会导致表单提交。我不想将 home 命令放在另一个表单标签中,因为它会导致 UI 失真。请提出出路。

最佳答案

命令按钮提交整个 POST 表单。对于普通的页面到页面导航,这是错误的工具。它对 SEO 也不友好(搜索机器人不索引 POST 表单)。

如果唯一的功能要求是有一个可以导航到不同页面的可点击图像,那么只需使用 <h:link><h:graphicImage> .

<h:link outcome="/index.jsf">
<h:graphicImage name="images/Save4.jpg" />
</h:link>

关于jsf - 防止 h :Commandbutton from submitting form,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21233948/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com