我如何从zk控制器中的列表框中只检索一个值

时间:2013-12-05 11:23:03

标签: java zk

@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 个答案:

答案 0 :(得分:0)

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

答案 1 :(得分:0)

String myString =(String)myListbox.getSelectedItem(); 此链接对您有用: http://books.zkoss.org/wiki/ZK_Getting_Started/Tutorial