📄 requesttypetag.java
字号:
/******************************************************************************
* The contents of this file are subject to the Compiere License Version 1.1
* ("License"); You may not use this file except in compliance with the License
* You may obtain a copy of the License at http://www.compiere.org/license.html
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
* The Original Code is Compiere ERP & CRM Smart Business Solution
* The Initial Developer of the Original Code is Jorg Janke and ComPiere, Inc.
* Portions created by Jorg Janke are Copyright (C) 1999-2003 Jorg Janke, parts
* created by ComPiere are Copyright (C) ComPiere, Inc.; All Rights Reserved.
* Contributor(s): ______________________________________.
*****************************************************************************/
package org.compiere.wstore;
import java.util.*;
import java.sql.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
import org.apache.ecs.xhtml.*;
import org.apache.log4j.Logger;
import org.compiere.util.Env;
import org.compiere.util.DB;
/**
* Request Type Tag.
* Create Drop Down List with valid values
*
* <cws:requestType/>
*
* @author Jorg Janke
* @version $Id: RequestTypeTag.java,v 1.6 2003/04/28 04:20:25 jjanke Exp $
*/
public class RequestTypeTag extends TagSupport
{
/** Logger */
private Logger log = Logger.getLogger (getClass());
/**
* Start Tag
* @return SKIP_BODY
*/
public int doStartTag()
{
JspWriter out = pageContext.getOut();
select select = getRequestType();
select.output(out);
//
return (SKIP_BODY);
} // doStartTag
/**
* Create Select List
* @return select list
*/
private select getRequestType()
{
select select = new select("RequestType", getOptions());
select.setID("ID_RequestType");
return select;
} // getRequestType
/**
* Get the Request Type options
* @return array of options
*/
private option[] getOptions()
{
Properties ctx = JSPEnv.getCtx((HttpServletRequest)pageContext.getRequest());
int AD_Client_ID = Env.getContextAsInt(ctx, "#AD_Client_ID");
if (AD_Client_ID == 0)
log.error("getOptions - AD_Client_ID not found");
else
log.info("getOptions - AD_Client_ID=" + AD_Client_ID);
ArrayList list = new ArrayList();
//
String sql = "SELECT R_RequestType_ID, Name FROM R_RequestType WHERE AD_Client_ID=? AND IsActive='Y'";
PreparedStatement pstmt = null;
try
{
pstmt = DB.prepareStatement(sql);
pstmt.setInt(1, AD_Client_ID);
ResultSet rs = pstmt.executeQuery();
while (rs.next())
{
option o = new option (rs.getString(1));
o.addElement(rs.getString(2));
list.add(o);
}
rs.close();
pstmt.close();
pstmt = null;
}
catch (Exception e)
{
log.error("getOptions", e);
}
finally
{
try
{
if (pstmt != null)
pstmt.close ();
}
catch (Exception e)
{}
pstmt = null;
}
// Return to Array and return
option options[] = new option [list.size()];
list.toArray(options);
log.debug("getOptions = #" + options.length);
return options;
} // getOptions
} // RequestTypeTag
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -