Expand my Community achievements bar.

SOLVED

AEM 6.2 - Touch UI 'pathbrowser' predicate is being ignored

Avatar

Level 3

I am noticing that the predicate defined in the Touch UI dialog in the pathbrowser widget is not picking up the predicate.

<testProperty

    jcr:primaryType="nt:unstructured"

    sling:resourceType="granite/ui/components/foundation/form/pathbrowser"

    fieldDescription="Select from a specific list"

    fieldLabel="Test Property"

    name="./testResult"

    predicate="testpredicate"

    rootPath="/content"/>

In the core project I have the predicate class (just showing the relevant code):

import com.day.cq.commons.predicate.AbstractNodePredicate;

import org.apache.commons.collections.Predicate;

.....

@Service(value = Predicate.class)

@Component(metatype = false)

@Properties({

    @Property(label = "Predicate Name", name = "predicate.name", value = "testpredicate", propertyPrivate = true) })

public class TestThePredicate extends AbstractNodePredicate  {

.....

    @Override

    public final boolean evaluate(final Node node) throws RepositoryException {

        System.out.println("Entro a evaluate(Node)" + node);

        LOGGER.error("********* TestThePredicate: " + "In method evaluate(Node)" + node.getPath);

    }

}

The problem I am facing is that AEM does not pick up the predicate class. I must be missing something somewhere.

In the Felix console the jar is there and also the predicate class is "state satisfied".

Is there by any chance some sort of configuration I need to add?

Thanks!

1 Accepted Solution

Avatar

Correct answer by
Level 3

It's always embarrassing when you not only answer your own question, but have to admit you missed something. I would love to blame this on coffee or beer, but hey, it's pure sloppiness...

The solution is that in the class signature you need to implement the Predicate interface:

public class TestThePredicate extends AbstractNodePredicate implements Predicate {

After adding the missing part, the predicate works!

View solution in original post

3 Replies

Avatar

Correct answer by
Level 3

It's always embarrassing when you not only answer your own question, but have to admit you missed something. I would love to blame this on coffee or beer, but hey, it's pure sloppiness...

The solution is that in the class signature you need to implement the Predicate interface:

public class TestThePredicate extends AbstractNodePredicate implements Predicate {

After adding the missing part, the predicate works!

Avatar

Level 10

Awesome work here - if you send me a package of this - we would love to add this to a community HELPX article.

Avatar

Level 1

Hi,

I think  com.day.cq.commons.predicate.AbstractNodePredicate is deprecated in the AEM 6.4. Do you now another alternative for predicate?