Element.getType function

currently, we have three properties for elements in general (ArrayLength, en getElement by Name/Index).

Is it possible to get a getType function?

The result of the function would be, for example: Label, Button, Portal, TabPanel etc…

tnx in advance…

Paul

I stand partially corrected… :D

You can, sort of get, the type, the following way:

plugins.dialogs.showInfoDialog('ElementType',forms[form].elements['name'],'OK')

For Beans you seem to get the Java Object as a string.

I also noticed that something I took for granted doesn’t work for Beans:

forms[form].elements[j].getName();

I assume this doesn’t work on beans, unless itimplements the getName method on the highest level (which is not the case for the PDFEncoder, on which I tested).

So, besides a getType function I’d also like a getName function, which returns the name which you can set on each element in the Servoy Property Editor.

With these functions, you can then loop through all elements on a form, getting their name and type and build your own security, based on named elements. The reason I would need the getType is because per element type you can implement different security features, like: enables, visible, readonly etc…

Tnx in advance again..

Paul

PS: I noticed that adding a portal to a form makes all the selected columns in the portal show up as elements on the form on which the portal is placed on in the Servoy Editor. This way you get acces to functions that shouldn’t be available/do nothing anyway. Is this correct?

PS2: when a Protal is placed on a form, the elements.length function seems to give an incorrect lenght. In my case, with 6 named elements on the form, the function only gives a length of 8, while there are 14 elements shown in the Servoy Editor (8 of them columns in the portal). Doesn’t soudns right to me…

As no one replied on this yet, I’ll just keep typing… :wink:

I now got around the missing getType function with some text string parsing here and there…

For the Name of Beans, I build my own plugin…

But now I got a new one: On elements you got the length, name and index properties. On forms, only the name property is shown in the Servoy Editor. I tried the forms.length property and it seemed to work :D But then I figured out it only takes into account forms that have been shows allready in my current session. So, if I only looked at one for and run the method, the forms.length = 1, if I open three other forms and then check forms.length again, I get 4.

Could this be changed to always give the No of forms in the solution, regardless if they have been shown in the current session?

Paul

can’t be changed at the moment
Also forms[1] can’t be used only forms[name]

That’s too bad… :(

Any other way of retrieving all forms in a solution?

Paul

PS: forms[1] so far seems to work fine… See code below

var formsArray = new Array();
for ( var i = 0 ; i < forms.length ; i++ )
{
	formsArray[i] = forms[i].controller.getName();
}

yes but that only loops through the current forms that are open. And also you have no idea what is under index 1 or 2 .. That can be changed at anytime.

what you need is something like:

application.getFormNames()

But there is currently no such function.

Yep, only the currently loaded forms will be looped trhough, that I discovered. :?

The thing that I do not know which for is at which index and that the index on a form might change at any point, doesn’t really matter, since I just want to get all the formnames.

Any change of adding the application.getforms() function (or adding/altering the logic behind forms.length and forms(index) to work over all forms in the solution and not only the loaded onces?

Can it be added to the feature request list?

Paul

form.length/form[index] will never work. Because it is completely dynamic and also all the forms will never be live if you have 100 forms. Only max +/-30 will be there at one time. It is just a cache.

application.getFormNames() is possible but why do you need to get all the forms?

I would like to be able to get all the named elements per form. I can then build my own security upon that info.

The Servoy Security is good, but I would like to enable the option to alter the settings per User/Usergroup in the Client, for SuperUsers. This is just something I’m accustomed to from other applications. And I would like to integrate this part of the Security with other security settings my solutions have, like which navigation buttons are shown on the form controller per user/usergroup.

Therefor, I was in the proces of extracting all the forms + named elements and storing them in a table, so I would then be able to build my own Security based on that info.

As explained, the application.getForms() function is missing. But, all of this is a workaround… (with quite a few difficulties in making it foolproof) I rather get more flexibility under the security node, so I could build my own Security Admin pages (with the same options as available on the Security form in Developer), which I can enable in the Client.

I think quite a few functions would have to be added to the securitynode, to make that happen.

Paul