使用 p:commandbutton 提交多个表单 [英] submit multiple forms with p:commandbutton

查看:26
本文介绍了使用 p:commandbutton 提交多个表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用一个提交按钮提交多个表单.我有多个表单,因为每个 p:fileUpload 都需要一个自己的表单(在高级模式下).

I want to submit multiple forms with one submit button. I have multiple forms because each p:fileUpload needs an own form (when in advanced mode).

这是我的提交按钮的代码:

Here's the code for my submit button:

<h:form id="form1">...</h:form>
<h:form id="form2">...</h:form>
<h:form>
    <p:commandButton value="Save" widgetVar="saveButtonBottom"
    action="#{bean.submit}" ajax="false"
    process=":form1,:form2,@this" />
</h:form>

它确实调用了 bean.submit(),但它不处理其他表单.也许我对处理的理解是错误的,但我想如果我把一个表单放在处理"中,那么它就会被提交.

It does call bean.submit(), but it does not process the other forms. Maybe my understanding of processing is wrong, but I thought if I put a form into "process", then it will be submitted.

知道如何让它工作吗?

推荐答案

这是 HTML 的限制.只有包含在当前表单中的输入数据(其中调用了命令)才会被发送到服务器端.至于process属性,它只标识提交数据的哪些部分在到达后必须由JSF处理.

That's the limitation of HTML. Only the input data containing within the current form (wherein the command is been invoked) will be sent to the server side. As to the process attribute, that only identifies which part(s) of that submitted data must be processed by JSF after they have arrived.

知道如何让它工作吗?

将所有相关数据放在同一个表格中.如有必要,仅使用单个 并支持多个文件选择.

Put all related data in the same form. Use if necessary just a single <p:fileUpload> with multiple file selection support.

这篇关于使用 p:commandbutton 提交多个表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