Page 1 of 1

How to use application.overrideStyle()

PostPosted: Sun Oct 04, 2009 8:19 pm
by Chuck.Amata
I would like to use the application.overrideStyle('current','new') feature in servoy 4.1.4 community edition on OSX 10.6 (smart & web client) to allow the user to dynamically change the style of the entire solution at runtime using styles contained in the resource. I created a test application with one form. If I change the style property on the form from default to one of the styles prior to running the application, the style is properly loaded and works fine in either smart or webclient. When I try to change the style programmatically using the onShow() event of the form and application.overrideStyle('current','new') nothing happens in either smart or web client. I can not figure out what I am doing wrong.

Can anyone help here? I looked at the servoy styles example and it creates a new form for each style. In a complex application, this would be a nightmare. The application.overrideStyle() function seams like it would be the elegant solution (if it can be made to work). I've searched the web for examples and comments on other posts but really have not found anything. I also wonder why servoy did not include use of the function in it's styles demo application.

Re: How to use application.overrideStyle()

PostPosted: Mon Oct 05, 2009 1:07 am
by david
Changing styles is not runtime modifiable unfortunately (once a form is loaded into memory, the style cannot be changed). Been hoping for something like this for quite a while now and using the Solution Model to create forms with a new style is as close as you can get right now.

Re: How to use application.overrideStyle()

PostPosted: Mon Oct 05, 2009 1:37 am
by Chuck.Amata
Thanks David. Do you know if it is a planned feature for a future release? (maybe 5.0?) I'll try the copy route and see what kind of performance and loading hit it causes. If there is a way to change the style element permanently on each form and then perform an application relaunch that might work too. Do you know of an easy way to recursively work through all the forms in a solution (including attached modules?)

Re: How to use application.overrideStyle()

PostPosted: Mon Oct 05, 2009 2:11 am
by Chuck.Amata
I forgot to ask on the last post. What does application.overrideStyle() actually do and when would it be used since it does not change the style on the fly.

Re: How to use application.overrideStyle()

PostPosted: Mon Oct 05, 2009 2:24 am
by david
Troy posted code that deconstructs to data and then reconstructs from data:

viewtopic.php?f=21&t=11272#p57829

That was in the early days of the Solution Model so a lot of stuff has changed since then. But it is a good starting point for delving into the Solution Model.

application.overrideStyle() has to be used before forms are loaded so that would be on solution startup. We use it for loading the correct style sheet for the platform you are on.

We're kind of picky so not only do we have style sheets for the various operating systems, but for versions of those operating systems (ie, tiger/leopard, XP, Vista, Vista in classic style, Windows 7, Ubuntu). Further, even for what version of Java is running per operating system.

Ok, so maybe that is almost obsessive compulsive....

Re: How to use application.overrideStyle()

PostPosted: Mon Oct 05, 2009 9:01 am
by martinh
david wrote:Changing styles is not runtime modifiable unfortunately (once a form is loaded into memory, the style cannot be changed). Been hoping for something like this for quite a while now and using the Solution Model to create forms with a new style is as close as you can get right now.



I asked for this functionality a while ago (case #199743) and I got reply that this request will be available in Servoy 5.0
The request has been implemented already.

Re: How to use application.overrideStyle()

PostPosted: Mon Oct 05, 2009 11:49 pm
by Chuck.Amata
Thanks again David. Last night I worked up a scheme that basically uses the database to store the desired style, reads the database on startup and then overrides all of the forms in the solution in a script. To allow the user to change styles, I implemented a dialog box in a styles module that updates the database with the desired style and then reboots the solution to allow the new style to take effect. The styles module basically has two functions, one to throw up a dialog to allow the user to select, and one to place in the init function of the solution and each of it's module's init function. This approach works well in both the smart and web client. I was never able to get the override Style function to work so I just plugged the value into the form form variable style directly prior to loading the form. I'm a C, C++ guy and really haven't worked with Java much. Seems very similar to C/Visual Basic though.