Search in sources :

Example 26 with WebSessionCtx

use of org.compiere.util.WebSessionCtx in project adempiere by adempiere.

the class WWindow method doGet.

/**
	 *  Process the HTTP Get request - Initial Call.
	 *  <br>
	 *  http://localhost/adempiere/WWindow?AD_Window_ID=123
	 *  <br>
	 *  Create Window with request parameters
	 *  AD_Window_ID
	 *  AD_Menu_ID
	 *
	 *  Clean up old/existing window
	 *
	 *  @param request
	 *  @param response
	 *  @throws ServletException
	 *  @throws IOException
	 */
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    //  Get Session attributes
    WebDoc doc = null;
    HttpSession sess = request.getSession();
    WebSessionCtx wsc = WebSessionCtx.get(request);
    if (wsc == null) {
        WebUtil.createTimeoutPage(request, response, this, null);
        return;
    }
    //  Parameter: AD_Window_ID
    int AD_Window_ID = WebUtil.getParameterAsInt(request, "AD_Window_ID");
    //  Get Parameter: Menu_ID
    int AD_Menu_ID = WebUtil.getParameterAsInt(request, "AD_Menu_ID");
    log.info("AD_Window_ID=" + AD_Window_ID + "; AD_Menu_ID=" + AD_Menu_ID);
    String TableName = null;
    //Check to see if Zoom
    int AD_Record_ID = WebUtil.getParameterAsInt(request, "AD_Record_ID");
    int AD_Table_ID = WebUtil.getParameterAsInt(request, "AD_Table_ID");
    if (AD_Record_ID != 0 || AD_Table_ID != 0) {
        AD_Window_ID = 0;
        int PO_Window_ID = 0;
        String sql = "SELECT TableName, AD_Window_ID, PO_Window_ID FROM AD_Table WHERE AD_Table_ID=?";
        try {
            PreparedStatement pstmt = DB.prepareStatement(sql, null);
            pstmt.setInt(1, AD_Table_ID);
            ResultSet rs = pstmt.executeQuery();
            if (rs.next()) {
                TableName = rs.getString(1);
                AD_Window_ID = rs.getInt(2);
                PO_Window_ID = rs.getInt(3);
            }
            rs.close();
            pstmt.close();
        } catch (SQLException e) {
            log.log(Level.SEVERE, sql, e);
        }
        if (TableName == null || AD_Window_ID == 0) {
            doc = WebDoc.createPopup("No Context");
            doc.addPopupClose(wsc.ctx);
        }
        //	PO Zoom ?
        boolean isSOTrx = true;
        if (PO_Window_ID != 0) {
            String whereClause = TableName + "_ID=" + AD_Record_ID;
            isSOTrx = DB.isSOTrx(TableName, whereClause);
            if (!isSOTrx)
                AD_Window_ID = PO_Window_ID;
        }
    }
    //  Clean up old Window
    WWindowStatus ws = WWindowStatus.get(request);
    if (ws != null) {
        int WindowNo = ws.mWindow.getWindowNo();
        log.fine("Disposing - WindowNo=" + WindowNo + ", ID=" + ws.mWindow.getAD_Window_ID());
        ws.mWindow.dispose();
        Env.clearWinContext(wsc.ctx, WindowNo);
    }
    /**
		 *  New Window data
		 */
    GridWindowVO mWindowVO = GridWindowVO.create(wsc.ctx, s_WindowNo++, AD_Window_ID, AD_Menu_ID);
    if (mWindowVO == null) {
        String msg = Msg.translate(wsc.ctx, "AD_Window_ID") + " " + Msg.getMsg(wsc.ctx, "NotFound") + ", ID=" + AD_Window_ID + "/" + AD_Menu_ID;
        WebUtil.createErrorPage(request, response, this, msg);
        sess.setAttribute(WWindowStatus.NAME, null);
        return;
    }
    //  Create New Window
    ws = new WWindowStatus(mWindowVO);
    sess.setAttribute(WWindowStatus.NAME, ws);
    //  Query
    if (AD_Record_ID != 0 || AD_Table_ID != 0) {
        //If Zoom
        ws.mWindow.initTab(ws.curTab.getTabNo());
        ws.curTab.setQuery(MQuery.getEqualQuery(TableName + "_ID", AD_Record_ID));
        ws.curTab.query(false);
    } else {
        ws.mWindow.initTab(ws.curTab.getTabNo());
        ws.curTab.query(ws.mWindow.isTransaction());
        ws.curTab.navigate(0);
    }
    if (ws.curTab.isSingleRow())
        doc = getSR_Form(request.getRequestURI(), wsc, ws);
    else
        doc = getMR_Form(request.getRequestURI(), wsc, ws);
    //	fini
    log.fine("Fini");
    //	log.trace(log.l6_Database, doc.toString());
    WebUtil.createResponse(request, response, this, null, doc, false);
    log.fine("Closed");
}
Also used : SQLException(java.sql.SQLException) WebDoc(org.compiere.util.WebDoc) HttpSession(javax.servlet.http.HttpSession) ResultSet(java.sql.ResultSet) GridWindowVO(org.compiere.model.GridWindowVO) PreparedStatement(java.sql.PreparedStatement) WebSessionCtx(org.compiere.util.WebSessionCtx)

