Search in sources :

Example 46 with WebDoc

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

the class WReport method doPost.

//  doGet
/**
	 *  Process the HTTP Post request
	 */
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    WebDoc doc = WebDoc.createPopup("Report - Post - Not Implemented");
    WebUtil.createResponse(request, response, this, null, doc, false);
}
Also used : WebDoc(org.compiere.util.WebDoc)

Example 47 with WebDoc

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

the class WReport method doGet.

//  init
/**
	 * Process the HTTP Get request
	 */
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    log.fine("doGet");
    log.info(response.toString());
    WebSessionCtx wsc = WebSessionCtx.get(request);
    WWindowStatus ws = WWindowStatus.get(request);
    m_curTab = ws.curTab;
    //
    WebDoc doc = null;
    File file = null;
    if (ws == null) {
        doc = WebDoc.createPopup("No Context");
        doc.addPopupClose(wsc.ctx);
    } else /**else if (fileName!=null)
		{			
			int AD_PInstance_ID = WebUtil.getParameterAsInt(request, "AD_PInstance_ID");
			File file = new File (fileName);
			String error = WebUtil.streamFile(response, file);
			if (error == null)
				return;
			doc = WebDoc.createWindow(error);
		}**/
    {
        log.info("");
        if (!MRole.getDefault().isCanReport(ws.curTab.getAD_Table_ID())) {
            doc = WebDoc.createPopup("Access Cannot Report");
            doc.addPopupClose(wsc.ctx);
        }
        //	Query
        MQuery query = new MQuery(m_curTab.getTableName());
        //	Link for detail records
        String queryColumn = m_curTab.getLinkColumnName();
        //	Current row otherwise
        if (queryColumn.length() == 0)
            queryColumn = m_curTab.getKeyColumnName();
        //	Find display
        String infoName = null;
        String infoDisplay = null;
        for (int i = 0; i < m_curTab.getFieldCount(); i++) {
            GridField field = m_curTab.getField(i);
            if (field.isKey())
                infoName = field.getHeader();
            if ((field.getColumnName().equals("Name") || field.getColumnName().equals("DocumentNo")) && field.getValue() != null)
                infoDisplay = field.getValue().toString();
            if (infoName != null && infoDisplay != null)
                break;
        }
        if (queryColumn.length() != 0) {
            if (queryColumn.endsWith("_ID"))
                query.addRestriction(queryColumn, MQuery.EQUAL, new Integer(Env.getContextAsInt(wsc.ctx, m_curTab.getWindowNo(), queryColumn)), infoName, infoDisplay);
            else
                query.addRestriction(queryColumn, MQuery.EQUAL, Env.getContext(wsc.ctx, m_curTab.getWindowNo(), queryColumn), infoName, infoDisplay);
        }
        file = getPrintFormats(m_curTab.getAD_Table_ID(), request, m_curTab, query);
        String error = WebUtil.streamFile(response, file);
        if (error == null)
            return;
        doc = WebDoc.createWindow(error);
    }
    //
    WebUtil.createResponse(request, response, this, null, doc, false);
}
Also used : WebDoc(org.compiere.util.WebDoc) MQuery(org.compiere.model.MQuery) GridField(org.compiere.model.GridField) WebSessionCtx(org.compiere.util.WebSessionCtx) File(java.io.File)

Example 48 with WebDoc

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

the class StoreFilter method doFilter.

//	destroy
/**
	 * 	Filter
	 *	@param request request
	 *	@param response response
	 *	@param chain chain
	 *	@throws IOException 
	 *	@throws ServletException
	 */
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
    //  Get URI
    String uri = "";
    if (request instanceof HttpServletRequest) {
        HttpServletRequest req = (HttpServletRequest) request;
        uri = req.getRequestURI();
    }
    //  Ignore static content
    boolean check = uri.indexOf("Servlet") != -1;
    boolean pass = true;
    // We need to check
    if (check) {
        String enc = request.getCharacterEncoding();
        try {
            enc = request.getCharacterEncoding();
            if (enc == null)
                request.setCharacterEncoding(WebEnv.ENCODING);
            if (enc == null)
                log.finer("Checked=" + uri);
            else
                log.finer("Checked=" + uri + " - Enc=" + enc);
        } catch (Exception e) {
            log.log(Level.SEVERE, "Set CharacterEndocung=" + enc + "->" + WebEnv.ENCODING, e);
        }
    }
    //  **  Start   **
    if (pass)
        chain.doFilter(request, response);
    else {
        log.warning("Rejected " + uri);
        String msg = "Error: Access Rejected";
        WebDoc doc = WebDoc.create(msg);
        //	Body
        body b = doc.getBody();
        b.addElement(new p(uri, AlignType.CENTER));
        //	fini
        response.setContentType("text/html");
        PrintWriter out = new PrintWriter(response.getOutputStream());
        doc.output(out);
        out.close();
    }
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) org.apache.ecs.xhtml.p(org.apache.ecs.xhtml.p) WebDoc(org.compiere.util.WebDoc) org.apache.ecs.xhtml.body(org.apache.ecs.xhtml.body) ServletException(javax.servlet.ServletException) IOException(java.io.IOException) PrintWriter(java.io.PrintWriter)

Example 49 with WebDoc

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

the class WFieldUpdate method doPost.

//  doPost
/**
	 *  Process the HTTP Post request
	 *  @param request
	 *  @param response
	 *  @throws ServletException
	 *  @throws IOException
	 */
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    //  Get Session Info
    WebSessionCtx wsc = WebSessionCtx.get(request);
    WWindowStatus ws = WWindowStatus.get(request);
    if (//  ws can be null for Login
    wsc == null || ws == null)
        ;
    //  Get Parameter
    String formName = WebUtil.getParameter(request, FIELD_FORM);
    String fieldName = WebUtil.getParameter(request, FIELD_NAME);
    String fieldValue = WebUtil.getParameter(request, FIELD_VALUE);
    String locationValue = WebUtil.getParameter(request, LOCATION_VALUE);
    log.info("doPost - Form=" + formName + " - Field=" + fieldName + " - Value=" + fieldValue + " - Location=" + locationValue);
    //  Document
    WebDoc doc = createPage(wsc, ws, formName, fieldName, fieldValue, locationValue);
    //  The Form
    form fu = new form(request.getRequestURI());
    fu.setName(FORM_NAME);
    fu.addElement(new input(input.TYPE_HIDDEN, FIELD_FORM, "y"));
    fu.addElement(new input(input.TYPE_HIDDEN, FIELD_NAME, "y"));
    fu.addElement(new input(input.TYPE_HIDDEN, FIELD_VALUE, "y"));
    fu.addElement(new input(input.TYPE_HIDDEN, LOCATION_VALUE, locationValue));
    doc.getBody().addElement(fu);
    //	log.trace(log.l1_User, "WFieldUpdate=" + doc.toString());
    //  Answer
    WebUtil.createResponse(request, response, this, null, doc, false);
}
Also used : 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) WebSessionCtx(org.compiere.util.WebSessionCtx)

Example 50 with WebDoc

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

the class WFieldUpdate method createPage.

//  doPost
/**
	 *	Create Reply.
	 *  <p>
	 *  Including special handling of login pages
	 *  @param wsc web session context
	 *  @param ws window status
	 *  @param formName
	 *  @param fieldName
	 *  @param fieldValue
	 */
private static WebDoc createPage(WebSessionCtx wsc, WWindowStatus ws, String formName, String fieldName, String fieldValue, String locationValue) {
    // plain
    WebDoc doc = WebDoc.create(true);
    body body = doc.getBody();
    log.info("Location-createpage: " + locationValue);
    //  Info
    StringBuffer sb = new StringBuffer("FieldUpdate - ").append(FIELD_FORM).append("=").append(formName).append(", ").append(FIELD_NAME).append("=").append(fieldName).append(", ").append(FIELD_VALUE).append("=").append(fieldValue).append(LOCATION_VALUE).append("=").append(locationValue);
    body.addElement(new p().addElement(sb.toString()));
    //  Called manually - do nothing
    if (formName == null || fieldName == null)
        ;
    else //
    if (formName.equals("Login2") && fieldName.equals(WLogin.P_ROLE))
        reply_Login2_Role(body, wsc, formName, fieldValue, locationValue);
    else //
    if (formName.equals("Login2") && fieldName.equals(WLogin.P_CLIENT))
        reply_Login2_Client(body, wsc, formName, fieldValue, locationValue);
    else //
    if (formName.equals("Login2") && fieldName.equals(WLogin.P_ORG))
        reply_Login2_Org(body, wsc, ws, formName, fieldValue, locationValue);
    //
    return doc;
}
Also used : org.apache.ecs.xhtml.p(org.apache.ecs.xhtml.p) WebDoc(org.compiere.util.WebDoc) org.apache.ecs.xhtml.body(org.apache.ecs.xhtml.body)

Aggregations

WebDoc (org.compiere.util.WebDoc)58 WebSessionCtx (org.compiere.util.WebSessionCtx)21 HttpSession (javax.servlet.http.HttpSession)13 org.apache.ecs.xhtml.td (org.apache.ecs.xhtml.td)13 org.apache.ecs.xhtml.p (org.apache.ecs.xhtml.p)12 org.apache.ecs.xhtml.tr (org.apache.ecs.xhtml.tr)12 org.apache.ecs.xhtml.table (org.apache.ecs.xhtml.table)11 org.apache.ecs.xhtml.body (org.apache.ecs.xhtml.body)9 org.apache.ecs.xhtml.input (org.apache.ecs.xhtml.input)9 org.apache.ecs.xhtml.form (org.apache.ecs.xhtml.form)8 org.apache.ecs.xhtml.script (org.apache.ecs.xhtml.script)7 Timestamp (java.sql.Timestamp)6 org.apache.ecs.xhtml.a (org.apache.ecs.xhtml.a)6 GridField (org.compiere.model.GridField)5 SQLException (java.sql.SQLException)4 org.apache.ecs.xhtml.i (org.apache.ecs.xhtml.i)4 File (java.io.File)3 IOException (java.io.IOException)3 Properties (java.util.Properties)3 ServletException (javax.servlet.ServletException)3