2 Replies Latest reply on Feb 4, 2009 12:16 PM by archana rao

    List Shuttle - How to capture the updated list

    archana rao Newbie


      I am using ListShuttle in my project. When ever I copy the items from SourceList to TargetLlist or whene ever I move the items with in the targetlist I don't see sourceValue or targetValue getting updated with the updated values. Has anybody using the ListShuttle component? If so could you please let me know how to capture the updated items?

      thank you

        • 1. Re: List Shuttle - How to capture the updated list
          Ilya Shaikovsky Master

          This case - fully implemented at richfaces online demo. Link in my signature, and there is also link to sources of the demo.

          • 2. Re: List Shuttle - How to capture the updated list
            archana rao Newbie


            I have implemented my code almost in the same way as the example code. When ever I press 'Ok' button it should print me the updated targetHostNameList and sourceHostNameList. But it always prints the inital list. I am not sure what am I missing in my code? Here is my xhtml code

            <td align="left">
             <rich:listShuttle id="hostNameListId"
             sourceCaptionLabel="Available Hosts"
             targetCaptionLabel="Active Hosts"
             <h:outputText value="#{items.actualName}">
             <a4j:commandButton value="OK" immediate="true"
             action="#{PitcherQueues.printUpdatedList}" />

            I have implemented my ListShuttleBean in the following way

            public class ListShuttleBean{
             private List<HostName> sourceHostNameList = new ArrayList<HostName>();
             private List<HostName> targetSouceNameList = new ArrayList<HostName>();
             private HtmlListShuttle hostNameShuttleList = new HtmlListShuttle();
            public ListShuttleBean() {
             HostName host1 = new HostName();
             targetSouceNameList .add(host1);
             HostName host2 = new HostName();
             targetSouceNameList .add(host2);
             HostName host3 = new HostName();
             targetSouceNameList .add(host3);
             HostName sourcehost1 = new HostName();
             sourceHostNameList .add(sourcehost1);
             HostName sourcehost2= new HostName();
             HostName sourcehost3= new HostName();
            public void setTargetHostNameList(List<HostName> targetHostNameList){
             this.targetHostNameList = targetHostNameList;
            public List<HostName> getTargetHostNameList() {
             return targetHostNameList;
            public void setSourceHostNameList(List<HostName> sourceHostNameList){
             this.sourceHostNameList = sourceHostNameList;
            public List<HostName> getSourceHostNameList() {
             return sourceHostNameList;
            public HtmlListShuttle getHostNameShuttleList() {
             return hostNameShuttleList;
            public void setHostNameShuttleList(HtmlListShuttle hostNameShuttleList) {
             this.hostNameShuttleList = hostNameShuttleList;
            public void printUpdatedList(){
             log.debug("TaregtHostNameList SIZE = " + targetHostNameList.size());
             for(HostName host : targetHostNameList){
             log.debug("Target HostName = " + host.getName());
             log.debug("SourceHostNameList SIZE = " + sourceHostNameList.size());
             for(HostName host : this.sourceHostNameList){
             log.debug("Source HostName = " + host.getName());
            public Converter getConvert() {
             return new Converter() {
             public Object getAsObject(FacesContext ontext, UIComponent component, String value){
             return null;
             int index = value.indexOf(":");
             HostName hostName;
             try {
             hostName = new HostName();
             hostName.setName(value.substring(0, index));
             hostName.setActualName(value.substring(index+1, value.length()));
             }catch (Exception e) {
             System.out.println("INSIDE EXCEPTION");
             return null;
             return hostName;
             public String getAsString(FacesContext context, UIComponent component, Object value) {
             return value.toString();

            Here is my HostName object

            public class HostName{
             private String name;
             private String actualName;
             public HostName() {
             public String getName(){
             return name;
             public void setName(String name) {
             this.name = name;
             public String getActualName(){
             return actualName;
             public void setActualHostName(String actualName) {
             this.actualName = actualName;
             public int hashCode() {
             final int prime = 31;
             int result = 1;
             result = prime * result + ((name == null) ? 0 : name.hashCode());
             return result;
             public boolean equals(Object obj) {
             if(this == obj)
             return true;
             if(obj == null)
             return false;
             if(getClass() != obj.getClass())
             return false;
             final HostName other = (HostName) obj;
             if(name == null) {
             if(other.name != null)
             return false;
             }else if(!name.equals(other.name))
             return false;
             if(actualName == null){
             if(other.actualName != null)
             return false;
             }else if(!actualName.equals(other.actualName))
             return false;
             return true;