当前位置: 首页>>代码示例>>Java>>正文


Java Page.getTemplate方法代码示例

本文整理汇总了Java中com.day.cq.wcm.api.Page.getTemplate方法的典型用法代码示例。如果您正苦于以下问题:Java Page.getTemplate方法的具体用法?Java Page.getTemplate怎么用?Java Page.getTemplate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.day.cq.wcm.api.Page的用法示例。


在下文中一共展示了Page.getTemplate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSearchContentResource

import com.day.cq.wcm.api.Page; //导入方法依赖的package包/类
private Resource getSearchContentResource(SlingHttpServletRequest request, Page currentPage) {
    Resource searchContentResource = null;
    RequestPathInfo requestPathInfo = request.getRequestPathInfo();
    Resource resource = request.getResource();
    String relativeContentResource = requestPathInfo.getSuffix();
    if (StringUtils.startsWith(relativeContentResource, "/")) {
        relativeContentResource = StringUtils.substring(relativeContentResource, 1);
    }
    if (StringUtils.isNotEmpty(relativeContentResource)) {
        searchContentResource = resource.getChild(relativeContentResource);
        if (searchContentResource == null) {
            PageManager pageManager = resource.getResourceResolver().adaptTo(PageManager.class);
            if (pageManager != null) {
                Template template = currentPage.getTemplate();
                if (template != null) {
                    Resource templateResource = request.getResourceResolver().getResource(template.getPath());
                    if (templateResource != null) {
                        searchContentResource = templateResource.getChild(NN_STRUCTURE + "/" + relativeContentResource);
                    }
                }
            }
        }
    }
    return searchContentResource;
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-core-wcm-components,代码行数:26,代码来源:SearchResultServlet.java

示例2: getTemplateWithTemplatePropertyReturnsTemplate

import com.day.cq.wcm.api.Page; //导入方法依赖的package包/类
@Test
public void getTemplateWithTemplatePropertyReturnsTemplate() throws Exception {
	Page target = aPage("/content/test/ko", ResourceProperty.TEMPLATE, "/libs/foobar/pages/page");
	
	Template actual = target.getTemplate();
	
	assertThat(client.getResourceResolver().getResource(actual.getPath()), resourceExistsAt("/libs/foobar/pages/page"));
}
 
开发者ID:quatico-solutions,项目名称:aem-testing,代码行数:9,代码来源:PageTestDriver.java

示例3: getAdapter

import com.day.cq.wcm.api.Page; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public <AdapterType> AdapterType getAdapter(Object o, Class<AdapterType> aClass) {
    if (aClass == ContentPolicyMapping.class && o instanceof Resource) {
        Resource resource = (Resource) o;
        ValueMap valueMap = resource.getValueMap();
        String policyPath = valueMap.get("cq:policy", StringUtils.EMPTY);
        Resource policyMappingResource = null;
        if (StringUtils.isNotEmpty(policyPath)) {
            policyMappingResource = resource;
        } else {
            PageManager pageManager = resource.getResourceResolver().adaptTo(PageManager.class);
            if (pageManager != null) {
                Page page = pageManager.getContainingPage(resource);
                if (page != null) {
                    Template template = page.getTemplate();
                    if (template != null && page.getPath().startsWith(template.getPath() + "/")) {
                        // in template; resolve relative to policies node
                        policyPath = template.getPath() + "/policies/" + resource.getPath().replace(template.getPath
                                () + "/structure/", "");
                        policyMappingResource = resource.getResourceResolver().getResource(policyPath);
                    }
                }
            }
        }
        if (policyMappingResource != null) {
            return (AdapterType) new MockContentPolicyMapping(policyMappingResource);
        }
    }
    return null;
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-core-wcm-components,代码行数:32,代码来源:MockAdapterFactory.java


注:本文中的com.day.cq.wcm.api.Page.getTemplate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。