Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

How to create custom pathbrowser predicate?

Avatar

Level 3
Here is part of the dialog <path jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/foundation/form/pathbrowser" fieldDescription="Select media list item link" fieldLabel="Media List Item link" name="./path" predicate="predicate" rootPath="/content"> </path> 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 ContentPagePredicate extends AbstractResourcePredicate { private static final String CQ_TEMPLATE_CONTENT = "/conf/pattern-lab/settings/wcm/templates/content-page"; @Override public boolean evaluate(Resource resource) { if (null != resource) { if (!resource.getResourceType().equals("cq:Page")) { return false; } Page page = resource.adaptTo(Page.class); return page.getTemplate().getName().equals(CQ_TEMPLATE_CONTENT); } return false; } }

Caused by: java.lang.VerifyError: Constructor must call super() or this() before return
Exception Details:
  Location:
    com/day/cq/commons/predicate/AbstractResourcePredicate.<init>()V @1: return
  Reason:
    Error exists in the bytecode
  Bytecode:
    0x0000000: 2ab1  

 

any ideas?

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor
1 Reply

Avatar

Correct answer by
Employee Advisor