내 커뮤니티 업적 표시줄을 확대합니다.

Submissions are now open for the 2026 Adobe Experience Maker Awards.

Mark Solution

활동이 없어 이 대화는 잠겼습니다. 새 게시물을 작성해 주세요.

해결됨

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 채택된 해결책 개

Avatar

정확한 답변 작성자:
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

원본 게시물의 솔루션 보기

2 답변 개

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

정확한 답변 작성자:
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