predicate property | Community
Skip to main content
Level 4
December 23, 2015
Solved

predicate property

  • December 23, 2015
  • 2 replies
  • 1366 views

I need to filter the extensions of files inside a pathfield.
the right way is the predicate.

import org.apache.jackrabbit.commons.predicate.Predicate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Service;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


@Component
@Service
@Property(name = "PredicateVideo", value = "PredicateVideo")
public class PredicateVideo implements Predicate {
protected final Logger log = LoggerFactory.getLogger(this.getClass());

public boolean evaluate(Object obj) {
    log.info("test "+obj.toString());
    return true;
}

}

I have a pathfield with the property predicate equal to PredicateVideo and when i run the page i can see inside the log:

Unable to retrieve the predicate PredicateVideo

Why?

Thanks

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by kautuk_sahni

Hi 

Please go through the documentation of "CQ.form.PathField",

Link:- https://docs.adobe.com/docs/en/cq/5-6/widgets-api/index.html?class=CQ.form.PathField

You can use :

regex :

linkPattern : String

A pattern to format links after selection in the browse dialog (using CQ.Util.patchText). This is used when only a tr...

parLinkPattern : String

A pattern to format links after selection of a paragraph in the browse dialog (using CQ.Util.patchText). This only ap...
  1.  
  2. regex :/\.(png|jpg|jpeg)$/,
  3. regexText : "Please choose an correct file"

 

Or you would need to write custom pathfield, 

Pathfield has a property called predicate which can be used for filtering. You can create and register a custom predicate that returns false for the paths you don't want to be visible in the the dialog. The name of the custom predicate can then be passed to the config of pathfield.

You can find information here : http://wemcode.wemblog.com/custom-predicate-for-pathfield

For more on predicates, the following links can be referred :

http://wemcode.wemblog.com/custom-predicate-for-pathfield

http://www.wemblog.com/2013/04/how-to-create-custom-query-predicate-in.html

http://labs.sixdimensions.com/blog/2013-07-10/custom-predicateevaluators-or-how-i-learned-stop-worrying-and-love/

 

I hope this would help you.

Thanks and Regards

Kautuk Sahni

2 replies

edubey
Level 10
December 23, 2015
Inorder to filter extension in path field you can go for        http://adobeaemclub.com/simple-way-to-restrict-image-type-in-pathfield-xtype/ approach
kautuk_sahni
Community Manager
kautuk_sahniCommunity ManagerAccepted solution
Community Manager
December 24, 2015

Hi 

Please go through the documentation of "CQ.form.PathField",

Link:- https://docs.adobe.com/docs/en/cq/5-6/widgets-api/index.html?class=CQ.form.PathField

You can use :

regex :

linkPattern : String

A pattern to format links after selection in the browse dialog (using CQ.Util.patchText). This is used when only a tr...

parLinkPattern : String

A pattern to format links after selection of a paragraph in the browse dialog (using CQ.Util.patchText). This only ap...
  1.  
  2. regex :/\.(png|jpg|jpeg)$/,
  3. regexText : "Please choose an correct file"

 

Or you would need to write custom pathfield, 

Pathfield has a property called predicate which can be used for filtering. You can create and register a custom predicate that returns false for the paths you don't want to be visible in the the dialog. The name of the custom predicate can then be passed to the config of pathfield.

You can find information here : http://wemcode.wemblog.com/custom-predicate-for-pathfield

For more on predicates, the following links can be referred :

http://wemcode.wemblog.com/custom-predicate-for-pathfield

http://www.wemblog.com/2013/04/how-to-create-custom-query-predicate-in.html

http://labs.sixdimensions.com/blog/2013-07-10/custom-predicateevaluators-or-how-i-learned-stop-worrying-and-love/

 

I hope this would help you.

Thanks and Regards

Kautuk Sahni

Kautuk Sahni