The composite elements are a new kind of user created element introduced in Jaspersoft® Studio with version 6.1.1. They allow to create a new element in the palette starting from one or more basic elements, and reuse them whenever you want in any report. For example it is possible to create a composite element using a static text and a text field with some attributes already predefined (like the fonts or the colors). You will have this new element in the palette and when you drag it in the report it will create the same Static Text and Text Field with the same set of properties of the originals.
This composite elements are stored inside a special folder of your Workspace, so when you switch your version of Jaspersoft Studio you can always find your previously created elements as soon as you use the same Workspace.
Create a Composite Element
Creating a Composite Element is really simple. In any report create the elements you want to add to the Composite Element and customize their properties as you want, when you have finished, select these elements, right click on them and from the contextual menu select "Save as Composite Element..". NOTE: A composite element can be created only from a set of Basic Elements, basic means elements that are not depending from a dataset.
When you click this option a Dialog will appear, in this dialog you will be able to specify:
- The name of your Composite Element, this information is mandatory since it will be used inside the palette and must be an unique name
- An optional description for the element
- An optional icon used in the palette for the Composite Element, if this field is leave blank then a default image is used.
- The palette section where this element will be placed
After you have set all the information, press Finish. The element will now be created in the selected palette, NOTE: If you create the element inside a palette and in the next run it is missing, then this can happen maybe because you have created it with a Jaspersoft Studio Pro, placing them inside the Pro Components section of the palette, but you are reusing them into a Community version. The Community version does not have the Pro Components section. In this case and in every case where the palette of a Composite Element is missing, it will be displayed in the Composite Elements section of the palette.
Use a Composite Element
To use your element, you have to simply drag and drop it inside a report, it and all its contents will be created in the same way it was defined originally.
Modify a Composite Element
When you right click on a Composite Element you have 3 options:
- Edit: This option reopens the dialog used to Create the element and all information (name, description, icon and palette location) can be changed.
- Open in Designer: This option can be used to modify the content of the composite element, in other words you can modify the single elements inside it. When this option is selected a special editor will be opened where you can see all the contents of the element and you can modify it as you wish. This editor will look really similar to the report editor but with some simplifications: there will be only a band where the content is placed, there will be no dataset and no possibility to create one and the palette will allow to use only a set of basic elements. In this editor you can add new elements, remove the existing ones or change their properties. When you have finished simply save your work and the associated Composite Element will be reloaded automatically
- Delete: After confirming request this action will simply delete the Composite Element and all its resources
Import/Export of the Composite Elements
The composite elements can be exported and imported in any instance of Jaspersoft Studio.
To Export a Composite Element:
- In the Palette, Right-Click on the the element you want to export and select "Export Composite Elements"
- A dialog will popup and here you can select any number of composite elements to export. The element that was selected in the palette will be already marked for the export. Every element selected in this page will be exported.
- Press "Finish" and select the destination, every element selected and their resources, like images, will be exported into a single Zip container. This container can then be used in the import procedure to get this elements back.
To Import a Composite Element:
- Right-Click on any position in the Palette and select "Import Composite Elements".
- Select a Zip container obtained during the Export procedure.
- A wizard will popup where you can review every element that will be imported, you can define the name, the icon, the description and the palette position of every imported element. However all this fields will be precompiled with the information of the original exported elements, but you can re-define them during the import procedure. If one of the imported elements has the same name as one of the Composite Elements in your workspace, you will need to provide a new name for it, since the name must be unique.
- When you have reviewed all the elements, press Finish to complete the import procedure.