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


Java Page.listChildren方法代码示例

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


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

示例1: extractPathList

import com.day.cq.wcm.api.Page; //导入方法依赖的package包/类
/**
 * Takes page, filter, depth, the current page path, and extracts a list of children paths
 *
 * @param page The page to extract the list of children paths from
 * @param filter The filter
 * @param depth The depth to recurse on
 * @param currentPage The path of the current page to flag is_current_page
 * @return extractedPaths This is a Collection of Map of Page Object
 */
public static Collection<Map<String, Object>> extractPathList(Page page, Filter<Page> filter, int depth, String currentPage) {
    Collection<Map<String, Object>> pathList = new ArrayList<>();
    Iterator<Page> children = page.listChildren(filter);
    if (depth > 0) {
        while (children.hasNext()) {
            Page child = children.next();
            Map<String, Object> currentPath = new HashMap<>();
            Collection<Map<String, Object>> childPaths = extractPathList(child, filter, depth - 1, currentPage);
            String path = child.getPath();
            currentPath.put(PATH_DETAILS_LIST_PATH_PROPERTY_NAME, path);
            currentPath.put(PATH_DETAILS_LIST_PATHS_PROPERTY_NAME, childPaths);
            if (path.equals(currentPage)) {
                currentPath.put(IS_CURRENT_PAGE,true);
            }
            pathList.add(currentPath);
        }
    }
    return pathList;
}
 
开发者ID:DantaFramework,项目名称:AEM,代码行数:29,代码来源:TraversedListUtils.java

示例2: extractPathListCP

import com.day.cq.wcm.api.Page; //导入方法依赖的package包/类
/**
 * Takes page, filter, depth, the current page path, excluded path, and extracts a list of children paths except the excluded path
 *
 * @param page The page to extract the list of children paths from
 * @param filter The filter
 * @param depth The depth to recurse on
 * @param currentPage The path of the current page to flag is_current_page
 * @param removeCurrentPage The path to be excluded
 * @return extractedPaths This is a Collection of Map of Page Object
 */
public static Collection<Map<String, Object>> extractPathListCP(Page page, Filter<Page> filter, int depth, String currentPage, boolean removeCurrentPage) {
    Collection<Map<String, Object>> pathList = new ArrayList<>();
    Iterator<Page> children = page.listChildren(filter);
    if (depth > 0) {
        while (children.hasNext()) {
            Page child = children.next();
            Map<String, Object> currentPath = new HashMap<>();
            Collection<Map<String, Object>> childPaths = extractPathList(child, filter, depth - 1, currentPage);
            String path = child.getPath();

            if (!path.equals(currentPage)) {
                currentPath.put(PATH_DETAILS_LIST_PATH_PROPERTY_NAME, path);
                currentPath.put(PATH_DETAILS_LIST_PATHS_PROPERTY_NAME, childPaths);
                pathList.add(currentPath);
            } else if (!removeCurrentPage) {
                currentPath.put(PATH_DETAILS_LIST_PATH_PROPERTY_NAME, path);
                currentPath.put(PATH_DETAILS_LIST_PATHS_PROPERTY_NAME, childPaths);
                currentPath.put(IS_CURRENT_PAGE, true);
                pathList.add(currentPath);
            }
        }
    }
    return pathList;
}
 
开发者ID:DantaFramework,项目名称:AEM,代码行数:35,代码来源:TraversedListUtils.java

示例3: findCities

import com.day.cq.wcm.api.Page; //导入方法依赖的package包/类
public List<City> findCities(String basePath, String relPath) {
	List<City> cities = new ArrayList<>();
	Resource resource = resourceResolver.getResource(basePath);

	Page page = resourceResolver.adaptTo(PageManager.class).getContainingPage(resource);
	Iterator<Page> cityPages = page.listChildren();
	while (cityPages.hasNext()) {
		Page cityPage = cityPages.next();
		ValueMap cityProps = cityPage.getContentResource().getValueMap();
		City city = new City();
		city.name = cityProps.get("jcr:title", String.class);
		city.id = cityPage.getName();
		Resource cityView = cityPage.getContentResource().getChild(relPath);
		Download download = new Download(cityView.getChild("image"));
		city.imageSrc = download.getHref();

		cities.add(city);

	}
	return cities;

}
 
