I m using EL 2.2 s functionality (with Tomcat 7) to pass parameters (in this case, entire items) from a JSF page to a backing bean. It s proving to be very handy, but I m running into a gigantic problem when the list of items is changed by another user between page refreshes. Here s some example code to help show what I mean:
JSF page:
<ui:repeat var="item" value="#{myBackingBean.listOfItems}">
<h:panelGrid columns="3">
<h:outputText value="#{item.name}" />
<p:commandLink value="(Change name to foo)" action="#{myBackingBean.changeNameToFoo(item)}" />
<p:commandLink value="(Delete this item)" action="#{myBackingBean.deleteThisItem(item)}" />
</h:panelGrid>
</ui:repeat>
MyBackingBean.java:
public void changeNameToFoo(Item i) {
i.setName("foo");
}
public void deleteThisItem(Item i) {
i.remove();
}
My situation is this: Say the listOfItems returns a list of five Items with the names [1, 2, 3, 4, 5]. Two different users load up this page at the same time. User A immediately deletes item 2, and now sees [1, 3, 4, 5]. User B, who still sees all five items, then tries to change item 3 s name to foo. When his page refreshes, he now sees [1, 3, foo, 5]. Because a user he wasn t even aware of removed the second item in the list, a completely different item than the one he clicked was changed.
我丢失了东西,或者在多个用户进入图像时,这真的是一个显示问题吗?
感谢!