Example 27 with WebSessionCtx

use of org.compiere.util.WebSessionCtx in project adempiere by adempiere.

the class WWindow method doPost.

//  doGet
/**************************************************************************
	 *  Process the HTTP Post request
	 *
	 *  @param request request
	 *  @param response response
	 *  @throws ServletException
	 *  @throws IOException
	 */
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    WebEnv.dump(request);
    //  Get Session Info
    WebSessionCtx wsc = WebSessionCtx.get(request);
    WWindowStatus ws = WWindowStatus.get(request);
    if (wsc == null || ws == null) {
        if (wsc == null)
            WebUtil.createTimeoutPage(request, response, this, "No Context");
        else
            doGet(request, response);
        return;
    }
    //  Get Parameter: Command
    String p_cmd = WebUtil.getParameter(request, P_Command);
    String column = WebUtil.getParameter(request, P_ChangedColumn);
    log.info("Cmd=" + p_cmd + " - ChangedColumn=" + column);
    //	Changed Column
    if (column != null && column.length() > 0) {
        updateFields(request, wsc, ws);
    } else //	Exit & Commands
    {
        if (p_cmd.equals("Exit")) {
            MSession cSession = MSession.get(wsc.ctx, false);
            if (cSession != null)
                cSession.logout();
            WebUtil.createLoginPage(request, response, this, ws.ctx, "Exit");
            return;
        }
        executeCommand(request, p_cmd, wsc, ws);
    }
    /**************************************************
		 *  Build Page
		 */
    WebDoc doc = null;
    //  Create Simgle/Multi Row
    if (ws.curTab.isSingleRow())
        doc = getSR_Form(request.getRequestURI(), wsc, ws);
    else
        doc = getMR_Form(request.getRequestURI(), wsc, ws);
    //
    log.fine("Fini");
    //	log.trace(log.l6_Database, doc.toString());
    WebUtil.createResponse(request, response, this, null, doc, false);
    log.fine("Closed");
}
Also used : WebDoc(org.compiere.util.WebDoc) MSession(org.compiere.model.MSession) WebSessionCtx(org.compiere.util.WebSessionCtx)

Example 28 with WebSessionCtx

use of org.compiere.util.WebSessionCtx in project adempiere by adempiere.

the class WLogin method createSecondPage.

//  createFirstPage
/**
	 *  Create Second Page
	 *  @param request request
	 *  @param roleOptions role options
	 *  @param errorMessage error message
	 *  @return WDoc page
	 */
