BF[2723605] date fields shown only in English format ("mm/dd/yyyy")
This commit is contained in:
parent
648979a759
commit
c020c9808c
|
@ -23,6 +23,7 @@ import java.util.Properties;
|
||||||
|
|
||||||
import javax.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
|
import org.adempiere.webui.apps.AEnv;
|
||||||
import org.adempiere.webui.desktop.DefaultDesktop;
|
import org.adempiere.webui.desktop.DefaultDesktop;
|
||||||
import org.adempiere.webui.desktop.IDesktop;
|
import org.adempiere.webui.desktop.IDesktop;
|
||||||
import org.adempiere.webui.session.SessionManager;
|
import org.adempiere.webui.session.SessionManager;
|
||||||
|
@ -51,7 +52,7 @@ import org.zkoss.zul.Window;
|
||||||
* @author <a href="mailto:agramdass@gmail.com">Ashley G Ramdass</a>
|
* @author <a href="mailto:agramdass@gmail.com">Ashley G Ramdass</a>
|
||||||
* @date Feb 25, 2007
|
* @date Feb 25, 2007
|
||||||
* @version $Revision: 0.10 $
|
* @version $Revision: 0.10 $
|
||||||
*
|
*
|
||||||
* @author hengsin
|
* @author hengsin
|
||||||
*/
|
*/
|
||||||
public class AdempiereWebUI extends Window implements EventListener, IWebClient
|
public class AdempiereWebUI extends Window implements EventListener, IWebClient
|
||||||
|
@ -69,19 +70,19 @@ public class AdempiereWebUI extends Window implements EventListener, IWebClient
|
||||||
private ClientInfo clientInfo;
|
private ClientInfo clientInfo;
|
||||||
|
|
||||||
private String langSession;
|
private String langSession;
|
||||||
|
|
||||||
private UserPreference userPreference;
|
private UserPreference userPreference;
|
||||||
|
|
||||||
private static final CLogger logger = CLogger.getCLogger(AdempiereWebUI.class);
|
private static final CLogger logger = CLogger.getCLogger(AdempiereWebUI.class);
|
||||||
|
|
||||||
public AdempiereWebUI()
|
public AdempiereWebUI()
|
||||||
{
|
{
|
||||||
this.addEventListener(Events.ON_CLIENT_INFO, this);
|
this.addEventListener(Events.ON_CLIENT_INFO, this);
|
||||||
this.setVisible(false);
|
this.setVisible(false);
|
||||||
|
|
||||||
userPreference = new UserPreference();
|
userPreference = new UserPreference();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onCreate()
|
public void onCreate()
|
||||||
{
|
{
|
||||||
this.getPage().setTitle(APP_NAME);
|
this.getPage().setTitle(APP_NAME);
|
||||||
|
@ -97,7 +98,7 @@ public class AdempiereWebUI extends Window implements EventListener, IWebClient
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
loginCompleted();
|
loginCompleted();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onOk()
|
public void onOk()
|
||||||
|
@ -113,48 +114,63 @@ public class AdempiereWebUI extends Window implements EventListener, IWebClient
|
||||||
*/
|
*/
|
||||||
public void loginCompleted()
|
public void loginCompleted()
|
||||||
{
|
{
|
||||||
if (loginDesktop != null)
|
if (loginDesktop != null)
|
||||||
{
|
{
|
||||||
loginDesktop.detach();
|
loginDesktop.detach();
|
||||||
loginDesktop = null;
|
loginDesktop = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Properties ctx = Env.getCtx();
|
Properties ctx = Env.getCtx();
|
||||||
String langLogin = Env.getContext(ctx, Env.LANGUAGE);
|
String langLogin = Env.getContext(ctx, Env.LANGUAGE);
|
||||||
if (langLogin == null || langLogin.length() <= 0) {
|
if (langLogin == null || langLogin.length() <= 0)
|
||||||
|
{
|
||||||
langLogin = langSession;
|
langLogin = langSession;
|
||||||
Env.setContext(ctx, Env.LANGUAGE, langSession);
|
Env.setContext(ctx, Env.LANGUAGE, langSession);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate language
|
// Validate language
|
||||||
Language language = Language.getLanguage(langLogin);
|
Language language = Language.getLanguage(langLogin);
|
||||||
|
String locale = Env.getContext(ctx, AEnv.LOCALE);
|
||||||
|
if (locale != null && locale.length() > 0 && !language.getLocale().toString().equals(locale))
|
||||||
|
{
|
||||||
|
String adLanguage = language.getAD_Language();
|
||||||
|
Language tmp = Language.getLanguage(locale);
|
||||||
|
language = new Language(tmp.getName(), adLanguage, tmp.getLocale(), tmp.isDecimalPoint(),
|
||||||
|
tmp.getDateFormat().toPattern(), tmp.getMediaSize());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Language tmp = language;
|
||||||
|
language = new Language(tmp.getName(), tmp.getAD_Language(), tmp.getLocale(), tmp.isDecimalPoint(),
|
||||||
|
tmp.getDateFormat().toPattern(), tmp.getMediaSize());
|
||||||
|
}
|
||||||
Env.verifyLanguage(ctx, language);
|
Env.verifyLanguage(ctx, language);
|
||||||
Env.setContext(ctx, Env.LANGUAGE, language.getAD_Language()); //Bug
|
Env.setContext(ctx, Env.LANGUAGE, language.getAD_Language()); //Bug
|
||||||
|
|
||||||
// Create adempiere Session - user id in ctx
|
// Create adempiere Session - user id in ctx
|
||||||
Session currSess = Executions.getCurrent().getDesktop().getSession();
|
Session currSess = Executions.getCurrent().getDesktop().getSession();
|
||||||
HttpSession httpSess = (HttpSession) currSess.getNativeSession();
|
HttpSession httpSess = (HttpSession) currSess.getNativeSession();
|
||||||
|
|
||||||
MSession.get (ctx, currSess.getRemoteAddr(),
|
MSession.get (ctx, currSess.getRemoteAddr(),
|
||||||
currSess.getRemoteHost(), httpSess.getId() );
|
currSess.getRemoteHost(), httpSess.getId() );
|
||||||
|
|
||||||
//enable full interface, relook into this when doing preference
|
//enable full interface, relook into this when doing preference
|
||||||
Env.setContext(ctx, "#ShowTrl", true);
|
Env.setContext(ctx, "#ShowTrl", true);
|
||||||
Env.setContext(ctx, "#ShowAcct", true);
|
Env.setContext(ctx, "#ShowAcct", true);
|
||||||
Env.setContext(ctx, "#ShowAdvanced", true);
|
Env.setContext(ctx, "#ShowAdvanced", true);
|
||||||
|
|
||||||
String autoCommit = userPreference.getProperty(UserPreference.P_AUTO_COMMIT);
|
String autoCommit = userPreference.getProperty(UserPreference.P_AUTO_COMMIT);
|
||||||
Env.setAutoCommit(ctx, "true".equalsIgnoreCase(autoCommit) || "y".equalsIgnoreCase(autoCommit));
|
Env.setAutoCommit(ctx, "true".equalsIgnoreCase(autoCommit) || "y".equalsIgnoreCase(autoCommit));
|
||||||
|
|
||||||
IDesktop d = (IDesktop) currSess.getAttribute("application.desktop");
|
IDesktop d = (IDesktop) currSess.getAttribute("application.desktop");
|
||||||
if (d != null && d instanceof IDesktop)
|
if (d != null && d instanceof IDesktop)
|
||||||
{
|
{
|
||||||
ExecutionCarryOver eco = (ExecutionCarryOver) currSess.getAttribute("execution.carryover");
|
ExecutionCarryOver eco = (ExecutionCarryOver) currSess.getAttribute("execution.carryover");
|
||||||
if (eco != null) {
|
if (eco != null) {
|
||||||
//try restore
|
//try restore
|
||||||
try {
|
try {
|
||||||
appDesktop = (IDesktop) d;
|
appDesktop = (IDesktop) d;
|
||||||
|
|
||||||
ExecutionCarryOver current = new ExecutionCarryOver(this.getPage().getDesktop());
|
ExecutionCarryOver current = new ExecutionCarryOver(this.getPage().getDesktop());
|
||||||
ExecutionCtrl ctrl = ExecutionsCtrl.getCurrentCtrl();
|
ExecutionCtrl ctrl = ExecutionsCtrl.getCurrentCtrl();
|
||||||
Visualizer vi = ctrl.getVisualizer();
|
Visualizer vi = ctrl.getVisualizer();
|
||||||
|
@ -163,7 +179,7 @@ public class AdempiereWebUI extends Window implements EventListener, IWebClient
|
||||||
try {
|
try {
|
||||||
ctrl = ExecutionsCtrl.getCurrentCtrl();
|
ctrl = ExecutionsCtrl.getCurrentCtrl();
|
||||||
ctrl.setVisualizer(vi);
|
ctrl.setVisualizer(vi);
|
||||||
|
|
||||||
//detach root component from old page
|
//detach root component from old page
|
||||||
Page page = appDesktop.getComponent().getPage();
|
Page page = appDesktop.getComponent().getPage();
|
||||||
Collection<?> collection = page.getRoots();
|
Collection<?> collection = page.getRoots();
|
||||||
|
@ -182,24 +198,24 @@ public class AdempiereWebUI extends Window implements EventListener, IWebClient
|
||||||
eco.cleanup();
|
eco.cleanup();
|
||||||
current.carryOver();
|
current.carryOver();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (appDesktop != null) {
|
if (appDesktop != null) {
|
||||||
//re-attach root components
|
//re-attach root components
|
||||||
for (Component component : rootComponents) {
|
for (Component component : rootComponents) {
|
||||||
component.setPage(this.getPage());
|
component.setPage(this.getPage());
|
||||||
}
|
}
|
||||||
appDesktop.setPage(this.getPage());
|
appDesktop.setPage(this.getPage());
|
||||||
currSess.setAttribute("execution.carryover", current);
|
currSess.setAttribute("execution.carryover", current);
|
||||||
}
|
}
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
//restore fail
|
//restore fail
|
||||||
appDesktop = null;
|
appDesktop = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (appDesktop == null)
|
if (appDesktop == null)
|
||||||
{
|
{
|
||||||
//create new desktop
|
//create new desktop
|
||||||
createDesktop();
|
createDesktop();
|
||||||
|
@ -211,22 +227,22 @@ public class AdempiereWebUI extends Window implements EventListener, IWebClient
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createDesktop()
|
private void createDesktop()
|
||||||
{
|
{
|
||||||
appDesktop = null;
|
appDesktop = null;
|
||||||
String className = MSysConfig.getValue(IDesktop.CLASS_NAME_KEY);
|
String className = MSysConfig.getValue(IDesktop.CLASS_NAME_KEY);
|
||||||
if ( className != null && className.trim().length() > 0)
|
if ( className != null && className.trim().length() > 0)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Class<?> clazz = this.getClass().getClassLoader().loadClass(className);
|
Class<?> clazz = this.getClass().getClassLoader().loadClass(className);
|
||||||
appDesktop = (IDesktop) clazz.newInstance();
|
appDesktop = (IDesktop) clazz.newInstance();
|
||||||
}
|
}
|
||||||
catch (Throwable t)
|
catch (Throwable t)
|
||||||
{
|
{
|
||||||
logger.warning("Failed to instantiate desktop. Class=" + className);
|
logger.warning("Failed to instantiate desktop. Class=" + className);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//fallback to default
|
//fallback to default
|
||||||
if (appDesktop == null)
|
if (appDesktop == null)
|
||||||
appDesktop = new DefaultDesktop();
|
appDesktop = new DefaultDesktop();
|
||||||
|
@ -238,12 +254,12 @@ public class AdempiereWebUI extends Window implements EventListener, IWebClient
|
||||||
public void logout()
|
public void logout()
|
||||||
{
|
{
|
||||||
appDesktop.logout();
|
appDesktop.logout();
|
||||||
|
|
||||||
MSession mSession = MSession.get(Env.getCtx(), false);
|
MSession mSession = MSession.get(Env.getCtx(), false);
|
||||||
if (mSession != null) {
|
if (mSession != null) {
|
||||||
mSession.logout();
|
mSession.logout();
|
||||||
}
|
}
|
||||||
|
|
||||||
SessionManager.clearSession();
|
SessionManager.clearSession();
|
||||||
super.getChildren().clear();
|
super.getChildren().clear();
|
||||||
Page page = this.getPage();
|
Page page = this.getPage();
|
||||||
|
@ -258,7 +274,7 @@ public class AdempiereWebUI extends Window implements EventListener, IWebClient
|
||||||
{
|
{
|
||||||
return appDesktop;
|
return appDesktop;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onEvent(Event event) {
|
public void onEvent(Event event) {
|
||||||
if (event instanceof ClientInfoEvent) {
|
if (event instanceof ClientInfoEvent) {
|
||||||
ClientInfoEvent c = (ClientInfoEvent)event;
|
ClientInfoEvent c = (ClientInfoEvent)event;
|
||||||
|
|
|
@ -29,6 +29,7 @@ import java.sql.SQLException;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
@ -49,6 +50,7 @@ import org.compiere.util.CLogger;
|
||||||
import org.compiere.util.DB;
|
import org.compiere.util.DB;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
import org.compiere.util.Ini;
|
import org.compiere.util.Ini;
|
||||||
|
import org.compiere.util.Language;
|
||||||
import org.zkoss.web.servlet.Servlets;
|
import org.zkoss.web.servlet.Servlets;
|
||||||
import org.zkoss.zk.ui.Component;
|
import org.zkoss.zk.ui.Component;
|
||||||
import org.zkoss.zk.ui.Execution;
|
import org.zkoss.zk.ui.Execution;
|
||||||
|
@ -62,7 +64,7 @@ import com.lowagie.text.pdf.PdfReader;
|
||||||
import com.lowagie.text.pdf.PdfWriter;
|
import com.lowagie.text.pdf.PdfWriter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Windows Application Environment and utilities
|
* ZK Application Environment and utilities
|
||||||
*
|
*
|
||||||
* @author Jorg Janke
|
* @author Jorg Janke
|
||||||
* @version $Id: AEnv.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $
|
* @version $Id: AEnv.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $
|
||||||
|
@ -71,6 +73,8 @@ import com.lowagie.text.pdf.PdfWriter;
|
||||||
*/
|
*/
|
||||||
public final class AEnv
|
public final class AEnv
|
||||||
{
|
{
|
||||||
|
public static final String LOCALE = "#Locale";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show in the center of the screen.
|
* Show in the center of the screen.
|
||||||
* (pack, set location and set visibility)
|
* (pack, set location and set visibility)
|
||||||
|
@ -94,7 +98,7 @@ public final class AEnv
|
||||||
* Show in the center of the screen.
|
* Show in the center of the screen.
|
||||||
* (pack, set location and set visibility)
|
* (pack, set location and set visibility)
|
||||||
* @param window Window to position
|
* @param window Window to position
|
||||||
* @param position
|
* @param position
|
||||||
*/
|
*/
|
||||||
public static void showScreen(Window window, String position)
|
public static void showScreen(Window window, String position)
|
||||||
{
|
{
|
||||||
|
@ -172,7 +176,7 @@ public final class AEnv
|
||||||
AD_Window_ID = PO_Window_ID;
|
AD_Window_ID = PO_Window_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
log.config(TableName + " - Record_ID=" + Record_ID + " (IsSOTrx=" + isSOTrx + ")");
|
log.config(TableName + " - Record_ID=" + Record_ID + " (IsSOTrx=" + isSOTrx + ")");
|
||||||
zoom(AD_Window_ID, MQuery.getEqualQuery(TableName + "_ID", Record_ID));
|
zoom(AD_Window_ID, MQuery.getEqualQuery(TableName + "_ID", Record_ID));
|
||||||
} // zoom
|
} // zoom
|
||||||
|
|
||||||
|
@ -204,10 +208,10 @@ public final class AEnv
|
||||||
int AD_Window_ID = DB.getSQLValue(null, "SELECT AD_Window_ID FROM AD_Window WHERE Name = 'Workflow Process'");
|
int AD_Window_ID = DB.getSQLValue(null, "SELECT AD_Window_ID FROM AD_Window WHERE Name = 'Workflow Process'");
|
||||||
s_workflow_Window_ID = AD_Window_ID;
|
s_workflow_Window_ID = AD_Window_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s_workflow_Window_ID <= 0)
|
if (s_workflow_Window_ID <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
MQuery query = new MQuery();
|
MQuery query = new MQuery();
|
||||||
query.addRestriction("AD_Table_ID", MQuery.EQUAL, AD_Table_ID);
|
query.addRestriction("AD_Table_ID", MQuery.EQUAL, AD_Table_ID);
|
||||||
query.addRestriction("Record_ID", MQuery.EQUAL, Record_ID);
|
query.addRestriction("Record_ID", MQuery.EQUAL, Record_ID);
|
||||||
|
@ -259,11 +263,11 @@ public final class AEnv
|
||||||
GridWindowVO mWindowVO = null;
|
GridWindowVO mWindowVO = null;
|
||||||
String locale = Env.getLanguage(Env.getCtx()).getLocale().toString();
|
String locale = Env.getLanguage(Env.getCtx()).getLocale().toString();
|
||||||
if (AD_Window_ID != 0 && Ini.isCacheWindow()) // try cache
|
if (AD_Window_ID != 0 && Ini.isCacheWindow()) // try cache
|
||||||
{
|
{
|
||||||
synchronized (windowCache)
|
synchronized (windowCache)
|
||||||
{
|
{
|
||||||
CCache<Integer,GridWindowVO> cache = windowCache.get(locale);
|
CCache<Integer,GridWindowVO> cache = windowCache.get(locale);
|
||||||
if (cache != null)
|
if (cache != null)
|
||||||
{
|
{
|
||||||
mWindowVO = cache.get(AD_Window_ID);
|
mWindowVO = cache.get(AD_Window_ID);
|
||||||
if (mWindowVO != null)
|
if (mWindowVO != null)
|
||||||
|
@ -274,7 +278,7 @@ public final class AEnv
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create Window Model on Client
|
// Create Window Model on Client
|
||||||
if (mWindowVO == null)
|
if (mWindowVO == null)
|
||||||
{
|
{
|
||||||
|
@ -285,14 +289,14 @@ public final class AEnv
|
||||||
synchronized (windowCache)
|
synchronized (windowCache)
|
||||||
{
|
{
|
||||||
CCache<Integer,GridWindowVO> cache = windowCache.get(locale);
|
CCache<Integer,GridWindowVO> cache = windowCache.get(locale);
|
||||||
if (cache == null)
|
if (cache == null)
|
||||||
{
|
{
|
||||||
cache = new CCache<Integer, GridWindowVO>("AD_Window", 10);
|
cache = new CCache<Integer, GridWindowVO>("AD_Window", 10);
|
||||||
windowCache.put(locale, cache);
|
windowCache.put(locale, cache);
|
||||||
}
|
}
|
||||||
cache.put(AD_Window_ID, mWindowVO);
|
cache.put(AD_Window_ID, mWindowVO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // from Client
|
} // from Client
|
||||||
if (mWindowVO == null)
|
if (mWindowVO == null)
|
||||||
return null;
|
return null;
|
||||||
|
@ -583,16 +587,16 @@ public final class AEnv
|
||||||
}
|
}
|
||||||
return uri;
|
return uri;
|
||||||
} // getImageIcon
|
} // getImageIcon
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public static boolean isFirefox2() {
|
public static boolean isFirefox2() {
|
||||||
Execution execution = Executions.getCurrent();
|
Execution execution = Executions.getCurrent();
|
||||||
if (execution == null)
|
if (execution == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Object n = execution.getNativeRequest();
|
Object n = execution.getNativeRequest();
|
||||||
if (n instanceof ServletRequest) {
|
if (n instanceof ServletRequest) {
|
||||||
String userAgent = Servlets.getUserAgent((ServletRequest) n);
|
String userAgent = Servlets.getUserAgent((ServletRequest) n);
|
||||||
|
@ -601,9 +605,9 @@ public final class AEnv
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param parent
|
* @param parent
|
||||||
* @param child
|
* @param child
|
||||||
* @return boolean
|
* @return boolean
|
||||||
|
@ -611,19 +615,19 @@ public final class AEnv
|
||||||
public static boolean contains(Component parent, Component child) {
|
public static boolean contains(Component parent, Component child) {
|
||||||
if (child == parent)
|
if (child == parent)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
Component c = child.getParent();
|
Component c = child.getParent();
|
||||||
while (c != null) {
|
while (c != null) {
|
||||||
if (c == parent)
|
if (c == parent)
|
||||||
return true;
|
return true;
|
||||||
c = c.getParent();
|
c = c.getParent();
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param pdfList
|
* @param pdfList
|
||||||
* @param outFile
|
* @param outFile
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
|
@ -633,13 +637,13 @@ public final class AEnv
|
||||||
public static void mergePdf(List<File> pdfList, File outFile) throws IOException,
|
public static void mergePdf(List<File> pdfList, File outFile) throws IOException,
|
||||||
DocumentException, FileNotFoundException {
|
DocumentException, FileNotFoundException {
|
||||||
Document document = null;
|
Document document = null;
|
||||||
PdfWriter copy = null;
|
PdfWriter copy = null;
|
||||||
for (File f : pdfList)
|
for (File f : pdfList)
|
||||||
{
|
{
|
||||||
PdfReader reader = new PdfReader(f.getAbsolutePath());
|
PdfReader reader = new PdfReader(f.getAbsolutePath());
|
||||||
if (document == null)
|
if (document == null)
|
||||||
{
|
{
|
||||||
document = new Document(reader.getPageSizeWithRotation(1));
|
document = new Document(reader.getPageSizeWithRotation(1));
|
||||||
copy = PdfWriter.getInstance(document, new FileOutputStream(outFile));
|
copy = PdfWriter.getInstance(document, new FileOutputStream(outFile));
|
||||||
document.open();
|
document.open();
|
||||||
}
|
}
|
||||||
|
@ -653,7 +657,7 @@ public final class AEnv
|
||||||
}
|
}
|
||||||
document.close();
|
document.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get window title
|
* Get window title
|
||||||
* @param ctx context
|
* @param ctx context
|
||||||
|
@ -680,4 +684,42 @@ public final class AEnv
|
||||||
}
|
}
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
} // getHeader
|
} // getHeader
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ctx
|
||||||
|
* @return Language
|
||||||
|
*/
|
||||||
|
public static Language getLanguage(Properties ctx) {
|
||||||
|
Locale locale = getLocale(ctx);
|
||||||
|
Language language = Env.getLanguage(ctx);
|
||||||
|
if (!language.getLocale().equals(locale)) {
|
||||||
|
Language tmp = Language.getLanguage(locale.toString());
|
||||||
|
String adLanguage = language.getAD_Language();
|
||||||
|
language = new Language(tmp.getName(), adLanguage, tmp.getLocale(), tmp.isDecimalPoint(),
|
||||||
|
tmp.getDateFormat().toPattern(), tmp.getMediaSize());
|
||||||
|
}
|
||||||
|
return language;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ctx
|
||||||
|
* @return Locale
|
||||||
|
*/
|
||||||
|
public static Locale getLocale(Properties ctx) {
|
||||||
|
String value = Env.getContext(ctx, AEnv.LOCALE);
|
||||||
|
Locale locale = null;
|
||||||
|
if (value != null && value.length() > 0)
|
||||||
|
{
|
||||||
|
String[] components = value.split("\\_");
|
||||||
|
String language = components.length > 0 ? components[0] : "";
|
||||||
|
String country = components.length > 1 ? components[1] : "";
|
||||||
|
locale = new Locale(language, country);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
locale = Env.getLanguage(ctx).getLocale();
|
||||||
|
}
|
||||||
|
|
||||||
|
return locale;
|
||||||
|
}
|
||||||
} // AEnv
|
} // AEnv
|
||||||
|
|
|
@ -20,16 +20,18 @@ package org.adempiere.webui.editor;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
import org.adempiere.webui.apps.AEnv;
|
||||||
import org.adempiere.webui.component.Datebox;
|
import org.adempiere.webui.component.Datebox;
|
||||||
import org.adempiere.webui.event.ValueChangeEvent;
|
import org.adempiere.webui.event.ValueChangeEvent;
|
||||||
import org.compiere.model.GridField;
|
import org.compiere.model.GridField;
|
||||||
import org.compiere.util.CLogger;
|
import org.compiere.util.CLogger;
|
||||||
import org.compiere.util.DisplayType;
|
import org.compiere.util.DisplayType;
|
||||||
|
import org.compiere.util.Env;
|
||||||
import org.zkoss.zk.ui.event.Event;
|
import org.zkoss.zk.ui.event.Event;
|
||||||
import org.zkoss.zk.ui.event.Events;
|
import org.zkoss.zk.ui.event.Events;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:agramdass@gmail.com">Ashley G Ramdass</a>
|
* @author <a href="mailto:agramdass@gmail.com">Ashley G Ramdass</a>
|
||||||
* @date Mar 12, 2007
|
* @date Mar 12, 2007
|
||||||
* @version $Revision: 0.10 $
|
* @version $Revision: 0.10 $
|
||||||
|
@ -39,16 +41,16 @@ public class WDateEditor extends WEditor
|
||||||
private static final String[] LISTENER_EVENTS = {Events.ON_CHANGE};
|
private static final String[] LISTENER_EVENTS = {Events.ON_CHANGE};
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private static final CLogger logger;
|
private static final CLogger logger;
|
||||||
|
|
||||||
static
|
static
|
||||||
{
|
{
|
||||||
logger = CLogger.getCLogger(WDateEditor.class);
|
logger = CLogger.getCLogger(WDateEditor.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Timestamp oldValue = new Timestamp(0);
|
private Timestamp oldValue = new Timestamp(0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param gridField
|
* @param gridField
|
||||||
*/
|
*/
|
||||||
public WDateEditor(GridField gridField)
|
public WDateEditor(GridField gridField)
|
||||||
|
@ -56,11 +58,11 @@ public class WDateEditor extends WEditor
|
||||||
super(new Datebox(), gridField);
|
super(new Datebox(), gridField);
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for use if a grid field is unavailable
|
* Constructor for use if a grid field is unavailable
|
||||||
*
|
*
|
||||||
* @param label
|
* @param label
|
||||||
* column name (not displayed)
|
* column name (not displayed)
|
||||||
* @param description
|
* @param description
|
||||||
|
@ -78,14 +80,14 @@ public class WDateEditor extends WEditor
|
||||||
setColumnName("Date");
|
setColumnName("Date");
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
public WDateEditor()
|
public WDateEditor()
|
||||||
{
|
{
|
||||||
this("Date", "Date", false, false, true);
|
this("Date", "Date", false, false, true);
|
||||||
} // VDate
|
} // VDate
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param columnName
|
* @param columnName
|
||||||
* @param mandatory
|
* @param mandatory
|
||||||
* @param readonly
|
* @param readonly
|
||||||
|
@ -97,24 +99,24 @@ public class WDateEditor extends WEditor
|
||||||
{
|
{
|
||||||
super(new Datebox(), columnName, title, null, mandatory, readonly, updateable);
|
super(new Datebox(), columnName, title, null, mandatory, readonly, updateable);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void init()
|
private void init()
|
||||||
{
|
{
|
||||||
getComponent().setFormat(DisplayType.getDateFormat().toPattern());
|
getComponent().setFormat(DisplayType.getDateFormat(AEnv.getLanguage(Env.getCtx())).toPattern());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onEvent(Event event)
|
public void onEvent(Event event)
|
||||||
{
|
{
|
||||||
if (Events.ON_CHANGE.equalsIgnoreCase(event.getName()))
|
if (Events.ON_CHANGE.equalsIgnoreCase(event.getName()))
|
||||||
{
|
{
|
||||||
Date date = getComponent().getValue();
|
Date date = getComponent().getValue();
|
||||||
Timestamp newValue = null;
|
Timestamp newValue = null;
|
||||||
|
|
||||||
if (date != null)
|
if (date != null)
|
||||||
{
|
{
|
||||||
newValue = new Timestamp(date.getTime());
|
newValue = new Timestamp(date.getTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
ValueChangeEvent changeEvent = new ValueChangeEvent(this, this.getColumnName(), oldValue, newValue);
|
ValueChangeEvent changeEvent = new ValueChangeEvent(this, this.getColumnName(), oldValue, newValue);
|
||||||
super.fireValueChange(changeEvent);
|
super.fireValueChange(changeEvent);
|
||||||
oldValue = newValue;
|
oldValue = newValue;
|
||||||
|
@ -162,9 +164,9 @@ public class WDateEditor extends WEditor
|
||||||
getComponent().setValue((Timestamp)value);
|
getComponent().setValue((Timestamp)value);
|
||||||
oldValue = (Timestamp)value;
|
oldValue = (Timestamp)value;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
getComponent().setText(value.toString());
|
getComponent().setText(value.toString());
|
||||||
} catch (Exception e) {}
|
} catch (Exception e) {}
|
||||||
|
@ -174,7 +176,7 @@ public class WDateEditor extends WEditor
|
||||||
oldValue = null;
|
oldValue = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Datebox getComponent() {
|
public Datebox getComponent() {
|
||||||
return (Datebox) component;
|
return (Datebox) component;
|
||||||
|
|
|
@ -21,6 +21,7 @@ import java.math.BigDecimal;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
|
|
||||||
import org.adempiere.webui.ValuePreference;
|
import org.adempiere.webui.ValuePreference;
|
||||||
|
import org.adempiere.webui.apps.AEnv;
|
||||||
import org.adempiere.webui.component.NumberBox;
|
import org.adempiere.webui.component.NumberBox;
|
||||||
import org.adempiere.webui.event.ContextMenuEvent;
|
import org.adempiere.webui.event.ContextMenuEvent;
|
||||||
import org.adempiere.webui.event.ValueChangeEvent;
|
import org.adempiere.webui.event.ValueChangeEvent;
|
||||||
|
@ -36,28 +37,28 @@ import org.zkoss.zk.ui.event.Events;
|
||||||
* @author <a href="mailto:agramdass@gmail.com">Ashley G Ramdass</a>
|
* @author <a href="mailto:agramdass@gmail.com">Ashley G Ramdass</a>
|
||||||
* @date Mar 11, 2007
|
* @date Mar 11, 2007
|
||||||
* @version $Revision: 0.10 $
|
* @version $Revision: 0.10 $
|
||||||
*
|
*
|
||||||
* @author Low Heng Sin
|
* @author Low Heng Sin
|
||||||
*/
|
*/
|
||||||
public class WNumberEditor extends WEditor
|
public class WNumberEditor extends WEditor
|
||||||
{
|
{
|
||||||
public static final String[] LISTENER_EVENTS = {Events.ON_CHANGE};
|
public static final String[] LISTENER_EVENTS = {Events.ON_CHANGE};
|
||||||
|
|
||||||
public static final int MAX_DISPLAY_LENGTH = 20;
|
public static final int MAX_DISPLAY_LENGTH = 20;
|
||||||
|
|
||||||
private BigDecimal oldValue;
|
private BigDecimal oldValue;
|
||||||
|
|
||||||
private boolean mandatory = false;
|
private boolean mandatory = false;
|
||||||
|
|
||||||
private int displayType;
|
private int displayType;
|
||||||
|
|
||||||
public WNumberEditor()
|
public WNumberEditor()
|
||||||
{
|
{
|
||||||
this("Number", false, false, true, DisplayType.Number, "");
|
this("Number", false, false, true, DisplayType.Number, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param gridField
|
* @param gridField
|
||||||
*/
|
*/
|
||||||
public WNumberEditor(GridField gridField)
|
public WNumberEditor(GridField gridField)
|
||||||
|
@ -67,9 +68,9 @@ public class WNumberEditor extends WEditor
|
||||||
this.displayType = gridField.getDisplayType();
|
this.displayType = gridField.getDisplayType();
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param gridField
|
* @param gridField
|
||||||
* @param integral
|
* @param integral
|
||||||
*/
|
*/
|
||||||
|
@ -81,7 +82,7 @@ public class WNumberEditor extends WEditor
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param columnName
|
* @param columnName
|
||||||
* @param mandatory
|
* @param mandatory
|
||||||
* @param readonly
|
* @param readonly
|
||||||
|
@ -90,9 +91,9 @@ public class WNumberEditor extends WEditor
|
||||||
* @param title
|
* @param title
|
||||||
*/
|
*/
|
||||||
public WNumberEditor(String columnName, boolean mandatory, boolean readonly, boolean updateable,
|
public WNumberEditor(String columnName, boolean mandatory, boolean readonly, boolean updateable,
|
||||||
int displayType, String title)
|
int displayType, String title)
|
||||||
{
|
{
|
||||||
super(new NumberBox(displayType == DisplayType.Integer), columnName, title, null, mandatory,
|
super(new NumberBox(displayType == DisplayType.Integer), columnName, title, null, mandatory,
|
||||||
readonly, updateable);
|
readonly, updateable);
|
||||||
this.displayType = displayType;
|
this.displayType = displayType;
|
||||||
init();
|
init();
|
||||||
|
@ -103,14 +104,14 @@ public class WNumberEditor extends WEditor
|
||||||
if (gridField != null)
|
if (gridField != null)
|
||||||
{
|
{
|
||||||
getComponent().setTooltiptext(gridField.getDescription());
|
getComponent().setTooltiptext(gridField.getDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!DisplayType.isNumeric(displayType))
|
if (!DisplayType.isNumeric(displayType))
|
||||||
displayType = DisplayType.Number;
|
displayType = DisplayType.Number;
|
||||||
DecimalFormat format = DisplayType.getNumberFormat(displayType, Env.getLanguage(Env.getCtx()));
|
DecimalFormat format = DisplayType.getNumberFormat(displayType, AEnv.getLanguage(Env.getCtx()));
|
||||||
getComponent().getDecimalbox().setFormat(format.toPattern());
|
getComponent().getDecimalbox().setFormat(format.toPattern());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event handler
|
* Event handler
|
||||||
* @param event
|
* @param event
|
||||||
|
@ -125,7 +126,7 @@ public class WNumberEditor extends WEditor
|
||||||
oldValue = newValue;
|
oldValue = newValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NumberBox getComponent() {
|
public NumberBox getComponent() {
|
||||||
return (NumberBox) component;
|
return (NumberBox) component;
|
||||||
|
@ -167,29 +168,29 @@ public class WNumberEditor extends WEditor
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setValue(Object value)
|
public void setValue(Object value)
|
||||||
{
|
{
|
||||||
if (value == null)
|
if (value == null)
|
||||||
oldValue = null;
|
oldValue = null;
|
||||||
else if (value instanceof BigDecimal)
|
else if (value instanceof BigDecimal)
|
||||||
oldValue = (BigDecimal) value;
|
oldValue = (BigDecimal) value;
|
||||||
else if (value instanceof Number)
|
else if (value instanceof Number)
|
||||||
oldValue = new BigDecimal(((Number)value).doubleValue());
|
oldValue = new BigDecimal(((Number)value).doubleValue());
|
||||||
else
|
else
|
||||||
oldValue = new BigDecimal(value.toString());
|
oldValue = new BigDecimal(value.toString());
|
||||||
getComponent().setValue(oldValue);
|
getComponent().setValue(oldValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] getEvents()
|
public String[] getEvents()
|
||||||
{
|
{
|
||||||
return LISTENER_EVENTS;
|
return LISTENER_EVENTS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle context menu events
|
* Handle context menu events
|
||||||
* @param evt
|
* @param evt
|
||||||
*/
|
*/
|
||||||
public void onMenu(ContextMenuEvent evt)
|
public void onMenu(ContextMenuEvent evt)
|
||||||
{
|
{
|
||||||
if (WEditorPopupMenu.PREFERENCE_EVENT.equals(evt.getContextEvent()) && gridField != null)
|
if (WEditorPopupMenu.PREFERENCE_EVENT.equals(evt.getContextEvent()) && gridField != null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,6 +20,7 @@ package org.adempiere.webui.panel;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
|
import org.adempiere.webui.apps.AEnv;
|
||||||
import org.adempiere.webui.component.ConfirmPanel;
|
import org.adempiere.webui.component.ConfirmPanel;
|
||||||
import org.adempiere.webui.component.Grid;
|
import org.adempiere.webui.component.Grid;
|
||||||
import org.adempiere.webui.component.Label;
|
import org.adempiere.webui.component.Label;
|
||||||
|
@ -35,6 +36,7 @@ import org.compiere.util.Env;
|
||||||
import org.compiere.util.KeyNamePair;
|
import org.compiere.util.KeyNamePair;
|
||||||
import org.compiere.util.Language;
|
import org.compiere.util.Language;
|
||||||
import org.compiere.util.Login;
|
import org.compiere.util.Login;
|
||||||
|
import org.zkoss.util.Locales;
|
||||||
import org.zkoss.zk.au.out.AuFocus;
|
import org.zkoss.zk.au.out.AuFocus;
|
||||||
import org.zkoss.zk.ui.Component;
|
import org.zkoss.zk.ui.Component;
|
||||||
import org.zkoss.zk.ui.WrongValueException;
|
import org.zkoss.zk.ui.WrongValueException;
|
||||||
|
@ -57,7 +59,7 @@ import org.zkoss.zul.Listitem;
|
||||||
public class LoginPanel extends Window implements EventListener
|
public class LoginPanel extends Window implements EventListener
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private static final String RESOURCE = "org.compiere.apps.ALoginRes";
|
private static final String RESOURCE = "org.compiere.apps.ALoginRes";
|
||||||
private ResourceBundle res = ResourceBundle.getBundle(RESOURCE);
|
private ResourceBundle res = ResourceBundle.getBundle(RESOURCE);
|
||||||
|
|
||||||
|
@ -79,7 +81,7 @@ public class LoginPanel extends Window implements EventListener
|
||||||
initComponents();
|
initComponents();
|
||||||
init();
|
init();
|
||||||
this.setId("loginPanel");
|
this.setId("loginPanel");
|
||||||
|
|
||||||
AuFocus auf = new AuFocus(txtUserId);
|
AuFocus auf = new AuFocus(txtUserId);
|
||||||
Clients.response(auf);
|
Clients.response(auf);
|
||||||
}
|
}
|
||||||
|
@ -94,7 +96,7 @@ public class LoginPanel extends Window implements EventListener
|
||||||
logo.setSpans("2");
|
logo.setSpans("2");
|
||||||
Image image = new Image();
|
Image image = new Image();
|
||||||
image.setSrc("images/logo.png");
|
image.setSrc("images/logo.png");
|
||||||
logo.appendChild(image);
|
logo.appendChild(image);
|
||||||
Row rowUser = new Row();
|
Row rowUser = new Row();
|
||||||
rowUser.setId("rowUser");
|
rowUser.setId("rowUser");
|
||||||
Row rowPassword = new Row();
|
Row rowPassword = new Row();
|
||||||
|
@ -160,7 +162,7 @@ public class LoginPanel extends Window implements EventListener
|
||||||
lstLanguage.setMold("select");
|
lstLanguage.setMold("select");
|
||||||
lstLanguage.addEventListener(Events.ON_SELECT, this);
|
lstLanguage.addEventListener(Events.ON_SELECT, this);
|
||||||
lstLanguage.setWidth("220px");
|
lstLanguage.setWidth("220px");
|
||||||
|
|
||||||
// Update Language List
|
// Update Language List
|
||||||
lstLanguage.getItems().clear();
|
lstLanguage.getItems().clear();
|
||||||
String[] availableLanguages = Language.getNames();
|
String[] availableLanguages = Language.getNames();
|
||||||
|
@ -215,18 +217,26 @@ public class LoginPanel extends Window implements EventListener
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
private void languageChanged(String langName)
|
private void languageChanged(String langName)
|
||||||
{
|
{
|
||||||
Language language = Language.getLanguage(langName);
|
Language language = findLanguage(langName);
|
||||||
Env.verifyLanguage(ctx, language);
|
|
||||||
Env.setContext(ctx, Env.LANGUAGE, language.getAD_Language());
|
|
||||||
|
|
||||||
res = ResourceBundle.getBundle(RESOURCE, language.getLocale());
|
res = ResourceBundle.getBundle(RESOURCE, language.getLocale());
|
||||||
lblUserId.setValue(res.getString("User"));
|
lblUserId.setValue(res.getString("User"));
|
||||||
lblPassword.setValue(res.getString("Password"));
|
lblPassword.setValue(res.getString("Password"));
|
||||||
lblLanguage.setValue(res.getString("Language"));
|
lblLanguage.setValue(res.getString("Language"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Language findLanguage(String langName) {
|
||||||
|
Language tmp = Language.getLanguage(langName);
|
||||||
|
Language language = new Language(tmp.getName(), tmp.getAD_Language(), tmp.getLocale(), tmp.isDecimalPoint(),
|
||||||
|
tmp.getDateFormat().toPattern(), tmp.getMediaSize());
|
||||||
|
Env.verifyLanguage(ctx, language);
|
||||||
|
Env.setContext(ctx, Env.LANGUAGE, language.getAD_Language());
|
||||||
|
Env.setContext(ctx, AEnv.LOCALE, language.getLocale().toString());
|
||||||
|
return language;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* validates user name and password when logging in
|
* validates user name and password when logging in
|
||||||
*
|
*
|
||||||
|
@ -247,11 +257,12 @@ public class LoginPanel extends Window implements EventListener
|
||||||
langName = (String) lstLanguage.getSelectedItem().getLabel();
|
langName = (String) lstLanguage.getSelectedItem().getLabel();
|
||||||
else
|
else
|
||||||
langName = Language.getBaseLanguage().getName();
|
langName = Language.getBaseLanguage().getName();
|
||||||
Language language = Language.getLanguage(langName);
|
Language language = findLanguage(langName);
|
||||||
Env.verifyLanguage(ctx, language);
|
wndLogin.loginOk(userId, userPassword);
|
||||||
wndLogin.loginOk(userId, userPassword);
|
|
||||||
|
|
||||||
Env.setContext(ctx, UserPreference.LANGUAGE_NAME, language.getName()); // Elaine 2009/02/06
|
Env.setContext(ctx, UserPreference.LANGUAGE_NAME, language.getName()); // Elaine 2009/02/06
|
||||||
|
|
||||||
|
Locales.setThreadLocal(language.getLocale());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ package org.adempiere.webui.session;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.adempiere.webui.apps.AEnv;
|
||||||
import org.compiere.util.Env;
|
import org.compiere.util.Env;
|
||||||
import org.zkoss.util.Locales;
|
import org.zkoss.util.Locales;
|
||||||
import org.zkoss.zk.ui.Component;
|
import org.zkoss.zk.ui.Component;
|
||||||
|
@ -31,7 +32,7 @@ import org.zkoss.zk.ui.util.ExecutionCleanup;
|
||||||
import org.zkoss.zk.ui.util.ExecutionInit;
|
import org.zkoss.zk.ui.util.ExecutionInit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:agramdass@gmail.com">Ashley G Ramdass</a>
|
* @author <a href="mailto:agramdass@gmail.com">Ashley G Ramdass</a>
|
||||||
* @date Feb 25, 2007
|
* @date Feb 25, 2007
|
||||||
* @version $Revision: 0.10 $
|
* @version $Revision: 0.10 $
|
||||||
|
@ -44,17 +45,17 @@ public class SessionContextListener implements ExecutionInit,
|
||||||
/**
|
/**
|
||||||
* @param exec
|
* @param exec
|
||||||
* @param parent
|
* @param parent
|
||||||
*
|
*
|
||||||
* @see ExecutionInit#init(Execution, Execution)
|
* @see ExecutionInit#init(Execution, Execution)
|
||||||
*/
|
*/
|
||||||
public void init(Execution exec, Execution parent)
|
public void init(Execution exec, Execution parent)
|
||||||
{
|
{
|
||||||
if (parent == null)
|
if (parent == null)
|
||||||
{
|
{
|
||||||
ServerContext ctx = (ServerContext)exec.getDesktop().getSession().getAttribute(SESSION_CTX);
|
ServerContext ctx = (ServerContext)exec.getDesktop().getSession().getAttribute(SESSION_CTX);
|
||||||
if (ctx == null)
|
if (ctx == null)
|
||||||
{
|
{
|
||||||
ctx = ServerContext.newInstance();
|
ctx = ServerContext.newInstance();
|
||||||
exec.getDesktop().getSession().setAttribute(SESSION_CTX, ctx);
|
exec.getDesktop().getSession().setAttribute(SESSION_CTX, ctx);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -62,7 +63,7 @@ public class SessionContextListener implements ExecutionInit,
|
||||||
ServerContext.setCurrentInstance(ctx);
|
ServerContext.setCurrentInstance(ctx);
|
||||||
}
|
}
|
||||||
exec.setAttribute(SESSION_CTX, ctx);
|
exec.setAttribute(SESSION_CTX, ctx);
|
||||||
|
|
||||||
//set locale
|
//set locale
|
||||||
Locales.setThreadLocal(Env.getLanguage(ctx).getLocale());
|
Locales.setThreadLocal(Env.getLanguage(ctx).getLocale());
|
||||||
}
|
}
|
||||||
|
@ -72,7 +73,7 @@ public class SessionContextListener implements ExecutionInit,
|
||||||
* @param exec
|
* @param exec
|
||||||
* @param parent
|
* @param parent
|
||||||
* @param errs
|
* @param errs
|
||||||
* @see ExecutionCleanup#cleanup(Execution, Execution, List)
|
* @see ExecutionCleanup#cleanup(Execution, Execution, List)
|
||||||
*/
|
*/
|
||||||
public void cleanup(Execution exec, Execution parent, List errs)
|
public void cleanup(Execution exec, Execution parent, List errs)
|
||||||
{
|
{
|
||||||
|
@ -80,7 +81,7 @@ public class SessionContextListener implements ExecutionInit,
|
||||||
{
|
{
|
||||||
exec.removeAttribute(SESSION_CTX);
|
exec.removeAttribute(SESSION_CTX);
|
||||||
ServerContext.dispose();
|
ServerContext.dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -102,11 +103,11 @@ public class SessionContextListener implements ExecutionInit,
|
||||||
ServerContext ctx = (ServerContext) Executions.getCurrent().getAttribute(
|
ServerContext ctx = (ServerContext) Executions.getCurrent().getAttribute(
|
||||||
SESSION_CTX);
|
SESSION_CTX);
|
||||||
ServerContext.setCurrentInstance(ctx);
|
ServerContext.setCurrentInstance(ctx);
|
||||||
|
|
||||||
// set locale
|
// set locale
|
||||||
Locales.setThreadLocal(Env.getLanguage(ctx).getLocale());
|
Locales.setThreadLocal(AEnv.getLocale(ctx));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -138,5 +139,5 @@ public class SessionContextListener implements ExecutionInit,
|
||||||
public void abortResume(Component comp, Event evt)
|
public void abortResume(Component comp, Event evt)
|
||||||
{
|
{
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue