From d5a839d4a3e0338b7bf8d2d328c29f7d30594576 Mon Sep 17 00:00:00 2001 From: hieplq Date: Tue, 1 Oct 2013 01:37:02 +0700 Subject: [PATCH] NPE when empty language --- .../org/adempiere/webui/panel/LoginPanel.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/LoginPanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/LoginPanel.java index 58cdc7ecef..7c4d3e5908 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/LoginPanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/LoginPanel.java @@ -120,7 +120,8 @@ public class LoginPanel extends Window implements EventListener protected A btnResetPassword; protected ConfirmPanel pnlButtons; protected boolean email_login = MSysConfig.getBooleanValue(MSysConfig.USE_EMAIL_FOR_LOGIN, false); - + protected String vailidLstLanguage = null; + public LoginPanel(Properties ctx, LoginWindow loginWindow) { this.ctx = ctx; @@ -379,6 +380,10 @@ public class LoginPanel extends Window implements EventListener btnResetPassword = new A(Msg.getMsg(Language.getBaseAD_Language(), "ForgotMyPassword")); btnResetPassword.setId("btnResetPassword"); + + if (lstLanguage.getItems().size() > 0){ + vailidLstLanguage = (String)lstLanguage.getItems().get(0).getLabel(); + } } public void onEvent(Event event) @@ -395,9 +400,14 @@ public class LoginPanel extends Window implements EventListener } else if (event.getName().equals(Events.ON_SELECT)) { - if(eventComp.getId().equals(lstLanguage.getId())) { - String langName = (String) lstLanguage.getSelectedItem().getLabel(); - languageChanged(langName); + if(eventComp.getId().equals(lstLanguage.getId())) { + if (lstLanguage.getSelectedItem() == null){ + lstLanguage.setValue(vailidLstLanguage); + }else{ + vailidLstLanguage = lstLanguage.getSelectedItem().getLabel(); + } + + languageChanged(vailidLstLanguage); } } else if (event.getTarget() == btnResetPassword)