Querybuilder | access property for which path is not fixed - aem

Normally I would use filter for property like cq:tags as mentioned below. Here I know where cq:tags property exists in content structure:
group.5_group.fulltext.relPath=jcr:content/#cq:tags
group.5_group.fulltext=*location*
For any page where I can drop any number of component and property is inside component node, how will I add filter for such properties.
E.g. My component name is component and prop is property. Some exmaple path for porp can be jcr:content/mainParsys/component/#prop or jcr:content/mainParsys/componen_anyrandomValue/#prop
group.5_group.fulltext.relPath=what_should_be_the_path_or_filter
group.5_group.fulltext=*location*

Why are you trying to search through path if it's undefined?
You can go with the resourceType of the component as it will remain same and try your query in Query Debugger as:
type=nt:unstructured
1_property=sling:resourceType
1_property.value=my-project/components/content/component
2_property=myprop
2_property.operation=exists
It worked for me to search for a property inside a component.

Related

Accessibility ARIA issues with react-select

We are using react-select component in one of our projects and trying to resolve accessibility issues. Right now, there is no way to provide the required aria attributes to the input element which has the aria-autocomplete="list" attribute.
https://www.digitala11y.com/aria-autocomplete-properties/
Above is the reference link to what we are trying to achieve. Below is the short story from the above link.
If an element has aria-autocomplete set to list or both, authors MUST ensure both of the following conditions are met:
The element has a value specified for aria-controls that refers to the element that contains the collection of suggested values.
Either the element or a containing element with role combobox has a value for aria-haspopup that matches the role of the element that contains the collection of suggested values.
I opened a PR to add the ability to add ARIA properties to the input element. https://github.com/JedWatson/react-select/pull/4132
But I wanted to check if I'm missing something if anyone has already worked on this. Please let me know if you need any other details.

Search for pages tagged with a tag title

In order to get pages tagged with a certain tag in AEM query builder, we will do as this doc (https://helpx.adobe.com/experience-manager/6-2/sites/developing/using/querybuilder-api.html)
path=/content/...
type=cq:Page
tagid=marketing:interest/product
tagid.property=jcr:content/cq:tags
But how do we get pages that have the same tag title without using the whole tag's ID or full path above ?
For example
path=/content/...
type=cq:Page
tagtitle=product
tagid.property=jcr:content/cq:tags
You could use something like that:
JCR like:
path=/content/..
type=cq:Page
property=jcr:content/#cq:tags
property.value=%tagname
property.operation=like
This would search for cq:tags property with value that ends with "product".
See more about jcr:like function.
Another possible solution:
Full text search:
path=/content/somesite
type=cq:Page
fulltext.relPath=jcr:content/#cq:tags
fulltext=tagname
See more about jcr:contains function

AEM DefaultValue written to JCR

I noticed that when I set my defaultValue for a dropdown, altho it is correctly selected in the drop down when I first add my component to the page it does not write the defaultValue to the corresponding JCR until I edit the component and save it. Even if I just open the corresponding dialog and click OK now my component works as expected because the values have been added to the JCR.
I am sure there is an important piece that I am missing here, does anyone knows how defaultValues that are required in order for the component to render properly can be added to the JCR when they are first added to the page?
Like Shwan say's that's the way it works. The default values or empty texts are only for the dialog. They aren't persisted until the dialog is authored. The properties have to be set by a different method. CQ already ships with this feature and you can do it without any custom code.
Under your component , create a node called cq:template[nt:unstructured] . If all the data is stored on the component node itself , add the default values as properties to cq:template node with name same as the ones in your dialog. In case the data is stored in a child node add a similar node under cq:template node.
Source : http://blogs.adobe.com/experiencedelivers/experience-management/defaults-in-your-component/
I believe that is simply the way it works. The default value specified in a dialog does not get used until the dialog is loaded/saved, so until that happens the node on the JCR repository that is being authored won't have the default value.
We got around this on a project by adding back-end code that was tied to the component (a tag) so that when the component was loaded, if the property did not exist, it would be written with the default the first time. Ex:
if (wcmMode == WCMMode.EDIT )
{
if(!currentNode.hasProperty("SomePropertyThatWillAlwaysExistIfTheDialogHasBeenSaved")) {
currentNode.setProperty("PropertyThatShouldHaveDefault", GlobalConstants.TRUE);
currentNode.getSession().save();
}
}
Like Sharath Madappa say's that's the way it works fine if component name and jsp name same. If you dont have componentname.jsp under component or page, cq:template won't work.(Reference:http://labs.6dglobal.com/blog/2014-07-08/using-the-cq-template/)
If you hava componentname.html under your component, changed the node [cq:template] type to [cq:Template] instead of [nt:unstructured]. In this case, defaultValues can be added to the JCR when they are first added to the page.

Access jcr:content propeties from page node

I have dropdown where the values of options are like jcr:content/jcr:title, jcr:content/jcr:description, /jcr:content/par/entry/text etc. Here the last one is the property of parent, like jcr:title is the property of jcr:content node & text is the property of entry node, but entry has parent par and par has parent jcr:content. I am at the page node and using the below code to fetch such values which doesn't work :
Node n = (Node)nodeIter.next();
log.info(n.getProperty("/jcr:content/par/entry/text"));
Any Idea how to get values in such a way.
Thanks
Remove the starting slash from the property path. It makes the path absolute while you are interested in the relative one (as in other examples you've described):
n.getProperty("jcr:content/par/entry/text");

Accessing value attribute in Protovis lines

I'm using Protovis Arc layout and I'd like to color links between nodes accoriding to the 'value' property defined in dataset. How can I access it?
Dataset is defined like that:
Nodes:
...
{nodeName:"Books"}
...
Links:
...
{source:1, target:4, value:20}
...
arc.link.add(pv.Line).strokeStyle(function(d) d.value > 10 ? "#cc0000" : "#eeeeee"); - does not work
The d property refers to the node. There's no value attribute defined on the node in this case; the link weights are defined on the links, which is why the property function isn't doing what you expect.
You can rewrite your property function to access the link (rather than node) data. The link data is associated with the link's parent panel, and is available as the second argument:
.strokeStyle(function(d, p) p.value > 10 ? "#c00" : "#eee")
There's more of an explanation in the layout documentation. And see also the pv.Layout.Network API reference:
The link mark is added to a child
panel, whose data property is
defined as layout's links property.
The link's data property is then a
two-element array of the source node
and target node. Thus, poperties such
as strokeStyle and fillStyle can
be overridden to compute properties
from either the node data (the first
argument) or the link data (the second
argument; the parent panel data)
dynamically.