private WebDoc createSecondPage(HttpServletRequest request, option[] roleOptions, String errorMessage) {
    log.info(" - " + errorMessage);
    WebSessionCtx wsc = WebSessionCtx.get(request);
    String windowTitle = Msg.getMsg(wsc.language, "LoginSuccess");
    //	Form - Get Menu
    String action = WebEnv.getBaseDirectory("WMenu");
    form myForm = null;
    myForm = new form(action).setName("Login2");
    myForm.setTarget(WebEnv.TARGET_MENU);
    table table = new table().setAlign(AlignType.CENTER);
    //	Role Pick
    tr line = new tr();
    //Modified by Rob Klein 4/29/07
    line.addElement(new td().addElement(" "));
    table.addElement(line);
    line = new tr();
    label roleLabel = new label().setFor(P_ROLE + "F").addElement(Msg.translate(wsc.language, "AD_Role_ID"));
    roleLabel.setID(P_ROLE + "L");
    line.addElement(new td().addElement(roleLabel).setAlign(AlignType.RIGHT));
    select role = new select(P_ROLE, roleOptions);
    role.setID(P_ROLE + "F");
    //  WFieldUpdate sets Client & Org
    role.setOnClick("fieldUpdate(this);");
    line.addElement(new td().addElement(role));
    table.addElement(line);
    //	Client Pick
    line = new tr();
    label clientLabel = new label().setFor(P_CLIENT + "F").addElement(Msg.translate(wsc.language, "AD_Client_ID"));
    clientLabel.setID(P_CLIENT + "L");
    line.addElement(new td().addElement(clientLabel).setAlign(AlignType.RIGHT));
    select client = new select(P_CLIENT);
    client.setID(P_CLIENT + "F");
    //  WFieldUpdate sets Org
    client.setOnClick("fieldUpdate(this);");
    line.addElement(new td().addElement(client));
    table.addElement(line);
    //	Org Pick
    line = new tr();
    label orgLabel = new label().setFor(P_ORG + "F").addElement(Msg.translate(wsc.language, "AD_Org_ID"));
    orgLabel.setID(P_ORG + "L");
    line.addElement(new td().addElement(orgLabel).setAlign(AlignType.RIGHT));
    select org = new select(P_ORG);
    org.setID(P_ORG + "F");
    //  WFieldUpdate sets Org
    org.setOnClick("fieldUpdate(this);");
    line.addElement(new td().addElement(org));
    table.addElement(line);
    //  Warehouse
    line = new tr();
    label whLabel = new label().setFor(P_WAREHOUSE + "F").addElement(Msg.translate(wsc.language, "M_Warehouse_ID"));
    whLabel.setID(P_WAREHOUSE + "L");
    line.addElement(new td().addElement(whLabel).setAlign(AlignType.RIGHT));
    select wh = new select(P_WAREHOUSE);
    wh.setID(P_WAREHOUSE + "F");
    line.addElement(new td().addElement(wh));
    table.addElement(line);
    //  Date
    String dateData = wsc.dateFormat.format(new java.util.Date());
    line = new tr();
    label dateLabel = new label().setFor(P_DATE + "F").addElement(Msg.getMsg(wsc.language, "Date"));
    dateLabel.setID(P_DATE + "L");
    line.addElement(new td().addElement(dateLabel).setAlign(AlignType.RIGHT));
    input date = new input(input.TYPE_TEXT, P_DATE, dateData).setSize(10).setMaxlength(10);
    date.setID(P_DATE + "F");
    line.addElement(new td().addElement(date).setAlign(AlignType.LEFT));
    table.addElement(line);
    //  ErrorMessage
    if (errorMessage != null && errorMessage.length() > 0) {
        line = new tr();
        line.addElement(new td().addElement(new strong(errorMessage)).setColSpan(2).setAlign(AlignType.CENTER));
        table.addElement(line);
    }
    //Modified by Rob Klein 4/29/07
    //  Finish		
    table tablebutton = new table().setAlign(AlignType.CENTER).setWidth("25%");
    line = new tr();
    //Modified by Rob Klein 4/29/07
    //input cancel = new input(input.TYPE_RESET, "Reset", Msg.getMsg(wsc.language, "Cancel"));
    input cancel = new input(input.TYPE_RESET, "Reset", "  " + "Cancel");
    cancel.setOnClick("window.top.location.replace('/adempiere/index.html');");
    cancel.setClass("cancelbtn");
    line.addElement(new td().addElement(cancel).setWidth("50%").setAlign(AlignType.CENTER));
    input submit = new input(input.TYPE_SUBMIT, "Submit", "  " + "OK");
    submit.setOnClick("showLoadingMenu('" + WebEnv.getBaseDirectory("") + "');");
    //Modified by Rob Klein 4/29/07
    submit.setClass("loginbtn");
    line.addElement(new td().addElement(submit).setWidth("50%").setAlign(AlignType.CENTER));
    tablebutton.addElement(line);
    table.addElement(tablebutton);
    //
    myForm.addElement(table);
    //  Create Document
    WebDoc doc = WebDoc.createWindow(windowTitle);
    //Modified by Rob Klein 4/29/07
    img img = new img(WebEnv.getImageDirectory("Logo.gif"), "logo");
    doc.addWindowCenter(true).addElement(img).addElement(new p()).addElement(myForm).addElement(new p()).addElement(new p());
    //
    //  init dependency updates
    String script = "fieldUpdate(document.Login2." + P_ROLE + ");";
    doc.getBody().addElement(new script(script));
    //  Note
    doc.addWindowFooter().addElement(new p(Msg.getMsg(wsc.language, "WLoginBrowserNote"), AlignType.CENTER));
    return doc;
}
Also used : org.apache.ecs.xhtml.strong(org.apache.ecs.xhtml.strong) org.apache.ecs.xhtml.img(org.apache.ecs.xhtml.img) org.apache.ecs.xhtml.select(org.apache.ecs.xhtml.select) org.apache.ecs.xhtml.label(org.apache.ecs.xhtml.label) WebSessionCtx(org.compiere.util.WebSessionCtx) org.apache.ecs.xhtml.script(org.apache.ecs.xhtml.script) org.apache.ecs.xhtml.td(org.apache.ecs.xhtml.td) org.apache.ecs.xhtml.p(org.apache.ecs.xhtml.p) org.apache.ecs.xhtml.input(org.apache.ecs.xhtml.input) org.apache.ecs.xhtml.form(org.apache.ecs.xhtml.form) WebDoc(org.compiere.util.WebDoc) org.apache.ecs.xhtml.table(org.apache.ecs.xhtml.table) org.apache.ecs.xhtml.tr(org.apache.ecs.xhtml.tr)

