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. DomainType
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-tp3555884p3555884.html Sent from the Struts - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org