Primefaces PickList传输时更新目标列表 [英] Primefaces PickList update target list on transfer

查看:142
本文介绍了Primefaces PickList传输时更新目标列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户将项目从一个列表转移到另一个列表时,我想更新Bean中的列表.有办法吗?

I want to update the lists in the bean when the user transfers an item from one list to another. Is there a way to do that?

谢谢.

推荐答案

在xhtml中:

<p:pickList value="#{myBean.myDepartment}" onTransfer="handleTransfer(e)"....>

在bean中:

List<Department> selectedDepartments = new ArrayList<Department>();
List<Department> availableDepartments = getAvailableDepartments();

private DualListModel<Department> myDepartment;
myDepartment = new DualListModel<Department>(availableDepartments, selectedDepartments);

提交时,可以使用selectedDepartments访问用户选择的部门

On Commit, Departments selected by the user can be accessed using selectedDepartments

还有脚本...

<script type="text/javascript">
function handleTransfer(e) {
    item = e.item;
    alert(item.text());

    fromList = e.from;
    toList = e.to;
    type = e.type; //type of transfer; command, dblclick or dragdrop)
}
</script>

这篇关于Primefaces PickList传输时更新目标列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