yash
yash

Reputation: 209

How to submit a form with a checkbox?

Is it possible to submit a JSF form with the help of a checkbox?

I have multiple checkboxes and when I click on one of them, then it should actually submit the form and go to the next page. The checkbox value should be bound to a backing bean.

Upvotes: 4

Views: 2922

Answers (1)

landal79
landal79

Reputation: 1520

With JSF 1.x you can do:

<h:selectBooleanCheckbox value="#{aBean.aFiled}" onclick="submit()" />

If you use JSF 2.x, then you can use ajax:

<h:selectBooleanCheckbox value="#{aBean.aFiled}">
  <f:ajax event="click" execute="@form" />
</h:selectBooleanCheckbox>

For JSF and ajax take a look at: Learning JSF2: Ajax in JSF – using f:ajax tag

Upvotes: 8

Related Questions