我仍在使用primefaces组件p:orderlist。 我已设法实现拖放行为(将来自另一个列表的项目放入p:orderlist),并且我还使p:commandButton在p:orderlist中工作。
现在我遇到了一个新问题。您可以在p:order列表中拖放项目,为其提供新订单。 (也就是说,为什么该组件被称为订单列表,与购物订单无关;-))。
但是如果我重新排序我的项目,我就不会收到任何通知或事件,告诉我的bean,有些事情发生了变化。
有人知道如何做到这一点吗?
这是我的p:orderlist,就像看起来知道的那样:
<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
此致 LStrike
仅供参考,以下是我解决的项目,关于p:orderlist:
Primefaces: CommandButton inside Orderlist not working
和
Primefaces: Orderlist: index out of bound exception while reordering
答案 0 :(得分:0)
自己想出一个解决方案。 这是某种黑客攻击,但它确实有效。 我使用列表的setter,我想要排序并将其发送到数据库。为了阅读列表,我在getter上使用@OrderBy注释。
@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;
}