private Page currentPage; // Initialized properly with annotation.
String navTitle = StringUtils.defaultIfEmpty(currentPage.getNavigationTitle(), currentPage.getTitle());
// Displays Navigation title: navTitle123
String newTitle = currentPage.getTitle();
// This displays "ABC Page" instead of "myPageTitle"
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @Mahesh_Gunaje,
I do not thing that there is any fallback. According to official documentation:
Returns the title of the page ornull
if none defined
So behavior you have described looks to be correct. Probably information you have found are wrong. I would suggest to rely on official documentation as a main source, and in case of doubts, ask the question in this community .
Hi @Mahesh_Gunaje,
I do not thing that there is any fallback. According to official documentation:
Returns the title of the page ornull
if none defined
So behavior you have described looks to be correct. Probably information you have found are wrong. I would suggest to rely on official documentation as a main source, and in case of doubts, ask the question in this community .
Thanks @lukasz-m for your quick help.
I was referring to this one. From many source (Not the official one), I got these details only. May be, this is misleading.
One more help I need. Out of the box breadcrumb feature gives the Navigation title first (if its present). else, Page title. Else, jcr:title
if possible, can you provide me the code snippet from the out of the box breadcrumb feature?
Thanks
@Mahesh_Gunaje I would assume that by OOTB Breadcrumb you mean, component from Core Components. In that case, you can find code under Adobe GitHub account.
Thanks @lukasz-m
Looks like, I have found the code used in out of the box breadcrumb feature.
com.adobe.cq.wcm.core.components.internal.models.v1.PageListItemImpl
/**
* Gets the title of a page list item from a given page.
* The list item title is derived from the page by selecting the first non-blank value from the
* following:
* <ul>
* <li>{@link Page#getNavigationTitle()}</li>
* <li>{@link Page#getPageTitle()}</li>
* <li>{@link Page#getTitle()}</li>
* <li>{@link Page#getName()}</li>
* </ul>
*
* @param page The page for which to get the title.
* @return The list item title.
*/
public static String getTitle(@NotNull final Page page) {
return Stream.<Supplier<String>>of(page::getNavigationTitle, page::getPageTitle, page::getTitle)
.map(Supplier::get)
.filter(StringUtils::isNotBlank)
.findFirst()
.orElseGet(page::getName);
}
Views
Like
Replies