1 14 package org.compiere.wstore; 15 16 import java.util.*; 17 import java.sql.*; 18 import javax.servlet.http.*; 19 import javax.servlet.jsp.*; 20 import javax.servlet.jsp.tagext.*; 21 22 import org.apache.ecs.xhtml.*; 23 import org.apache.log4j.Logger; 24 25 import org.compiere.util.Env; 26 import org.compiere.util.DB; 27 28 37 public class RequestTypeTag extends TagSupport 38 { 39 40 private Logger log = Logger.getLogger (getClass()); 41 42 46 public int doStartTag() 47 { 48 JspWriter out = pageContext.getOut(); 49 select select = getRequestType(); 50 select.output(out); 51 return (SKIP_BODY); 53 } 55 59 private select getRequestType() 60 { 61 select select = new select(RequestServlet.P_REQUESTTYPE_ID, getOptions()); 62 select.setID("ID_" + RequestServlet.P_REQUESTTYPE_ID); 63 return select; 64 } 66 70 private option[] getOptions() 71 { 72 Properties ctx = JSPEnv.getCtx((HttpServletRequest)pageContext.getRequest()); 73 int AD_Client_ID = Env.getContextAsInt(ctx, "#AD_Client_ID"); 74 if (AD_Client_ID == 0) 75 log.error("getOptions - AD_Client_ID not found"); 76 else 77 log.info("getOptions - AD_Client_ID=" + AD_Client_ID); 78 ArrayList list = new ArrayList(); 79 String sql = "SELECT R_RequestType_ID, Name FROM R_RequestType " 81 + "WHERE AD_Client_ID=? AND IsActive='Y' AND IsSelfService='Y' " 82 + "ORDER BY IsDefault DESC, Name"; 83 PreparedStatement pstmt = null; 84 try 85 { 86 pstmt = DB.prepareStatement(sql); 87 pstmt.setInt(1, AD_Client_ID); 88 ResultSet rs = pstmt.executeQuery(); 89 while (rs.next()) 90 { 91 option o = new option (rs.getString(1)); 92 o.addElement(rs.getString(2)); 93 list.add(o); 94 } 95 rs.close(); 96 pstmt.close(); 97 pstmt = null; 98 } 99 catch (Exception e) 100 { 101 log.error("getOptions", e); 102 } 103 finally 104 { 105 try 106 { 107 if (pstmt != null) 108 pstmt.close (); 109 } 110 catch (Exception e) 111 {} 112 pstmt = null; 113 } 114 115 option options[] = new option [list.size()]; 117 list.toArray(options); 118 log.debug("getOptions = #" + options.length); 119 return options; 120 } 122 } | Popular Tags |