0 Replies Latest reply on Feb 4, 2009 5:22 PM by archanarrao

    ListShuttle Problem - Please Help It is urgent

    archanarrao

      Hi,

      The problem I am facing with RichShuttle is, after I manipulate data in the source list and target list i.e moving the items between the trargetlist and sourcelist I am not able to get hold of new values in the sourceList and targetList. My code always display the targetlistvalue and sourcelist value with the same old values. How to capture the updated targetlist and sourcelist values?

      Here is my jsf code

      <td align="left">
       <rich:listShuttle id="hostNameListId"
       binding="#{ListShuttleBean.hostNameShuttleList}"
       converter="#{ListShuttleBean.convert}"
       sourceValue="#{ListShuttleBean.sourceHostNameList}"
       targetValue="#{ListShuttleBean.targetHostNameList}"
       sourceCaptionLabel="Available Hosts"
       targetCaptionLabel="Active Hosts"
       var="items">
       <rich:column>
       <h:outputText value="#{items.actualName}">
       </h:outputText>
       </rich:column>
       </rich:listShuttle>
       </td>
       <a4j:commandButton value="OK" immediate="true"
       action="#{ListShuttleBean.printUpdatedList}" />
      


      Here is my Bean object

      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();
       host1.setName("TargetTest1");
       host1.setActualName("TargetTest1");
       targetSouceNameList .add(host1);
       HostName host2 = new HostName();
       host2.setName("TargetTest2");
       host2.setActualName("TargetTest2");
       targetSouceNameList .add(host2);
       HostName host3 = new HostName();
       host3.setName("TargetTest3");
       host3.setActualName("TargetTest13);
       targetSouceNameList .add(host3);
      
       HostName sourcehost1 = new HostName();
       sourcehost1.setName("SourceTest1");
       sourcehost1.setActualName("SourceTest1");
       sourceHostNameList .add(sourcehost1);
       HostName sourcehost2= new HostName();
       sourcehost2.setName("SourceTest2");
       sourcehost2.setActualName("SourceTest2");
       sourceHostNameList.add(sourcehost2);
       HostName sourcehost3= new HostName();
       sourcehost2.setName("SourceTest3");
       sourcehost2.setActualName("SourceTest3");
       sourceHostNameList.add(sourcehost3);
      }
      
      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){
       if(value.isEmpy()){
       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;
       }