Search in sources :

Example 6 with AuScript

use of org.zkoss.zk.au.out.AuScript in project adempiere by adempiere.

the class LoginPanel method validateLogin.

/**
     *  validates user name and password when logging in
     *
    **/
public void validateLogin() {
    Login login = new Login(ctx);
    String userId = txtUserId.getValue();
    String userPassword = txtPassword.getValue();
    //check is token
    String token = (String) txtPassword.getAttribute("user.token.hash");
    if (token != null && token.equals(userPassword)) {
        userPassword = "";
        int AD_Session_ID = (Integer) txtPassword.getAttribute("user.token.sid");
        MSession session = new MSession(Env.getCtx(), AD_Session_ID, null);
        if (session.get_ID() == AD_Session_ID) {
            MUser user = MUser.get(Env.getCtx(), session.getCreatedBy());
            if (BrowserToken.validateToken(session, user, token)) {
                userPassword = user.getPassword();
            }
        }
    }
    KeyNamePair[] rolesKNPairs = login.getRoles(userId, userPassword);
    if (rolesKNPairs == null || rolesKNPairs.length == 0)
        throw new WrongValueException("User Id or Password invalid!!!");
    else {
        String langName = null;
        if (lstLanguage.getSelectedItem() != null)
            langName = (String) lstLanguage.getSelectedItem().getLabel();
        else
            langName = Language.getBaseLanguage().getName();
        Language language = findLanguage(langName);
        wndLogin.loginOk(userId, userPassword);
        // Elaine 2009/02/06
        Env.setContext(ctx, UserPreference.LANGUAGE_NAME, language.getName());
        Locales.setThreadLocal(language.getLocale());
        String timeoutText = getUpdateTimeoutTextScript();
        if (!Strings.isEmpty(timeoutText))
            Clients.response("zkLocaleJavaScript2", new AuScript(null, timeoutText));
    }
    // This temporary validation code is added to check the reported bug
    // [ adempiere-ZK Web Client-2832968 ] User context lost?
    // https://sourceforge.net/tracker/?func=detail&atid=955896&aid=2832968&group_id=176962
    // it's harmless, if there is no bug then this must never fail
    Session currSess = Executions.getCurrent().getDesktop().getSession();
    currSess.setAttribute("Check_AD_User_ID", Env.getAD_User_ID(ctx));
    // End of temporary code for [ adempiere-ZK Web Client-2832968 ] User context lost?
    Env.setContext(ctx, BrowserToken.REMEMBER_ME, chkRememberMe.isChecked());
    /* Check DB version */
    String version = DB.getSQLValueString(null, "SELECT Version FROM AD_System");
    //  Identical DB version
    if (!Adempiere.DB_VERSION.equals(version)) {
        String AD_Message = "DatabaseVersionError";
        //  Code assumes Database version {0}, but Database has Version {1}.
        //  complete message
        String msg = Msg.getMsg(ctx, AD_Message);
        msg = MessageFormat.format(msg, new Object[] { Adempiere.DB_VERSION, version });
        throw new ApplicationException(msg);
    }
}
Also used : MSession(org.compiere.model.MSession) Login(org.compiere.util.Login) AuScript(org.zkoss.zk.au.out.AuScript) ApplicationException(org.adempiere.webui.exception.ApplicationException) Language(org.compiere.util.Language) KeyNamePair(org.compiere.util.KeyNamePair) MUser(org.compiere.model.MUser) WrongValueException(org.zkoss.zk.ui.WrongValueException) MSession(org.compiere.model.MSession) Session(org.zkoss.zk.ui.Session)

Example 7 with AuScript

use of org.zkoss.zk.au.out.AuScript in project adempiere by adempiere.

the class StatusBarPanel method showPopup.

private void showPopup() {
    popup.setVisible(true);
    popup.setStyle(popupStyle);
    /* TODO-evenos: zk 6 */
    String script = "var d = zk.Widget.$('" + popup.getUuid() + "').$n();";
    script += "d.style.display='block';d.style.visibility='hidden';";
    script += "var dhs = document.defaultView.getComputedStyle(d, null).getPropertyValue('height');";
    script += "var dh = parseInt(dhs, 10);";
    script += "var r = zk.Widget.$('" + getRoot().getUuid() + "').$n();";
    script += "var rhs = document.defaultView.getComputedStyle(r, null).getPropertyValue('height');";
    script += "var rh = parseInt(rhs, 10);";
    script += "var p = jq('#" + getRoot().getUuid() + "').zk.cmOffset();";
    script += "d.style.top=(rh-dh-5)+'px';";
    script += "d.style.left=(p[0]+1)+'px';";
    script += "d.style.visibility='visible';";
    AuScript aus = new AuScript(popup, script);
    Clients.response(aus);
}
Also used : AuScript(org.zkoss.zk.au.out.AuScript)

