Search in sources :

Example 21 with Login

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

the class WFieldUpdate method reply_Login2_Client.

//  reply_Login2_Role
/**
	 *  Login 2nd page Response - Field Client.
	 *  <p>
	 *  fill Org & Warehouse -
	 *  @param body body
	 *  @param wsc context
	 *  @param formName form name
	 *  @param fieldValue value
	 */
private static void reply_Login2_Client(body body, MobileSessionCtx wsc, String formName, String fieldValue, String locationValue) {
    log.info("Location-Client: " + locationValue);
    //  Formname
    String form = null;
    //if (locationValue!=null)
    form = locationValue + MobileEnv.TARGET_WINDOW + ".document." + formName + ".";
    //else
    //form = "top." + WebEnv.TARGET_WINDOW + ".document." + formName + ".";		
    StringBuffer script = new StringBuffer();
    //log.info("form_client->"+form);
    //  Set Organization ----
    //  var A=top.WWindow.document.formName.selectName.options;
    script.append("var B=").append(form).append(WLogin.P_ORG).append(".options; ");
    //  A.length=0;                         //  resets options
    script.append("B.length=0; ");
    //  A[0]=new Option('text','value');    //  add new oprtion
    KeyNamePair client = new KeyNamePair(Integer.parseInt(fieldValue), fieldValue);
    Login login = new Login(wsc.ctx);
    KeyNamePair[] orgs = login.getOrgs(client);
    for (int i = 0; i < orgs.length; i++) {
        KeyNamePair p = orgs[i];
        script.append("B[").append(i).append("]=new Option('");
        //  text
        script.append(p.getName());
        script.append("','");
        //  value
        script.append(p.getKey());
        script.append("'); ");
    }
    script.append("\n");
    //  Set Warehouse ----
    //  var A=top.WWindow.document.formName.selectName.options;
    script.append("var C=").append(form).append(WLogin.P_WAREHOUSE).append(".options; ");
    //  A.length=0;                         //  resets options
    script.append("C.length=0; ");
    //  A[0]=new Option('text','value');    //  add new oprtion
    KeyNamePair[] whs = login.getWarehouses(orgs[0]);
    if (whs != null) {
        for (int i = 0; i < whs.length; i++) {
            KeyNamePair p = whs[i];
            script.append("C[").append(i).append("]=new Option('");
            //  text
            script.append(p.getName());
            script.append("','");
            //  value
            script.append(p.getKey());
            script.append("'); ");
        }
    }
    //  add script
    body.addElement(new p().addElement(WLogin.P_WAREHOUSE + "="));
    body.addElement(new script(script.toString()));
//	log.trace(log.l6_Database, "Login2-Client - Script=" + script.toString());
}
Also used : org.apache.ecs.xhtml.p(org.apache.ecs.xhtml.p) KeyNamePair(org.compiere.util.KeyNamePair) Login(org.compiere.util.Login) org.apache.ecs.xhtml.script(org.apache.ecs.xhtml.script)

Example 22 with Login

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

the class WFieldUpdate method reply_Login2_Role.

//  getReply
/**
	 *  Login 2nd page Response - Field Role.
	 *  <p>
	 *  fill Client, Org, Warehouse
	 *  @param body document body
	 *  @param wsc web session context
	 *  @param formName
	 *  @param fieldValue
	 */
