Is the "titleText" property of JSLabel objects deprecated?

Hi all,

I encountered an error in the servoy_sample_solutionModel example, where the createElement() function in globals.js throws the following error message when loading a form that had previously been edited by a user (using the sample solutions “Design” mode) and contains a new JSLabel entity:

Java class "com.servoy.j2db.scripting.solutionmodel.JSLabel" has no public instance field or method named "titleText".

I checked the code and found that while JSComponent does list “titleText” as a property, JSLabels’ documentation does not list the property:

http://wiki.servoy.com/display/public/DOCS/JSLabel;jsessionid=64A6E95EFFB7F7B265EAAF457CA75109

To add to the confusion, the Properties panel in the Servoy development environment also shows the “titleText” attribute when selecting a label in the design view.

So I was wondering whether the “titleText” property is deprecated in the newest version of Servoy (using 6.0.6 - build 1232), or whether the error is somewhere else. In the meantime I commented out the culprit line of code from createElement(), as this doesn’t seem to affect functionality.

Thanks and kind regards,

Micah

just use:

jsLabel.text = "myTxt"

Hi Marc,

thanks for the reply. I’ve had another look at the sample solution and that code at the beginning of createElement() seems to be a little dodgy.

/** @type {JSComponent}*/
	var jscomponent;
	if (element_rec.element_type == 0)
	{
		
		jscomponent = jsform.newField(element_rec['dataprovider_id'], element_rec['field_type'], element_rec['xlocation'], element_rec['ylocation'], element_rec['width'], element_rec['height'])
		if (element_rec.display_options == 1) jscomponent.editable = false;
		jscomponent.titleText = element_rec['label'];
	}
	else if (element_rec.element_type == 1)
	{
		jscomponent = jsform.newLabel(element_rec['label'], element_rec['xlocation'], element_rec['ylocation'], element_rec['width'], element_rec['height'], null);
		jscomponent.transparent = true;
		jscomponent.text = element_rec['label'];//Micah: text Seems to be deprecated? 
	}

The jscomponent variable is created with a JSComponent type, but is then initialised as either a JSField or JSLabel. In the else statement, where the variable is initialised as a JSLabel, Servoy seems to get confused, seing the variable as a JSField, which doesn’t have the .text property.

It’s not a major issue, but I wanted to bring it up because it might confuse others trying to use the sample. If there is any “perfect” solution for this, I think it would be useful, since this kind of programming pattern can appear in other places too.

Cheers,
Micah