Search in sources :

Example 16 with WebSessionCtx

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);
}
Also used : HttpSession(javax.servlet.http.HttpSession) WebDoc(org.compiere.util.WebDoc) WebSessionCtx(org.compiere.util.WebSessionCtx) org.apache.ecs.xhtml.body(org.apache.ecs.xhtml.body)

Example 17 with WebSessionCtx

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);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) HtmlCode(org.compiere.util.HtmlCode) HttpSession(javax.servlet.http.HttpSession) WebUser(org.compiere.util.WebUser) Properties(java.util.Properties) WebSessionCtx(org.compiere.util.WebSessionCtx) JspWriter(javax.servlet.jsp.JspWriter) WebInfo(org.compiere.util.WebInfo)

Example 18 with WebSessionCtx

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);
}
Also used : HttpSession(javax.servlet.http.HttpSession) Properties(java.util.Properties) WebSessionCtx(org.compiere.util.WebSessionCtx)

Example 19 with WebSessionCtx

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;
}
Also used : MPrintFormat(org.compiere.print.MPrintFormat) WebSessionCtx(org.compiere.util.WebSessionCtx) File(java.io.File)

Example 20 with WebSessionCtx

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;
}
Also used : SQLException(java.sql.SQLException) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) KeyNamePair(org.compiere.util.KeyNamePair) WebSessionCtx(org.compiere.util.WebSessionCtx) File(java.io.File)

Aggregations

WebSessionCtx (org.compiere.util.WebSessionCtx)38 WebDoc (org.compiere.util.WebDoc)21 File (java.io.File)13 HttpSession (javax.servlet.http.HttpSession)11 SQLException (java.sql.SQLException)8 Properties (java.util.Properties)6 MPrintFormat (org.compiere.print.MPrintFormat)6 IOException (java.io.IOException)4 PreparedStatement (java.sql.PreparedStatement)4 ResultSet (java.sql.ResultSet)4 ServletException (javax.servlet.ServletException)4 GridField (org.compiere.model.GridField)4 org.apache.ecs.xhtml.body (org.apache.ecs.xhtml.body)3 org.apache.ecs.xhtml.input (org.apache.ecs.xhtml.input)3 org.apache.ecs.xhtml.p (org.apache.ecs.xhtml.p)3 org.apache.ecs.xhtml.td (org.apache.ecs.xhtml.td)3 ReportEngine (org.compiere.print.ReportEngine)3 ProcessInfo (org.compiere.process.ProcessInfo)3 KeyNamePair (org.compiere.util.KeyNamePair)3 Trx (org.compiere.util.Trx)3