Example 29 with WebSessionCtx

use of org.compiere.util.WebSessionCtx in project adempiere by adempiere.

the class WLookup method doGet.

//  init
/**
	 * Process the HTTP Get request - initial Start
	 * Needs to have parameters FormName and ColumnName
	 *
	 * @param request
	 * @param response
	 * @throws ServletException
	 * @throws IOException
	 */
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    WebEnv.dump(request);
    WebEnv.dump(request.getSession());
    //Modified by Rob Klein 4/29/07
    //
    WebSessionCtx wsc = WebSessionCtx.get(request);
    WWindowStatus ws = WWindowStatus.get(request);
    if (wsc == null) {
        WebUtil.createTimeoutPage(request, response, this, null);
        return;
    }
    //  Get Mandatory Parameters
    String columnName = WebUtil.getParameter(request, "ColumnName");
    //Lookup called from a process
    //Modified by Rob Klein 4/29/07
    int AD_Process_ID = WebUtil.getParameterAsInt(request, "AD_Process_ID");
    //Lookup modified to include paging
    //Modified by Rob Klein 07/07/07
    int page = WebUtil.getParameterAsInt(request, "page");
    log.info("This is the page on original call" + page);
    if (AD_Process_ID > 0) {
        if (AD_Process_ID < 1 || columnName == null || columnName.equals("")) {
            WebUtil.createErrorPage(request, response, this, Msg.getMsg(wsc.ctx, "ParameterMissing"));
            return;
        }
        String targetBase = "'" + columnName;
        MProcess process = MProcess.get(wsc.ctx, AD_Process_ID);
        MProcessPara para = null;
        MProcessPara[] parameter = process.getParameters();
        for (int i = 0; i < parameter.length; i++) {
            para = parameter[i];
            if (para.getColumnName().equals(columnName))
                i = parameter.length;
        }
        //  Create Document
        WebDoc doc = WebDoc.createPopup(para.getColumnName());
        div panel = new div();
        panel.setStyle("height: 330px;overflow: scroll;overflow: auto;");
        panel.addElement(fillTable(wsc, para.getColumnName(), para.getAD_Reference_Value_ID(), request.getRequestURI(), targetBase, false, page));
        //tr tr = new tr().addElement(panel);
        //  Reset
        String text = "Reset";
        //if (wsc.ctx != null)
        //	text = Msg.getMsg (wsc.ctx, "Reset");
        input resetbtn = new input("button", text, "  " + text);
        resetbtn.setID(text);
        resetbtn.setClass("resetbtn");
        String script = targetBase + "F.value='';" + targetBase + "D.value='';closePopup();";
        resetbtn.setOnClick(script);
        //
        //			
        //First Page
        text = "First";
        //if (wsc.ctx != null)
        //	text = Msg.getMsg (wsc.ctx, "Next Page");		
        input firstpgbtn = new input(input.TYPE_BUTTON, text, "  " + text);
        firstpgbtn.setOnClick("startLookup('" + columnName + "', " + AD_Process_ID + ", 1);return false;");
        firstpgbtn.setID(text);
        firstpgbtn.setClass("firstpgbtn");
        //Previous Page
        text = "Prior";
        //if (wsc.ctx != null)
        //	text = Msg.getMsg (wsc.ctx, "Prior Page");		
        input prevpgbtn = new input(input.TYPE_BUTTON, text, "  " + text);
        int prevpage = (page == 1) ? 1 : page - 1;
        prevpgbtn.setOnClick("startLookup('" + columnName + "', " + AD_Process_ID + ", " + prevpage + ");return false;");
        prevpgbtn.setID(text);
        prevpgbtn.setClass("prevpgbtn");
        //Next Page
        text = "Next";
        //if (wsc.ctx != null)
        //	text = Msg.getMsg (wsc.ctx, "Next Page");		
        input nextpgbtn = new input(input.TYPE_BUTTON, text, "  " + text);
        int nextpage = (page + 1);
        nextpgbtn.setOnClick("startLookup('" + columnName + "', " + AD_Process_ID + ", " + nextpage + ");return false;");
        nextpgbtn.setID(text);
        nextpgbtn.setClass("nextpgbtn");
        //Last Page
        text = "Next";
        //if (wsc.ctx != null)
        //	text = Msg.getMsg (wsc.ctx, "Next Page");		
        input lastpgbtn = new input(input.TYPE_BUTTON, text, "  " + text);
        int lastpage = m_recordCount / MAX_LINES + 1;
        lastpgbtn.setOnClick("startLookup('" + columnName + "', " + AD_Process_ID + ", " + lastpage + ");return false;");
        lastpgbtn.setID(text);
        lastpgbtn.setClass("lastpgbtn");
        int index1 = (page - 1) * MAX_LINES + 1;
        int index2 = (page) * MAX_LINES < m_recordCount ? (page) * MAX_LINES : m_recordCount;
        doc.getTable().addElement(new tr(new td(panel).setColSpan(2)));
        doc.addPopupClose(ws.ctx)[0].addElement("&nbsp;#&nbsp;" + index1 + "-" + index2 + " / " + m_recordCount).addElement(resetbtn).addElement(firstpgbtn).addElement(prevpgbtn).addElement(nextpgbtn).addElement(lastpgbtn);
        WebUtil.createResponse(request, response, this, null, doc, false);
    } else //Lookup called from a window
    {
        //	Modified by Rob Klein 7/01/07
        if (ws == null) {
            WebUtil.createTimeoutPage(request, response, this, null);
            return;
        }
        GridField mField = ws.curTab.getField(columnName);
        log.config("ColumnName=" + columnName + ", MField=" + mField);
        if (mField == null || columnName == null || columnName.equals("")) {
            WebUtil.createErrorPage(request, response, this, Msg.getMsg(ws.ctx, "ParameterMissing"));
            return;
        }
        //	parent = framesetWindow
        //	Label - Dtata - Field - Button
        String targetBase = "'" + columnName;
        //  Create Document
        WebDoc doc = WebDoc.createPopup(mField.getHeader());
        boolean hasDependents = ws.curTab.hasDependants(columnName);
        boolean hasCallout = mField.getCallout().length() > 0;
        div panel = new div();
        panel.setStyle("height: 330px;overflow: scroll;overflow: auto;");
        panel.addElement(fillTable(wsc, mField.getColumnName(), mField.getAD_Reference_Value_ID(), request.getRequestURI(), targetBase, hasDependents || hasCallout, page));
        //tr tr = new tr().addElement(panel);
        //  Reset
        String text = "Reset";
        //if (wsc.ctx != null)
        //	text = Msg.getMsg (wsc.ctx, "Reset");		
        input resetbtn = new input(input.TYPE_RESET, text, "  " + text);
        resetbtn.setID(text);
        resetbtn.setClass("resetbtn");
        String script = targetBase + "F.value='';" + targetBase + "D.value='';self.close();";
        if (hasDependents || hasCallout)
            script += "startUpdate(" + targetBase + "F);";
        resetbtn.setOnClick(script);
        //First Page
        text = "First";
        //if (wsc.ctx != null)
        //	text = Msg.getMsg (wsc.ctx, "First");		
        input firstpgbtn = new input(input.TYPE_BUTTON, text, "  " + text);
        firstpgbtn.setOnClick("startLookup('" + columnName + "', " + AD_Process_ID + ", 1);return false;");
        firstpgbtn.setID(text);
        firstpgbtn.setClass("firstpgbtn");
        //Previous Page
        text = "Prior";
        //if (wsc.ctx != null)
        //	text = Msg.getMsg (wsc.ctx, "Prior");		
        input prevpgbtn = new input(input.TYPE_BUTTON, text, "  " + text);
        int prevpage = (page == 1) ? 1 : page - 1;
        prevpgbtn.setOnClick("startLookup('" + columnName + "', " + AD_Process_ID + ", " + prevpage + ");return false;");
        prevpgbtn.setID(text);
        prevpgbtn.setClass("prevpgbtn");
        //Next Page
        text = "Next";
        //if (wsc.ctx != null)
        //	text = Msg.getMsg (wsc.ctx, "Next");		
        input nextpgbtn = new input(input.TYPE_BUTTON, text, "  " + text);
        int nextpage = (page + 1);
        nextpgbtn.setOnClick("startLookup('" + columnName + "', " + AD_Process_ID + ", " + nextpage + ");return false;");
        nextpgbtn.setID(text);
        nextpgbtn.setClass("nextpgbtn");
        //Last Page
        text = "Last";
        //if (wsc.ctx != null)
        //	text = Msg.getMsg (wsc.ctx, "Last");		
        input lastpgbtn = new input(input.TYPE_BUTTON, text, "  " + text);
        int lastpage = m_recordCount / MAX_LINES + 1;
        lastpgbtn.setOnClick("startLookup('" + columnName + "', " + AD_Process_ID + ", " + lastpage + ");return false;");
        lastpgbtn.setID(text);
        lastpgbtn.setClass("lastpgbtn");
        int index1 = (page - 1) * MAX_LINES + 1;
        int index2 = (page) * MAX_LINES < m_recordCount ? (page) * MAX_LINES : m_recordCount;
        doc.getTable().addElement(new tr(new td(panel).setColSpan(2)));
        doc.addPopupClose(ws.ctx)[0].addElement("&nbsp;#&nbsp;" + index1 + "-" + index2 + " / " + m_recordCount).addElement(resetbtn).addElement(firstpgbtn).addElement(prevpgbtn).addElement(nextpgbtn).addElement(lastpgbtn);
        WebUtil.createResponse(request, response, this, null, doc, false);
    }
}
Also used : MProcess(org.compiere.model.MProcess) MProcessPara(org.compiere.model.MProcessPara) GridField(org.compiere.model.GridField) WebSessionCtx(org.compiere.util.WebSessionCtx) org.apache.ecs.xhtml.div(org.apache.ecs.xhtml.div) org.apache.ecs.xhtml.td(org.apache.ecs.xhtml.td) org.apache.ecs.xhtml.input(org.apache.ecs.xhtml.input) WebDoc(org.compiere.util.WebDoc) org.apache.ecs.xhtml.tr(org.apache.ecs.xhtml.tr)

