4

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.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
yash
  • 189
  • 1
  • 4
  • 14

1 Answers1

8

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

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
landal79
  • 1,520
  • 1
  • 11
  • 26
  • okay, it takes the value of the bean.. but the question remains partly unanswered. I need to pass the checkbox value to a query and display a chart using xml.. so i need to completely reload another page. Any better idea is welcomed. – yash Feb 08 '12 at 12:22
  • [Here](http://stackoverflow.com/questions/5406855/jsf-navigation-with-ajax) there is a discussion about ajax and navigation. I think, you can't do a page navigation. you could try to put the graph on the same page, render it only upon check box selection and at the same time you hide the form. – landal79 Feb 08 '12 at 13:04