简体   繁体   English

如何使用复选框创建JSF表?

[英]How to create a JSF table with checkboxes?

I want to create a JSF table like this . 我想创建一个像这样的JSF表。 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? 可以用AJAX完成吗? I don't want to refresh the page. 我不想刷新页面。

Best wishes 最好的祝愿

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? 因为您想要一个使用f:ajax的示例,并且其他答案使用如何使用JSF的h:selectBooleanCheckbox和h:dataTable中的给定示例来为每行创建一个对象? 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 ) 它针对jsf 1(而不是2),您可以将delete按钮修改为类似这样的东西(利用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) 并将public void submit() public void submit(AjaxBehaviorEvent ev) public void submit()更改为public void submit(AjaxBehaviorEvent ev)

Balusc has a great tutorial about datatables in JSF. Balusc在JSF中提供了有关数据表的出色教程。 One part is about row selection with checkboxes: http://balusc.blogspot.com/2006/06/using-datatables.html#SelectMultipleRows 一部分是关于带有复选框的行选择: http : //balusc.blogspot.com/2006/06/using-datatables.html#SelectMultipleRows

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM