3 Replies Latest reply on Apr 7, 2009 3:56 AM by betul aydin

    submit button  doesnt work with rich:pickList

    betul aydin Newbie

      Hi
      Ä°n my simple application I want to use rich:pickList .I use richfaces 3.3.0 GA ,jboss 4.2.3 server .
      On my form picklist works fine but the button doent works when I submit it?
      I removed rich:pickList from the form and submit button worked. Can anybody explain what is the problem
      Pick.java

      
      public final class Pick extends Object {
      
       private ArrayList testkod=new ArrayList();
       private List testad=new ArrayList();
       private Connection con;
       private Statement stm;
      
      public void setTestkod(ArrayList testkod){
      
       this.testkod=testkod;
       }
       public ArrayList getTestkod(){
       return testkod;
       }
       public void setTestad(List testad) {
       this.testad=testad;
       }
       public List getTestad(){
       return testad;
       }
      
      
       public void initdatabase(){
      
      
       try {
       if(con==null ||con.isClosed()){
      
      
       InitialContext ctx = new InitialContext();
       DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/AS400DataSource");
       con = ds.getConnection();
      
       }
      
      
       } catch(NamingException e) {
       System.out.println("Kullanıcı:"+e.getMessage());
       System.out.println("Kullanıcı:"+e.getClass().getName());
       } catch(SQLException e) {
       System.out.println("Kullanıcı:"+e.getMessage());
       System.out.println("Kullanıcı:"+e.getClass().getName());
       }
      
       }
       public Pick(){
       try{
       this.initdatabase();
       // test adları listele----------------------------------------------------------------------
      
       String sql="";
       SelectItem item;
       this.testad=new ArrayList();
       stm=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
       ResultSet rs=stm.executeQuery("select TKTSKD,TKTSAD from DNMDAT.TSKOD00K");
      
       while(rs.next()){
       item=new SelectItem(rs.getString("TKTSKD").trim(),rs.getString("TKTSAD").trim());
       this.testad.add(item);
      
       }
       stm.close();
      
       }catch(java.lang.ArrayIndexOutOfBoundsException ar){
       System.out.println("liste ekleme hata");
       System.out.println("Kullanıcı:"+ar.getMessage());
       System.out.println("Kullanıcı:"+ar.getClass().getName());}
      
       catch(java.lang.NullPointerException we){
      
       System.out.println("liste ekleme hata");
       System.out.println("Kullanıcı:"+we.getMessage());
       System.out.println("Kullanıcı:"+we.getClass().getName());
       }
      
       catch(java.sql.SQLException de){
       System.out.println("liste ekleme hata");
       System.out.println("Kullanıcı:"+de.getMessage());
       System.out.println("Kullanıcı:"+de.getClass().getName());
       }
      
       catch(java.lang.Exception e) {
       System.out.println("listede ekleme hata");
       System.out.println("Kullanıcı:"+e.getMessage());
       System.out.println("Kullanıcı:"+e.getClass().getName());
       }
      
      
      
      
       }
      
      
       public void den(){
      
       System.out.println("show value show");
       for(int i=0;i<this.getTestkod().size();i++){
       System.out.println("sonuc"+this.getTestkod().get(i));
      
       }
       }
      
      
      public final class Pick extends Object {
      
       private ArrayList testkod=new ArrayList();
       private List testad=new ArrayList();
       private Connection con;
       private Statement stm;
      
      public void setTestkod(ArrayList testkod){
      
       this.testkod=testkod;
       }
       public ArrayList getTestkod(){
       return testkod;
       }
       public void setTestad(List testad) {
       this.testad=testad;
       }
       public List getTestad(){
       return testad;
       }
      
      
       public void initdatabase(){
      
      
       try {
       if(con==null ||con.isClosed()){
      
      
       InitialContext ctx = new InitialContext();
       DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/AS400DataSource");
       con = ds.getConnection();
      
       }
      
      
       } catch(NamingException e) {
       System.out.println("Kullanıcı:"+e.getMessage());
       System.out.println("Kullanıcı:"+e.getClass().getName());
       } catch(SQLException e) {
       System.out.println("Kullanıcı:"+e.getMessage());
       System.out.println("Kullanıcı:"+e.getClass().getName());
       }
      
       }
       public Pick(){
       try{
       this.initdatabase();
       // test adları listele----------------------------------------------------------------------
      
       String sql="";
       SelectItem item;
       this.testad=new ArrayList();
       stm=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
       ResultSet rs=stm.executeQuery("select TKTSKD,TKTSAD from DNMDAT.TSKOD00K");
      
       while(rs.next()){
       item=new SelectItem(rs.getString("TKTSKD").trim(),rs.getString("TKTSAD").trim());
       this.testad.add(item);
      
       }
       stm.close();
      
       }catch(java.lang.ArrayIndexOutOfBoundsException ar){
       System.out.println("liste ekleme hata");
       System.out.println("Kullanıcı:"+ar.getMessage());
       System.out.println("Kullanıcı:"+ar.getClass().getName());}
      
       catch(java.lang.NullPointerException we){
      
       System.out.println("liste ekleme hata");
       System.out.println("Kullanıcı:"+we.getMessage());
       System.out.println("Kullanıcı:"+we.getClass().getName());
       }
      
       catch(java.sql.SQLException de){
       System.out.println("liste ekleme hata");
       System.out.println("Kullanıcı:"+de.getMessage());
       System.out.println("Kullanıcı:"+de.getClass().getName());
       }
      
       catch(java.lang.Exception e) {
       System.out.println("listede ekleme hata");
       System.out.println("Kullanıcı:"+e.getMessage());
       System.out.println("Kullanıcı:"+e.getClass().getName());
       }
      
      
      
      
       }
      
      
       public void den(){
      
       System.out.println("show value show");
       for(int i=0;i<this.getTestkod().size();i++){
       System.out.println("sonuc"+this.getTestkod().get(i));
      
       }
       }
      
      
      

      onay.jsp page

      
      <h:form>
       <rich:pickList id="p" switchByClick="true" value="#{Pick.testkod}" copyAllControlLabel="hepsini kopyala" copyControlLabel="kopyala" listsHeight="150" removeAllControlLabel="hepsini sil" removeControlLabel="seçili olanısil" sourceListWidth="220" targetListWidth="220" >
       <f:selectItems value="#{Pick.testad}"/>
      
       </rich:pickList>
      
       <h:commandButton type="submit" action="#{Pick.den}" value="Göster" styleClass="button"/>
      
       </h:form>
      
      
      
      


        • 1. Re:  submit button  doesnt work with rich:pickList
          betul aydin Newbie

           

          "btl_ayd" wrote:
          Hi
          Ä°n my simple application I want to use rich:pickList .I use richfaces 3.3.0 GA ,jboss 4.2.3 server .
          On my form picklist works fine but the button doent works when I submit it?
          I removed rich:pickList from the form and submit button worked. Can anybody explain what is the problem
          Pick.java

          
          public final class Pick extends Object {
          
           private ArrayList testkod=new ArrayList();
           private List testad=new ArrayList();
           private Connection con;
           private Statement stm;
          
          public void setTestkod(ArrayList testkod){
          
           this.testkod=testkod;
           }
           public ArrayList getTestkod(){
           return testkod;
           }
           public void setTestad(List testad) {
           this.testad=testad;
           }
           public List getTestad(){
           return testad;
           }
          
          
           public void initdatabase(){
          
          
           try {
           if(con==null ||con.isClosed()){
          
          
           InitialContext ctx = new InitialContext();
           DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/AS400DataSource");
           con = ds.getConnection();
          
           }
          
          
           } catch(NamingException e) {
           System.out.println("Kullanıcı:"+e.getMessage());
           System.out.println("Kullanıcı:"+e.getClass().getName());
           } catch(SQLException e) {
           System.out.println("Kullanıcı:"+e.getMessage());
           System.out.println("Kullanıcı:"+e.getClass().getName());
           }
          
           }
           public Pick(){
           try{
           this.initdatabase();
           // test adları listele----------------------------------------------------------------------
          
           String sql="";
           SelectItem item;
           this.testad=new ArrayList();
           stm=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
           ResultSet rs=stm.executeQuery("select TKTSKD,TKTSAD from DNMDAT.TSKOD00K");
          
           while(rs.next()){
           item=new SelectItem(rs.getString("TKTSKD").trim(),rs.getString("TKTSAD").trim());
           this.testad.add(item);
          
           }
           stm.close();
          
           }catch(java.lang.ArrayIndexOutOfBoundsException ar){
           System.out.println("liste ekleme hata");
           System.out.println("Kullanıcı:"+ar.getMessage());
           System.out.println("Kullanıcı:"+ar.getClass().getName());}
          
           catch(java.lang.NullPointerException we){
          
           System.out.println("liste ekleme hata");
           System.out.println("Kullanıcı:"+we.getMessage());
           System.out.println("Kullanıcı:"+we.getClass().getName());
           }
          
           catch(java.sql.SQLException de){
           System.out.println("liste ekleme hata");
           System.out.println("Kullanıcı:"+de.getMessage());
           System.out.println("Kullanıcı:"+de.getClass().getName());
           }
          
           catch(java.lang.Exception e) {
           System.out.println("listede ekleme hata");
           System.out.println("Kullanıcı:"+e.getMessage());
           System.out.println("Kullanıcı:"+e.getClass().getName());
           }
          
          
          
          
           }
          
          
           public void den(){
          
           System.out.println("show value show");
           for(int i=0;i<this.getTestkod().size();i++){
           System.out.println("sonuc"+this.getTestkod().get(i));
          
           }
           }
          
          
          
          
          

          onay.jsp page

          
          <h:form>
           <rich:pickList id="p" switchByClick="true" value="#{Pick.testkod}" copyAllControlLabel="hepsini kopyala" copyControlLabel="kopyala" listsHeight="150" removeAllControlLabel="hepsini sil" removeControlLabel="seçili olanısil" sourceListWidth="220" targetListWidth="220" >
           <f:selectItems value="#{Pick.testad}"/>
          
           </rich:pickList>
          
           <h:commandButton type="submit" action="#{Pick.den}" value="Göster" styleClass="button"/>
          
           </h:form>
          
          
          
          


          • 2. Re:  submit button  doesnt work with rich:pickList
            Ilya Shaikovsky Master

            add rich:messages to your page.

            • 3. Re:  submit button  doesnt work with rich:pickList
              betul aydin Newbie

              Thanks for your reply I used ric:messages and I saw java illegal argumant exception.I used List place of Arraylist and the problem has been solved.