Search in sources :

Example 16 with WebDoc

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

the class WHelp method doPost.

public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    WebDoc doc = WebDoc.create("Help - Post - Not Implemented");
    WebUtil.createResponse(request, response, this, null, doc, false);
}
Also used : WebDoc(org.compiere.util.WebDoc)

Example 17 with WebDoc

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

the class WLocation method doGet.

/**
	 * Process the HTTP Get request - initial Start
	 * Needs to have parameters FormName and ColumnName
	 *
	 * @param request request
	 * @param response response
	 * @throws ServletException
	 * @throws IOException
	 */
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    log.fine("");
    HttpSession sess = request.getSession();
    WWindowStatus ws = WWindowStatus.get(request);
    if (ws == null) {
        WebUtil.createTimeoutPage(request, response, this, null);
        return;
    }
    //  Get Mandatory Parameters
    String columnName = WebUtil.getParameter(request, "ColumnName");
    log.info("ColumnName=" + columnName + " - " + ws.toString());
    //
    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;
    }
    MLocation location = null;
    Object value = mField.getValue();
    if (value != null && value instanceof Integer)
        location = new MLocation(ws.ctx, ((Integer) value).intValue(), null);
    else
        location = new MLocation(ws.ctx, 0, null);
    //String targetBase = "parent.WWindow." + WWindow.FORM_NAME + "." + columnName;
    String targetBase = "opener.WWindow." + WWindow.FORM_NAME + "." + columnName;
    String action = request.getRequestURI();
    //  Create Document
    WebDoc doc = WebDoc.createPopup(mField.getHeader());
    doc.addPopupClose(ws.ctx);
    boolean hasDependents = ws.curTab.hasDependants(columnName);
    boolean hasCallout = mField.getCallout().length() > 0;
    //  Reset
    button reset = new button();
    //  translate
    reset.addElement("Reset");
    String script = targetBase + "D.value='';" + targetBase + "F.value='';closePopup();";
    if (hasDependents || hasCallout)
        script += "startUpdate(" + targetBase + "F);";
    reset.setOnClick(script);
    //
    doc.getTable().addElement(new tr().addElement(fillForm(ws, action, location, targetBase, hasDependents || hasCallout)).addElement(reset));
    //
    doc.addPopupClose(ws.ctx);
    //	log.trace(log.l6_Database, doc.toString());
    WebUtil.createResponse(request, response, this, null, doc, true);
}
Also used : org.apache.ecs.xhtml.button(org.apache.ecs.xhtml.button) HttpSession(javax.servlet.http.HttpSession) WebDoc(org.compiere.util.WebDoc) GridField(org.compiere.model.GridField) MLocation(org.compiere.model.MLocation) org.apache.ecs.xhtml.tr(org.apache.ecs.xhtml.tr)

Example 18 with WebDoc

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

the class WLocation method doPost.

//  doGet
/**
	 *  Process the HTTP Post request (update Address)
	 *
	 *  @param request request
	 *  @param response response
	 *  @throws ServletException
	 *  @throws IOException
	 */
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    log.fine("");
    HttpSession sess = request.getSession();
    WWindowStatus ws = WWindowStatus.get(request);
    if (ws == null) {
        WebUtil.createTimeoutPage(request, response, this, null);
        return;
    }
    int C_Location_ID = WebUtil.getParameterAsInt(request, P_C_LOCATION_ID);
    String targetBase = "opener.WWindow." + WWindow.FORM_NAME + ".C_Location_ID";
    //  Create Location
    MLocation location = new MLocation(ws.ctx, C_Location_ID, null);
    log.fine("doPost updating C_Location_ID=" + C_Location_ID + " - " + targetBase);
    location.setAddress1(WebUtil.getParameter(request, P_ADDRESS1));
    location.setAddress2(WebUtil.getParameter(request, P_ADDRESS2));
    location.setAddress3(WebUtil.getParameter(request, P_ADDRESS3));
    location.setAddress4(WebUtil.getParameter(request, P_ADDRESS4));
    location.setCity(WebUtil.getParameter(request, P_CITY));
    location.setPostal(WebUtil.getParameter(request, P_POSTAL));
    location.setC_Country_ID(WebUtil.getParameterAsInt(request, P_C_COUNTRY_ID));
    location.setC_Region_ID(WebUtil.getParameterAsInt(request, P_C_REGION_ID));
    System.out.println("location =========== " + location);
    //  Document
    WebDoc doc = WebDoc.createPopup("WLocation");
    doc.addPopupClose(ws.ctx);
    //  Save Location
    location.saveEx();
    C_Location_ID = location.getC_Location_ID();
    td center = doc.addPopupCenter(false);
    if (C_Location_ID == 0)
        center.addElement(new p(new b("ERROR - Location=0")));
    center.addElement(new p().addElement(location.toString()));
    //  Update Target
    script script = new script(new StringBuffer().append(targetBase).append("D.value='").append(C_Location_ID).append("';").append(targetBase).append("F.value='").append(location.toString()).append("';closePopup();").toString());
    doc.getBody().addElement(script);
    log.fine("script=" + script.toString());
    //
    form myForm = null;
    myForm = new form();
    table table = new table();
    table.setID("WLocation");
    button button = new button();
    button.addElement("ok");
    StringBuffer script2 = new StringBuffer();
    String targetBase2 = "opener.document.WForm.C_Location_ID";
    script2.append(targetBase2).append("D.value='").append(C_Location_ID).append("';").append(targetBase2).append("F.value='").append(location.toString()).append("';submit();window.close();");
    button.setOnClick(script2.toString());
    table.addElement(button);
    myForm.addElement(table);
    doc.getTable().addElement(myForm);
    WebUtil.createResponse(request, response, this, null, doc, true);
}
Also used : org.apache.ecs.xhtml.b(org.apache.ecs.xhtml.b) HttpSession(javax.servlet.http.HttpSession) 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.button(org.apache.ecs.xhtml.button) org.apache.ecs.xhtml.form(org.apache.ecs.xhtml.form) WebDoc(org.compiere.util.WebDoc) MLocation(org.compiere.model.MLocation) org.apache.ecs.xhtml.table(org.apache.ecs.xhtml.table)

Example 19 with WebDoc

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

the class WLogin method doPost.

//	doGet
/**
	 *	Process the HTTP Post request.
	 *  <pre>
	 *  - Optionally create Session
	 *  - Check database connection
	 *  - LoginInfo from request?
	 *      - Yes: DoLogin success ?
	 *          - Yes: return (second) preferences page
	 *          - No: return (first) user/password page
	 *      - No: User Principal ?
	 *          - Yes: DoLogin success ?
	 *              - Yes: return (second) preferences page
	 *              - No: return (first) user/password page
	 *          - No: return (first) user/password page
	 *  </pre>
	 *  @param request request
	 *  @param response response
	 *  @throws ServletException
	 *  @throws IOException
	 */
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    log.info("");
    //  Create New Session
    HttpSession sess = request.getSession(true);
    sess.setMaxInactiveInterval(WebEnv.TIMEOUT);
    //  Get Cookie Properties
    Properties cProp = WebUtil.getCookieProprties(request);
    //  Create Context
    WebSessionCtx wsc = WebSessionCtx.get(request);
    //  Page
    WebDoc doc = null;
    //  Check DB connection
    if (!DB.isConnected()) {
        String msg = Msg.getMsg(wsc.ctx, "WLoginNoDB");
        if (msg.equals("WLoginNoDB"))
            msg = "No Database Connection";
        doc = WebDoc.createWindow(msg);
    } else //  Login Info from request?
    {
        //  Get Parameters:     UserName/Password
        String usr = WebUtil.getParameter(request, P_USERNAME);
        String pwd = WebUtil.getParameter(request, P_PASSWORD);
        //  Get Principle
        Principal userPrincipal = request.getUserPrincipal();
        log.info("Principal=" + userPrincipal + "; User=" + usr);
        //  Login info not from request and not pre-authorized
        if (userPrincipal == null && (usr == null || pwd == null))
            doc = createFirstPage(cProp, request, "");
        else //  Login info from request or authorized
        {
            KeyNamePair[] roles = null;
            Login login = new Login(wsc.ctx);
            //  Pre-authorized
            if (userPrincipal != null) {
                roles = login.getRoles(userPrincipal);
                usr = userPrincipal.getName();
            } else
                roles = login.getRoles(usr, pwd);
            //
            if (roles == null)
                doc = createFirstPage(cProp, request, Msg.getMsg(wsc.ctx, "UserPwdError"));
            else {
                doc = createSecondPage(request, WebUtil.convertToOption(roles, null), "");
                //	Create adempiere Session - user id in ctx
                MSession.get(wsc.ctx, request.getRemoteAddr(), request.getRemoteHost(), sess.getId());
            }
            //  Can we save Cookie ?
            if (WebUtil.getParameter(request, P_STORE) == null) {
                //  erase all
                cProp.clear();
            } else //  Save Cookie Parameter
            {
                cProp.setProperty(P_USERNAME, usr);
                cProp.setProperty(P_STORE, "Y");
                //  For test only
                cProp.setProperty(P_PASSWORD, pwd);
            }
        }
    }
    WebUtil.createResponse(request, response, this, cProp, doc, false);
}
Also used : HttpSession(javax.servlet.http.HttpSession) WebDoc(org.compiere.util.WebDoc) KeyNamePair(org.compiere.util.KeyNamePair) Login(org.compiere.util.Login) Properties(java.util.Properties) WebSessionCtx(org.compiere.util.WebSessionCtx) Principal(java.security.Principal)

