I have a form named frmCore which all other forms extend. The styleName on that form is ‘style1’. Depending on the client (Web vs. Smart) I need to change the style of frmCore to style2 for the Web Client. So, here is the code I am using to try to accomplish this:
if(application.getApplicationType() == APPLICATION_TYPES.WEB_CLIENT){
var _cForm = solutionModel.getForm('frmCore')
_cForm.styleName = 'style2';
forms.frmCore.controller.recreateUI();
}
I’ve tried doing it in frmCore’s onLoad method and also in the onSolutionOpen method of my solution but it does not work. Any suggestions?
Thanks,
Keith
Upon further testing I attached a method to onLoad of frmCore:
function onLoadCore(event) {
var _cForm = solutionModel.getForm('frmCore');
application.output('frmCore :'+_cForm);
}
In my onSolutionOpen method I also output _cForm. In onSolutionOpen I get this before the styleName is changed:
frmCore :JSForm[name:frmCore,size:java.awt.Dimension[width=640,height=480],datasource:null,style]
In onLoadCore I get this output:
frmCore :JSForm[name:frmCore,size:java.awt.Dimension[width=640,height=480],datasource:null,style]
So it appears that is changing the style for frmCore, however the actual style changes are not being rendered, i.e. font size changes from 10pt to 12pt, red text turns to green text, etc.
So, i kept digging and found that while it appears frmCore’s styleName is changing, frmLogin (the second form I have that is extending frmCore) never gets the style change. I have attached a sample solution for review.
Is there something wrong with the code or is this a bug that needs to be submitted to support?
Thanks,
Keith
styleChange.servoy (6 KB)
Ok, one more update. The above solution was made in Servoy 6.1 rc3. So, I made another solution in Servoy 6.0.6 just to see if it may be a 6.1 issue, however, it behaves the same way. Attached is the 6.0.6 version if needed.
styleChange606.servoy (6.59 KB)
Hi Keith,
Somehow this is not working when extending forms.
What does work is just setting the content of style1 with the content of style2 (so don’t even change the assigned style of the form)
var _jsStyle1 = solutionModel.getStyle('style1');
var _jsStyle2 = solutionModel.getStyle('style2');
_jsStyle1.text = _jsStyle2.text;
Hope this helps.
TY Marc, that is a good work around. I will submit it to support as well.
Thanks again,
Keith
There is an application function that does the same thing ```
application.overrideStyle(‘style1’,‘style2’);
CFDaddy:
I have a form named frmCore which all other forms extend. The styleName on that form is ‘style1’. Depending on the client (Web vs. Smart) I need to change the style of frmCore to style2 for the Web Client. So, here is the code I am using to try to accomplish this:
if(application.getApplicationType() == APPLICATION_TYPES.WEB_CLIENT){
var _cForm = solutionModel.getForm('frmCore')
_cForm.styleName = 'style2';
forms.frmCore.controller.recreateUI();
}
I've tried doing it in frmCore's onLoad method and also in the onSolutionOpen method of my solution but it does not work. Any suggestions?
Thanks,
Keith
Will be fixed in Servoy 6.0.7 release.