how I can retrive only one value from listbox in zk cotroller

100 Views Asked by At
@Listen("onSelect = #myListbox;onOK = #listpid;onOK = #listfname;onOK = #listlname")
    public void showDetail() throws ClassNotFoundException, SQLException
    {

        detailbox.setVisible(true);
        // how i can get only single value in s from list box whether it is strinh integer or any other.
        String s=myListbox.getItemes;
        System.out.println(s);

            if (s!=null && !s.isEmpty())
            {
                Class.forName("com.mysql.jdbc.Driver");

                Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/cis?user=root&password=");
                System.out.println("Connection Succesful");

                Statement se=conn.createStatement();
                ResultSet rs=se.executeQuery("select * from registration");
                while(rs.next())
                {
                    System.out.println("in while loop reg");
                    if(((rs.getString(1)).toLowerCase()).equals(s.toLowerCase()))
                    {
                        pid.setValue(rs.getString(1));

                        pname.setValue(rs.getString(2)+" "+ rs.getString(3));
                        contact.setValue(rs.getString(16));

                    }

                }
2

There are 2 best solutions below

0
On
String s = (String) myListbox.getSelectedItem();
0
On

String myString=(String)myListbox.getSelectedItem(); This link would be useful for you: http://books.zkoss.org/wiki/ZK_Getting_Started/Tutorial