7 Replies Latest reply on Jan 26, 2010 11:42 PM by jsfgeeks

    ListShuttle problem

    jsfgeeks

      hi,

           i am using listshuttle in one of my page.

                i have one dropdown(h:selectonemenu) of class list, and on it's process value change i am populating listshuttle.

               first it populates properly from constructor with default class selected but when change value in class dropdown it give following error

                " javax.el.PropertyNotFoundException
        The class 'java.lang.String' does  not have the property 'st_name'"

      i have populated list with one arraylist of type custom class.

       

       

      public class std_list
          {
              int st_id;
              String st_name;

       

              public int getSt_id()
              {
                  return st_id;
              }

       

              public void setSt_id(int st_id)
              {
                  this.st_id = st_id;
              }

       

              public String getSt_name()
              {
                  return st_name;
              }

       

              public void setSt_name(String st_name)
              {
                  this.st_name = st_name;
              }

       


              public std_list(int st_id1, String st_name1)
              {
                  this.st_id = st_id1;
                  this.st_name = st_name1;

       


              }
        }

        List<std_list> user_stulst = new ArrayList<std_list>(); //array List for source value

       

          public List<std_list> getUser_stulst()
          {
              return user_stulst;
          }

       

          public void setUser_stulst(List<std_list> user_stulst)
          {
              this.user_stulst = user_stulst;
          }

       

      List<std_list> stu_sellist = new ArrayList<std_list>(); //array List fortarget value

       

          public List<std_list> getStu_sellist()
           {
               return stu_sellist;
           }

       

          public void setStu_sellist(List<std_list> stu_sellist)
           {
               this.stu_sellist = stu_sellist;
           }

       

       

       

      <h:selectOneMenu binding="#{manage_admin1.dropDown_classlst}"
                                       id="dropDown_classlst"
                                       style="left: 210px; top: 95px; position: absolute; width: 225px"
                                       valueChangeListener="#{manage_admin1.dropDown_classlst_processValueChange}" >
                          <f:selectItems value="#{manage_admin1.user_classlst}"/>
                          <a4j:support event="onchange"  process="form1:dropDown_classlstuser_type_dropdown,form1:layoutPanel_ceuser" reRender="form1:layoutPanel_ceuser,form1:button_cancel"/>
                      </h:selectOneMenu>

       

      rich:listShuttle orderControlsVisible="false" fastOrderControlsVisible="false" sourceValue="#{manage_admin1.user_stulst}"    binding="#{manage_admin1.listbox_liststu}" id="listbox_liststu" style="height: 60px; left: 211px; top: 159px; position: absolute; width: 224px" var="items" listsHeight="100"
                  sourceListWidth="130" targetListWidth="130" sourceCaptionLabel="Available Students"
                  targetCaptionLabel="Assigned Students"
                 >
                  <rich:column>
                      <h:outputText value="#{items.st_name}"></h:outputText>
                  </rich:column>

       


              </rich:listShuttle>

      any help will be apreciated!!!!

        • 1. Re: ListShuttle problem
          jsfgeeks

          i solved the above problem by just rerender shuttlelist only other than whole panel on dropdown value change event.

          but, i have another issue.

          when i select & copy some item from list & it's get added to target list. but when i change class dropdown value list id rerendered & target values list cleared i want to maintain targer value list if i rerender the shuttle list by changing dropdown class value. is it possible?

          • 2. Re: ListShuttle problem
            agallo73
            The problem you are referecning to in the above discussion is due to the fact that you are not using a converter for the elements containied within the listshuttle and so the framework complains of not finding some properties since these elements are treated as strings. Try defining a converter. You can find several examples on the network and there's also one in the practical richfaces book in the listshuttle samples.
            • 3. Re: ListShuttle problem
              jsfgeeks

              hello, thanks

              i have tried to use converter but still it gives me property not found exception when i click on edit button without ajaxsingle true on edit button.

              if i set ajax single true on button than it works fine but my calendar is not working properly i mean i am not getting date from calendar in my bean & it's throwing null pointer exception . similar things happen with limittoList attribute

               

               

               

               

              <rich:simpleTogglePanel   id="smpltglpnl_newsdates" switchType="client" label="Event Dates">
                                  <h:panelGrid id="pnlgrd_newsdates" columns="4">
                                      <h:outputText binding="#{newsEvents.startdate_lablel}"  id="startdate_lablel"
                                                    value="#{news['newscreate.startdate']}"/>
                                      <rich:calendar ignoreDupResponses="true" ajaxSingle="true" limitToList="true"  showWeeksBar="false" showApplyButton="true"    binding="#{newsEvents.startdate_calendar}"  datePattern="yyyy-MM-dd HH:mm" id="startdate_calendar">
                                          <a4j:support event="oncollapse" ignoreDupResponses="true" ajaxSingle="true" limitToList="true" action="#{newsEvents.setdate_end}" reRender="vis_startdate_calendar1"/>
                                      </rich:calendar>
                                  
                                      <h:outputText binding="#{newsEvents.enddate_label}"  id="enddate_label"
                                                     style=" text-align: right;  width: 105px" value="#{news['newscreate.enddate']}"/>
                                      <rich:calendar ignoreDupResponses="true" ajaxSingle="true" limitToList="true" showWeeksBar="false" showApplyButton="true"   binding="#{newsEvents.enddate_calendar2}"   datePattern="yyyy-MM-dd HH:mm"  id="enddate_calendar2"
                                                >
                                          <a4j:support event="oncollapse" ignoreDupResponses="true" ajaxSingle="true" limitToList="true" action="#{newsEvents.setdate_start}" reRender="vis_enddate_calendar"/>
                                      </rich:calendar>

               

                                      <h:outputText binding="#{newsEvents.vis_startdate_label}"   id="vis_startdate_label"
                                                     style="  text-align: right;  width: 105px;" value="#{news['newscreate.visstartdate']}"/>
                                      <rich:calendar ignoreDupResponses="true" ajaxSingle="true" limitToList="true" showWeeksBar="false" showApplyButton="true"  binding="#{newsEvents.vis_startdate_calendar1}"  datePattern="yyyy-MM-dd HH:mm" id="vis_startdate_calendar1"
                                                      />
                                 
                                      <h:outputText binding="#{newsEvents.vis_enddate_label}"    id="vis_enddate_label"
                                                     value="#{news['newscreate.visenddate']}"/>
                                      <rich:calendar ignoreDupResponses="true" ajaxSingle="true" limitToList="true" showWeeksBar="false" binding="#{newsEvents.vis_enddate_calendar}" showApplyButton="true"    datePattern="yyyy-MM-dd HH:mm" id="vis_enddate_calendar"
                                                      />
                                         </h:panelGrid>
                                      <rich:messages  binding="#{newsEvents.alert3}"  globalOnly="true" id="alert3" showSummary="true" ajaxRendered="true" style="font-size:14px;background-color:lightyellow;color:red;height: 30px;"  />
                                      <rich:messages  binding="#{newsEvents.alert4}"  globalOnly="true"  id="alert4" showSummary="true" ajaxRendered="true" style="font-size:14px;background-color:lightyellow;color:red;height: 30px;" />
                              
                                   <rich:messages  binding="#{newsEvents.alert2}"  globalOnly="true" id="alert2" showSummary="true" ajaxRendered="true"  style="font-size:14px;background-color:lightyellow;color:red;height: 30px;" />
                                     <rich:messages  binding="#{newsEvents.alert6}"  globalOnly="true" id="alert6" showSummary="true" ajaxRendered="true" style="font-size:14px;background-color:lightyellow;color:red;height: 30px;"  />
                              </rich:simpleTogglePanel>

              <rich:tabPanel rendered="#{newsEvents.assignvalue=='0'}" id="tbpnl_assign_news"  switchType="client" headerSpacing="2" width="500" style="border: 1px solid #336699; background-color: #336699" height="120">
                                      <rich:tab label=" Class " id="tab_assign_to_class" style="font-size: 16px">
                                        
                                              <h:panelGrid id="pnlgrid_assign_to_class" style="hight:200px;left: 0px; top: 0px; position: absolute" columns="2">
                                                  <h:outputText id="outtxt_sel_cls" value="Select Class : " style="font-size: 13px"/>
                                                     <h:outputText id="outtxt_asgn_cls" value="Assigne Class : " style="font-size: 13px"/>
                                                     <rich:listShuttle  immediate="true"  converter="ListConvertet"  targetCaptionLabel="Currently Active Items" sourceListWidth="130" targetListWidth="130" sourceCaptionLabel="Available Items"   listsHeight="100" sourceValue="#{newsEvents.clss_lst}" targetValue="#{newsEvents.target_clss_lst}"  id="list_class" var="cls">
                                                   
                 
                                                     <rich:column>
                              <h:outputText value="#{cls.list_name}"></h:outputText>
                          </rich:column>
                                                     </rich:listShuttle>
                                                   
                                                    
                                              </h:panelGrid>
                                              <br/><br/>
                                       
                                      </rich:tab>
                                      <rich:tab id="tab_assign_to_grp" label=" Group ">
                                        
                                              <h:panelGrid id="pnlgrid_assign_to_grp" style="left: 30px; top: 15px; position: absolute" columns="7">
                                                  <h:outputText id="outtxt_lp_sel_grp" value="Select Group : " style="font-size: 13px"/>
                                               
                                                
                                              </h:panelGrid>
                                      
                                      </rich:tab>
                                  </rich:tabPanel>

              <rich:toolBar    id="pnl_btncntrldwn" >
                                  <rich:separator width="250" id="sprtr-btns" lineType="none"/>

               

               

               

                                  <a4j:commandButton id="news_edit"
                                                     value="#{news['admin.Edit']}" action="#{newsEvents.news_edit_action}"
                                                     />
                                  <a4j:commandButton  id="news_del"

               

                                                      value="#{news['admin.delete']}" rendered="false"/>
                                  <rich:spacer width="100" id="spc2" />
                                  <a4j:commandButton  id="news_save" style=" align:right"
                                                      value="#{news['admin.save']}" limitToList="true"  reRender="startdate_calendar,vis_startdate_calendar1,enddate_calendar2,vis_enddate_calendar,smpltglpnl_newsdeyail,alert1,alert2,alert3,alert4,alert6,smpltglpnl_newsdates" process="startdate_calendar,vis_startdate_calendar1,enddate_calendar2,vis_enddate_calendar,smpltglpnl_newsdeyail,smpltglpnl_newsdates,alert1,alert2,alert3,alert4,alert6" binding="#{newsEvents.news_save}" action="#{newsEvents.news_save_action}" />
                              </rich:toolBar>

               

               

              my convertor is below:

              /*
              * To change this template, choose Tools | Templates
              * and open the template in the editor.
              */

               

              package org.my.richfaces;

               

              import javax.faces.component.UIComponent;
              import javax.faces.context.FacesContext;
              import javax.faces.convert.Converter;

               

              /**
              *
              * @author Administrator
              */
              public class ListConvertet  implements Converter {

               

                   public ListConvertet() {
                  }
                   @Override
                   public Object getAsObject(FacesContext arg0, UIComponent arg1, String arg2) {
                       return (Object)arg2;
                   }

               

                   @Override
                   public String getAsString(FacesContext arg0, UIComponent arg1, Object arg2) {
                       return arg2.toString();
                   }

               

              }
              and face-contenct entry

                <converter>
                   <converter-id>ListConvertet</converter-id>
                   <converter-class>org.my.richfaces.ListConvertet</converter-class>
                 
              </converter>

               

              any idea?

              • 4. Re: ListShuttle problem
                liuliu

                hi,

                 

                your converter is not good. getAsObject returns always a string. you need create your object from the string.

                 

                par ex: creat a hashmap, getAsString returns the key, getAsObject returns map.get(key)

                 

                hope this help

                 

                liu

                • 5. Re: ListShuttle problem
                  jsfgeeks

                  hi,

                  thank you very much for your time and quick response.

                  Actually i am not getting you. if you can provide a example it would be great help.!!!!!!

                  • 6. Re: ListShuttle problem
                    nbelaevski
                    • 7. Re: ListShuttle problem
                      jsfgeeks

                      hi,

                      that helped me. Thanks all my converter looks like below:

                       

                      /*
                      * To change this template, choose Tools | Templates
                      * and open the template in the editor.
                      */

                       

                      package org.my.richfaces;

                       


                      import javax.faces.component.UIComponent;
                      import javax.faces.context.FacesContext;
                      import javax.faces.convert.Converter;

                       


                      /**
                      *
                      * @author Administrator
                      */

                       


                      public class ListConvertet  implements Converter {

                       


                           public ListConvertet() {
                          }
                           @Override
                           public Object getAsObject(FacesContext arg0, UIComponent arg1, String value) {
                             
                              String id = value.substring(0,value.indexOf(":"));
                               System.out.println(id);
                              String name =value.substring(value.lastIndexOf(":")+1);
                               System.out.println(name);
                              selectlist mylist= new selectlist(id, name);
                             
                             
                              return mylist;

                       


                             
                           }

                       

                           @Override
                           public String getAsString(FacesContext arg0, UIComponent arg1, Object arg2) {
                               return arg2.toString();
                           }

                       

                      }

                      and selectlist class is below:

                       

                      /*
                      * To change this template, choose Tools | Templates
                      * and open the template in the editor.
                      */

                      package org.my.richfaces;

                      /**
                      *
                      * @author Administrator
                      */
                      public class selectlist {

                             public String list_id;

                              public String getList_id() {
                                  return list_id;
                              }

                              public void setList_id(String list_id) {
                                  this.list_id = list_id;
                              }
                              public String list_name;



                              public String getList_name() {
                                  return list_name;
                              }

                              public void setList_name(String list_name) {
                                  this.list_name = list_name;
                              }


                              public selectlist(String list_id1,String list_name1){
                                  this.list_id = list_id1;
                                  this.list_name = list_name1;


                              }
                              @Override
                              @SuppressWarnings("EqualsWhichDoesntCheckParameterClass")
                              public boolean equals(Object obj) {
                          selectlist ci = (selectlist)obj;
                          if ( this.list_id.equals(ci.getList_id()) &&
                               this.list_name.equals(ci.getList_name()))
                              return true;
                          else
                              return false;
                              }

                              @Override
                              public int hashCode() {
                                  int hash = 5;
                                  hash = 53 * hash + (this.list_id != null ? this.list_id.hashCode() : 0);
                                  hash = 53 * hash + (this.list_name != null ? this.list_name.hashCode() : 0);
                                  return hash;
                              }
                              @Override
                      public String toString(){
                          return list_id +":"+ list_name;
                      }
                         }