5

I want to submit (execute) values from multiple forms, not just the enclosing form. So, I want to be able to do something like this:

<h:form id="form1>
    <h:inputText id="testinput1" value="#{testBean.input1}" />
</h:form>

<h:form id="form2>
    <h:inputText id="testinput2" value="#{testBean.input2}" />

    <h:commandButton value="Submit">
        <f:ajax execute=":form1 :form2"/>
    </h:commandButton>
</h:form>

How would you solve this?

What is <f:ajax execute="@all"> really supposed to do? It POSTs only the enclosing form seems to be related, but addresses a slightly different problem and also does not solve it (or this).

Community
  • 1
  • 1
Thorben Croisé
  • 12,407
  • 8
  • 39
  • 50

1 Answers1

5

Ajax or not, this is not possible with plain JSF/HTML. All input elements which needs to be processed really needs to go inside the same form.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • 1
    @Matt: that's correct. There's however difference for them in the `render` attribute. – BalusC Mar 09 '12 at 17:33
  • Thanks for clarification, BalusC. Is this per specification or a constraint from html/js? – Matt Handy Mar 09 '12 at 17:34
  • 2
    @Matt: the spec has never stated that `@all` will execute all forms. Technically, it's also impossible (although it's easy for JS to workaround this by merging the form values, but in JSF the view state and action is dependent on the form). IMO the `@all` should never have been one of the available values of `execute`. It adds no value and is only confusing. – BalusC Mar 09 '12 at 17:42