0 Replies Latest reply on Aug 19, 2011 12:56 AM by leonardo ginting

    h:selectOneMenu and valueChangeListener

    leonardo ginting Newbie

      hi guys i have an issue
      i use Combobox with h:selectOneMenu and value changeListner

      but why when the value in the first comboBox i already change,,  value in the second ComboBox wasnt came out,,
      this is my code for first ComboBox

       

      1. <h:panelGroup> 
      2.                                         <a4j:region renderRegionOnly="true"> 
      3.                                             <h:selectOneMenu value="#{harianPenerimaanMBean.compoffices.officeId}" valueChangeListener="#{harianPenerimaanMBean.updatePerwakimName}" required="true" requiredMessage="Pilih Salah Satu" id="perwakim"
      4.                                             <f:selectItem itemValue="" itemLabel="Pilih Kantor Wilayah/Perwakim"/> 
      5. <!--                                            <f:selectItem itemValue="" itemLabel="Semua Kantor Wilayah/Perwakim"/>--> 
      6.                                             <f:selectItems value="#{harianPenerimaanMBean.perwakim}"/> 
      7.                                             <a4j:support event="onchange" reRender="kanim" ajaxSingle="true"/> 
      8.                                         </h:selectOneMenu> 
      9.                                         <h:panelGroup id="msgPerwakim"> 
      10.                                             <h:message for="perwakim" styleClass="error"/> 
      11.                                         </h:panelGroup> 
      12.                                             </a4j:region> 
      13.                                     </h:panelGroup> 


      second ComboBox

       

      1. h:panelGroup> 
      2.                                         <a4j:region renderRegionOnly="true"> 
      3.                                             <h:selectOneMenu value="#{harianPenerimaanMBean.compoffices.officeId}" id="kanim" required="true" requiredMessage="Harus diPilih!"
      4.                                             <f:selectItem itemValue="0" itemLabel="---Pilih Jenis PNBP---"/> 
      5.                                             <f:selectItems value="#{harianPenerimaanMBean.kanim}"/> 
      6.                                             <a4j:support event="onchange" ajaxSingle="true"/> 
      7.                                         </h:selectOneMenu> 
      8.                                     <h:panelGroup id="msgKanim"> 
      9.                                 <h:message for="kanim" styleClass="error"/> 
      10.                             </h:panelGroup> 
      11.                                             </a4j:region> 
      12.                                     </h:panelGroup> 

       

       

      my Bean

       

      1.         public HarianPenerimaanMBean() { 
      2.      
      3. //    layananJpaController = new LayananJpaController(); 
      4.     compOfficesJpaController = new CompOfficesJpaController(); 
      5.     compoffices = new CompOffices(); 
      6.      
      7. perwakim = new ArrayList<SelectItem>(); 
      8. kanim = new ArrayList<SelectItem>(); 
      9. jenisPNBP = new ArrayList<SelectItem>(); 
      10.  
      11.     } 
      12.  
      13.  
      14.  
      15.  
      16.             public void updatePerwakimName(ValueChangeEvent event){ 
      17.                 Long compOffices = (Long) event.getNewValue(); 
      18. //                BigInteger id = new BigInteger(compOffices.toString()); 
      19. //                System.out.println(id); 
      20.                 setKanim(new ArrayList<SelectItem>()); 
      21. //                getKanim().add(new SelectItem("","Semua Kantor Imigrasi")); 
      22.                 for(CompOffices compOffice : compOfficesJpaController.findCompOfficesEntities()){ 
      23.                     if (compOffice.getOfficeId().longValue() == compOffices) { 
      24.                         System.out.println(compOffice.getOfficeName()); 
      25.                         getKanim().add(new SelectItem(compOffice.getOfficeId().longValue())); 
      26.                      
      27.                     } 
      28.                  
      29.                  
      30.                 } 
      31.  
      32.  
      33.             } 
      34.              
      35.              
      36. //             
      37. //            public void updatePerwakimName(CompOffices compOffices){ 
      38. //                Long comOffice  = (Long) compOffices.getOfficeId(); 
      39. //            getPerwakim().clear(); 
      40. //            for(CompOffices compOffice : compOfficesJpaController.findCompOfficesEntities()){ 
      41. //                if (compOffice.getOfficeId() == comOffice){ 
      42. //                    getPerwakim().add(new SelectItem(compOffice, compOffice.getOfficeName())); 
      43. //                 
      44. //                } 
      45. //             
      46. //             
      47. //            } 
      48. //             
      49. //            } 
      50.       
      51.              
      52.              
      53.              
      54.             public List<SelectItem> getJenisPNBP(){ 
      55.     List<SelectItem> jenisPNBP = new ArrayList<SelectItem>(); 
      56.     jenisPNBP.add(new SelectItem("1","PNBP Imigrasi")); 
      57.     jenisPNBP.add(new SelectItem("2","PNBP AHU")); 
      58.     jenisPNBP.add(new SelectItem("3","PNBP Deplu")); 
      59.     jenisPNBP.add(new SelectItem("4","Non PNBP")); 
      60.      
      61.     return jenisPNBP; 
      62.     } 
      63.  
      64.  
      65.  
      66.  
      67.     public Addresses getAddress() { 
      68.         return address; 
      69.     } 
      70.  
      71.     public void setAddress(Addresses address) { 
      72.         this.address = address; 
      73.     } 
      74.  
      75.     public Biaya getBiaya() { 
      76.         return biaya; 
      77.     } 
      78.  
      79.     public void setBiaya(Biaya biaya) { 
      80.         this.biaya = biaya; 
      81.     } 
      82.  
      83.     public CompOffices getCompoffices() { 
      84.         return compoffices; 
      85.     } 
      86.  
      87.     public void setCompoffices(CompOffices compoffices) { 
      88.         this.compoffices = compoffices; 
      89.     } 
      90.  
      91.     public DetailPendapatan getDetail() { 
      92.         return detail; 
      93.     } 
      94.  
      95.     public void setDetail(DetailPendapatan detail) { 
      96.         this.detail = detail; 
      97.     } 
      98.  
      99.     public List<SelectItem> getJenis() { 
      100.         return jenisPNBP; 
      101.     } 
      102.  
      103.     public void setJenis(List<SelectItem> jenis) { 
      104.         this.jenisPNBP = jenis; 
      105.     } 
      106.  
      107.     public JenisLokasi getJenisLokasi() { 
      108.         return jenisLokasi; 
      109.     } 
      110.  
      111.     public void setJenisLokasi(JenisLokasi jenisLokasi) { 
      112.         this.jenisLokasi = jenisLokasi; 
      113.     } 
      114.  
      115.     public List<SelectItem> getKanim() { 
      116. //    List<SelectItem> kanim= new ArrayList<SelectItem>(); 
      117.     return kanim; 
      118.     } 
      119.  
      120.     public void setKanim(List<SelectItem> kanim) { 
      121.         this.kanim = kanim; 
      122.     } 
      123.  
      124.     public Layanan getLayanan() { 
      125.         return layanan; 
      126.     } 
      127.  
      128.     public void setLayanan(Layanan layanan) { 
      129.         this.layanan = layanan; 
      130.     } 
      131.  
      132.     public Pendapatan getPendapatan() { 
      133.         return pendapatan; 
      134.     } 
      135.  
      136.     public void setPendapatan(Pendapatan pendapatan) { 
      137.         this.pendapatan = pendapatan; 
      138.     } 
      139.  
      140.     public Permohonan getPermohonan() { 
      141.         return permohonan; 
      142.     } 
      143.  
      144.     public void setPermohonan(Permohonan permohonan) { 
      145.         this.permohonan = permohonan; 
      146.     } 
      147.  
      148.     public List<SelectItem> getPerwakim() { 
      149.          
      150.          
      151.             List<SelectItem> perwakim= new ArrayList<SelectItem>(); 
      152.             perwakim.add(new SelectItem("","Semua Kantor Wilayah/Perwakim")); 
      153.                       for(CompOffices com : compOfficesJpaController.findCompOfficesEntities()){ 
      154.                           if(com.getOfficeType().equals(new BigInteger("2"))){ 
      155.                     perwakim.add(new SelectItem(com.getOfficeId(), com.getOfficeName())); 
      156.                           } 
      157.                 } 
      158.                 return perwakim; 
      159.         } 
      160.          
      161.         
      162.  
      163.     public void setPerwakim(List<SelectItem> perwakim) { 
      164.         this.perwakim = perwakim; 
      165.     } 
      166.  
      167.  
      168.  

       

       

      thanks guys