How to create a new picker?
How to create my own new picker that only allow to pick a type of node?
Imagine that we want to create a picker that only allow to pick nodes with the mixin
So first, let's declare this mixin:
And let's declare a few components that use this mixin
[jnt:nodeType1] > jnt:content, jmix:basicContent, jmix:testNodeType, jmix:editorialContent - prop1 (string) [jnt:nodeType2] > jnt:content, jmix:basicContent, jmix:testNodeType, jmix:editorialContent - prop2 (string) [jnt:nodeType3] > jnt:content, jmix:basicContent, jmix:testNodeType, jmix:editorialContent - prop3 (string)
Now, we want to declare a new component with a
weakreference property that only allow us to pick nodes with the
[jnt:nodeTypePicker] > jnt:content, jmix:basicContent - nodeTypeRef (weakreference, picker[type='testNodeType'])
To do that, we first need to create a new picker with this name
In the module spring file, we can declare a new bean
testNodeTypepicker. Note that the ID of the bean need to be an aggregation of the name of the picker (
testNodeType) followed by "
Let's set the
editorialpicker as the parent, so we can browse all the
folderTypes from the editorial picker.
And then, we will redefine the list of
nodeTypes we want to allow in our
So this new picker will look like this:
<bean id="testNodeTypepicker" parent="editorialpicker"> <property name="nodeTypes"> <list> <value>jmix:testNodeType</value> </list> </property> </bean>
Note that the editorial picker will only allow you to browse the following list of nodes. This list is defined in the applicationcontext-contentpicker.xml
So maybe you will need to add the
jmix:browsableInEditorialPicker mixin to some of your definitions if you need to browse them (open from the left panel).