Sometimes the xtypes provided by AEM doesn’t fulfill our requirements. So we need to design our custom xtypes on regular basis.
While working with xtype pathfield, I stumbled upon a use case/problem. I wanted a pathfield so that I can choose the product under /etc/commerce/products/accunity/en_us/products hierarchy by a productName property.
Note: Generally, pathfield can show the nodes by its name or jcr:title.
Steps I followed:
I created a widget of xtype:pathfield
If I opened my dialog, I could select any values under /content.
So needed to set rootPath in the widget.
The nodes under products are of type nt:unstructured. By default, pathfield doesn’t allow this types of nodes in the tree hierarchy.
So added a property predicate: nosystem
Now the pathfield looked like this:
But still, it is a very tedious task for the author to select a particular product. I wanted pathfield to show the productName in place of node-name. So I decided to write custom xtype.
The first question here is how this tree structure shows up here:
So while debugging my dialog, I found, it calls currentPath.ext.json and shows the “name”property of JSON in the tree hierarchy.