How to refresh an ice:selectManyListbox
schizo1987 Mar 13, 2012 9:54 AMI need to build a pick list, I used two [b]ice:selectManyListbox [/b] and two button "left" "right". My problem is, when I pass list item from left to right that I find myself obliged to refresh the page to see the change.
Is that it is possible to see the changes without refreshing the page ?
Help me please.
The pick list code :
[code]
<ice:selectManyListbox size="10" style="width: 150px;" valueChangeListener="#{EventForm.toRightListener}"
rendered="true" partialSubmit="true" value="#{EventForm.selectedLeftContact}">
<s:selectItems value="#{contactLeftList}"
var="contact" label="#{contact.name}" />
<s:convertEntity />
</ice:selectManyListbox>
<ice:panelGrid columns="1">
<ice:commandButton value=" > "
action="#{EventForm.toRight}" />
<ice:commandButton value=" < " action="#{EventForm.toLeft}" />
</ice:panelGrid>
<ice:selectManyListbox size="10" style="width: 150px;" valueChangeListener="#{EventForm.toRightListener}"
rendered="true" partialSubmit="true"
value="#{EventForm.selectedRightContact}">
<s:selectItems value="#{EventForm.contactRightList}"
var="contact" label="#{contact.name}" />
<s:convertEntity />
</ice:selectManyListbox>
<ice:commandButton value=" Sort left column"
action="#{EventForm.sortLeft()}" />
<ice:panelGroup></ice:panelGroup>
<ice:commandButton value=" Sort right column"
action="#{EventForm.sortRight()}" />
</ice:panelGrid>
[/code]
The managed bean code :
[code]
List<Contact> contactLeftList = new ArrayList<Contact>();
private List<Contact> selectedLeftContact = new ArrayList<Contact>();
private List<Contact> selectedRightContact = new ArrayList<Contact>();
private List<Contact> contactRightList = new ArrayList<Contact>();
@Factory("contactLeftList")
public List<Contact> initContactLeftList() {
contactLeftList = em
.createQuery("select contact from Contact contact")
.getResultList();
return contactLeftList;
}
public void toRight() {
Iterator<Contact> selected = selectedLeftContact.iterator();
while (selected.hasNext()) {
Object o;
Object item = selected.next();
Iterator<Contact> iterator = contactLeftList.iterator();
while (iterator.hasNext()) {
o = iterator.next();
if (((Contact) o).equals(item)) {
contactLeftList.remove(o);
contactRightList.add((Contact) o);
break;
}
}
}
selectedLeftContact = null;
}
public void toLeft() {
Iterator<Contact> selected = selectedRightContact.iterator();
while (selected.hasNext()) {
Object o;
Object item = selected.next();
Iterator<Contact> iterator = contactRightList.iterator();
while (iterator.hasNext()) {
o = iterator.next();
if (((Contact) o).equals(item)) {
contactRightList.remove(o);
contactLeftList.add((Contact) o);
break;
}
}
}
selectedRightContact = null;
}
[/code]