« [Tutorial] Cascading Valuelists Without Any Coding | Main | [Commentary] PowerDesigner (Sybase) Webinars »
May 02, 2006
[Tip] Making the extra Client Info look nice
by Paul Bakker
Know about this nice feature to add client information to the Servoy admin pages (application.addClientInfo)? For some time now, you can add information about the client to the Servoy Admin pages. You can access this info by clicking one of the clients on the admin pages. The added info shows up under "addition info".
What can you put there as extra info? Well, whatever you want, but some things that might be helpfull are:
- OS user: to identify which OS user started the client (security.getSystemUserName())
- Server URL: to identify through which URL the user connected to the server (application.getServerURL())
- Application user: If you're using your own Security system, instead of Servoy's
You can just add each value by calling "application.addClientInfo('string');", but the function allows you to place HTML layout as well. So, what can you do with this? Well, I use it to make a nice layout, using a html table and bold text. Result:
So, how did I do this? Here's some code fo the onSolutionOpen method:
var clientInfo = '<table border="0" cellpadding="0" cellspacing="0" width="100%">\n'+
'<tr><td width="125">Server URL:<td><b>'+application.getServerURL()+'</b>\n'+
'<tr><td width="125">OS User:<td><b>'+security.getSystemUserName()+'</b>\n'+
'</table>';
application.addClientInfo(clientInfo);
We build our own security, that allows users to logout of our solution and login again, while the Servoy solution doesn't actually close. Therefor, we use the code below in our custom login procedure, to see under which CompanyType and User they have logged in as:
var clientInfo = '<table border="0" cellpadding="0" cellspacing="0" width="100%">\n'+
'<tr><td width="125">Login TimeStamp:<td><b>'+utils.stringReplace(application.getServerTimeStamp(),' ',' ')+'</b>\n'+
'<tr><td width="125">UserName:<td><b>'+globals.user_name+'</b\n>'+
'<tr><td width="125">CompanyCode:<td><b>'+globals.company_id+'</b>\n'+
'</table>';
application.addClientInfo(clientInfo);
A couple of tips and explanations:
- Instead of using regular spaces in the text, use " ": This prevents strings with spaces in it to be broken up into multiple lines by the browser.
- Put a "\n" behind every line to make the generated HTML code more readable
- Set the width of the first column to something that works for you. If you don't set a width, the HTML renderer will format the first column of your HTML table to make the longest value fit. In our case, this would mean the first column of the first table and the second table would have had different widths. You can also specify the width as a percentage, for example 40%.
- To highlight certain data, use the <b></b> for bold.
Good luck!
| Posted by David Workman on May 2, 2006 at 07:02 AM in Tips | Permalink