Example 20 with WebDoc

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

the class WAttachment method createPage.

//  doPost
/**
	 * 	Create Attachment Page
	 * 	@param ctx context
	 *	@param AD_Attachment_ID id for existing attachment
	 *	@param AD_Table_ID table for new attachment
	 *	@param Record_ID record for new attachment
	 *	@param m_error optional m_error message
	 *	@return WebDoc
	 */
private WebDoc createPage(Properties ctx, MAttachment attachment, String error) {
    WebDoc doc = WebDoc.createPopup(Msg.translate(ctx, "AD_Attachment_ID"));
    table table = doc.getTable();
    //
    if (error != null) {
        table.addElement(new tr().addElement(new td("popupHeader", AlignType.RIGHT, AlignType.TOP, false, null)).addElement(new td("popupHeader", AlignType.LEFT, AlignType.TOP, false, //	window.css
        new p(error, AlignType.LEFT).setClass("Cerror"))));
    }
    //
    tr tr = new tr();
    td left = new td("popupCenter", AlignType.LEFT, AlignType.TOP, false, new label("TextMsg", "T", Msg.translate(ctx, "TextMsg")));
    //
    td right = new td("popupCenter", AlignType.LEFT, AlignType.TOP, false);
    //	Text Message Update
    form textMsg = new form("WAttachment");
    textMsg.addElement(new input(input.TYPE_HIDDEN, P_Attachment_ID, attachment.getAD_Attachment_ID()));
    textMsg.addElement(new input(input.TYPE_HIDDEN, "AD_Table_ID", attachment.getAD_Table_ID()));
    textMsg.addElement(new input(input.TYPE_HIDDEN, "Record_ID", attachment.getRecord_ID()));
    textarea msg = new textarea(P_TEXTMSG, 5, 40);
    msg.addElement(attachment.getTextMsg());
    textMsg.addElement(msg);
    textMsg.addElement(new br());
    //textMsg.addElement(new input (input.TYPE_SUBMIT, "submit", "Submit"));
    //Submit Button
    //String textbtn = "Submit";
    //String text = null;
    //if (ctx != null)
    //text = Msg.getMsg (ctx, "Submit");		
    //input submitbtn = new input(input.TYPE_SUBMIT, textbtn, "  "+text);		
    //submitbtn.setID(text);
    //submitbtn.setClass("submitbtn");
    //textMsg.addElement(submitbtn);
    right.addElement(textMsg);
    //	Existing Links
    p p = new p();
    MAttachmentEntry[] entries = attachment.getEntries();
    for (int i = 0; i < entries.length; i++) {
        MAttachmentEntry entry = entries[i];
        if (i > 0)
            p.addElement(" - ");
        String url = "WAttachment?" + P_Attachment_ID + "=" + attachment.getAD_Attachment_ID() + "&" + P_ATTACHMENT_INDEX + "=" + entry.getIndex();
        p.addElement(new a(url, null, a.TARGET_BLANK, entry.getName()));
    }
    right.addElement(p);
    //	Upload
    form upload = FileUpload.createForm("WAttachment");
    upload.addElement(new input(input.TYPE_HIDDEN, P_Attachment_ID, attachment.getAD_Attachment_ID()));
    upload.addElement(new input(input.TYPE_HIDDEN, "AD_Table_ID", attachment.getAD_Table_ID()));
    upload.addElement(new input(input.TYPE_HIDDEN, "Record_ID", attachment.getRecord_ID()));
    right.addElement(upload);
    //
    tr.addElement(left);
    tr.addElement(right);
    table.addElement(tr);
    //	Footer
    //Modified by Rob Klein 4/29/07
    doc.addPopupClose(ctx);
    //	System.out.println(doc);
    return doc;
}
Also used : org.apache.ecs.xhtml.textarea(org.apache.ecs.xhtml.textarea) org.apache.ecs.xhtml.a(org.apache.ecs.xhtml.a) MAttachmentEntry(org.compiere.model.MAttachmentEntry) org.apache.ecs.xhtml.textarea(org.apache.ecs.xhtml.textarea) org.apache.ecs.xhtml.label(org.apache.ecs.xhtml.label) org.apache.ecs.xhtml.td(org.apache.ecs.xhtml.td) org.apache.ecs.xhtml.p(org.apache.ecs.xhtml.p) org.apache.ecs.xhtml.br(org.apache.ecs.xhtml.br) 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)

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