Example 30 with WebSessionCtx

use of org.compiere.util.WebSessionCtx in project adempiere by adempiere.

the class WMenu method doPost.

//  doGet
/**************************************************************************
	 *  Process the HTTP Post request - Verify Input & Create Menu
	 *
	 * @param request request
	 * @param response response
	 * @throws ServletException
	 * @throws IOException
	 */
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    log.fine("doPost - Create Menu");
    //  Get Session attributes
    WebSessionCtx wsc = WebSessionCtx.get(request);
    if (wsc == null) {
        WebUtil.createTimeoutPage(request, response, this, null);
        return;
    }
    //Added by Rob Klein 4/29/07
    //Reset WWindow
    WebUtil.getClearFrame(WebEnv.TARGET_WINDOW);
    //  Get Parameters: Role, Client, Org, Warehouse, Date
    String role = WebUtil.getParameter(request, WLogin.P_ROLE);
    String client = WebUtil.getParameter(request, WLogin.P_CLIENT);
    String org = WebUtil.getParameter(request, WLogin.P_ORG);
    String wh = WebUtil.getParameter(request, WLogin.P_WAREHOUSE);
    if (wh == null)
        wh = "";
    //  Get context
    if (role == null || client == null || org == null) {
        WebUtil.createTimeoutPage(request, response, this, Msg.getMsg(wsc.ctx, "ParameterMissing"));
        return;
    }
    //  Get Info from Context - User, Role, Client
    int AD_User_ID = Env.getAD_User_ID(wsc.ctx);
    int AD_Role_ID = Env.getAD_Role_ID(wsc.ctx);
    int AD_Client_ID = Env.getAD_Client_ID(wsc.ctx);
    //  Not available in context yet - Org, Warehouse
    int AD_Org_ID = -1;
    int M_Warehouse_ID = -1;
    //  Get latest info from context
    try {
        int req_role = Integer.parseInt(role);
        if (req_role != AD_Role_ID) {
            log.fine("AD_Role_ID - changed from " + AD_Role_ID);
            AD_Role_ID = req_role;
            Env.setContext(wsc.ctx, "#AD_Role_ID", AD_Role_ID);
        }
        log.fine("AD_Role_ID = " + AD_Role_ID);
        //
        int req_client = Integer.parseInt(client);
        if (req_client != AD_Client_ID) {
            log.fine("AD_Client_ID - changed from " + AD_Client_ID);
            AD_Client_ID = req_client;
            Env.setContext(wsc.ctx, "#AD_Client_ID", AD_Client_ID);
        }
        log.fine("AD_Client_ID = " + AD_Client_ID);
        //
        AD_Org_ID = Integer.parseInt(org);
        log.fine("AD_Org_ID = " + AD_Org_ID);
        //
        if (wh.length() > 0) {
            M_Warehouse_ID = Integer.parseInt(wh);
            log.fine("M_Warehouse_ID = " + M_Warehouse_ID);
        }
    } catch (Exception e) {
        log.log(Level.SEVERE, "Parameter", e);
        WebUtil.createTimeoutPage(request, response, this, Msg.getMsg(wsc.ctx, "ParameterMissing"));
        return;
    }
    //  Check Login info and set environment
    wsc.loginInfo = checkLogin(wsc.ctx, AD_User_ID, AD_Role_ID, AD_Client_ID, AD_Org_ID, M_Warehouse_ID);
    if (wsc.loginInfo == null) {
        WebUtil.createErrorPage(request, response, this, Msg.getMsg(wsc.ctx, "RoleInconsistent"));
        return;
    }
    //  Set cookie for future defaults
    Properties cProp = WebUtil.getCookieProprties(request);
    cProp.setProperty(WLogin.P_ROLE, String.valueOf(AD_Role_ID));
    cProp.setProperty(WLogin.P_CLIENT, String.valueOf(AD_Client_ID));
    cProp.setProperty(WLogin.P_ORG, String.valueOf(AD_Org_ID));
    if (M_Warehouse_ID == -1)
        cProp.setProperty(WLogin.P_WAREHOUSE, "");
    else
        cProp.setProperty(WLogin.P_WAREHOUSE, String.valueOf(M_Warehouse_ID));
    //  Set Date
    Timestamp ts = WebUtil.getParameterAsDate(request, WLogin.P_DATE);
    if (ts == null)
        ts = new Timestamp(System.currentTimeMillis());
    //  JDBC format
    Env.setContext(wsc.ctx, "#Date", ts);
    //  Can we store Cookie ?
    if (!cProp.getProperty(WLogin.P_STORE, "N").equals("Y"))
        cProp.clear();
    WebDoc doc = createPage(request, wsc, AD_Role_ID, AD_User_ID, AD_Client_ID, AD_Org_ID);
    //Added by Rob Klein 4/29/07
    doc.getBody().addElement(WebUtil.getClearFrame(WebEnv.TARGET_WINDOW));
    WebUtil.createResponse(request, response, this, cProp, doc, false);
//WebUtil.createResponse (request, response, this, cProp, doc, true);
}
Also used : WebDoc(org.compiere.util.WebDoc) WebSessionCtx(org.compiere.util.WebSessionCtx) Properties(java.util.Properties) Timestamp(java.sql.Timestamp) ServletException(javax.servlet.ServletException) SQLException(java.sql.SQLException) IOException(java.io.IOException)

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