← servoy magazine

[Tip] Finding associated objects in Servoy 4

  • Tips

by David Workman
Data Mosaic

The Eclipse platform brings powerful searching features to Servoy that we didn't have before. Here are a couple of examples.

1. Find all the objects a method is attached to

How many times have you created a new global method and wanted to use it in place of another global method throughout your solution except for a few instances? This involves finding all the objects that use the old global method. Have fun doing this in Servoy pre-4.0.

In Servoy 4, all methods have a UUID displayed prominently above the method:

[image unavailable: Picture_55]

Copy this UUID, open a new search from the navigation bar, and paste this string in:

[image unavailable: Picture_56]

Running the search will return in the search view pane a list of all the objects that contains this UUID neatly categorized by the containing objects:

[image unavailable: Picture_58]

It is quite easy to tell that on the form "CRM_0F_companies" the UUID string shows up in the form's javascript file and on four objects. Selecting those objects will verify that each one has the method we searched for attached to the "onAction()" event.

2. Find all the forms a form is attached to

It doesn't take long developing a solution in Servoy to create quite a collection of forms. Many of these forms will be included in other forms via tab panels. This leads to form re-usability which is a good thing. It can also lead to editing a form that you didn't realize was used in multiple situations -- which isn't always a good thing.

So before embarking on editing a form, maybe you want to find all the forms which use it. As it turns out, all objects in Servoy have a UUID including forms. It follows that if we use the same search steps used in the first example, the search will return a list of objects containing our form UUID.

The only trick: where is the form UUID? It is not prominently displayed in the "form design" perspective:

[image unavailable: Picture_59]

You need to open the "resource" perspective to find this information:

[image unavailable: Picture_63]

In the project explorer view pane of this perspective, you will see a folder and an object file for each of your forms. Open the object file for the form you want to search for and there you will find the form's UUID:

[image unavailable: Picture_60]

Now do a new search and you will get a search result pane with the results. The form I searched for shows up in two tab panels in two different forms:

[image unavailable: Picture_61]

Switching back to the form design perspective:

[image unavailable: Picture_62]

Summary

Using Eclipse's powerful search capabilities and Servoy UUID's, you can easily find associations between various objects in your solution.

Comments (2)

John Allen
Hi David, Looking forward to playing more with 4.0 (when I get more time!) and utilizing these things. In theory aren't these things available in the servoy_repository db pre-4.0? The problem always has been to link those UUIDs to the objects which I've never been able to figure out :-)
David Workman
Yea, in 3.5 you can do it but it gets a little complicated. Here's an example query to get you started: SELECT element_id, property_value, (select property_name from servoy_content_spec a where a.content_id = b.content_id) as "Property Type", (select (select name from servoy_object_types c where c.object_type_id = a.object_type_id) from servoy_content_spec a where a.content_id = b.content_id) as "Object Type" FROM servoy_element_properties b where element_id in (SELECT element_id FROM servoy_elements where parent_element_id = (SELECT element_id FROM servoy_element_properties where property_value = "FRAMEWORKS_0F_solution" and content_id = 37)) order by element_id Note 1: replace "FRAMEWORKS_0F_solution" with any form name. Note 2: this query does not take into account what the active solution is or what the revision_history is for each element. I would have to expend some brain cells to recall how that is done -- so if you need this, drop me an email.