private static void reply_Login2_Role(body body, MobileSessionCtx wsc, String formName, String fieldValue, String locationValue) {
    //  Formname
    String form = null;
    log.info("Location-Role: " + locationValue);
    //if (locationValue!=null)
    form = locationValue + MobileEnv.TARGET_WINDOW + ".document.forms." + formName + ".";
    //else
    //form = "top." + WebEnv.TARGET_WINDOW + ".document.forms." + formName + ".";
    //log.info("form_role->"+form);
    Login login = new Login(wsc.ctx);
    //  Get Data
    KeyNamePair[] clients = login.getClients(new KeyNamePair(Integer.parseInt(fieldValue), fieldValue));
    //  Set Client ----
    StringBuffer script = new StringBuffer();
    //  var A=top.WWindow.document.formName.selectName.options;
    script.append("var A=").append(form).append(WLogin.P_CLIENT).append(".options; ");
    //  A.length=0;                         //  resets options
    script.append("A.length=0; ");
    for (int i = 0; i < clients.length; i++) {
        KeyNamePair p = clients[i];
        script.append("A[").append(i).append("]=new Option('");
        //  text
        script.append(p.getName());
        script.append("','");
        //  value
        script.append(p.getKey());
        script.append("'); ");
    }
    script.append("\n");
    if (clients.length > 0) {
        //  var A=top.WWindow.document.formName.selectName.options;
        script.append("var B=").append(form).append(WLogin.P_ORG).append(".options; ");
        //  A.length=0;                         //  resets options
        script.append("B.length=0; ");
        //  A[0]=new Option('text','value');    //  add new oprtion
        KeyNamePair[] orgs = login.getOrgs(clients[0]);
        for (int i = 0; i < orgs.length; i++) {
            KeyNamePair p = orgs[i];
            script.append("B[").append(i).append("]=new Option('");
            //  text
            script.append(p.getName());
            script.append("','");
            //  value
            script.append(p.getKey());
            script.append("'); ");
        }
        script.append("\n");
        if (orgs.length > 0) {
            //  var A=top.WWindow.document.formName.selectName.options;
            script.append("var C=").append(form).append(WLogin.P_WAREHOUSE).append(".options; ");
            //  A.length=0;                         //  resets options
            script.append("C.length=0; ");
            //  A[0]=new Option('text','value');    //  add new oprtion
            KeyNamePair[] whs = login.getWarehouses(orgs[0]);
            if (whs != null) {
                for (int i = 0; i < whs.length; i++) {
                    KeyNamePair p = whs[i];
                    script.append("C[").append(i).append("]=new Option('");
                    //  text
                    script.append(p.getName());
                    script.append("','");
                    //  value
                    script.append(p.getKey());
                    script.append("'); ");
                }
            }
        }
    //	we have a org
    }
    //	we have a client
    //  add script
    body.addElement(new p().addElement(WLogin.P_CLIENT + "="));
    body.addElement(new script(script.toString()));
//	log.trace(log.l6_Database, "reply_Login2_Role - Script=" + script.toString());
}
Also used : org.apache.ecs.xhtml.p(org.apache.ecs.xhtml.p) Login(org.compiere.util.Login) KeyNamePair(org.compiere.util.KeyNamePair) org.apache.ecs.xhtml.script(org.apache.ecs.xhtml.script)

Example 23 with Login

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

the class WFieldUpdate method reply_Login2_Org.

//  reply_Login2_Client
/**
	 *  Login 2nd page Response - Field Org.
	 *  <p>
	 *  fill Warehouse
	 *  @param body document body
	 *  @param wsc web session context
	 *  @param formName
	 *  @param fieldValue
	 */
