vrijdag 31 augustus 2007

info.language

If you're in a situation when you do not want to switch from client to server too often, but you do need to fetch the user's language constantly (like setting a language dependant description in the postLoad on a record), you might want to try this:

in the Application class:
- add a variable infoLangUser (str 5) in the classdeclaration
- add a method:
str 5 infoLangUser(str 5 _language = infoLangUser)
{
;
if (!prmIsDefault(_language))
infoLangUser = _language;
return infoLangUser;
}
- add the following line to the starupPost method in the Application class:
this.aceInfoLangUser(infolog.language());
- in the Global class, add a method:
static client server str 5 infoUserLanguage()
{
str 5 retValue;
;
if (!isRunningOnServer())
retValue = infolog.language();
else
retValue = appl.infoLangUser();
return retValue;
}

If you're on the server side and you need to fetch the language of the user, just call the infoUserLanguage method on the Global class. This will not cause any round-trips to the client because the method in the global class has this check build in that either sends you to the infolog class if you're running on the client, or to the application class (where the language is stored during startup) if you're running on the server.

This is especially useful in environments with a high network latency.

Geen opmerkingen: