DOCUMENTATION How-to use spring configurations to modify Jahia GWT Interfaces Jahia’s next-generation, open source CMS stems from a widely acknowledged vision of enterprise application convergence – web, document, search, social and portal – unified by the simplicity of web content management. Jahia Solutions Group SA 9 route des Jeunes, CH-1227 Les acacias Geneva, Switzerland http://www.jahia.com How-to use spring configurations to modify Jahia GWT Interfaces Summary 1 Introduction ................................................................................................................................................ 3 1.1 Pre-requisites........................................................................................................................................ 3 1.2 Generate your module ......................................................................................................................... 3 1.3 Create or modify UIs through your modules ........................................................................................ 4 1.3.1 Add a new GWT menu Item .......................................................................................................... 4 1.3.2 Add a new GWT tab in the Selector ............................................................................................... 8 1.3.3 Use spring to create your own picker .......................................................................................... 10 1.4 Use spring to override Jahia configuration......................................................................................... 12 © 2002 – 2013 Jahia Solutions Group SA Page 2 / 15 How-to use spring configurations to modify Jahia GWT Interfaces 1 Introduction In Jahia 6.5, you can now embed spring configuration files directly in your module. The goal of this documentation is to show you what you can do with this spring files in order to modify / extend Jahia’s Edit Mode GUI (created and compiled with GWT). 1.1 Pre-requisites Have a running Maven configuration Have a Java IDE that supports Maven (Eclipse + M2 / IntelliJ / Netbeans / …) 1.2 Generate your module In command line, enter: mvn archetype:generate -DarchetypeCatalog=http://maven.jahia.org/maven2 When prompted, choose: 3: http://maven.jahia.org/maven2 -> jahia-module-archetype (Jahia archetype for creating a new module (for Jahia version >= 6.5)) Then fulfill the different values : artifactId : springDemo jahiaPackageVersion : 6.5.0 moduleName : Spring Demo Your module is now generated. It is a maven project than you can open in your IDE. In the webapp /META-INF/spring folder, you a file springDemo.xml.disabled. You can rename it to springDemo.xml to start playing with spring configuration. © 2002 – 2013 Jahia Solutions Group SA Page 3 / 15 How-to use spring configurations to modify Jahia GWT Interfaces 1.3 Create or modify UIs through your modules You can add some GWT items in the Jahia interfaces (Edit Mode / Studio Mode / Administration / …) directly by using Spring configuration. Of course, you can directly modify the applicationcontext-*.xml files, but a more elegant way is to put your configuration directly in your own modules. Let’s see a few examples have what can be easily achieved 1.3.1 Add a new GWT menu Item You may want to add a new item in the right click on a page of the left panel like that: For that, you just have to define the object to create in your definition.cnd : [jnt:navMenuImage] > jnt:content, jmix:navMenuItem, mix:title - image (weakreference, picker[type='image']) mandatory - type (string, choicelist[linktypechoicelist]) mandatory And then to create an item in the spring configuration file (springDemo .xml) associated with this type : © 2002 – 2013 Jahia Solutions Group SA Page 4 / 15 How-to use spring configurations to modify Jahia GWT Interfaces In this bean, we of course define values for the different Item’s attributes (please refer to the related documentation for more details about that), but we also specify some properties to define where Spring need to inject the bean. This is the case of the parent property and positionBefore property. How does it work? The parent property represents the path of the parent where we want to be injected as child. In our case, the path is “editmode.tabs[0].treeContextMenu” it means that we are looking for a bean named “editmode”… This bean is in applicationcontext-editmode.xml : Inside this bean, we want to “enter” in the first bean of the tabs list: © 2002 – 2013 Jahia Solutions Group SA Page 5 / 15 How-to use spring configurations to modify Jahia GWT Interfaces And finally we target the treeContextMenu property: © 2002 – 2013 Jahia Solutions Group SA Page 6 / 15 How-to use spring configurations to modify Jahia GWT Interfaces We are now positioned on the parent. Let’s use the positionBefore property to know where to put the bean to inject. In our case the value of this property is Toolbar.Item.Publish, so we will be injected here: © 2002 – 2013 Jahia Solutions Group SA Page 7 / 15 How-to use spring configurations to modify Jahia GWT Interfaces Depending on the situation, you can use the positionAfter property, which uses the same mechanism, or the position property, which take a number as value to specify the position. Now that you know how to inject a GWT Item in a specific path, you can adapt this example to your needs. 1.3.2 Add a new GWT tab in the Selector In some situations, it could be useful to add a new tab in the left panel we call Selector: © 2002 – 2013 Jahia Solutions Group SA Page 8 / 15 How-to use spring configurations to modify Jahia GWT Interfaces One more time, the spring configuration allows doing this directly from modules, here is an example, which adds a new “content tab” that only displays modules of type social components: Here, as there is only one point to insert a side panel tab, we just have to specify the id of the parent bean and not the full path. Moreover, we need to specify the position where we want to put the item. It will inject the bean at the right position in the tabs property list: © 2002 – 2013 Jahia Solutions Group SA Page 9 / 15 How-to use spring configurations to modify Jahia GWT Interfaces Some Jahia users create a new tab to display all their specific content types, while default ones provided by Jahia are located in the standard tab, some others used this technic to regroup domain specific content types (finance, law, chemistery…) then use the permissions to define what group of users can access those different tabs. 1.3.3 Use spring to create your own picker Sometimes, you want to use your own picker, to select pages or specific types of nodes. For example, imagine you have this kind of data structure: You want to have a dedicated picker to associate a speaker to your video. It should allow to browse the web site, but only to select nodes of type “jnt:speaker”. For that, you will first create a new picker in the springDemo.xml file : © 2002 – 2013 Jahia Solutions Group SA Page 10 / 15 How-to use spring configurations to modify Jahia GWT Interfaces Please take a look at this file “\webapp\WEB-INF\etc\spring\uicomponents\applicationcontextcontentpicker.xml” in the Jahia install dir to get a full example of picker. The interesting parts of a picker are, the nodeTypes, it defines the selectable node types; the folderType, it defines the folder types that can be displayed. And then it is a configuration of what should be displayed in the picker, for example copy © 2002 – 2013 Jahia Solutions Group SA Page 11 / 15 How-to use spring configurations to modify Jahia GWT Interfaces / paste button, search fields, ect … Finally, you can see a repositories property, it allows to define what the user will be able to browse : site for the current site, sites for all the web site of the platform, … When your new picker is defined, you can now use it in your definition file. For that, take the bean id value, without the picker post fix: It’s done, you will now use your custom picker to select nodes only of type jnt:speaker, on any site of the platform. /!\ Warning, if you define your picker in a module A, and use it in the CND of a module B, you must define a dependency from B to A. Fo r that add a <depends> tag in the pom.xml of module B, and put the name of module A inside. 1.4 Use spring to override Jahia configuration The latest interesting usage of Spring inside your module, is to override the Jahia configuration without modifying the original configuration files. For the example, we want to override some existing GWT items to put some restrictions on it. For example, modify the Import / Export items to be only displayed for users who have special permissions. For that we need to create a special package in the resources folder of our module, named “org.jahia.config” and create inside a file named applicationcontext-xxxxx.xml : © 2002 – 2013 Jahia Solutions Group SA Page 12 / 15 How-to use spring configurations to modify Jahia GWT Interfaces When Jahia is started, Spring loads all the Jahia applicationcontext-xxx.xml files, in the /etc/spring folder, and then load all the applicationcontext-xxx.files in the org.jahia.config package defined by modules. That’s why the module configuration overrides the Jahia configuration. In this file, we have nothing special to do. Just create a bean with the same ID than the bean that you want to override, and modify or add properties depending of what you want to do. In our cases we just add a visibility property. Original beans: Overridden beans: © 2002 – 2013 Jahia Solutions Group SA Page 13 / 15 How-to use spring configurations to modify Jahia GWT Interfaces That’s all! So you are free to override any beans in Jahia with a specified ID. The main advantage of this method is to keep standard configuration fi © 2002 – 2013 Jahia Solutions Group SA Page 14 / 15 How-to use spring configurations to modify Jahia GWT Interfaces Jahia Solutions Group SA 9 route des Jeunes, CH-1227 Les acacias Geneva, Switzerland http://www.jahia.com © 2002 – 2013 Jahia Solutions Group SA Page 15 / 15
© Copyright 2024