The following example shows two useful variants when adding custom menu items:
| • | You can add your own menus to the main menu bar. |
| • | Menu items, added to either existing or custom menus, can link outside of the server. |
This example creates a new menu named Accounts. It contains the internal search item created in the previous example and an external search with Google.
| 1. | Edit the file <js-webapp>/WEB-INF/actionModel-navigation.xml. Add the menu definition with two menu items to the end of the file. |
The two menu items have a label and an action defined, but no conditions. All users can access these menu items.
The internal search item is the same as the MyCompany Accounts example above. The external search item needs to have its own action that you’ll define in another file.
| 2. | Open the properties file for your edition of JasperReports Server: |
Commercial Editions: | <js-webapp>/WEB-INF/bundles/pro_nav_messages.properties |
Community Project: | <js-webapp>/WEB-INF/bundles/jasperserver_messages.properties |
| 3. | Add three simple labels, one for each key defined in the actionModel file. |
| 4. | If you support multiple locales, add the same message key to the other language bundles. |
| 5. | Edit the file <js-webapp>/scripts/actionModel.primaryNavigation.js. Add the accounts navigation path if you didn’t do so in the previous procedure: |
The accounts navigation path used in the previous example is the same as the one used in this example. It performs a search of reports in the repository containing the word account in their name or description.
| 6. | In the same <js-webapp>/scripts/actionModel.primaryNavigation.js file, add the external search handler function to the end of the file, outside of all other definitions: |
| 8. | When the web app has reloaded, log into JasperReports Server as joeuser. You can see the new Accounts menu with Accounts > Google MyCompany accounts opening a Google search. The following figure shows both the new menu and the external search results. |
Creating a Custom Menu and an External Link |
|
| The menu shown is the one seen by joeuser. The actionModel automatically creates and places the new menu and its menu items. For jasperadmin who also sees the Manage menu, the Accounts menu would be closer to the metalinks; a second menu might overlap them. When creating custom menus whose visibility is based on roles, be sure to test different users to see the different UI layouts. You may need to adjust other parts of the UI, such as the placement of the metalinks or search field. In this case you could use the Themes mechanism as described in Changing the Layout of the UI to avoid overlap with the search field. |
Recommended Comments
There are no comments to display.