Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 891
yash Avatar asked Feb 22 '23 13:02

yash


1 Answers

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

like image 143
landal79 Avatar answered Mar 04 '23 08:03

landal79