Return-Path: Delivered-To: apmail-struts-user-archive@www.apache.org Received: (qmail 71441 invoked from network); 14 Mar 2011 04:53:40 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 14 Mar 2011 04:53:40 -0000 Received: (qmail 63385 invoked by uid 500); 14 Mar 2011 04:53:38 -0000 Delivered-To: apmail-struts-user-archive@struts.apache.org Received: (qmail 63365 invoked by uid 500); 14 Mar 2011 04:53:38 -0000 Mailing-List: contact user-help@struts.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Struts Users Mailing List" Reply-To: "Struts Users Mailing List" Delivered-To: mailing list user@struts.apache.org Received: (qmail 63357 invoked by uid 99); 14 Mar 2011 04:53:38 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 14 Mar 2011 04:53:38 +0000 X-ASF-Spam-Status: No, hits=2.0 required=5.0 tests=SPF_NEUTRAL,URI_HEX X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [216.139.236.26] (HELO sam.nabble.com) (216.139.236.26) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 14 Mar 2011 04:53:31 +0000 Received: from [192.168.236.26] (helo=sam.nabble.com) by sam.nabble.com with esmtp (Exim 4.69) (envelope-from ) id 1PyzmI-0002Ym-Q1 for user@struts.apache.org; Sun, 13 Mar 2011 21:53:10 -0700 Date: Sun, 13 Mar 2011 21:53:10 -0700 (PDT) From: JavaNoobie87 To: user@struts.apache.org Message-ID: <1300078390799-3555885.post@n5.nabble.com> Subject: loading Dropdown dynamically from database MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Hi All, Im developing a Crud example using Struts 2 where im in the need to load values for a dropdown box dynamically from a database . However im just getting a empty dropdown now . The JSP code snippet is as below. The action class and DAO for the same function are as below. Action. public String loadDomainType(){ // Class used to get the domaintype from domaintype table System.out.println("my logging statement"); String result=SUCCESS; try { System.out.println("Inside loaddomaintype"); List loadDomainType = DomainDAO.loadDomainType(); dtList=loadDomainType; } catch (Exception e) { // TODO Auto-generated catch block; result=ERROR; e.printStackTrace(); } DAO Class-- public static List loadDomainType() throws Exception { Connection con = null; PreparedStatement stmt = null; ResultSet rs = null; System.out.println("loadDomaintype DAO"); DomainBean bean = new DomainBean(); ArrayList dtList = new ArrayList(); try { con= DBConnector.getConnection(); if (con != null){ System.out.println("Connected"); String query= " SELECT CODE,DESCRIPTION,OBJECTID FROM DOMAINTYPE " ; stmt = con.prepareStatement(query); rs = stmt.executeQuery(); System.out.println("inside loadDomainType"); while (rs.next()){ bean.setCode(rs.getString("CODE")); bean.setDescription(rs.getString("DESCRIPTION")); bean.setObjid(rs.getInt("OBJECTID")); dtList.add(bean); } } } catch (SQLException sqe) { sqe.printStackTrace(); } finally { DBConnector.closeResultSet(rs); DBConnector.closeStatement(stmt); DBConnector.closeConnection(con); } return dtList; } -- View this message in context: http://struts.1045723.n5.nabble.com/loading-Dropdown-dynamically-from-database-tp3555885p3555885.html Sent from the Struts - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@struts.apache.org For additional commands, e-mail: user-help@struts.apache.org