我试图找出是否有可能自定义节点的AEM创建时,我首先删除网页上的组件名称。
对CQ:组件节点,在我的组件定义被命名为“知识中心问题”当我放弃它,AEM创建一个使用它的默认命名逻辑页面的节点树命名为“knowledge_center_que”节点。我宁愿为节点名称为“问题”时,它被丢弃(但我宁愿不重命名组件本身)。
好像这种事情必须能够给出是AEM一切是如何定制的,但我在努力寻找答案。
看看:nameHints
,它可以作为发送POST参数传递给SlingPostServlet
:https://sling.apache.org/documentation/bundles/manipulating-content-the-slingpostservlet-servlets-post.html#algorithm-for-node-name-creation
你需要写一个自定义的吊带后处理器。后一个组件在页面下降吊带后处理器被调用。示例代码:
@Component(service = SlingPostProcessor.class, immediate = true, name = "com.aem.CustomPostProcessor")
public class CustomPostProcessor implements SlingPostProcessor {
@Override
public void process(SlingHttpServletRequest request, List<Modification> modifications) throws Exception {
if (accepts(request)) {
final Resource resource = request.getResourceResolver().getResource(request.getResource().getPath());
// Your logic
modifications.add(Modification.onCreated(resource.getPath()));
}
}
protected boolean accepts(SlingHttpServletRequest request) {
return "/my/resource/type".equals(request.getResource().getResourceType());
}
}