使用<p:pickList>拖放元素时如何调用bean方法? [英] How to call bean method when drag-drop the element using <p:pickList>?

查看:63
本文介绍了使用<p:pickList>拖放元素时如何调用bean方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为基于 jsf 的应用程序使用 primefaces 3.3 库.

我正在使用 来处理从源到目标的拖放元素,反之亦然.

我想在元素从源传输(通过拖放)到目标(反之亦然)时调用 jsf bean 方法并在那里处理一些逻辑事情.

我按照链接PrimeFaces 展示pickList 来实现我的功能.这是5.2.7版本.

primefaces 5.2.7 中,它可以通过 <p:ajax event="transfer"/> 轻松完成,但是我如何使用 primafaces 3.3.

我尝试了 valueChangeListener 属性,但它不起作用.有一个名为 onTransfer 的属性,但它用于客户端回调.

这可以通过放置提交按钮来实现.但我想通过拖放来实现它.那我该怎么做?

提前致谢.

解决方案

首先,您应该考虑更新您的 primefaces 版本.更新不仅提供新功能,还提供错误修复、改进(性能、稳定性)等.

目前我找不到 3.3 的文档,但您可以尝试使用 p:remoteCommand(它在 3.5 文档中,因此可能可用):

使用 onTransfer="submitToBean()" 以及可能如下所示的 p:remoteCommand:

然后 onTransfer 事件将调用 javascript 方法 submitToBean(),后者将处理您的选择列表并调用操作方法.

I am using primefaces 3.3 library for jsf based application.

I am using <p:pickList> to handle drag and drop the element from source to target and vide versa.

I want to call the jsf bean method when element transferring(by drag-drop ) from source to target and vice versa and handle some logical things there.

I follow the link PrimeFaces showcase for pickList to implement my functionality. This is the version 5.2.7.

In primefaces 5.2.7 it can be easily done by <p:ajax event="transfer" /> , but how can I achieve this using primafaces 3.3.

I try valueChangeListener attribute but it is not working. There is one attribute called onTransfer , but it is for clientSide callback.

This can be achieve by putting submit button. But I want to achieve it on drag and drop. So how can i do that ?

Thanks in advance.

解决方案

First, you should consider an update of your primefaces version. Updates are not only provided for new features but also for bug fixes, improvements (performance, stability) etc.

Currently I cannot find the documentation for 3.3, but what you could try is using p:remoteCommand (its in the 3.5 documentation, so maybe available):

use onTransfer="submitToBean()" along with a p:remoteCommand that might look like this:

<p:remoteCommand 
   name="submitToBean" 
   action="#{myBean.doSomething}"
   process="idOfYourPickList" 
   partialSubmit="true" />

Then the onTransfer Event will call the javascript method submitToBean() which in turn will process your picklist and call the action method.

这篇关于使用&lt;p:pickList&gt;拖放元素时如何调用bean方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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