|
Configuration
XML configuration fileXML configuration file consists of of a single root element jibe-config and a number of children called configuration elements <jibe-config xmlns="http://www.icodix.com/jibe/config">
<properties-config>
....
</properties-config>
<form-def id="repo.nodeProperties">
.....
</form-def>
<form-def id="repo.nodePropertiesEdit">
....
</form-def>
<form-def id="repo.nodePropertiesEdit" condition="type:'cm:content'">
....
</form-def>
<form-def id="repo.nodePropertiesEdit" condition="group:'GROUP_Some group'" replace="true">
....
</form-def>
</jibe-config>Configuration elementConfiguration element is a child of jibe-core element in xml configuration file. Each configuration element can have following attributes
Configuration evaluationIn order to fully exploit the potential of the framework, it is important to understand how the configuration is evaluated. All registered xml configuration files are parsed in the order of registration. The result of parsing is a list of all configuration elements defined in registered configuration files. This list is indexed with two keys, configuration element name and id attribute. In order to explain how configuration elements are fetched, we will use a small example. Configuration service is usually queried with this type of query. Give me form-def configuration element which has id="repo.nodePropertiesEditLooking at the configuration snippet above the result of such query will be three configuration elements. <form-def id="repo.nodePropertiesEdit"> .... </form-def> <form-def id="repo.nodePropertiesEdit" condition="type:'cm:content'"> .... </form-def> <form-def id="repo.nodePropertiesEdit" condition="group:'GROUP_Some group'" replace="true"> .... </form-def> The next step will be iteration over results and merging using the algorithm explained in the pseudo code bellow. Set result to null
FOR each element in configuration elements list
IF element has condition attribute THAN
IF element condition is satisfied THAN
IF result is not null THAN
IF element has replace attrribute THAN
set result to combine(result,element)
ELSE
set result to element
END IF
ELSE
set result to element
END IF
END IF
ELSE
IF result is not null
IF element has replace attrribute THAN
set result to combine(result, element)
ELSE
set result to element
END IF
ELSE
set result to element
END IF
END IF
END FOR
As we can see from the pseudo code, if condition is satisfied and replace attribute is not true, two configuration elements will be combined into single configuration element. Combination of configuration elementsComponent definition configuration elementThis configuration element is responsible to describe ExtJs component definition in JSON format. This component definition will be sent to client and used to instantiate and render ExtJs component. More details about different component configuration options can be found in ExtJs documentation. In order to explain how exactly is definition JSON created from xml configuration a simple example will be used. This is a definition of initial viewport taken from the quick start guide. <component-def id="core.viewPort" replace="true">
<xtype>viewport</xtype>
<layout>absolute</layout>
<items>
<component id="todoTasks">
<xtype>panel</xtype>
<pageX>20</pageX>
<pageY>20</pageY>
<width>300</width>
<height>300</height>
<html>Hello from Jibe component</html>
</component>
</items>
</component-def>After rendering process the resulting json will look like this {
"xtype" : "viewport",
"layout" : "absolute",
"items" : [{
"xtype" : "panel",
"pageX" : 20,
"pageY" : 20,
"width" : 300,
"height" : 300,
"html" : "Hello from Jibe component",
"id" : "todoTasks"
}]
}As we can see, the structure of resulting JSON and xml configuration is pretty similar with few exceptions. Children of items property are rendered as JSON array, and component element is completely missing and id attribute is added as id property. These differences are result of rendering algorithm which will be explained bellow. Recursively, each child of component-def element is processed. Each processed element appends the result to the JSON stream. What will be the nature of processing depends on the param-templates which can be found in /org.jibeframework.core/src/main/resources/config/configuration-config.xml, just search for the param-templates element. Each param template can define the following for the corresponding element
Returning to the example above, we can see that items element has a handler defined with value core.items. Therefore, to provide content of the item property method org.jibeframework.core.app.controller.ParamHandlers.handleItems(BaseParam) will be invoked. It is also possible to override values defined in param-templates in the component definition <items handler="my.itemsHandler">
<component id="todoTasks">
<xtype>panel</xtype>
<pageX>20</pageX>
<pageY>20</pageY>
<width>300</width>
<height>300</height>
<html>Hello from Jibe component</html>
</component>
</items>Component element which is represented by org.jibeframework.core.ui.param.ComponentParam deserves a bit more explanation. It represent child components and can accept following attributes
| |||||||||||||||||||||||