/** Read all screen form data from HTTP request */ protected GenericSearchFormData getWebFormRequest( GenericSearchFormData form, HttpServletRequest request) { HolidaySearchFormData iSearchData = (HolidaySearchFormData) form; iSearchData.setData( HolidaySearchFormData.holidayDate, request.getParameter(iSearchData.getFieldname(HolidaySearchFormData.holidayDate))); iSearchData.setData( HolidaySearchFormData.holidayDescription, request.getParameter(iSearchData.getFieldname(HolidaySearchFormData.holidayDescription))); return iSearchData; }
public Vector actionSearch(GenericSearchFormData o) { HolidaySearchFormData iSearchData = (HolidaySearchFormData) o; Vector v = new Vector(); Connection conn = null; PreparedStatement ps = null; ResultSet rs = null; String sql = "SELECT DATE_FORMAT(DATE, '%d/%m/%Y') AS DATE, DESCRIPTION FROM HOLIDAY WHERE STATUS = 'READY' "; if (!CircUtilities.isEmptyString(iSearchData.getData(HolidaySearchFormData.holidayDescription))) sql += "AND LCASE(DESCRIPTION) like LCASE('%" + iSearchData.getData(HolidaySearchFormData.holidayDescription) + "%') "; if (!CircUtilities.isEmptyString(iSearchData.getData(HolidaySearchFormData.holidayDate))) sql += "AND DATE = ? "; sql += "ORDER BY DATE_FORMAT(DATE, '%Y%m%d') "; try { System.out.println("HOLIDAY SEARCH=" + sql); conn = JdbcConnection.getConnection(); ps = conn.prepareStatement(sql); if (!CircUtilities.isEmptyString(iSearchData.getData(HolidaySearchFormData.holidayDate))) ps.setTimestamp(1, iSearchData.getTimestampByField(HolidaySearchFormData.holidayDate)); rs = ps.executeQuery(); while (rs.next()) { HolidayData iData = new HolidayData(rs); v.add((HolidayData) iData); } } catch (Exception e) { // ignore search error, just return empty vector } finally { if (rs != null) try { rs.close(); } catch (Exception e) { e.printStackTrace(); } if (ps != null) try { ps.close(); } catch (Exception e) { e.printStackTrace(); } if (conn != null) try { conn.close(); } catch (Exception e) { e.printStackTrace(); } } return v; }