How to use application.overrideStyle()

Find out how to get things done with Servoy. Post how YOU get things done with Servoy

How to use application.overrideStyle()

Postby Chuck.Amata » Sun Oct 04, 2009 8:19 pm

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.
Chuck.Amata
 
Posts: 50
Joined: Sun Oct 04, 2009 8:02 pm
Location: USA

Re: How to use application.overrideStyle()

Postby david » Mon Oct 05, 2009 1:07 am

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.
David Workman, Kabootit

Image
Everything you need to build great apps with Servoy
User avatar
david
 
Posts: 1727
Joined: Thu Apr 24, 2003 4:18 pm
Location: Washington, D.C.

Re: How to use application.overrideStyle()

Postby Chuck.Amata » Mon Oct 05, 2009 1:37 am

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?)
Chuck.Amata
 
Posts: 50
Joined: Sun Oct 04, 2009 8:02 pm
Location: USA

Re: How to use application.overrideStyle()

Postby Chuck.Amata » Mon Oct 05, 2009 2:11 am

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.
Chuck.Amata
 
Posts: 50
Joined: Sun Oct 04, 2009 8:02 pm
Location: USA

Re: How to use application.overrideStyle()

Postby david » Mon Oct 05, 2009 2:24 am

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....
David Workman, Kabootit

Image
Everything you need to build great apps with Servoy
User avatar
david
 
Posts: 1727
Joined: Thu Apr 24, 2003 4:18 pm
Location: Washington, D.C.

Re: How to use application.overrideStyle()

Postby martinh » Mon Oct 05, 2009 9:01 am

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.
Martin
------------------------------------------------
Servoy Developer
Version 5.2.10/5.2.13
Java version 1.6 update 31
Database SQL Server 2008 R2
martinh
 
Posts: 857
Joined: Wed May 09, 2007 5:34 pm
Location: Belgium

Re: How to use application.overrideStyle()

Postby Chuck.Amata » Mon Oct 05, 2009 11:49 pm

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.
Chuck.Amata
 
Posts: 50
Joined: Sun Oct 04, 2009 8:02 pm
Location: USA


Return to How To

Who is online

Users browsing this forum: No registered users and 2 guests