private static void reply_Login2_Org(body body, MobileSessionCtx wsc, WWindowStatus ws, String formName, String fieldValue, String locationValue) {
    //  Formname
    String form = null;
    log.info("Location-Org: " + locationValue);
    //if (locationValue!=null)
    form = locationValue + MobileEnv.TARGET_WINDOW + ".document." + formName + ".";
    //else
    //form = "top." + WebEnv.TARGET_WINDOW + ".document." + formName + ".";
    //log.info("form_org->"+form);
    StringBuffer script = new StringBuffer();
    //  Set Warehouse ----
    //  var A=top.WWindow.document.formName.selectName.options;
    script.append("var C=").append(form).append(WLogin.P_WAREHOUSE).append(".options; ");
    //  A.length=0;                         //  resets options
    script.append("C.length=0; ");
    //  A[0]=new Option('text','value');    //  add new oprtion
    KeyNamePair org = new KeyNamePair(Integer.parseInt(fieldValue), fieldValue);
    Login login = new Login(wsc.ctx);
    String error = login.validateLogin(org);
    if (error != null && error.length() > 0) {
        //todo graceful dead
        log.severe(error);
        ws.mWindow = null;
        wsc.ctx = new Properties();
        return;
    }
    KeyNamePair[] whs = login.getWarehouses(org);
    if (whs != null) {
        for (int i = 0; i < whs.length; i++) {
            KeyNamePair p = whs[i];
            script.append("C[").append(i).append("]=new Option('");
            //  text
            script.append(p.getName());
            script.append("','");
            //  value
            script.append(p.getKey());
            script.append("'); ");
        }
    }
    //  add script
    body.addElement(new p().addElement(WLogin.P_WAREHOUSE + "="));
    body.addElement(new script(script.toString()));
//	log.trace(log.l6_Database, "Login2-Org - Script=" + script.toString());
}
Also used : org.apache.ecs.xhtml.p(org.apache.ecs.xhtml.p) KeyNamePair(org.compiere.util.KeyNamePair) Login(org.compiere.util.Login) Properties(java.util.Properties) org.apache.ecs.xhtml.script(org.apache.ecs.xhtml.script)

Example 24 with Login

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

the class LoginDynUpdate method reply_Login2_Org.

//  reply_Login2_Client
/**
	 *  Login 2nd page Response - Field Org.
	 *  <p>
	 *  fill Warehouse
	 *  @param body document body
	 *  @param wsc web session context
	 *  @param formName
	 *  @param fieldValue
	 */
private static void reply_Login2_Org(body body, MobileSessionCtx wsc, WWindowStatus ws, String formName, String fieldValue, String locationValue) {
    //  Formname
    String form = null;
    log.info("Location-Org: " + locationValue);
    //if (locationValue!=null)
    form = locationValue + MobileEnv.TARGET_WINDOW + ".document." + formName + ".";
    //else
    //form = "top." + WebEnv.TARGET_WINDOW + ".document." + formName + ".";
    //log.info("form_org->"+form);
    StringBuffer script = new StringBuffer();
    //  Set Warehouse ----
    //  var A=top.WWindow.document.formName.selectName.options;
    script.append("var C=").append(form).append(WLogin.P_WAREHOUSE).append(".options; ");
    //  A.length=0;                         //  resets options
    script.append("C.length=0; ");
    //  A[0]=new Option('text','value');    //  add new oprtion
    KeyNamePair org = new KeyNamePair(Integer.parseInt(fieldValue), fieldValue);
    Login login = new Login(wsc.ctx);
    String error = login.validateLogin(org);
    if (error != null && error.length() > 0) {
        //todo graceful dead
        log.severe(error);
        ws.mWindow = null;
        wsc.ctx = new Properties();
        return;
    }
    KeyNamePair[] whs = login.getWarehouses(org);
    if (whs != null) {
        for (int i = 0; i < whs.length; i++) {
            KeyNamePair p = whs[i];
            script.append("C[").append(i).append("]=new Option('");
            //  text
            script.append(p.getName());
            script.append("','");
            //  value
            script.append(p.getKey());
            script.append("'); ");
        }
    }
    //  add script
    body.addElement(new p().addElement(WLogin.P_WAREHOUSE + "="));
    body.addElement(new script(script.toString()));
//	log.trace(log.l6_Database, "Login2-Org - Script=" + script.toString());
}
Also used : org.apache.ecs.xhtml.p(org.apache.ecs.xhtml.p) KeyNamePair(org.compiere.util.KeyNamePair) Login(org.compiere.util.Login) Properties(java.util.Properties) org.apache.ecs.xhtml.script(org.apache.ecs.xhtml.script)

Example 25 with Login

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

the class LoginDynUpdate method reply_Login2_Client.

//  reply_Login2_Role
/**
	 *  Login 2nd page Response - Field Client.
	 *  <p>
	 *  fill Org & Warehouse -
	 *  @param body body
	 *  @param wsc context
	 *  @param formName form name
	 *  @param fieldValue value
	 */
private static void reply_Login2_Client(body body, MobileSessionCtx wsc, String formName, String fieldValue, String locationValue) {
    log.info("Location-Client: " + locationValue);
    //  Formname
    String form = null;
    //if (locationValue!=null)
    form = locationValue + MobileEnv.TARGET_WINDOW + ".document." + formName + ".";
    //else
    //form = "top." + WebEnv.TARGET_WINDOW + ".document." + formName + ".";		
    StringBuffer script = new StringBuffer();
    //log.info("form_client->"+form);
    //  Set Organization ----
    //  var A=top.WWindow.document.formName.selectName.options;
    script.append("var B=").append(form).append(WLogin.P_ORG).append(".options; ");
    //  A.length=0;                         //  resets options
    script.append("B.length=0; ");
    //  A[0]=new Option('text','value');    //  add new oprtion
    KeyNamePair client = new KeyNamePair(Integer.parseInt(fieldValue), fieldValue);
    Login login = new Login(wsc.ctx);
    KeyNamePair[] orgs = login.getOrgs(client);
    for (int i = 0; i < orgs.length; i++) {
        KeyNamePair p = orgs[i];
        script.append("B[").append(i).append("]=new Option('");
        //  text
        script.append(p.getName());
        script.append("','");
        //  value
        script.append(p.getKey());
        script.append("'); ");
    }
    script.append("\n");
    //  Set Warehouse ----
    //  var A=top.WWindow.document.formName.selectName.options;
    script.append("var C=").append(form).append(WLogin.P_WAREHOUSE).append(".options; ");
    //  A.length=0;                         //  resets options
    script.append("C.length=0; ");
    //  A[0]=new Option('text','value');    //  add new oprtion
    KeyNamePair[] whs = login.getWarehouses(orgs[0]);
    if (whs != null) {
        for (int i = 0; i < whs.length; i++) {
            KeyNamePair p = whs[i];
            script.append("C[").append(i).append("]=new Option('");
            //  text
            script.append(p.getName());
            script.append("','");
            //  value
            script.append(p.getKey());
            script.append("'); ");
        }
    }
    //  add script
    body.addElement(new p().addElement(WLogin.P_WAREHOUSE + "="));
    body.addElement(new script(script.toString()));
//	log.trace(log.l6_Database, "Login2-Client - Script=" + script.toString());
}
Also used : org.apache.ecs.xhtml.p(org.apache.ecs.xhtml.p) KeyNamePair(org.compiere.util.KeyNamePair) Login(org.compiere.util.Login) org.apache.ecs.xhtml.script(org.apache.ecs.xhtml.script)

Aggregations

Login (org.compiere.util.Login)29 KeyNamePair (org.compiere.util.KeyNamePair)22 org.apache.ecs.xhtml.p (org.apache.ecs.xhtml.p)8 org.apache.ecs.xhtml.script (org.apache.ecs.xhtml.script)8 Properties (java.util.Properties)6 SQLException (java.sql.SQLException)5 IOException (java.io.IOException)4 PreparedStatement (java.sql.PreparedStatement)4 ResultSet (java.sql.ResultSet)4 Timestamp (java.sql.Timestamp)4 ServletException (javax.servlet.ServletException)3 Principal (java.security.Principal)2 ArrayList (java.util.ArrayList)2 HttpSession (javax.servlet.http.HttpSession)2 Language (org.compiere.util.Language)2 PrintWriter (java.io.PrintWriter)1 AccessException (java.rmi.AccessException)1 Callback (javax.security.auth.callback.Callback)1 NameCallback (javax.security.auth.callback.NameCallback)1 PasswordCallback (javax.security.auth.callback.PasswordCallback)1