Expand my Community achievements bar.

TouchUI Dialog Pathbrowser Predicates

Avatar

Level 2

Use Case: I want sorted nodes in touUI dialog Pathbrowser . .I am using predicates for implementing the same .But Somehow Predicate Java class is not running .

Dialog node

<productPath jcr:primaryType="cq:Widget" allowBlank="false" predicate="predicate" <-- refers to the OSGi service fieldLabel="Product" name="./productPath" xtype="granite/ui/components/foundation/form/pathbrowser"/>

 

Java Class :

package com.cs.core.components;

import javax.jcr.Node;
import javax.jcr.RepositoryException;

import org.apache.commons.collections.Predicate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Properties;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.api.resource.Resource;

import com.day.cq.commons.predicate.AbstractResourcePredicate;
import com.day.cq.wcm.api.Page;

@Component(label = "Content-page Predicate", description = "This predicate is used to restricted to allow selection of pages that have template content-page")
@Service(value = Predicate.class)
@Properties({
     @Property(label = "Predicate Name", name = "predicate.name", value = "predicate", propertyPrivate = true) })
public class Test extends AbstractResourcePredicate {

  //  private static final String CQ_TEMPLATE_CONTENT = "/home/user/author";

    @Override
    public boolean evaluate(Resource resource) {
        if (null != resource) {
           
           
try {
     Node node = resource.adaptTo(Node.class);
    System.out.println("Node name :"+node.getName());
} catch (RepositoryException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}
            //return page.getTemplate().getName().equals(CQ_TEMPLATE_CONTENT);

        }
        return false;
    }
}

0 Replies