在JSF中发出发布请求时,如何将inputText发送到Bean?

编程入门 行业动态 更新时间:2024-10-28 01:25:33
本文介绍了在JSF中发出发布请求时,如何将inputText发送到Bean?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我的约束是我的JSF + Primefaces页面必须以纯HTML格式包含发布请求:

The constraint I have is that my JSF + Primefaces page must include a post request in straight html:

<form id="checkout" method="post" action="/checkout"> <div id="payment-form"></div> <input type="submit" value="Pay $10"> </form>

我不能碰它.

在同一页面上,我有一个inputText,用户将在其中放置其电子邮件地址: <p:inputText value="#{bean.emailAddress}"/>

On the same page, I have an inputText where the user will put their email address: <p:inputText value="#{bean.emailAddress}"/>

当单击<form>中的按钮以进行发布请求时,我也希望将inputText提交并发送到服务器上的bean.我怎样才能做到这一点?仅在<form></form>标记中包含<p:inputText value="#{bean.emailAddress}"/>似乎无效.

When the button in the <form> is clicked for the post request, I'd like to have the inputText submitted as well and sent to a bean on my server. How could I achieve that? Just including <p:inputText value="#{bean.emailAddress}"/> inside the <form></form> tag seems not to work.

推荐答案

将JavaScript事件监听器挂接到该表单,该触发器触发<p:remoteCommand>处理至少感兴趣的<p:inputText>.

Hook a JavaScript event listener to that form which triggers a <p:remoteCommand> processing at least the <p:inputText> of interest.

在使用PrimeFaces时,您将拥有jQuery.因此,应该这样做:

As you're using PrimeFaces, you'll have jQuery at hands. So, this should do:

<form id="checkout" ...> ... </form> <h:form> <p:inputText ... /> <p:remoteCommand name="checkout" process="@form" action="#{bean.checkout}" /> </h:form>

$(document).on("submit", "#checkout", function() { checkout(); });

更多推荐

在JSF中发出发布请求时,如何将inputText发送到Bean?

本文发布于:2023-10-11 22:15:46,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1482991.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:发送到   如何将   中发   JSF   inputText

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!