Expand my Community achievements bar.

SOLVED

predicate property

Avatar

Level 4

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

1 Accepted Solution

Avatar

Correct answer by
Administrator

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-worry...

 

I hope this would help you.

Thanks and Regards

Kautuk Sahni



Kautuk Sahni

View solution in original post

2 Replies

Avatar

Level 10
Inorder to filter extension in path field you can go for        http://adobeaemclub.com/simple-way-to-restrict-image-type-in-pathfield-xtype/ approach

Avatar

Correct answer by
Administrator

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-worry...

 

I hope this would help you.

Thanks and Regards

Kautuk Sahni



Kautuk Sahni