JSF forms when submit

2019-09-04 11:00发布

问题:

If we have several forms like below and when i finally press submit button, it should send all the values from "froms1 to forms3" to the server. Is it something possible? I am using primefaces.

<h:form id="forms1">
 <inputText .........
 </h:form>
......
<h:form id="forms2">
 ......
</h:form>
.......
<h:form id="forms3">
.....
</h:form>

<p:commandButton value="submit" action="#{bean.action}" onSubmit="this.forms1,this.forms2,this.forms3" partialSubmit="true" />

回答1:

it is not a good idea to submit multi ple form but you can submit by following code..

<p:commandButton title="Submit" value="Submit" action="#{bean.action}" process="form1,form2,form3">

this may work 4 you...



回答2:

You may be able to put some hacky solution together to submit 3 forms with one button, but it would be best to just use 1 form with 1 submit button inside the form.

If you're using multiple forms to get some separation with the way things look, try using fieldsets instead. Primefaces even has a fieldset component <p:fieldset></p:fieldset>