Friday, March 24, 2006

Control Your Element Names

For most people, the default element names are just fine. Typically, I write a lot of code because I am trying to show off features of the language. For me, it is easier to use standard and distinct names for all of my report elements. For example, when you add a new DataSource to your project you get the following dialog:

The name of the DataSource is "Data Source". I like all of my DataSources to start with the prefix src and then have a logical name to the DataSource, so I would name this srcClassic. So what I do is I go in and delete the word Data Source, and change it to src.

Fortunately, there is a better way. If you go to:
Windows -> Preferences -> BIRT -> Element Names
you can specify the basic name that is used for any of the BIRT report elements. This makes it easy to create a common set of prefixes to your elements.

I have changed all of my DataSource elements to start with src and all of my DataSet elements start with set. I use ssrc and sset for ScriptedDataSources and ScriptedDataSets. Once I have made this change, I get a new base name for my data sets.

When I create a new DataSrc after applying these changes to the editor, I get the following dialog.

Now my DataSet starts with a prefix of src, all I need to do to change this is add my standard name. This allows me to impose a bit better naming standards on my designs.

This is also a great place to start learning about the differences between the different types of report elements that make up a report. As you start to add prefixes to all of your report elements, you will start to see how each of these elements maps to the Report Object Model.

Scott Rosenbaum


T. Newman said...

From your text, I suspect that the final screenshot (showing the creation of a data source) should show a suggested data source name of src, not set.

Scott Rosenbaum said...

Good catch on the source element. I actually saw that a couple of days after posting, but did not get around to fixing the blog. It is fixed now.