1

I want to create a JSF table like this. But instead delete button in every row I want to place check box in every row in the first column because I want to delete more than one row simultaneously. How I can create such a row and delete button which deletes every selected row? And can this be done with AJAX? I don't want to refresh the page.

Best wishes

user1285928
  • 1,328
  • 29
  • 98
  • 147

2 Answers2

4

Since you want an example that uses f:ajax and since other answer uses the given example in How to use JSF's h:selectBooleanCheckbox with h:dataTable to create one object per row? which is aimed for jsf 1 (and not 2) you can modify the delete button into something like this (make use of the f:ajax)

<h:commandButton value="Delete Selected">
    <f:ajax execute="@form" render="@form" listener="#{bean.submit}"/>
</h:commandButton>

and change public void submit() into public void submit(AjaxBehaviorEvent ev)

Community
  • 1
  • 1
Daniel
  • 36,833
  • 10
  • 119
  • 200
3

Balusc has a great tutorial about datatables in JSF. One part is about row selection with checkboxes: http://balusc.blogspot.com/2006/06/using-datatables.html#SelectMultipleRows

Steven De Groote
  • 2,187
  • 5
  • 32
  • 52