Primefaces:如何持久保存来自p:orderList的重新排序的数据? [英] Primefaces: How to persist reordered data from a p:orderList?
问题描述
我仍在使用primefaces组件p:orderlist. 我已经实现了拖放行为(将另一个列表中的项目放入p:orderlist),并且使p:commandButton在p:orderlist中起作用.
I am still working on with the primefaces component p:orderlist. I have managed to implement a drag and drop behaviour (to put items from another list in to the p:orderlist) and I also make the p:commandButton work inside the p:orderlist.
现在我有一个新问题.您可以将项目拖放到p:order列表中,以为其赋予新的顺序. (也就是说,为什么将该组件称为订单清单,与购物订单无关;-)).
Now I have a new problem. You can drag and drop items inside the p:order list, to give them a new order. (That is, why the component is called orderlist, nothing to do with a shopping order ;-) ).
但是,如果我重新订购商品,则不会收到通知或事件,告诉我的bean,某些东西已更改.
But if I reorder my items I get no notification or event, which tells my bean, that something was changed.
有人知道如何做到这一点吗?
Has anybody an idea how to make this possible?
这是我的p:orderlist,看起来像这样:
Here is my p:orderlist, like it looks know:
<h:panelGroup>
<p:remoteCommand name="removeTechniker" actionListener="#{systemlandschaftRessourceHandler.removeTechnikerByRemoteCommand}"
out="technikersTable" update="@form"/>
<p:orderList id="technikersTable"
value="#{systemlandschaftRessourceHandler.entity.technikers}"
var="_techniker"
itemValue="#{_techniker}"
converter="#{entityConverter}"
controlsLocation="none">
<f:facet name="caption">Techniker</f:facet>
<p:column>
<p:commandButton id="deleteTechnikerFromListButton"
styleClass="colButton"
icon="ui-icon-trash"
type="button"
onclick="removeTechniker([{name:'id', value:'#{_techniker.id}'}]);"
update="@form"/>
</p:column>
<p:column style="width:75%;" id="outTech">
<p:outputLabel value="#{_techniker.verantwortlich.displayName}"/>
</p:column>
</p:orderList>
<p:droppable id="technikerDrop"
for="technikersTable"
tolerance="touch"
activeStyleClass="ui-state-highlight"
datasource=":systemLandschaftTabView:sysObjektDetailPanelForm:userTable"
scope="userDraggable">
<p:ajax listener="#{systemlandschaftRessourceHandler.onDropTechniker}" update="@form" />
</p:droppable>
</h:panelGroup>
我已经在primefaces社区中找到了一些东西,但这是行不通的,甚至不能说出原因. 链接: http://forum.primefaces.org/viewtopic.php? f = 3& t = 26539
I already found something on the primefaces community, but this doesn't work, can' even say why. Link: http://forum.primefaces.org/viewtopic.php?f=3&t=26539
问候 LStrike
Regards LStrike
仅供参考,以下是我解决的有关p:orderlist的项目:
Just for info, here are my solved items, regarding the p:orderlist:
界面:Orderlist中的CommandButton不起作用
和
推荐答案
我自己想出了一个解决方案. 这是某种黑客手段,但确实有效. 我使用列表的设置器,我想对其进行排序并将其发送到数据库.为了读取列表,我在吸气剂上使用@OrderBy批注.
Figured out a solution myself. It's some kind of hack, but it works. I use the setter of the list, I want to have sorted and send it to the database. For reading the list I use the @OrderBy annotation on the getter.
@OrderBy("ranking ASC")
@ManyToMany(fetch = FetchType.LAZY)
@JoinTable(name="MWEB_SYSLAND_RES_ENTWUSER_L", joinColumns = {@JoinColumn(name = "ID_SYSLAND_RES", nullable = false, updatable = false)} ,inverseJoinColumns = { @JoinColumn(name ="ID_SYSLAND_USER", nullable = false, updatable = false) })
public List<SystemlandschaftUser> getEntwicklers() {
return entwicklers;
}
public void setEntwicklers(List<SystemlandschaftUser> entwicklers) {
this.entwicklers = sortSysUserList(entwicklers);
@Transient
private List<SystemlandschaftUser> sortSysUserList(List<SystemlandschaftUser> input){
if(input != null && input.size() > 0){
for(int i=1, size=input.size(); i <= size; i++){
SystemlandschaftUser t = input.get(i-1);
t.setRanking(i);
}
}
return input;
}
这篇关于Primefaces:如何持久保存来自p:orderList的重新排序的数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!