Nov 25, 2008

[Free] Servoy Image Viewer Module

Hi,

I have developed a "Servoy Image Viewer Module" to view the uploaded image. The module has the option to flip, zoom, rotate, upload, save the image.

Here is the preview of the "Servoy Image Viewer Module" in Rich Client.




This module can be used in 3.5 + and 4.0 +.and is Rich & WebClient compatible. Please, feel free to use, modify & distrubute as per your want.

The Module can be downloaded form the original post from the Servoy Forum.
http://www.servoy.com/forum/viewtopic.php?f=14&t=11627

Cheers.

Nov 19, 2008

Checking Performance Issue in Servoy

By the help of Debugging, we can make our code bug free, but it can't help us for checking performance issue which may creep into our code and Servoy does't offer any such tool to check or monitor these issues, such as which Servoy method called, and how many time it takes to finish the code etc.

Yes, a simple checking can be done by adding a timestamp at the method start and end.

Here is a nice solution for your above issue, suggested by Greg Pierce of Agile Tortoise. It requires no changes to your original code to track the timestamps, etc.

function profile_global_method()
{
var orig = arguments[0]; //Method name to test the performance
var newName = orig + '_orig';

if(typeof globals[newName] == 'function')
globals[orig] = globals[newName];
globals[newName] = globals[orig];

var pStart;
var before = function() { pStart = new Date(); };
var after = function() { application.output(orig + ":" + (new Date() - pStart)); };

var repl = function() {
switch(typeof before)
{
case 'string' : eval(before); break;
case 'function' : before(); break;
}
var result = globals[newName].apply(this, arguments);
switch(typeof after)
{
case 'string' : eval(after); break;
case 'function' : after(); break;
}
return result;
}
globals[orig] = repl;
}


You can profile your global method for performance testing by using the profile_global_method() and passing the method name as an argument. Now, you can call your method from somewhere else, typically in an "enter profiler mode" method somewhere that will call it repeated for the different methods you want to watch. It aliases the original global method in the runtime and replaces it with a version that tracks profiling ticks and outputs them to the console. No further modifications to your original code are required. Now, every time the method is called you can able to get the time consumed by the method like “methodName:[ticks]” in milliseconds. No, you can track the execution time into the db or keep counting the number of times the particular methods are called.

to Greg Pierce of Agile Tortoise for the same.

Here is an improved version which, now, can able to figure out the start, end and count of the method.

function profile_global_method()
{
var orig = arguments[0];
var newName = orig + '_orig';

if(typeof globals[newName] == 'function') globals[orig] = globals[newName];
globals[newName] = globals[orig];

if(typeof $profileData == 'undefined') $profileData = { };
if(typeof $profileData[orig] == 'undefined') $profileData[orig] = {count:0, lastStart:null, lastEnd:null, ticks:0};

var before = function() {
$profileData[orig].count = $profileData[orig].count + 1;
$profileData[orig].lastStart = new Date();
application.output("START | globals." + orig + " | count: " + $profileData[orig].count);
};
var after = function() {
$profileData[orig].lastEnd = new Date();
$profileData[orig].ticks = $profileData[orig].lastEnd - $profileData[orig].lastStart;
application.output('END | globals.' + orig + " | count: " + $profileData[orig].count + ", ticks: " + $profileData[orig].ticks);
};

var repl = function() {
before();
var result = globals[newName].apply(this, arguments);
after();
return result;
}
globals[orig] = repl;
}


Now, the console output will be like ...

START | method1 | count: 6
START | method1 | count: 7
END | method1 | count: 7, ticks: 10
END | method2 | count: 6, ticks: 50

The original post is at http://www.servoy.com/forum/viewtopic.php?f=22&t=11579.

Oct 8, 2008

SERVOY 4.1 PreRelease : DONE !!

Yes,

Servoy 4.1 PreRelease version is on your hand now, with lots of fixes and enhancements and in addition to these with a new revolutionary change called, "Solution Model".

With this PreRelease of Servoy 4.1, you can now able to see a node "SolutionModel" just below to the Application node. SolutionModel node gives you the capability to change or create new form & form objects such as forms, fields, labels, buttons, and tabpanels (portals coming in b2) on the FLY. yes, at the runtime....
and the most important and surprising thing is...... You can have this with your WebClient also. Yes, You can change or create new form & form objects on the fly in your WebClient also.

You can add whatever or any number of controls to your form or a newly created form. For the first time, you can now able to change any of the properties on objects , even the data binding on any object at runtime. You can also able to add/change parts of a form at runtime.

Isn't it a revolutionary change in Servoy ??

NOTE :-
  1. You can only change the properties of an object on a form that is not currently visible;
  2. The changes only persist as long as the client session does. So if you want to keep the changes between sessions - you need to code your solution to restore the changes the user made.

Just looking at to the SolutionModel node....

Let you want to change the style class of the form on the fly(on the runtime) :

//Get the form that you want to change the Style Class
var form = solutionModel.getForm("formName");

//Change the StyleClass
form.styleClass = "newStyleClass"

Let you want to add a new button to a newly created form :

//Get the Form
var newForm = solutionModel.newForm("frm", controller.getServerName(), controller.getTableName(), "svy_Cherry", true, 200, 200);

//Add a button to the newly created Form
newForm.newButton("showForm",100,100, 80,20,showForm);

//Show the newly crated form
forms['frm'].controller.show();


NOTE :- this is PRE-RELEASE software - so make sure to back up your databases and workspace before trying it out.

Oct 6, 2008

[FREE] 3-State Check Box Bean for Servoy

The 3-State Check Box Bean has the three states called, "NOT_SELECTED", "CHECKED", "CROSSED". You can get/set the state by using the state property of the bean.

To Get the State :

var state = elements.bn_triState.state

To Set the State :

//Set to Checked
elements.bn_triState.state = "CHECKED";

//Set to Not Selected
elements.bn_triState.state = "NOT_SELECTED";

//Set to Crossed
elements.bn_triState.state = "CROSSED";

I have posted the bean at Servoy Forum. Please check at here.

Record Plugin is at Servoy Newsletter October 2008

My Record Plug-in for Servoy, "mfRecordPro" has been added to the "Servoy Newsletter October 2008" :) :)

Check the Newsletter at here. Check for "FREE: New Third-party Servoy Training Tools" heading.