Example 8 with AuScript

use of org.zkoss.zk.au.out.AuScript in project adempiere by adempiere.

the class StatusBarPanel method setStatusLine.

/**
     * @param text
     * @param error
     * @param showPopup ignore for embedded
     */
public void setStatusLine(String text, boolean error, boolean showPopup) {
    statusLine.setText(text);
    if (error)
        statusLine.setStyle("color: red");
    else
        statusLine.setStyle("color: black");
    statusLine.setTooltiptext(text);
    if (showPopup && AEnv.isBrowserSupported()) {
        Text t = new Text(text);
        popupContent.getChildren().clear();
        popupContent.appendChild(t);
        popupContent.setStyle(POPUP_TEXT_STYLE);
        if (error) {
            popupStyle = POPUP_ERROR_BACKGROUND_STYLE;
        } else {
            popupStyle = POPUP_INFO_BACKGROUND_STYLE;
        }
        String shadow = SHADOW_STYLE;
        popupStyle = popupStyle + shadow + POPUP_POSITION_STYLE;
        showPopup();
        //auto hide
        /* TODO-evenos: ZK6 */
        String script = "setTimeout('zk.Widget.$(\"" + popup.getUuid() + "\").$n().style.display = \"none\"',";
        if (error)
            script += "3500";
        else
            script += "1000";
        script += ")";
        AuScript aus = new AuScript(popup, script);
        Clients.response("statusPopupFade", aus);
    }
}
Also used : Text(org.zkoss.zhtml.Text) AuScript(org.zkoss.zk.au.out.AuScript)

Example 9 with AuScript

use of org.zkoss.zk.au.out.AuScript in project adempiere by adempiere.

the class NavBarDesktop method autoHideMenu.

private void autoHideMenu() {
    if (layout.getWest().isCollapsible() && !layout.getWest().isOpen()) {
        //using undocumented js api, need to be retested after every version upgrade
        String id = layout.getWest().getUuid() + "!real";
        String btn = layout.getWest().getUuid() + "!btn";
        String script = "zk.show('" + id + "', false);";
        script += "$e('" + id + "')._isSlide = false;";
        script += "$e('" + id + "')._lastSize = null;";
        script += "$e('" + btn + "').style.display = '';";
        AuScript aus = new AuScript(layout.getWest(), script);
        Clients.response("autoHideWest", aus);
    }
}
Also used : AuScript(org.zkoss.zk.au.out.AuScript)

Example 10 with AuScript

use of org.zkoss.zk.au.out.AuScript in project adempiere by adempiere.

the class LayoutUtils method sendDeferLayoutEvent.

/**
	 * @param layout
	 */
public static void sendDeferLayoutEvent(Borderlayout layout, int timeout) {
    StringBuilder content = new StringBuilder();
    content.append("ad_deferRenderBorderLayout('").append(layout.getUuid()).append("',").append(timeout).append(");");
    AuScript as = new AuScript(null, content.toString());
    Clients.response("deferRenderBorderLayout", as);
}
Also used : AuScript(org.zkoss.zk.au.out.AuScript)

Aggregations

AuScript (org.zkoss.zk.au.out.AuScript)12 UnsupportedEncodingException (java.io.UnsupportedEncodingException)3 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)3 ApplicationException (org.adempiere.webui.exception.ApplicationException)1 MSession (org.compiere.model.MSession)1 MUser (org.compiere.model.MUser)1 KeyNamePair (org.compiere.util.KeyNamePair)1 Language (org.compiere.util.Language)1 Login (org.compiere.util.Login)1 Text (org.zkoss.zhtml.Text)1 AbstractComponent (org.zkoss.zk.ui.AbstractComponent)1 Component (org.zkoss.zk.ui.Component)1 HtmlBasedComponent (org.zkoss.zk.ui.HtmlBasedComponent)1 Session (org.zkoss.zk.ui.Session)1 WrongValueException (org.zkoss.zk.ui.WrongValueException)1 Div (org.zkoss.zul.Div)1