本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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()));
}
}
}
示例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());
}
示例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());
}
示例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());
}
示例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);
}
}
}
示例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;
}
示例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;
}
示例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;
}