我的约束是我的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?
发布评论