开发者ID:sinnerschrader,项目名称:aem-react,代码行数:23,代码来源:CityFinderModel.java

示例4: getItems

import com.day.cq.wcm.api.Page; //导入方法依赖的package包/类
private List<NavigationItem> getItems(Page root) {
    List<NavigationItem> pages = new ArrayList<>();
    if (root.getDepth() < structureDepth) {
        Iterator<Page> it = root.listChildren(new PageFilter());
        while (it.hasNext()) {
            Page page = it.next();
            boolean active = currentPage.getPath().equals(page.getPath()) || currentPage.getPath().startsWith(page.getPath() + "/");
            String title = page.getNavigationTitle();
            if (title == null) {
                title = page.getTitle();
            }
            List<NavigationItem> children = getItems(page);
            int level = page.getDepth() - startLevel;
            Page localizedPage = getLocalizedPage(currentPage, page);
            if (localizedPage != null) {
                page = localizedPage;
            }
            pages.add(new LanguageNavigationItemImpl(page, active, request, level, children, title));
        }
    }

    return pages;
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-core-wcm-components,代码行数:24,代码来源:LanguageNavigationImpl.java

示例5: getItems

import com.day.cq.wcm.api.Page; //导入方法依赖的package包/类
/**
 * Builds the navigation tree for a {@code navigationRoot} page.
 *
 * @param navigationRoot the global navigation tree root (start page)
 * @param subtreeRoot the current sub-tree root (changes depending on the level of recursion)
 * @return the list of collected navigation trees
 */
private List<NavigationItem> getItems(NavigationRoot navigationRoot, Page subtreeRoot) {
    List<NavigationItem> pages = new ArrayList<>();
    if (navigationRoot.structureDepth == -1 || getLevel(subtreeRoot) < navigationRoot.structureDepth) {
        Iterator<Page> it = subtreeRoot.listChildren(new PageFilter());
        while (it.hasNext()) {
            Page page = it.next();
            int pageLevel = getLevel(page);
            int level = pageLevel - navigationRoot.startLevel;
            List<NavigationItem> children = getItems(navigationRoot, page);
            boolean isSelected = checkSelected(page);
            if (skipNavigationRoot) {
                level = level - 1;
            }
            pages.add(new NavigationItemImpl(page, isSelected, request, level, children));
        }
    }
    return pages;
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-core-wcm-components,代码行数:26,代码来源:NavigationImpl.java

示例6: populateItems

import com.day.cq.wcm.api.Page; //导入方法依赖的package包/类
private void populateItems() {
    Page rootPage = WeRetailHelper.findRoot(getCurrentPage());
    if (rootPage != null) {
        Iterator<Page> pageIterator = rootPage.listChildren(new PageFilter());
        while (pageIterator.hasNext()) {
            items.add(UrlHelper.resolveRedirectPage(pageIterator.next(), getPageManager()));
        }
    }
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-sample-we-retail,代码行数:10,代码来源:Footer.java

示例7: listChildrenWithSingleChildPageReturnsIteratorWithThatPage

import com.day.cq.wcm.api.Page; //导入方法依赖的package包/类
@Test
public void listChildrenWithSingleChildPageReturnsIteratorWithThatPage() throws Exception {
	aPage("/content/test/ko/foobar");
	Page target = aPage("/content/test/ko");
	
	Iterator<Page> actual = target.listChildren();
	
	assertThat(actual.next(), pageExistsAt("/content/test/ko/foobar"));
	assertFalse(actual.hasNext());
}
 
开发者ID:quatico-solutions,项目名称:aem-testing,代码行数:11,代码来源:PageTestDriver.java

示例8: listChildrenFilterOfPageWithTrueFilterReturnsAllChildren

import com.day.cq.wcm.api.Page; //导入方法依赖的package包/类
@Test
public void listChildrenFilterOfPageWithTrueFilterReturnsAllChildren() throws Exception {
	aPage("/content/test/ko/foobar");
	Page target = aPage("/content/test/ko");
	
	Iterator<Page> actual = target.listChildren(element -> true);
	
	assertThat(actual.next(), pageExistsAt("/content/test/ko/foobar"));
	assertFalse(actual.hasNext());
}
 
开发者ID:quatico-solutions,项目名称:aem-testing,代码行数:11,代码来源:PageTestDriver.java

示例9: listChildrenFilterOfPageWithFalseFilterReturnsNoChildren

import com.day.cq.wcm.api.Page; //导入方法依赖的package包/类
@Test
public void listChildrenFilterOfPageWithFalseFilterReturnsNoChildren() throws Exception {
	aPage("/content/test/ko/foobar");
	Page target = aPage("/content/test/ko");
	
	Iterator<Page> actual = target.listChildren(element -> false);
	
	assertFalse(actual.hasNext());
}
 
开发者ID:quatico-solutions,项目名称:aem-testing,代码行数:10,代码来源:PageTestDriver.java

示例10: collectChildren

import com.day.cq.wcm.api.Page; //导入方法依赖的package包/类
private void collectChildren(int startLevel, Page parent) {
    Iterator<Page> childIterator = parent.listChildren();
    while (childIterator.hasNext()) {
        Page child = childIterator.next();
        listItems.add(child);
        if (child.getDepth() - startLevel < childDepth) {
            collectChildren(startLevel, child);
        }
    }
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-core-wcm-components,代码行数:11,代码来源:ListImpl.java

示例11: getPages

import com.day.cq.wcm.api.Page; //导入方法依赖的package包/类
/**
 * Returns all the pages of a sub-tree
 * root - root node to start listing from
 * level - how deep to get into the tree
 */
private List<PagePojo> getPages(Page root, int level, Page currentPage) {
    if (root == null || level == 0) {
        return null;
    }
    List<PagePojo> pages = new ArrayList<PagePojo>();
    Iterator<Page> it = root.listChildren(new PageFilter());

    while (it.hasNext()) {
        Page page = it.next();
        Resource pageContentResource = page.getContentResource();
        ValueMap pageValueMap = pageContentResource.adaptTo(ValueMap.class);
        if (pageValueMap.get(PROP_HIDE_IN_NAV, false)) {
            continue;
        }
        if (REDIRECT_RESOURCE_TYPE.equals(pageContentResource.getResourceType())) {
            page = resolveRedirect(pageValueMap);
        }
        boolean isSelected = (currentPage != null
                                && page != null
                                && currentPage.getPath().contains(page.getPath()));
        List<PagePojo> children = pageValueMap.get(PROP_HIDE_SUB_IN_NAV, false)
                ? new ArrayList<PagePojo>()
                : getPages(page, level - 1, currentPage);


        pages.add(new PagePojo(page, isSelected, children));
    }
    return pages;
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-sample-we-retail,代码行数:35,代码来源:Header.java

示例12: getCountries

import com.day.cq.wcm.api.Page; //导入方法依赖的package包/类
/**
 * Returns the list of countries supported by the site
 */
private List<Country> getCountries(Page siteRoot) {
    List<Country> countries = new ArrayList<Country>();
    Page countryRoot = siteRoot.getParent(2);
    if (countryRoot == null) {
        return new ArrayList<Country>();
    }
    Iterator<Page> it = countryRoot.listChildren(new PageFilter());
    while (it.hasNext()) {
        Page countrypage = it.next();
        countries.add(new Country(countrypage.getName(), getLanguages(countrypage, siteRoot)));
    }
    return countries;
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-sample-we-retail,代码行数:17,代码来源:Header.java

示例13: getLanguages

import com.day.cq.wcm.api.Page; //导入方法依赖的package包/类
/**
 * Returns the list of languages supported by the site
 */
private List<Language> getLanguages(Page countryRoot, Page siteRoot) {
    List<Language> languages = new ArrayList<Language>();
    Iterator<Page> langIt = countryRoot.listChildren(new PageFilter());
    while (langIt.hasNext()) {
        Page langPage = langIt.next();
        languages.add(new Language(langPage.getPath(), langPage.getParent().getName(), langPage.getName(),
                langPage.getTitle(), siteRoot.getPath().equals(langPage.getPath())));
    }
    return languages;
}
 
开发者ID:Adobe-Marketing-Cloud,项目名称:aem-sample-we-retail,代码行数:14,代码来源:Header.java


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