use of org.compiere.util.WebSessionCtx in project adempiere by adempiere.
the class WFindAdv method doGet.
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
HttpSession sess = request.getSession(false);
WWindowStatus ws = null;
WebSessionCtx wsc = WebSessionCtx.get(request);
if (sess != null)
ws = WWindowStatus.get(request);
if (wsc == null) {
WebUtil.createTimeoutPage(request, response, this, null);
return;
}
WebDoc doc = preparePage();
body body = doc.getBody();
String pTab = request.getParameter(P_Tab);
if (pTab != null && pTab.equals("FindAdv")) {
body.addElement(createPageFindAdv(request, response, ws));
} else {
body.addElement(createPageFind(request, response, ws));
}
WebUtil.createResponse(request, response, this, null, doc, true);
}
use of org.compiere.util.WebSessionCtx in project adempiere by adempiere.
the class InfoLinkTag method doStartTag.
// setOneLine
/**
* Start Tag
* @return SKIP_BODY
* @throws JspException
*/
public int doStartTag() throws JspException {
HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
// creates wsc/wu
Properties ctx = JSPEnv.getCtx(request);
WebSessionCtx wsc = WebSessionCtx.get(request);
//
HttpSession session = pageContext.getSession();
WebUser wu = (WebUser) session.getAttribute(WebUser.NAME);
if (wu != null && wu.isLoggedIn()) {
if (ctx != null) {
WebInfo info = (WebInfo) session.getAttribute(WebInfo.NAME);
if (info == null || wu.getAD_User_ID() != info.getAD_User_ID()) {
info = new WebInfo(ctx, wu);
session.setAttribute(WebInfo.NAME, info);
}
}
//
// log.fine("WebUser exists - " + wu);
//
JspWriter out = pageContext.getOut();
HtmlCode html = new HtmlCode();
//
if (wu.isCustomer() || wu.isVendor())
menuBPartner(html, wsc.wstore);
if (wu.isSalesRep())
menuSalesRep(html, wsc.wstore);
if (wu.isEmployee() || wu.isSalesRep())
menuUser(html, wu.isEmployee(), wsc.wstore);
menuAll(html, wsc.wstore);
//
html.output(out);
} else {
if (CLogMgt.isLevelFiner())
log.fine("No WebUser");
if (session.getAttribute(WebInfo.NAME) == null)
session.setAttribute(WebInfo.NAME, WebInfo.getGeneral());
}
return (SKIP_BODY);
}
use of org.compiere.util.WebSessionCtx in project adempiere by adempiere.
the class RequestServlet method doGet.
/**
* Process Get Request
* @param request
* @param response
* @throws ServletException
* @throws IOException
*/
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String l_szRequestID = null;
HttpSession sess = request.getSession(true);
sess.setMaxInactiveInterval(WebEnv.TIMEOUT);
ctx = getCtx();
if (sess.getAttribute("ctx") != null)
ctx = (Properties) sess.getAttribute("ctx");
WebSessionCtx wsc = (WebSessionCtx) sess.getAttribute(WebSessionCtx.NAME);
// Create New Request
if (wsc != null) {
String mode = WebUtil.getParameter(request, "Mode");
if (mode != null && mode.equals("RequestNew")) {
l_szRequestID = Request.createRequest(request, ctx);
} else if (mode != null && mode.equals("RequestChange")) {
l_szRequestID = Request.changeRequest(request, ctx);
}
}
String url = request.getParameter("ForwardTo") + l_szRequestID;
if (!url.startsWith("/"))
url = "/" + url;
response.sendRedirect(url);
}
use of org.compiere.util.WebSessionCtx in project adempiere by adempiere.
the class WReport method copyFormat.
// createNewFormat
/**
* Copy existing Format
* @param AD_PrintFormat_ID print format
* @param To_Client_ID to client
*/
private File copyFormat(int AD_PrintFormat_ID, int To_Client_ID, HttpServletRequest request, GridTab m_curTab, MQuery m_query) {
WebSessionCtx wsc = WebSessionCtx.get(request);
MPrintFormat pf = MPrintFormat.copyToClient(wsc.ctx, AD_PrintFormat_ID, To_Client_ID);
File file = launchReport(pf, request, m_curTab, m_query);
return file;
}
use of org.compiere.util.WebSessionCtx in project adempiere by adempiere.
the class WReport method getPrintFormats.
// doPost
/**
* Get the Print Formats for the table.
* Fill the list and the popup menu
* @param AD_Table_ID table
* @param invoker component to display popup (optional)
*/
private File getPrintFormats(int AD_Table_ID, HttpServletRequest request, GridTab m_curTab, MQuery m_query) {
WebSessionCtx wsc = WebSessionCtx.get(request);
WWindowStatus ws = WWindowStatus.get(request);
int AD_Client_ID = Env.getAD_Client_ID(wsc.ctx);
File file = null;
m_list = new ArrayList<KeyNamePair>();
//
String sql = MRole.getDefault().addAccessSQL("SELECT AD_PrintFormat_ID, Name, AD_Client_ID " + "FROM AD_PrintFormat " + "WHERE AD_Table_ID=? AND IsTableBased='Y' " + // Own First
"ORDER BY AD_Client_ID DESC, IsDefault DESC, Name", "AD_PrintFormat", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO);
KeyNamePair pp = null;
try {
PreparedStatement pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, AD_Table_ID);
ResultSet rs = pstmt.executeQuery();
while (rs.next()) {
pp = new KeyNamePair(rs.getInt(1), rs.getString(2));
if (rs.getInt(3) == AD_Client_ID) {
m_list.add(pp);
//m_popup.add(pp.toString()).addActionListener(this);
}
}
rs.close();
pstmt.close();
} catch (SQLException e) {
log.log(Level.SEVERE, sql, e);
}
// No Format exists - create it
if (m_list.size() == 0) {
if (pp == null)
// calls launch
file = createNewFormat(AD_Table_ID, request, m_curTab, m_query);
else
file = copyFormat(pp.getKey(), AD_Client_ID, request, m_curTab, m_query);
} else
// One Format exists or no invoker - show it
//else if (m_list.size() == 1 || invoker == null)
file = launchReport((KeyNamePair) m_list.get(0), request, m_curTab, m_query);
//m_popup.show(invoker, 0, invoker.getHeight()); // below button
return file;
}
Aggregations