<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Sourced Code</title>
	<atom:link href="https://sourcedcode.com/feed" rel="self" type="application/rss+xml" />
	<link>https://sourcedcode.com</link>
	<description>AEM Blog Made Just for You.</description>
	<lastBuildDate>Fri, 10 Apr 2026 20:15:24 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.4.8</generator>

<image>
	<url>https://sourcedcode.com/wp-content/uploads/2019/09/cropped-favicon-32x32.png</url>
	<title>Sourced Code</title>
	<link>https://sourcedcode.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Pipeline-Free URL Redirects &#038; ACS Commons Redirect Map Manager Now Supported on AEMaaCS</title>
		<link>https://sourcedcode.com/blog/aem/pipeline-free-url-redirects-acs-commons-redirect-map-manager-now-supported-on-aemaacs</link>
					<comments>https://sourcedcode.com/blog/aem/pipeline-free-url-redirects-acs-commons-redirect-map-manager-now-supported-on-aemaacs#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Thu, 07 Nov 2024 02:11:50 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[AEMaaCS]]></category>
		<category><![CDATA[Caching]]></category>
		<category><![CDATA[Dispatcher]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=7520</guid>

					<description><![CDATA[<p>Adobe’s recent AEM version 18311 release (October 28-30, 2024) brings valuable updates for URL redirection management in AEM as a Cloud Service (AEMaaCS). This release introduces Pipeline-Free URL Redirects and, importantly, full support for ACS Commons Redirect Map Manager. These changes allow AEM developers to manage URL redirects directly within the AEM Cloud environment, with [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/pipeline-free-url-redirects-acs-commons-redirect-map-manager-now-supported-on-aemaacs">Pipeline-Free URL Redirects &#038; ACS Commons Redirect Map Manager Now Supported on AEMaaCS</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Adobe’s recent <strong>AEM version <a href="https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/release-notes/maintenance/2024/2024-10-0?lang=en#18311" rel="noopener" target="_blank">18311</a></strong> release (October 28-30, 2024) brings valuable updates for URL redirection management in <strong>AEM as a Cloud Service (AEMaaCS)</strong>. This release introduces <strong><a href="https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/implementing/content-delivery/pipeline-free-url-redirects" rel="noopener" target="_blank">Pipeline-Free URL Redirects</a></strong> and, importantly, full support for <strong><a href="https://adobe-consulting-services.github.io/acs-aem-commons/features/redirect-map-manager/index.html" rel="noopener" target="_blank">ACS Commons Redirect Map Manager</a></strong>. These changes allow AEM developers to manage URL redirects directly within the AEM Cloud environment, with improved performance, scalability, and flexibility.</p>
<div class="mention-block">
    <strong>Quick Links</strong></p>
<ol>
<li><a href="#background_redirect_map_manager_vs_redirect_manager_in_aemaacs">Background: Redirect Map Manager vs. Redirect Manager in AEMaaCS</a></li>
<li><a href="#key_benefits_of_the_new_setup">Key Benefits of the New Setup</a></li>
<li><a href="#how_to_configure_pipeline_free_url_redirects_with_redirect_map_manager">How to Configure Pipeline-Free URL Redirects with Redirect Map Manager</a></li>
<li><a href="#conclusion">Conclusion</a></li>
</ol>
</div>
<p><a href="https://sourcedcode.com/wp-content/uploads/2024/11/adobes-redirect-solutions.png"><img fetchpriority="high" decoding="async" src="https://sourcedcode.com/wp-content/uploads/2024/11/adobes-redirect-solutions.png" alt="Adobe's Supported AEMaaCS Redirect Solutions" width="1642" height="872" class="alignnone size-full wp-image-7524" srcset="https://sourcedcode.com/wp-content/uploads/2024/11/adobes-redirect-solutions.png 1642w, https://sourcedcode.com/wp-content/uploads/2024/11/adobes-redirect-solutions-300x159.png 300w, https://sourcedcode.com/wp-content/uploads/2024/11/adobes-redirect-solutions-1024x544.png 1024w, https://sourcedcode.com/wp-content/uploads/2024/11/adobes-redirect-solutions-768x408.png 768w, https://sourcedcode.com/wp-content/uploads/2024/11/adobes-redirect-solutions-1536x816.png 1536w, https://sourcedcode.com/wp-content/uploads/2024/11/adobes-redirect-solutions-600x319.png 600w" sizes="(max-width: 1642px) 100vw, 1642px" /></a></p>
<hr class="spacer-large"/>
<h2 id="background_redirect_map_manager_vs_redirect_manager_in_aemaacs">Background: Redirect Map Manager vs. Redirect Manager in AEMaaCS</h2>
<p>Previously, <strong>ACS Commons Redirect Map Manager</strong> was unsupported on AEMaaCS, limiting options for handling redirects. As a workaround, customers needed to use <strong>ACS Commons Redirect Manager</strong>, which came with several challenges:</p>
<ul>
<li><strong>Reliance on Dispatcher Rules</strong>: Redirect Manager required that all redirect requests pass through the Dispatcher’s rules to reach the AEM publishers, where Redirect Manager rules could then be executed. This dependency on Dispatcher configurations often led to complications. Only requests meeting specific Dispatcher criteria reached the publisher, and requests blocked by earlier Dispatcher rules (e.g., rules for file types or specific paths) would bypass the publisher entirely, causing some redirects to fail.</li>
<li><strong>Potential for Conflicting Rules</strong>: Dispatcher has its own rewrite rules, which can sometimes interfere with redirects set in Redirect Manager. If a Dispatcher rewrite rule processes a request before it reaches Redirect Manager, it can override the redirect, leading to unexpected behaviors or even redirect loops. This makes troubleshooting and coordinating rules more challenging.</li>
<li><strong>Increased Maintenance and Complexity</strong>: Coordinating Dispatcher rules with Redirect Manager required ongoing adjustments to ensure consistency across both levels. This setup added maintenance overhead, as new rules or configurations in the Dispatcher required verification to avoid interfering with existing redirects.</li>
</ul>
<p>With <strong>AEM version <a href="https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/release-notes/maintenance/2024/2024-10-0?lang=en#18311" rel="noopener" target="_blank">18311</a></strong> and the support for <strong>ACS Commons Redirect Map Manager</strong>, these limitations are greatly reduced. Redirect Map Manager now allows redirect processing to be handled entirely at the edge by the Dispatcher, minimizing reliance on AEM publishers and aligning with Adobe’s best practices for cloud environments.</p>
<hr class="spacer-large"/>
<h2 id="key_benefits_of_the_new_setup">Key Benefits of the New Setup</h2>
<h3>1. Offloading Redirects to the Dispatcher</h3>
<p>With <strong>ACS Commons Redirect Map Manager</strong>, redirect processing is managed at the Dispatcher level, reducing the need for requests to be handled by publishers. This shift improves performance and scalability:</p>
<ul>
<li><strong>Previous Configuration with Redirect Manager</strong>: The first request for a redirect had to be processed by the AEM publisher, placing load on the AEM instance until CDN caching took effect. For high-traffic sites, this dependency on the publisher created potential performance bottlenecks.</li>
<li><strong>New Configuration with Redirect Map Manager</strong>: Redirects are processed directly by the Dispatcher, with CDN caching supporting subsequent requests. This reduces publisher load and improves response times, allowing for smoother handling of large-scale redirects.</li>
</ul>
<h3>2. Simplified Management with Fewer Conflicts</h3>
<p>Redirect Map Manager reduces the likelihood of conflicts with Apache’s Dispatcher rewrite rules:</p>
<ul>
<li><strong>Better Coordination with Dispatcher Rules</strong>: With redirect processing fully managed at the Dispatcher, Redirect Map Manager rules are less likely to conflict with existing rewrite rules, eliminating the need to pass through complex Dispatcher configurations to reach the publisher.</li>
<li><strong>Reduced Complexity</strong>: Redirect Map Manager’s edge-based handling simplifies redirect rule management, enabling more consistent behavior and reducing the need for Dispatcher-publisher coordination.</li>
</ul>
<h3>3. Greater Flexibility for Business Users</h3>
<p>This update provides a more accessible and flexible redirection setup for business users who need to control redirects but may lack access to development pipelines:</p>
<ul>
<li><strong>User-Friendly Management Interface</strong>: ACS Commons Redirect Map Manager offers an intuitive interface within AEM for managing redirects. Business users can easily create, edit, and organize large numbers of redirects without requiring deployments or extensive pipeline configurations.</li>
<li><strong>Scalability for Large-Scale Operations</strong>: Redirect Map Manager supports thousands of redirects directly within AEM, making it ideal for business-driven redirect management at scale.</li>
</ul>
<hr class="spacer-large"/>
<h2 id="how_to_configure_pipeline_free_url_redirects_with_redirect_map_manager">How to Configure Pipeline-Free URL Redirects with Redirect Map Manager</h2>
<p>Setting up pipeline-free redirects with the ACS Commons Redirect Map Manager in AEMaaCS is straightforward:</p>
<ol>
<li><strong>Define Redirect Maps</strong>: In the <span class="code-highlight-secondary">managed-rewrite-maps.yaml</span> file, specify paths to redirect files stored in the publish repository.</li>
<li><strong>Manage Redirects in Redirect Map Manager</strong>: Use the Redirect Map Manager’s user interface to set up and organize redirect mappings. The tool’s UI allows direct integration with Dispatcher for a streamlined process.</li>
<li><strong>Configure Apache RewriteMap</strong>:
<ul>
<li>Set up the <span class="code-highlight-secondary">RewriteMap</span> directive in Apache to ensure optimal redirect caching and performance at the Dispatcher level. Here’s a sample configuration:</li>
</ul>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">RewriteMap map.<span style="color: #006633;">foo</span> dbm<span style="color: #339933;">=</span>sdbm<span style="color: #339933;">:/</span>tmp<span style="color: #339933;">/</span>rewrites<span style="color: #339933;">/</span>my.<span style="color: #006633;">map</span><br />
RewriteCond $<span style="color: #009900;">&#123;</span>map.<span style="color: #006633;">foo</span><span style="color: #339933;">:</span>$1<span style="color: #009900;">&#125;</span> <span style="color: #339933;">!</span><span style="color: #0000ff;">&quot;&quot;</span><br />
RewriteRule <span style="color: #339933;">^</span><span style="color: #009900;">&#40;</span>.<span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span>$ $<span style="color: #009900;">&#123;</span>map.<span style="color: #006633;">foo</span><span style="color: #339933;">:</span>$1<span style="color: #339933;">|/</span><span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#91;</span>L,R<span style="color: #339933;">=</span><span style="color: #cc66cc;">301</span><span style="color: #009900;">&#93;</span></div></td></tr></tbody></table></div>
</li>
</ol>
<p>For a deeper dive into this feature, visit Adobe’s full article: <a href="https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/implementing/content-delivery/pipeline-free-url-redirects" target="_blank" rel="noopener">Pipeline-Free URL Redirects</a>.</p>
<p>Visit the official <a href="https://adobe-consulting-services.github.io/acs-aem-commons/features/redirect-map-manager/index.html" rel="noopener" target="_blank">ACS Commons Redirect Map Manager Page</a>.</p>
<hr class="spacer-large"/>
<h2 id="conclusion">Conclusion</h2>
<p>The introduction of ACS Commons Redirect Map Manager support in AEMaaCS marks a significant improvement in URL redirection management. By handling redirects at the Dispatcher, this feature enhances performance, reduces complexity, and minimizes publisher load, all while aligning with Adobe’s best practices for AEM Cloud environments.</p>
<p>With these changes, managing large-scale redirects in AEMaaCS becomes more efficient, flexible, and scalable, making it easier for teams to maintain high performance and consistency across their AEM implementations.</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/pipeline-free-url-redirects-acs-commons-redirect-map-manager-now-supported-on-aemaacs">Pipeline-Free URL Redirects &#038; ACS Commons Redirect Map Manager Now Supported on AEMaaCS</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/pipeline-free-url-redirects-acs-commons-redirect-map-manager-now-supported-on-aemaacs/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>AEM is Dead in 2024 and Beyond, Blog for AEM Engineers</title>
		<link>https://sourcedcode.com/blog/aem/aem-is-dead-in-2024-and-beyond-blog-for-aem-engineers</link>
					<comments>https://sourcedcode.com/blog/aem/aem-is-dead-in-2024-and-beyond-blog-for-aem-engineers#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Sun, 08 Sep 2024 19:34:54 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=7380</guid>

					<description><![CDATA[<p>The global recession of 2023 and 2024 has shaken the tech industry to its core. Layoffs are frequent, and platforms like layoffs.fyi show us just how widespread the downsizing has become. As a result, the job market is flooded with skilled engineers, and employers have their pick of the best talent. This makes it an [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/aem-is-dead-in-2024-and-beyond-blog-for-aem-engineers">AEM is Dead in 2024 and Beyond, Blog for AEM Engineers</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>The global recession of 2023 and 2024 has shaken the tech industry to its core. Layoffs are frequent, and platforms like <a href="https://layoffs.fyi/" rel="noopener" target="_blank">layoffs.fyi</a> show us just how widespread the downsizing has become. As a result, the job market is flooded with skilled engineers, and employers have their pick of the best talent. This makes it an incredibly competitive landscape for those looking to land new roles.</p>
<p>As an <strong>AEM (Adobe Experience Manager)</strong> engineer, you might be feeling the weight of these challenges. Perhaps you&#8217;re seeing fewer full-time positions, rejections are piling up, or you’re struggling to even secure interviews. It&#8217;s understandable that you might start wondering if <strong>AEM is becoming obsolete</strong> or that your career path is in jeopardy.</p>
<p>But here’s the truth: <strong>AEM is far from dead</strong>. In fact, with the rise of <strong>AEM as a Cloud Service (AEMaaCS)</strong>, the platform is only growing in relevance as more organizations adopt cloud-native digital experience solutions. Now, more than ever, <strong>AEM engineers should stay the course</strong>. Here’s why.</p>
<div class="mention-block">
    <strong>Quick Links</strong></p>
<ol>
<li><a href="#why_aem_engineers_shouldnt_give_up">Why AEM Engineers Shouldn’t Give Up</a></li>
<li><a href="#aem_engineers_and_anmga_opportunities_in_the_top_5_tech_companies">AEM Engineers and ANMGA: Opportunities in the Top 5 Tech Companies</a></li>
<li><a href="#the_rise_of_aem_as_a_cloud_service_aemaacs">The Rise of AEM as a Cloud Service (AEMaaCS)</a></li>
<li><a href="#aem_65_still_going_strong_with_no_plans_for_deprecation">AEM 6.5: Still Going Strong with No Plans for Deprecation</a></li>
<li><a href="#aem_thrives_in_major_enterprises">AEM Thrives in Major Enterprises</a></li>
<li><a href="#aem_is_evolving_not_dying">AEM is Evolving—Not Dying</a></li>
<li><a href="#conclusion_aem_is_alive_and_thriving">Conclusion: AEM is Alive and Thriving</a></li>
</ol>
</div>
<hr class="spacer-larger"/>
<h2 id="why_aem_engineers_shouldnt_give_up">1. Why AEM Engineers Shouldn’t Give Up</h2>
<p>It’s no secret that the current recession has made it harder for AEM engineers to find long-term roles. Companies are in survival mode, focusing on cost-cutting, which often means pausing hiring for major projects. As an AEM engineer, you might feel like opportunities are shrinking.</p>
<p>But this downturn is <strong>temporary</strong>. AEM has proven resilient over the years, evolving alongside the digital landscape. <strong>AEMaaCS</strong> is a game-changer, and it’s helping businesses stay nimble in the cloud-first world. As companies move to cloud platforms, <strong>the demand for AEM experts is not disappearing—it’s evolving</strong>.</p>
<p>While full-time roles may be harder to find, many businesses are still in need of <strong>AEM consultants</strong> and <strong>freelancers</strong> to keep their digital platforms running smoothly. Whether it’s handling content migrations, site optimizations, or cloud transitions, there are still plenty of <strong>contract-based opportunities</strong> out there to help you stay active in the industry in this temporary downturn.</p>
<hr class="spacer-larger"/>
<h2 id="aem_engineers_and_anmga_opportunities_in_the_top_5_tech_companies">2. AEM Engineers and ANMGA: Opportunities in the Top 5 Tech Companies</h2>
<p>If you’ve ever dreamed of working for a major tech company, the landscape has changed. What was once referred to as <strong>FANG</strong> (Facebook, Apple, Netflix, Google) has evolved into <strong>ANMGA</strong>—the <strong>top 5 tech companies in the world</strong>: <strong>Apple</strong>, <strong>NVIDIA</strong>, <strong>Microsoft</strong>, <strong>Google</strong>, and <strong>Amazon</strong>. And here’s the great news: <strong>AEM is a critical tool in the digital ecosystems of these tech giants</strong>.</p>
<p>In fact, <strong>Apple</strong>, <strong>Microsoft</strong>, and <strong>NVIDIA</strong> all use <strong>Adobe Experience Manager</strong> to manage their digital presence. This significantly boosts the chances for an AEM engineer to land a role at a <strong>top 5 tech company</strong>. As these organizations continue to scale and expand their digital operations, the demand for skilled AEM engineers will remain strong.</p>
<hr class="spacer-medium"/>
<h3 id="top_5_tech_companies_using_aem_anmga">Top 5 Tech Companies Using AEM (ANMGA):</h3>
<ul>
<li><a href="https://www.apple.com"><strong>Apple</strong></a>: Known for its innovation and user-centric experiences, Apple uses AEM to manage vast amounts of content across its digital channels.</li>
<li><a href="https://www.nvidia.com"><strong>NVIDIA</strong></a>: A leader in AI and graphics processing, NVIDIA leverages AEM to streamline its digital experiences for customers and partners.</li>
<li><a href="https://www.microsoft.com"><strong>Microsoft</strong></a>: As a global tech powerhouse, Microsoft uses AEM to handle the complex, large-scale content needs of its diverse digital products and services.</li>
<li><a href="https://www.google.com"><strong>Google</strong></a>: Does not use AEM.</li>
<li><a href="https://www.amazon.com"><strong>Amazon</strong></a>: Does not use AEM.</li>
</ul>
<hr class="spacer-larger"/>
<h2 id="the_rise_of_aem_as_a_cloud_service_aemaacs">3. The Rise of AEM as a Cloud Service (AEMaaCS)</h2>
<p>In recent years, AEM has evolved into AEM as a Cloud Service (AEMaaCS), Adobe&#8217;s cloud-native version of the platform. This shift has been a game-changer. Many organizations are transitioning to AEMaaCS because of the inherent benefits it offers over traditional on-premise solutions.</p>
<p>The introduction of <strong>AEM as a Cloud Service (AEMaaCS)</strong> is transforming how businesses use Adobe’s powerful content management platform. AEMaaCS is a <strong>cloud-native version</strong> of the platform, designed to be more flexible, scalable, and efficient than ever before.</p>
<h3 id="benefits_of_aemaacs">Benefits of AEMaaCS:</h3>
<ol>
<li><strong>Scalability</strong>: AEMaaCS automatically adjusts to the needs of businesses, scaling up or down based on traffic demands. This flexibility ensures that enterprises don’t have to worry about over- or under-provisioning resources.</li>
<li><strong>Continuous Updates</strong>: One of the most significant advantages of AEMaaCS is the automatic updates. Instead of waiting for major release cycles, companies get regular updates with new features, improvements, and security patches, ensuring they are always running the latest version.</li>
<li><strong>Faster Time to Market</strong>: AEMaaCS eliminates the need for on-premise infrastructure management, allowing developers and content creators to focus on delivering content and experiences faster. This leads to reduced time-to-market for new campaigns and features.</li>
<li><strong>Cost Efficiency</strong>: With AEMaaCS, companies pay only for the resources they use, which makes it a cost-effective solution for businesses looking to optimize their content management processes.</li>
<li><strong>Global Availability</strong>: AEMaaCS provides enhanced performance and uptime across regions, making it ideal for global companies that require consistent and reliable digital experiences across the globe.</li>
<li><strong>Scalability</strong>: AEMaaCS automatically adjusts to the needs of businesses, scaling up or down based on traffic demands. This dynamic auto-scaling means that organizations no longer need to manually adjust infrastructure to accommodate fluctuations in traffic. It also eliminates the need for in-house DevOps teams to manage server capacity, performance, or uptime. By leveraging this built-in scalability, businesses can significantly reduce costs associated with AEM DevOps management. This is a key advantage for companies looking to optimize resources without sacrificing the ability to deliver seamless digital experiences during high-demand periods, such as product launches or marketing campaigns.</li>
</ol>
<hr class="spacer-larger"/>
<h2 id="aem_65_still_going_strong_with_no_plans_for_deprecation">4. AEM 6.5: Still Going Strong with No Plans for Deprecation</h2>
<p>While <strong>AEMaaCS</strong> is gaining widespread adoption, it’s important to note that <strong>AEM 6.5</strong>—the on-premise or managed service version of AEM—<strong>is not going anywhere either</strong>. <strong>Adobe has no plans to deprecate AEM 6.5</strong>, and it will continue to be fully supported for the foreseeable future.</p>
<hr class="spacer-medium"/>
<h3 id="why_aem_65_is_important">Why?</h3>
<p>Many <strong>enterprise companies</strong> rely on <strong>highly customized AEM implementations</strong> that simply can’t be replicated in a cloud environment. These businesses have complex content workflows, integrations, and security requirements that are uniquely tailored to their operations. <strong>AEM 6.5</strong> provides the flexibility and control needed to meet these specific needs.</p>
<p>One of the most important reasons companies stick with <strong>AEM 6.5</strong> on-premise is <strong>data privacy</strong>. Many industries—such as finance, healthcare, and government—have strict regulatory requirements for storing and processing sensitive customer data. By using <strong>AEM 6.5</strong> on-premise, organizations maintain full control over their data, ensuring compliance with industry regulations and safeguarding against potential breaches that might occur in a cloud-based environment.</p>
<hr class="spacer-medium"/>
<h3 id="additional_reasons_for_aem_65">Additional reasons why businesses choose AEM 6.5 on-premise include:</h3>
<ul>
<li><strong>Customization</strong>: Companies with unique workflows or integrations that require more control over their system prefer the flexibility of AEM 6.5.</li>
<li><strong>Security</strong>: With on-premise AEM 6.5, organizations have greater control over their security measures, which is crucial for industries handling sensitive data.</li>
<li><strong>Infrastructure Control</strong>: For enterprises that need to manage their own infrastructure, AEM 6.5 allows full control over servers, storage, and other resources.</li>
<li><strong>Performance Optimization</strong>: Businesses with high-performance needs may prefer to optimize and tune their own infrastructure for speed, reliability, and custom use cases.</li>
</ul>
<hr class="spacer-larger"/>
<h2 id="aem_thrives_in_major_enterprises">5. AEM Thrives in Major Enterprises</h2>
<p>It’s not just ANMGA adopting AEMaaCS—<strong>many of the world’s largest enterprises</strong> continue to rely on AEM to manage their digital content and experiences. These organizations understand the power of AEM when it comes to delivering personalized, scalable, and consistent content to millions of users.</p>
<h3 id="list_of_companies_using_aem">Here’s a list of companies that currently use AEM (including AEMaaCS) to power their digital platforms:</h3>
<ul>
<li><a href="https://www.apple.com"><strong>Apple</strong></a></li>
<li><a href="https://www.microsoft.com"><strong>Microsoft</strong></a></li>
<li><a href="https://www.nvidia.com"><strong>NVIDIA</strong></a></li>
<li><a href="https://www.linkedin.com"><strong>LinkedIn</strong></a></li>
<li><a href="https://www.mcdonalds.com"><strong>McDonald&#8217;s</strong></a></li>
<li><a href="https://www.canada.ca"><strong>Canada.ca</strong></a></li>
<li><a href="https://www.canadiantire.ca"><strong>Canadian Tire</strong></a></li>
<li><a href="https://www.td.com"><strong>TD Bank</strong></a></li>
<li><a href="https://www.tiffany.ca"><strong>Tiffany &#038; Co.</strong></a></li>
<li><a href="https://www.budget.com"><strong>Budget Rent-a-Car</strong></a></li>
<li><a href="https://www.visa.com"><strong>Visa</strong></a></li>
<li><a href="https://www.mastercard.us"><strong>Mastercard</strong></a></li>
<li><a href="https://www.coke.com"><strong>Coca-Cola</strong></a></li>
<li><a href="https://www.caesars.com"><strong>Caesars Entertainment</strong></a></li>
<li><a href="https://www.toyota.com"><strong>Toyota</strong></a></li>
<li><a href="https://www.sunlife.ca"><strong>Sun Life Financial</strong></a></li>
<li><a href="https://www.homedepot.ca"><strong>Home Depot</strong></a></li>
<li><a href="https://www.tangerine.ca"><strong>Tangerine Bank</strong></a></li>
<li><a href="https://www.loccitane.com"><strong>L&#8217;Occitane</strong></a></li>
<li><a href="https://www.cisco.com"><strong>Cisco</strong></a></li>
<li><a href="https://www.bose.com"><strong>Bose</strong></a></li>
<li><a href="https://www.ledcor.com"><strong>Ledcor</strong></a></li>
<li><a href="https://www.phonak.com"><strong>Phonak</strong></a></li>
<li><a href="https://www.advancedbionics.com"><strong>Advanced Bionics</strong></a></li>
<li><a href="https://www.premierinn.com"><strong>Premier Inn</strong></a></li>
<li><a href="https://www.finning.com"><strong>Finning</strong></a></li>
</ul>
<hr class="spacer-larger"/>
<h2 id="aem_is_evolving_not_dying">6. AEM is Evolving—Not Dying</h2>
<p>As businesses increasingly move towards cloud-native solutions, <strong>AEMaaCS</strong> positions itself as a vital player in the future of digital experience management. Adobe continues to invest in AEM, ensuring that it remains a <strong>leading digital experience platform</strong> for enterprises.</p>
<hr class="spacer-medium"/>
<h3 id="why_you_should_stick_with_aem">Why You Should Stick with AEM:</h3>
<ul>
<li><strong>Cloud-Native Solutions</strong>: With <strong>AEMaaCS</strong>, you’re not just working on a legacy platform—you’re engaging with a cutting-edge, cloud-native solution designed for the future.</li>
<li><strong>Enterprise Adoption is Growing</strong>: Some of the largest and most influential companies in the world (ANMGA) use AEM to run their digital ecosystems. This increases the potential for you, as an AEM engineer, to work at a top-tier organization.</li>
<li><strong>Opportunities in Consulting and Freelancing</strong>: Even during economic downturns, <strong>AEM specialists</strong> are in demand for freelance projects and consulting roles.</li>
<li><strong>AEM 6.5 is Here to Stay</strong>: For businesses with complex, custom requirements, <strong>AEM 6.5</strong> remains a vital option, and Adobe will continue to support it for years to come.</li>
<li><strong>The Market Will Rebound</strong>: The current recession won’t last forever. As companies ramp up their digital transformation efforts, the need for AEM expertise will grow.</li>
</ul>
<hr class="spacer-larger"/>
<h2 id="conclusion_aem_is_alive_and_thriving">7. Conclusion: AEM is Alive and Thriving</h2>
<p>Despite the economic uncertainty, <strong>AEM is not going anywhere</strong>. With the rise of <strong>AEMaaCS</strong>, the platform is becoming even more crucial for businesses looking to deliver personalized, cloud-based digital experiences. <strong>AEM 6.5</strong> also remains a key solution for businesses with complex, custom requirements that can’t be easily migrated to the cloud.</p>
<p><strong>AEM engineers shouldn’t give up</strong>—continue to hone your skills, embrace the opportunities available today, and be ready for the surge in demand once the market rebounds. Whether it’s working for a global enterprise or a top 5 tech company like <strong>Apple</strong>, <strong>NVIDIA</strong>, or <strong>Microsoft</strong>, <strong>AEM is still a powerful career path</strong> with endless possibilities.</p>
<p><strong>AEM isn’t dead—it&#8217;s evolving. The future for AEM engineers is bright.</strong></p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/aem-is-dead-in-2024-and-beyond-blog-for-aem-engineers">AEM is Dead in 2024 and Beyond, Blog for AEM Engineers</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/aem-is-dead-in-2024-and-beyond-blog-for-aem-engineers/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to Clear &#038; Flush AEMaaCS Cache After Code Deployment</title>
		<link>https://sourcedcode.com/blog/aem/how-to-clear-flush-aemaacs-cache-after-code-deployment</link>
					<comments>https://sourcedcode.com/blog/aem/how-to-clear-flush-aemaacs-cache-after-code-deployment#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Tue, 13 Aug 2024 04:19:51 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[AEMaaCS]]></category>
		<category><![CDATA[Caching]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=7316</guid>

					<description><![CDATA[<p>Flushing the cache in Adobe Experience Manager as a Cloud Service (AEMaaCS) after a code deployment is a critical step to ensure that users receive the most up-to-date content. Good new for you, AEMaaCS automates much of this process through its rolling deployment strategy, which involves coordinated steps to deploy code, update configurations, and invalidate [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/how-to-clear-flush-aemaacs-cache-after-code-deployment">How to Clear &#038; Flush AEMaaCS Cache After Code Deployment</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Flushing the cache in Adobe Experience Manager as a Cloud Service (AEMaaCS) after a code deployment is a critical step to ensure that users receive the most up-to-date content. Good new for you, AEMaaCS automates much of this process through its rolling deployment strategy, which involves coordinated steps to deploy code, update configurations, and invalidate the Dispatcher cache across all instances.</p>
<div class="mention-block">
    <strong>Quick Links</strong></p>
<ol>
<li><a href="#rolling_deployment_process_in_aemaa_cs">Rolling Deployment Process in AEMaaCS</a></li>
<li><a href="#why_is_this_process_important">Why Is This Process Important?</a></li>
<li><a href="#additional_considerations">Additional Considerations</a></li>
</ol>
</div>
<hr class="spacer-large"/>
<h2 id="rolling_deployment_process_in_aemaa_cs">1. Rolling Deployment Process in AEMaaCS</h2>
<p>During a production deployment, AEMaaCS follows a rolling deployment strategy to minimize downtime and ensure continuous availability. Here’s how it works:</p>
<ol>
<li><strong>Deploy AEM Packages to Author:</strong>
<ul>
<li>The deployment begins by pushing the updated AEM packages to the author instance. This ensures that the author environment is updated first, preparing it for any content authoring that might be needed post-deployment.</li>
</ul>
</li>
<li><strong>Detach Dispatcher1 from the Load Balancer:</strong>
<ul>
<li>The first Dispatcher (dispatcher1) is temporarily removed from the load balancer. This prevents it from serving any requests during the deployment, ensuring that users do not access potentially outdated or unstable content.</li>
</ul>
</li>
<li><strong>Deploy AEM Packages to Publish1 and Dispatcher1:</strong>
<ul>
<li>With dispatcher1 detached, the deployment of AEM packages to the first publish instance (publish1) and the corresponding Dispatcher package to dispatcher1 occurs simultaneously.</li>
<li>After the deployment, the <span class="code-highlight-primary">Dispatcher cache is flushed</span>. This step is critical as it clears the old cache, ensuring that the updated content is served once the Dispatcher is brought back online.</li>
</ul>
</li>
<li><strong>Reattach Dispatcher1 to the Load Balancer:</strong>
<ul>
<li>Once the deployment to publish1 and the cache flush on dispatcher1 are complete, dispatcher1 is added back to the load balancer. It can now serve requests with the updated content and configurations.</li>
</ul>
</li>
<li><strong>Repeat for Dispatcher2:</strong>
<ul>
<li>The process is repeated for the second Dispatcher (dispatcher2). Dispatcher2 is detached from the load balancer, the deployment is made to publish2 and dispatcher2, the <span class="code-highlight-primary">cache is flushed</span>, and then dispatcher2 is reattached to the load balancer.</li>
</ul>
</li>
<li><strong>Continue for All Instances:</strong>
<ul>
<li>This rolling deployment process continues until all publish and Dispatcher instances in the topology have been updated. By updating one Dispatcher at a time, AEMaaCS ensures that there is always at least one Dispatcher available to serve requests, thus maintaining high availability throughout the deployment.</li>
</ul>
</li>
</ol>
<hr class="spacer-large"/>
<h2 id="why_is_this_process_important">2. Why Is This Process Important?</h2>
<p>Flushing the Dispatcher cache after code deployment is essential for ensuring that users receive the latest content and that no outdated files are served. The rolling deployment strategy employed by AEMaaCS automates this process, making it seamless and reducing the risk of downtime or content inconsistencies.</p>
<hr class="spacer-large"/>
<h2 id="additional_considerations">3. Additional Considerations</h2>
<p>While AEMaaCS automates much of the deployment and cache flushing process, it’s important to ensure that your Dispatcher configurations are optimized for this process. Properly configured <span class="code-highlight-primary">.stat</span> files and cache invalidation rules help to ensure that the cache is only flushed when necessary, preserving performance while ensuring content freshness.</p>
<p>For more detailed information on the rolling deployment process and how AEMaaCS handles cache invalidation, refer to the official <a href="https://experienceleague.adobe.com/en/docs/experience-manager-cloud-manager/content/using/code-deployment" target="_blank" rel="noopener">Adobe Experience Manager documentation</a> .</p>
<p>This step-by-step approach ensures a smooth transition during code deployments, keeping your AEM environment optimized and responsive.</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/how-to-clear-flush-aemaacs-cache-after-code-deployment">How to Clear &#038; Flush AEMaaCS Cache After Code Deployment</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/how-to-clear-flush-aemaacs-cache-after-code-deployment/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to Speed Up Unit Tests in JUnit 5 AEM Projects with SLF4J-NOP</title>
		<link>https://sourcedcode.com/blog/aem/how-to-speed-up-unit-tests-in-junit-5-aem-projects-with-slf4j-nop</link>
					<comments>https://sourcedcode.com/blog/aem/how-to-speed-up-unit-tests-in-junit-5-aem-projects-with-slf4j-nop#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Wed, 07 Aug 2024 12:12:18 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[AEMaaCS]]></category>
		<category><![CDATA[JUNIT]]></category>
		<category><![CDATA[JUNIT4]]></category>
		<category><![CDATA[JUNIT5]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=7304</guid>

					<description><![CDATA[<p>Optimizing the performance of unit tests in AEM projects is crucial for maintaining efficient development cycles. One effective method to achieve this is by disabling logging during test execution using the slf4j-nop library. Here&#8217;s why and how you can implement it, along with some performance benchmarks. Quick Links Why Disable Logs During Unit Tests? Adding [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/how-to-speed-up-unit-tests-in-junit-5-aem-projects-with-slf4j-nop">How to Speed Up Unit Tests in JUnit 5 AEM Projects with SLF4J-NOP</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Optimizing the performance of unit tests in AEM projects is crucial for maintaining efficient development cycles. One effective method to achieve this is by disabling logging during test execution using the <strong>slf4j-nop</strong> library. Here&#8217;s why and how you can implement it, along with some performance benchmarks.</p>
<div class="mention-block">
    <strong>Quick Links</strong></p>
<ol>
<li><a href="#why_disable_logs_during_unit_tests">Why Disable Logs During Unit Tests?</a></li>
<li><a href="#adding_slf4j_nop_to_your_project">Adding slf4j-nop to Your Project</a></li>
<li><a href="#benchmarks_and_examples">Benchmarks and Examples</a></li>
<li><a href="#further_optimizing_aem_tests">Further Optimizing AEM Tests</a></li>
</ol>
</div>
<hr class="spacer-large"/>
<h2 id="why_disable_logs_during_unit_tests">1. Why Disable Logs During Unit Tests?</h2>
<p>Logging during unit tests can add unnecessary overhead, especially in large projects where tests generate extensive logs. While logging is essential in production and development environments for debugging, it offers little value during unit tests where the focus is on verifying the correctness of isolated components. Disabling logs during tests provides several benefits:</p>
<ul>
<li><span class="code-highlight-primary">Reduced I/O Overhead:</span> Logging operations require I/O, which can slow down test execution. Disabling logging eliminates this overhead, leading to faster tests.</li>
<li><span class="code-highlight-primary">Cleaner Test Output:</span> With logs disabled, test outputs are cleaner, making it easier to focus on test results without the distraction of log entries.</li>
<li><span class="code-highlight-primary">Improved Test Performance:</span> Benchmarks have shown that disabling logs can significantly speed up test execution.</li>
</ul>
<hr class="spacer-large"/>
<h2 id="adding_slf4j_nop_to_your_project">2. Adding slf4j-nop to Your Project</h2>
<p>To disable logging, you can add the <span class="code-highlight-primary">slf4j-nop</span> dependency to your <span class="code-highlight-primary">pom.xml</span>:</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #339933;">&lt;</span>dependency<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>groupId<span style="color: #339933;">&gt;</span>org.<span style="color: #006633;">slf4j</span><span style="color: #339933;">&lt;/</span>groupId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>artifactId<span style="color: #339933;">&gt;</span>slf4j<span style="color: #339933;">-</span>nop<span style="color: #339933;">&lt;/</span>artifactId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>version<span style="color: #339933;">&gt;</span>20.0.16<span style="color: #339933;">&lt;/</span>version<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>scope<span style="color: #339933;">&gt;</span>test<span style="color: #339933;">&lt;/</span>scope<span style="color: #339933;">&gt;</span><br />
<span style="color: #339933;">&lt;/</span>dependency<span style="color: #339933;">&gt;</span></div></td></tr></tbody></table></div>
<p>For multi-module AEM projects, ensure this dependency is also included in the <span class="code-highlight-primary">core/pom.xml</span> file.</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #339933;">&lt;</span>dependency<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>groupId<span style="color: #339933;">&gt;</span>org.<span style="color: #006633;">slf4j</span><span style="color: #339933;">&lt;/</span>groupId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>artifactId<span style="color: #339933;">&gt;</span>slf4j<span style="color: #339933;">-</span>nop<span style="color: #339933;">&lt;/</span>artifactId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>scope<span style="color: #339933;">&gt;</span>test<span style="color: #339933;">&lt;/</span>scope<span style="color: #339933;">&gt;</span><br />
<span style="color: #339933;">&lt;/</span>dependency<span style="color: #339933;">&gt;</span></div></td></tr></tbody></table></div>
<p><a href="https://mvnrepository.com/artifact/org.slf4j/slf4j-nop" rel="noopener" target="_blank">https://mvnrepository.com/artifact/org.slf4j/slf4j-nop</a></p>
<hr class="spacer-large"/>
<h2 id="benchmarks_and_examples">3. Benchmarks and Examples</h2>
<p>Here’s a comparison of test execution times to illustrate the impact of disabling logs:</p>
<ul>
<li>JUnit 5 (with logging):
<ul>
<li>Run from IntelliJ IDEA: 9.276 seconds</li>
<li>Run with mvn clean test: 8.696 seconds</li>
</ul>
</li>
<li>JUnit 5 (with slf4j-nop):
<ul>
<li>Run from IntelliJ IDEA: <span class="code-highlight-primary">2.116 seconds</span></li>
<li>Run with mvn clean test: <span class="code-highlight-primary">1.892 seconds</span></li>
</ul>
</li>
</ul>
<p>These results clearly demonstrate that disabling logging can drastically reduce test execution times, allowing for faster feedback during development.</p>
<hr class="spacer-large"/>
<h2 id="further_optimizing_aem_tests">4. Further Optimizing AEM Tests</h2>
<p>In addition to disabling logging, further optimization can be achieved by selecting the appropriate <span class="code-highlight-primary">AemContext</span>:</p>
<ul>
<li><span class="code-highlight-primary">NoResourceResolverTypeAemContext (Fastest):</span> Ideal for tests that don&#8217;t require resource resolution.</li>
<li><span class="code-highlight-primary">ResourceResolverMockAemContext (Default):</span> Best for tests that need a mocked resource resolver.</li>
<li><span class="code-highlight-primary">JcrMockAemContext:</span> Useful for tests requiring JCR features like indexing.</li>
<li><span class="code-highlight-primary">JcrOakAemContext (Slowest):</span> Necessary for simulating a full JCR, though it’s the slowest option.</li>
</ul>
<p>By combining these strategies—disabling unnecessary logging and selecting the appropriate context—you can achieve significantly faster and more efficient unit tests.</p>
<p>Implementing these strategies ensures your unit tests are optimized, allowing you to maintain high development velocity without being slowed down by lengthy test runs.</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/how-to-speed-up-unit-tests-in-junit-5-aem-projects-with-slf4j-nop">How to Speed Up Unit Tests in JUnit 5 AEM Projects with SLF4J-NOP</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/how-to-speed-up-unit-tests-in-junit-5-aem-projects-with-slf4j-nop/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>When is the End of Support for AEM On-Prem?</title>
		<link>https://sourcedcode.com/blog/aem/when-is-the-end-of-support-for-aem-on-prem</link>
					<comments>https://sourcedcode.com/blog/aem/when-is-the-end-of-support-for-aem-on-prem#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Thu, 01 Aug 2024 07:23:31 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=7269</guid>

					<description><![CDATA[<p>AEM 6.5 Gets Long-Term Support (LTS) As of the latest Adobe updates, AEM 6.5 is officially classified under Long-Term Support (LTS), ensuring it remains fully supported with service packs, security updates, and enhancements for the foreseeable future. This means AEM 6.5 is not deprecated or end-of-life — and continues to be a strategic solution alongside [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/when-is-the-end-of-support-for-aem-on-prem">When is the End of Support for AEM On-Prem?</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div class="mention-block--gold">
    <strong>AEM 6.5 Gets Long-Term Support (LTS)</strong></p>
<p>As of the latest Adobe updates, AEM 6.5 is officially classified under <strong>Long-Term Support (LTS)</strong>, ensuring it remains fully supported with service packs, security updates, and enhancements for the foreseeable future.</p>
<p>This means AEM 6.5 is <strong>not deprecated or end-of-life</strong> — and continues to be a strategic solution alongside AEM as a Cloud Service (AEMaaCS).</p>
<p>➡️ View official LTS release notes here: <a href="https://experienceleague.adobe.com/en/docs/experience-manager-65-lts/content/release-notes/release-notes" target="_blank" rel="noopener">AEM 6.5 LTS Release Notes</a></p>
</div>
<p>Adobe Experience Manager (AEM) has gone through significant evolution since its inception as CQ, continually enhancing its capabilities. With the introduction of AEM as a Cloud Service (AEMaaCS) in 2020, Adobe has pivoted towards cloud-based solutions, while gradually phasing out support for older on-premises versions. Here, we outline the history of AEM releases and their respective support timelines, focusing on the latest updates and future direction. In this article we will share you the History of AEM Versions and Support Timeline based on Adobe&#8217;s Documentation. </p>
<div class="mention-block">
    <strong>Quick Links</strong></p>
<ol>
<li><a href="#history_of_aem_versions_and_support_timeline">History of AEM Versions and Support Timeline</a></li>
<li><a href="#transition_to_aem_as_a_cloud_service_aemaa_cs">Transition to AEM as a Cloud Service (AEMaaCS)</a></li>
<li><a href="#key_points_for_aemaa_cs">Key Points for AEMaaCS</a></li>
</ol>
</div>
<hr class="spacer-large"/>
<h2 id="history_of_aem_versions_and_support_timeline">1. History of AEM Versions and Support Timeline</h2>
<p>Adobe Experience Manager (AEM) has undergone significant development since its early days as CQ. Here’s a brief overview of its versions and their support timelines:</p>
<ul>
<li><strong><s>CQ 5.4:</s></strong>
<ul>
<li>Released on February 22, 2011</li>
<li>Ended core support on February 22, 2014</li>
<li>Ended extended support on February 22, 2016</li>
</ul>
</li>
<li><strong><s>CQ 5.5:</s></strong>
<ul>
<li>Released on February 25, 2012</li>
<li>Ended core support on February 25, 2015</li>
<li>Ended extended support on February 25, 2017</li>
</ul>
</li>
<li><strong><s>AEM 5.6:</s></strong>
<ul>
<li>Released on February 8, 2013</li>
<li>Ended core support on February 8, 2016</li>
<li>Ended extended support on February 8, 2018</li>
</ul>
</li>
<li><strong><s>AEM 6.0:</s></strong>
<ul>
<li>Released on May 22, 2014</li>
<li>Ended core support on May 31, 2017</li>
<li>Ended extended support on May 31, 2019</li>
</ul>
</li>
<li><strong><s>AEM 6.1:</s></strong>
<ul>
<li>Released on May 28, 2015</li>
<li>Ended core support on May 31, 2018</li>
<li>Ended extended support on May 31, 2020</li>
</ul>
</li>
<li><strong><s>AEM 6.2:</s></strong>
<ul>
<li>Released on April 21, 2016</li>
<li>Ended core support on April 30, 2019</li>
<li>Ended extended support on April 30, 2021</li>
</ul>
</li>
<li><strong><s>AEM 6.3:</s></strong>
<ul>
<li>Released on April 26, 2017</li>
<li>Ended core support on April 30, 2020</li>
<li>Ended extended support on April 30, 2022</li>
</ul>
</li>
<li><strong><s>AEM 6.4:</s></strong>
<ul>
<li>Released on April 4, 2018</li>
<li>Ended core support on April 30, 2021</li>
<li>Ended extended support on April 30, 2023</li>
</ul>
</li>
<li><strong class="code-highlight--primary">AEM 6.5:</strong>
<ul>
<li>Released on April 8, 2019</li>
<li>No end date for core or extended support announced yet</li>
</ul>
</li>
</ul>
<p>Click here to view the official end of support, Adobe Matrix &#8211; <a href="https://helpx.adobe.com/ca/support/programs/eol-matrix.html" rel="noopener" target="_blank">https://helpx.adobe.com/ca/support/programs/eol-matrix.html</a></p>
<div class="mention-block--gold">
Adobe&#8217;s AEM team has been evolving, with a clear focus on AEM as a Cloud Service (AEMaaCS) and the ongoing support for AEM 6.5. The release roadmap outlines the latest updates, features, and planned enhancements for both AEMaaCS and AEM 6.5, ensuring users have access to the latest innovations and support. <a href="https://experienceleague.adobe.com/en/docs/experience-manager-release-information/aem-release-updates/update-releases-roadmap" rel="noopener" target="_blank">Check out the official Adobe Release Roadmap Page</a>
</div>
<hr class="spacer-large"/>
<h2 id="transition_to_aem_as_a_cloud_service_aemaa_cs">2. Transition to AEM as a Cloud Service (AEMaaCS)</h2>
<p>As Adobe continues to support AEM 6.5, the focus is increasingly shifting towards AEM as a Cloud Service (AEMaaCS). AEMaaCS, launched in 2020, offers modern cloud-native capabilities, including seamless updates and scalable infrastructure. This shift is aimed at providing a more flexible and cost-effective solution compared to traditional on-premises installations.</p>
<hr class="spacer-large"/>
<h2 id="key_points_for_aemaa_cs">3. Key Points for AEMaaCS</h2>
<ul>
<li><strong>Continuous Updates:</strong> AEMaaCS ensures users always have access to the latest features and security updates without manual intervention.</li>
<li><strong>Scalability and Flexibility:</strong> The cloud infrastructure allows for easy scaling based on business requirements, eliminating the need for managing physical servers.</li>
<li><strong>Reduced Total Cost of Ownership (TCO):</strong> By removing the need for dedicated hardware and maintenance, AEMaaCS can reduce overall costs associated with content management.</li>
</ul>
<p>Organizations currently using older on-premises versions of AEM should consider migrating to AEMaaCS to benefit from these modern capabilities. For further details on support lifecycle and migration strategies, refer to Adobe&#8217;s <a href="https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/overview/introduction" target="_blank" rel="noopener">official support documentation</a>.</p>
<div class="mention-block">
Need Advice and Guidance on how to move from AEM On-Prem to AEMaaCS? Contact me directly on <a href="https://www.linkedin.com/in/briankasingli" rel="noopener" target="_blank">Linkedin</a> or my email address <a href="mailto:contact@sourcedcode.com" rel="noopener" target="_blank">contact@sourcedcode.com</a>, let&#8217;s have a chat.
</div>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/when-is-the-end-of-support-for-aem-on-prem">When is the End of Support for AEM On-Prem?</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/when-is-the-end-of-support-for-aem-on-prem/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Serving New Client Library CSS and JS After Release on AEM as a Cloud Service (AEMaaCS)</title>
		<link>https://sourcedcode.com/blog/aem/serving-new-client-library-css-and-js-after-release-on-aem-as-a-cloud-service-aemaacs</link>
					<comments>https://sourcedcode.com/blog/aem/serving-new-client-library-css-and-js-after-release-on-aem-as-a-cloud-service-aemaacs#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Wed, 31 Jul 2024 06:25:19 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[AEMaaCS]]></category>
		<category><![CDATA[Caching]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=7232</guid>

					<description><![CDATA[<p>How does new client library code for JS and CSS gets served in my AEMaaCS website after development, staging, production release, and how does the correct version of the client libs are being used on AEMaaCS? Ensuring that users receive the latest updates—such as new client libraries (CSS and JS)—requires a carefully managed caching strategy. [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/serving-new-client-library-css-and-js-after-release-on-aem-as-a-cloud-service-aemaacs">Serving New Client Library CSS and JS After Release on AEM as a Cloud Service (AEMaaCS)</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>How does new client library code for JS and CSS gets served in my AEMaaCS website after development, staging, production release, and how does the correct version of the client libs are being used on AEMaaCS?</p>
<p>Ensuring that users receive the latest updates—such as new client libraries (CSS and JS)—requires a carefully managed caching strategy. This article explores how cache invalidation is handled upon releasing new code, particularly clientlibs, and uses the Adobe WKND project as an example to explain the process.</p>
<div class="mention-block">
    <strong>Quick Links</strong></p>
<ol>
<li><a href="#introduction">Introduction</a></li>
<li><a href="#automatic_cache_invalidation_how_it_works">Automatic Cache Invalidation: How It Works</a></li>
<li><a href="#example_configuration_adobe_wknd_project">Example Configuration: Adobe WKND Project</a></li>
<li><a href="#breakdown_of_the_configuration">Breakdown of the Configuration</a></li>
<li><a href="#key_mechanisms_and_timings">Key Mechanisms and Timings</a></li>
<li><a href="#conclusion">Conclusion</a></li>
</ol>
</div>
<hr class="spacer-large"/>
<h2 id="introduction">1. Introduction</h2>
<p>In this article, we will step through how typically an AEMaaCS website serves newly released client-libraries JS and CSS to users, and we will take a look at the <a href="https://github.com/adobe/aem-guides-wknd/blob/33aa8fda2defe45a6c8c8607ead0026e1492ff01/dispatcher/src/conf.d/available_vhosts/wknd.vhost#L158" rel="noopener" target="_blank">Adobe WKND project</a> as an example.</p>
<hr class="spacer-large"/>
<h2 id="automatic_cache_invalidation_how_it_works">2. Automatic Cache Invalidation: How It Works</h2>
<p>Upon releasing new client libraries, AEMaaCS uses versioned clientlibs. This involves adding a unique hash (previous understanding of the hash generated is pretty much converting the entire minified CSS and JS into <a href="https://adobe-consulting-services.github.io/acs-aem-commons/features/versioned-clientlibs/index.html" rel="noopener" target="_blank">MD5 Hash &#8211; ACS Commons Approach</a>) to the filenames of clientlibs, served on newly fresh requested HTML pages from the AEM publishers, which forces the CDN and browser caches to recognize and fetch the new files. This automatic mechanism helps ensure that users are served the updated versions. </p>
<p>And please keep in mind, it&#8217;s the fresh uncached version of the AEM .html pages who actually serves the path of the versioned clientlibs files. Lets understand .html are cached invalidated from the dispatcher and CDN cache.</p>
<p>Examples of hashed client libs:<br />
/etc.clientlibs/settings/wcm/designs/gandalf/clientlibs/css/all.en-us.min.LIHASHed376af2042959edf283b2591e37eff9.css
</p>
<hr class="spacer-large"/>
<h2 id="example_configuration_adobe_wknd_project">3. Example Configuration: Adobe WKND Project</h2>
<p>In this article, we will purely inspect the <a href="https://github.com/adobe/aem-guides-wknd/blob/33aa8fda2defe45a6c8c8607ead0026e1492ff01/dispatcher/src/conf.d/available_vhosts/wknd.vhost#L158" rel="noopener" target="_blank">Adobe WKND project</a> which is production live code examples of recommended rules for cache invalidating .html files. The following configuration from the WKND project shows how HTML pages are handled in terms of caching:</p>
<div class="codecolorer-container apache default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br /></div></td><td><div class="apache codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&lt;<span style="color: #000000; font-weight:bold;">LocationMatch</span> <span style="color: #7f007f;">&quot;^/content/.*<span style="color: #000099; font-weight: bold;">\.</span>html$&quot;</span>&gt;<br />
&nbsp; &nbsp; <span style="color: #00007f;">Header</span> unset Cache-Control<br />
&nbsp; &nbsp; <span style="color: #00007f;">Header</span> always set Cache-Control <span style="color: #7f007f;">&quot;max-age=300,stale-while-revalidate=3600&quot;</span> <span style="color: #7f007f;">&quot;expr=%{REQUEST_STATUS} &lt; 400&quot;</span><br />
&nbsp; &nbsp; <span style="color: #00007f;">Header</span> always set Surrogate-Control <span style="color: #7f007f;">&quot;stale-while-revalidate=43200,stale-if-error=43200&quot;</span> <span style="color: #7f007f;">&quot;expr=%{REQUEST_STATUS} &lt; 400&quot;</span><br />
&nbsp; &nbsp; <span style="color: #00007f;">Header</span> set Age <span style="color: #ff0000;">0</span><br />
&lt;/<span style="color: #000000; font-weight:bold;">LocationMatch</span>&gt;</div></td></tr></tbody></table></div>
<hr class="spacer-large"/>
<h2 id="breakdown_of_the_configuration">4. Breakdown of the Configuration</h2>
<p>1. <strong> LocationMatch, Targeting HTML Pages:</strong></p>
<p>&#8211; The configuration applies to all HTML pages under the <span class="code-highlight-primary">/content/</span> path.</p>
<p>2. <strong>Cache-Control Settings:</strong></p>
<ul>
<li><span class="code-highlight-primary">max-age=300</span>: HTML pages are cached for 5 minutes. During this time, the CDN serves the cached content without checking with the origin server.</li>
<li><span class="code-highlight-primary">stale-while-revalidate=3600</span>: After 5 minutes, if a request is made, the CDN serves the stale content and fetches a new version from the server in the background. This background fetch happens within 1 hour, ensuring minimal disruption.</li>
</ul>
<p>3. <strong>Surrogate-Control for CDN:</strong></p>
<ul>
<li><span class="code-highlight-primary">stale-while-revalidate=43200</span>: The CDN can continue serving stale content while fetching fresh content for up to 12 hours.</li>
<li><span class="code-highlight-primary">stale-if-error=43200</span>: In the event of errors fetching the new content, the CDN serves stale content for up to 12 hours.</li>
</ul>
<p>4. <strong>Age Header:</strong></p>
<p>&#8211; <span class="code-highlight-primary">Header set Age 0</span>: This resets the age of the content to zero, indicating that it is freshly cached.</p>
<hr class="spacer-large"/>
<h2 id="key_mechanisms_and_timings">5. Key Mechanisms and Timings</h2>
<p><strong>Initial Cache Period (<span class="code-highlight-primary">max-age=300</span>):</strong></p>
<p>&#8211; For the first 300 seconds (5 minutes) after the content is cached, the CDN serves the cached version without rechecking with the origin server.</p>
<p><strong>Stale-While-Revalidate (<span class="code-highlight-primary">stale-while-revalidate=3600</span>):</strong></p>
<p>&#8211; After 5 minutes, the <span class="code-highlight-primary">max-age</span> period expires, if a user requests the content, the CDN serves the stale (cached) content immediately and fetches a new version from the origin server in the background. This mechanism ensures that users receive immediate responses, even if the content is slightly outdated, while the cache is refreshed in the background. And again, <em style="color:red;">it&#8217;s the fresh uncached version of the AEM .html pages who actually serves the path of the versioned clientlibs files, which is why invalidation on the HTML file is important here.</em></p>
<p><strong>After Stale-While-Revalidate:</strong></p>
<p>&#8211; If a new version has not been successfully fetched within the <span class="code-highlight-primary">stale-while-revalidate</span> window (up to 1 hour), and another request is made, the CDN serves the most recently cached version while attempting to fetch the new version again.</p>
<hr class="spacer-large"/>
<h2 id="conclusion">6. Conclusion</h2>
<p>The correct dispatcher configurations ensures that new client libraries and other updates are served efficiently. The HTML pages need to reference the new clientlibs versioned paths to reflect the latest updates. Since the WKND configuration sets HTML page caching to a maximum of 5 minutes with additional revalidation periods, the new HTML pages and associated clientlibs may not appear immediately; after 5 minutes, if a user requests the content, the CDN serves the stale (cached) content immediately and fetches a new version from the origin server in the background. This mechanism ensures that users receive immediate responses, even if the content is slightly outdated, while the cache is refreshed in the background, the <span class="code-highlight-primary">stale-while-revalidate</span> directive helps ensure users see updated content with minimal disruption. This setup minimizes the impact of cache misses and ensures that updated content is available without noticeable delay to the user. This well-balanced approach allows for efficient content delivery while maintaining a seamless user experience.</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/serving-new-client-library-css-and-js-after-release-on-aem-as-a-cloud-service-aemaacs">Serving New Client Library CSS and JS After Release on AEM as a Cloud Service (AEMaaCS)</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/serving-new-client-library-css-and-js-after-release-on-aem-as-a-cloud-service-aemaacs/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How can I add the French trademark symbol MD to my Website?</title>
		<link>https://sourcedcode.com/blog/aem/content/how-can-i-add-the-french-trademark-symbol-md-to-my-website</link>
					<comments>https://sourcedcode.com/blog/aem/content/how-can-i-add-the-french-trademark-symbol-md-to-my-website#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Sat, 20 Jul 2024 11:12:30 +0000</pubDate>
				<category><![CDATA[Content]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=7213</guid>

					<description><![CDATA[<p>While creating content on a website, sometimes we would want to use the symbol MD (Marque Déposée) on our website. We would try to use &#x1F16B;(Raised Md Sign) but that does not work as some web browsers are not supporting this symbol. Even using HTML Entity like &#38;#127339; or &#38;#x1F16B; again web browsers are not [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/content/how-can-i-add-the-french-trademark-symbol-md-to-my-website">How can I add the French trademark symbol MD to my Website?</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>While creating content on a website, sometimes we would want to use the symbol MD (Marque Déposée) on our website. We would try to use &#x1F16B;<a href="https://www.compart.com/en/unicode/U+1F16B" rel="noopener" target="_blank">(Raised Md Sign)</a> but that does not work as some web browsers are not supporting this symbol. Even using HTML Entity like &amp;#127339; or &amp;#x1F16B;  again web browsers are not supporting this symbol. We try to use the alpha character &#8220;M&#8221; and &#8220;D&#8221;, but this does not follow the guidelines of really using the Marque Déposée. While using the MD (Marque Déposée), we need to copy these two strange characters ᴹ (Modifier Letter Capital M) and ᴰ (Modifier Letter Capital D), and together ᴹᴰ. By using the Modifier Letter Capital M &#038; D, we have ᴹᴰ.</p>
<p><strong style="margin-bottom:-20px;">Supported Symbol of MD (Marque Déposée) All Major Browsers:</strong><br />
<span style="font-size:50px;">ᴹᴰ</span></p>
<hr class="spacer-large"/>
<h2 id="why_use_ᴹᴰ_instead_of_md">1. Why Use ᴹᴰ Instead of MD?</h2>
<p>It&#8217;s important to use ᴹᴰ, rather than the letters &#8220;M&#8221; or &#8220;D&#8221; superscripted because of <span class="code-highlight-primary">Search Engine Optimization</span> (SEO) and documentation. The usage of ᴹᴰ ensures that the content is accurately represented and indexed correctly by search engines, which may not recognize plain superscripted letters as the official Marque Déposée symbol. Additionally, using the correct symbols ensures compliance with legal and branding guidelines, preserving the authenticity and recognition of the trademark.</p>
<hr class="spacer-large"/>
<h2 id="correct_representation_across_browsers_and_platforms">2. Correct Representation Across Browsers and Platforms</h2>
<p>Another critical reason for using ᴹᴰ instead of a HTML Entity (&amp;#127339; or &amp;#x1F16B;), simple &#8220;M&#8221; and &#8220;D&#8221; or other symbols is that the Modifier Letter Capital M and D are universally supported across most modern browsers and platforms. In contrast, the &#x1F16B;<a href="https://www.compart.com/en/unicode/U+1F16B" rel="noopener" target="_blank">(Raised Md Sign)</a> and other HTML entities may not render consistently, leading to potential misrepresentation of the content. By using ᴹᴰ (ᴹ (Modifier Letter Capital M) and ᴰ (Modifier Letter Capital D)), we ensure that the trademark symbol is correctly displayed to all users, regardless of their browser or device.</p>
<hr class="spacer-large"/>
<h2 id="steps_to_use_ᴹᴰ_in_your_content">3. Steps to Use ᴹᴰ in Your Content</h2>
<p>To use ᴹᴰ in your content, you can simply copy to clipboard the characters from here: <span class="code-highlight-primary">ᴹᴰ</span>, and paste them directly into your website&#8217;s text editor. All major browsers should support these characters and prevents any display issues. If your current font does not support these characters, a default web-safe font would be invoked, and will include the standard font look and feel on your page.</p>
<p><strong style="margin-bottom:-20px;">Supported Symbol of MD (Marque Déposée) All Major Browsers:</strong><br />
<span style="font-size:50px;">ᴹᴰ</span><br />
Take a look at these production example websites who are using on their websites:</p>
<ol>
<li><a href="https://www.purina.ca/fr/beggin/dog-treats/beggin-strips-bacon-peanut-butter" rel="noopener" target="_blank">https://www.purina.ca/fr/beggin/dog-treats/beggin-strips-bacon-peanut-butter</a></li>
<li><a href="https://www.nestleprofessional.ca/fr/nestle-confectionery/miettes-de-smarties" rel="noopener" target="_blank">https://www.nestleprofessional.ca/fr/nestle-confectionery/miettes-de-smarties</a></li>
<li><a href="https://business.michelin.ca/fr/pneus/michelin-megaxbib" rel="noopener" target="_blank">https://business.michelin.ca/fr/pneus/michelin-megaxbib</a></li>
</ol>
<div class="mention-block">
<strong>Important Note</strong></p>
<p>The ᴹ (Modifier Letter Capital M) and ᴰ (Modifier Letter Capital D) characters are part of the Phonetic Extensions block in Unicode. These characters might not be well supported by all custom fonts, especially if the font doesn&#8217;t have glyphs designed specifically for them. When the font doesn&#8217;t support these characters, the browser may fall back to another font that does, which can lead to inconsistent styling. This fallback mechanism is an automatic process where the browser selects the closest available font that contains the necessary glyphs. As a result, the appearance of these characters can differ significantly from the rest of the text, causing visual disruption on your website. </p>
<p>The fallback font might have different proportions, weight, or stylistic features, creating a jarring experience for users. This inconsistency can detract from the overall design aesthetic and professionalism of your site. Additionally, some fallback fonts might render these characters with a completely different style, potentially making them appear out of place or even unreadable compared to the surrounding content. This issue is particularly important to address in content that relies heavily on these specific symbols, such as phonetic transcriptions or specialized academic texts.</p>
<p>Examples of the inconsistent design of website examples are mentioned above this &#8220;Important Note&#8221; mention block.
</p></div>
<hr class="spacer-large"/>
<h2 id="conclusion">4. Conclusion</h2>
<p>Using the correct representation for the French trademark symbol, ᴹᴰ, is essential for both legal compliance and proper content indexing by search engines. By following the guidelines outlined above, you can ensure that your content accurately reflects the Marque Déposée symbol and is correctly displayed across all platforms and browsers. This small but significant detail helps maintain the professionalism and credibility of your website.</p>
<p>This structured approach ensures clarity and compliance with proper usage, enhancing both the legal accuracy and user experience on your site.</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/content/how-can-i-add-the-french-trademark-symbol-md-to-my-website">How can I add the French trademark symbol MD to my Website?</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/content/how-can-i-add-the-french-trademark-symbol-md-to-my-website/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>AEM Blog</title>
		<link>https://sourcedcode.com/blog/aem/aem-blog</link>
					<comments>https://sourcedcode.com/blog/aem/aem-blog#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Fri, 12 Jul 2024 05:35:17 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=7175</guid>

					<description><![CDATA[<p>Welcome to the AEM Blog on SourcedCode.com! This is your popular AEM blog as a resource for everything related to Adobe Experience Manager (AEM). Whether you are a seasoned developer, a tech enthusiast, or someone new to the AEM landscape, this blog is designed to provide you with valuable insights, learning opportunities, and the latest [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/aem-blog">AEM Blog</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Welcome to the AEM Blog on SourcedCode.com! This is your popular AEM blog as a resource for everything related to Adobe Experience Manager (AEM). Whether you are a seasoned developer, a tech enthusiast, or someone new to the AEM landscape, this blog is designed to provide you with valuable insights, learning opportunities, and the latest updates in the AEM world.</p>
<div class="mention-block">
    <strong>Quick Links</strong></p>
<ol>
<li><a href="#welcome_to_the_aem_blog">Welcome to the AEM Blog</a></li>
<li><a href="#what_youll_find_here">1. What You’ll Find Here</a></li>
<li><a href="#learning_and_collaboration">2. Learning and Collaboration</a></li>
<li><a href="#get_involved">3. Get Involved</a></li>
</ol>
</div>
<hr class="spacer-large"/>
<h2 id="what_youll_find_here">1. What You’ll Find Here</h2>
<p>This blog is dedicated to sharing knowledge and fostering a community of learning around AEM. Here’s what you can expect:</p>
<ul>
<li><strong>In-Depth Tutorials:</strong> Detailed guides and tutorials on various aspects of AEM, from basic concepts to advanced techniques. Whether you&#8217;re looking to enhance your skills in AJAX, Java, JavaScript, or HTML within the AEM context, you’ll find comprehensive resources here.</li>
<li><strong>Latest Updates:</strong> Stay informed about the latest developments and updates in the AEM ecosystem. This includes new features, best practices, and industry trends that can help you stay ahead in your projects.</li>
<li><strong>Practical Insights:</strong> Real-world insights and experiences from working with AEM. Learn from case studies, project experiences, and practical advice that can help you tackle common challenges and optimize your AEM implementations.</li>
<li><strong>Community Engagement:</strong> This blog is not just about one-way communication. It’s about building a community. Engage with other AEM professionals, share your thoughts, and collaborate on ideas that push the boundaries of digital experiences.</li>
</ul>
<hr class="spacer-large"/>
<h2 id="learning_and_collaboration">2. Learning and Collaboration</h2>
<p>The AEM Blog is a place for continuous learning and collaboration. Whether you’re looking to solve a specific problem, learn a new skill, or stay updated with the latest in AEM, this blog aims to be a valuable resource.</p>
<hr class="spacer-large"/>
<h2 id="get_involved">3. Get Involved</h2>
<p>Your participation is what makes this community thrive. Feel free to leave comments, share your own experiences, and connect with like-minded individuals. Together, we can make this blog a vibrant hub for all things AEM.</p>
<p>Thank you for being a part of this journey. Let&#8217;s explore the fascinating world of AEM together!</p>
<p>&#8220;`</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/aem-blog">AEM Blog</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/aem-blog/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>AEM Dispatcher Uncacheable Requests</title>
		<link>https://sourcedcode.com/blog/aem/aem-dispatcher-uncacheable-requests</link>
					<comments>https://sourcedcode.com/blog/aem/aem-dispatcher-uncacheable-requests#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Fri, 12 Jul 2024 05:11:04 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Dispatcher]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=7169</guid>

					<description><![CDATA[<p>The AEM Dispatcher plays a crucial role in caching to optimize the performance and delivery of content in Adobe Experience Manager (AEM). However, not all requests can be cached. This blog post will outline the criteria for cacheable requests and highlight scenarios that make requests uncacheable by the Dispatcher. Quick Links 1. Cacheable Requests 2. [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/aem-dispatcher-uncacheable-requests">AEM Dispatcher Uncacheable Requests</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>The AEM Dispatcher plays a crucial role in caching to optimize the performance and delivery of content in Adobe Experience Manager (AEM). However, not all requests can be cached. This blog post will outline the criteria for cacheable requests and highlight scenarios that make requests uncacheable by the Dispatcher.</p>
<div class="mention-block">
    <strong>Quick Links</strong></p>
<ol>
<li><a href="#cacheable_requests">1. Cacheable Requests</a></li>
<li><a href="#non_cacheable_requests_or_responses">2. Non-Cacheable Requests or Responses</a></li>
<li><a href="#conclusion">3. Conclusion</a></li>
</ol>
</div>
<hr class="spacer-large"/>
<h2 id="cacheable_requests">1. Cacheable Requests</h2>
<p>The Dispatcher can cache a URL if it meets the following criteria:</p>
<ul>
<li><strong>Configured to be Cacheable:</strong> The request is explicitly configured as cacheable in the Dispatcher configuration.</li>
<li><strong>Plain GET Request:</strong> The request is a simple HTTP GET request.</li>
<li><strong>URL with Extension:</strong> The request URL must include an extension, such as <span class="code-highlight-primary">.html</span>.</li>
</ul>
<hr class="spacer-large"/>
<h2 id="non_cacheable_requests_or_responses">2. Non-Cacheable Requests or Responses</h2>
<p>There are several scenarios where requests or responses cannot be cached by the Dispatcher:</p>
<ul>
<li><strong>Denied by Configuration:</strong> Requests that are denied caching by specific configuration settings, such as paths, patterns, or MIME types.</li>
<li><strong>Special Headers:</strong>
<ul>
<li>Responses that include a &#8220;Dispatcher: no-cache&#8221; header.</li>
<li>Responses that include a &#8220;Cache-Control: no-cache&#8221; or &#8220;Cache-Control: private&#8221; header.</li>
<li>Responses that include a &#8220;Pragma: no-cache&#8221; header.</li>
</ul>
</li>
<li><strong>Request with Query Parameters:</strong> Any request that contains query parameters.</li>
<li><strong>URL Without Extension:</strong> URLs that do not have an extension cannot be cached.</li>
<li><strong>URL with Suffix Without Extension:</strong> URLs that have a suffix lacking an extension.</li>
<li><strong>Non-200 Status Code:</strong> Responses that return a status code other than 200.</li>
<li><strong>POST Requests:</strong> HTTP POST requests cannot be cached as they typically involve changes to the server state.</li>
</ul>
<hr class="spacer-large"/>
<h2 id="conclusion">3. Conclusion</h2>
<p>Understanding which requests and responses are cacheable is crucial for optimizing the performance of your AEM instance. By ensuring that only appropriate content is cached and by configuring your Dispatcher settings correctly, you can improve both the speed and reliability of your website. Keep these rules in mind to ensure effective caching with AEM Dispatcher.</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/aem-dispatcher-uncacheable-requests">AEM Dispatcher Uncacheable Requests</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/aem-dispatcher-uncacheable-requests/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Caching AEM Pages with Extensionless (.html)</title>
		<link>https://sourcedcode.com/blog/aem/caching-aem-pages-with-extensionless-html</link>
					<comments>https://sourcedcode.com/blog/aem/caching-aem-pages-with-extensionless-html#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Tue, 09 Jul 2024 17:01:59 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Dispatcher]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=7164</guid>

					<description><![CDATA[<p>One of the key aspects of optimizing your Adobe Experience Manager (AEM) implementation is effective caching, particularly through the AEM Dispatcher. However, not all URLs are created equal when it comes to caching. In this article, we will explore why URLs without extensions are not cached, the restrictions involved, and how to use Apache rules [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/caching-aem-pages-with-extensionless-html">Caching AEM Pages with Extensionless (.html)</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>One of the key aspects of optimizing your Adobe Experience Manager (AEM) implementation is effective caching, particularly through the AEM Dispatcher. However, not all URLs are created equal when it comes to caching. In this article, we will explore why URLs without extensions are not cached, the restrictions involved, and how to use Apache rules as a fallback with the <span class="code-highlight-primary">[PT]</span> (Pass Through) flag.</p>
<div class="mention-block">
    <strong>Quick Links</strong></p>
<ol>
<li><a href="#urls_without_extensions_are_not_cached">URLs Without Extensions Are Not Cached</a></li>
<li><a href="#examples">Examples</a></li>
<li><a href="#using_apache_pt_pass_through_as_a_fallback">Using Apache [PT] Pass Through as a Fallback</a></li>
<li><a href="#additional_examples">Additional Examples</a></li>
<li><a href="#conclusion">Conclusion</a></li>
</ol>
</div>
<hr class="spacer-large"/>
<h2 id="urls_without_extensions_are_not_cached">1. URLs Without Extensions Are Not Cached</h2>
<p>In AEM, URLs must always have an extension to be cacheable by the Dispatcher. While you can serve URLs without extensions in AEM, these URLs will not be cached by the Dispatcher, leading to potential performance issues.</p>
<hr class="spacer-large"/>
<h2 id="examples">2. Examples</h2>
<p><strong>Cacheable URL:</strong></p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//domain.com/home.html</span></div></td></tr></tbody></table></div>
<p>This URL includes an extension (<span class="code-highlight-primary">.html</span>) and is therefore cacheable by the Dispatcher.</p>
<p><strong>Non-cacheable URL:</strong></p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//domain.com/home</span></div></td></tr></tbody></table></div>
<p>This URL lacks an extension and will not be cached by the Dispatcher. However, if you use the <span class="code-highlight-primary">[PT]</span> pass through to internal AEM resource ending with <span class="code-highlight-primary">.html</span>, it will be cached.</p>
<hr class="spacer-large"/>
<h2 id="using_apache_pt_pass_through_as_a_fallback">3. Using Apache [PT] Pass Through as a Fallback</h2>
<p>To handle URLs without extensions and ensure they are still processed correctly, you can use Apache&#8217;s <span class="code-highlight-primary">[PT]</span> (Pass Through) flag. This allows the URL to be passed through to the backend server, appending <span class="code-highlight-primary">.html</span> to the request, thereby enabling it to be cached by the Dispatcher.</p>
<h3>Example Apache Configuration</h3>
<p>Consider the following common dispatcher configuration to handle extensionless URLs:</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">RewriteEngine On<br />
RewriteCond <span style="color: #339933;">%</span><span style="color: #009900;">&#123;</span>REQUEST_URI<span style="color: #009900;">&#125;</span> <span style="color: #339933;">!^/</span>apps<br />
RewriteCond <span style="color: #339933;">%</span><span style="color: #009900;">&#123;</span>REQUEST_URI<span style="color: #009900;">&#125;</span> <span style="color: #339933;">!^/</span>bin<br />
RewriteCond <span style="color: #339933;">%</span><span style="color: #009900;">&#123;</span>REQUEST_URI<span style="color: #009900;">&#125;</span> <span style="color: #339933;">!^/</span>content<br />
RewriteCond <span style="color: #339933;">%</span><span style="color: #009900;">&#123;</span>REQUEST_URI<span style="color: #009900;">&#125;</span> <span style="color: #339933;">!^/</span>etc<br />
RewriteCond <span style="color: #339933;">%</span><span style="color: #009900;">&#123;</span>REQUEST_URI<span style="color: #009900;">&#125;</span> <span style="color: #339933;">!^/</span>home<br />
RewriteCond <span style="color: #339933;">%</span><span style="color: #009900;">&#123;</span>REQUEST_URI<span style="color: #009900;">&#125;</span> <span style="color: #339933;">!^/</span>libs<br />
RewriteCond <span style="color: #339933;">%</span><span style="color: #009900;">&#123;</span>REQUEST_URI<span style="color: #009900;">&#125;</span> <span style="color: #339933;">!^/</span>saml_login<br />
RewriteCond <span style="color: #339933;">%</span><span style="color: #009900;">&#123;</span>REQUEST_URI<span style="color: #009900;">&#125;</span> <span style="color: #339933;">!^/</span>system<br />
RewriteCond <span style="color: #339933;">%</span><span style="color: #009900;">&#123;</span>REQUEST_URI<span style="color: #009900;">&#125;</span> <span style="color: #339933;">!^/</span>tmp<br />
RewriteCond <span style="color: #339933;">%</span><span style="color: #009900;">&#123;</span>REQUEST_URI<span style="color: #009900;">&#125;</span> <span style="color: #339933;">!^/</span>var<br />
RewriteCond <span style="color: #339933;">%</span><span style="color: #009900;">&#123;</span>REQUEST_URI<span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#40;</span>.<span style="color: #006633;">html</span><span style="color: #339933;">|</span>.<span style="color: #006633;">jpe</span><span style="color: #339933;">?</span>g<span style="color: #339933;">|</span>.<span style="color: #006633;">png</span><span style="color: #339933;">|</span>.<span style="color: #006633;">svg</span><span style="color: #009900;">&#41;</span>$<br />
RewriteRule <span style="color: #339933;">^/</span><span style="color: #009900;">&#40;</span>.<span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span>$ <span style="color: #339933;">/</span>content<span style="color: #339933;">/</span>$<span style="color: #009900;">&#123;</span>CONTENT_FOLDER_NAME<span style="color: #009900;">&#125;</span><span style="color: #339933;">/</span>$1 <span style="color: #009900;">&#91;</span>PT,L<span style="color: #009900;">&#93;</span></div></td></tr></tbody></table></div>
<p>With this configuration, when a domain like <span class="code-highlight-primary">http://domain.com/en/home</span> is hit, it will actually map to:</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #339933;">/</span>content<span style="color: #339933;">/</span>$<span style="color: #009900;">&#123;</span>CONTENT_FOLDER_NAME<span style="color: #009900;">&#125;</span><span style="color: #339933;">/</span>en<span style="color: #339933;">/</span>home.<span style="color: #006633;">html</span></div></td></tr></tbody></table></div>
<p>For example, if <span class="code-highlight-primary">${CONTENT_FOLDER_NAME}</span> is <span class="code-highlight-primary">wknd</span>, the URL <span class="code-highlight-primary">http://domain.com/en/home</span> would map to:</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #339933;">/</span>content<span style="color: #339933;">/</span>wknd<span style="color: #339933;">/</span>en<span style="color: #339933;">/</span>home.<span style="color: #006633;">html</span></div></td></tr></tbody></table></div>
<p>This allows the Dispatcher to cache the resource correctly.</p>
<hr class="spacer-large"/>
<h2 id="additional_examples">4. Additional Examples</h2>
<p><strong>Original URL:</strong></p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//domain.com/en/home</span></div></td></tr></tbody></table></div>
<p><strong>Rewritten URL with [PT]:</strong></p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #339933;">/</span>content<span style="color: #339933;">/</span>wknd<span style="color: #339933;">/</span>en<span style="color: #339933;">/</span>home.<span style="color: #006633;">html</span></div></td></tr></tbody></table></div>
<p><strong>Original URL:</strong></p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//domain.com/about</span></div></td></tr></tbody></table></div>
<p><strong>Rewritten URL with [PT]:</strong></p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #339933;">/</span>content<span style="color: #339933;">/</span>wknd<span style="color: #339933;">/</span>about.<span style="color: #006633;">html</span></div></td></tr></tbody></table></div>
<p>In both examples, the extensionless URLs are mapped to URLs ending in <span class="code-highlight-primary">.html</span>, making them cacheable by the Dispatcher.</p>
<hr class="spacer-large"/>
<h2 id="conclusion">5. Conclusion</h2>
<p>To ensure your pages are cached by the Dispatcher, always add extensions to your URLs. Some may argue that having extensions in URLs could negatively affect SEO rankings. However, an uncached page can lead to slow loading times, which can hurt your SEO rankings even more.</p>
<p>By following these guidelines and using Apache <span class="code-highlight-primary">[PT]</span> rules as a fallback, you can optimize your AEM Dispatcher caching strategy and improve the performance and reliability of your AEM instance.</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/caching-aem-pages-with-extensionless-html">Caching AEM Pages with Extensionless (.html)</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/caching-aem-pages-with-extensionless-html/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Embed Youtube Iframe on Website with Video Loop</title>
		<link>https://sourcedcode.com/blog/general-web/embed-youtube-iframe-on-website-with-video-loop</link>
					<comments>https://sourcedcode.com/blog/general-web/embed-youtube-iframe-on-website-with-video-loop#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Thu, 04 Jul 2024 06:23:55 +0000</pubDate>
				<category><![CDATA[General Web]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=7133</guid>

					<description><![CDATA[<p>Embedding YouTube videos on your website is a common practice, but sometimes you may want the video to loop continuously. Fortunately, YouTube provides an easy way to set up looping for embedded videos. Basic Embed Code Start with the basic YouTube embed code (without loop). For example: 12345&#60;iframe src=&#34;https://www.youtube.com/embed/1O0yazhqaxs&#34; &#160; &#160; &#160; &#160;width=&#34;560&#34; &#160; &#160; [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/general-web/embed-youtube-iframe-on-website-with-video-loop">Embed Youtube Iframe on Website with Video Loop</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Embedding YouTube videos on your website is a common practice, but sometimes you may want the video to loop continuously. Fortunately, YouTube provides an easy way to set up looping for embedded videos.</p>
<hr class="spacer-large" />
<h3 id="basic-embed-code">Basic Embed Code</h3>
<p>Start with the basic YouTube embed code (without loop). For example:</p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&lt;<span style="color: #000000; font-weight: bold;">iframe</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;https://www.youtube.com/embed/1O0yazhqaxs&quot;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">width</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;560&quot;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">height</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;315&quot;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">title</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;3 Second Video&quot;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">frameborder</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;0&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">iframe</span>&gt;</div></td></tr></tbody></table></div>
<hr class="spacer-large" />
<h3 id="add-loop-parameter">Step 1: add Required &#8220;loop&#8221; Parameter</h3>
<p>To enable looping, you need to add <span class="code-highlight-primary">loop=1</span> to the URL parameters.</p>
<hr class="spacer-large" />
<h3 id="add-playlist-parameter">Step 2: add Required &#8220;playlist&#8221; Parameter</h3>
<p>You also need to include the <span class="code-highlight-primary">playlist</span> parameter with the video ID to ensure the video loops. The <span class="code-highlight-primary">playlist</span> parameter should have the same video ID as the video you want to loop.</p>
<hr class="spacer-large" />
<h3 id="complete-embed-code">Complete Embed Code</h3>
<p>Combine these parameters to create the final embed code. Here’s the complete code to loop the YouTube video:</p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&lt;<span style="color: #000000; font-weight: bold;">iframe</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;https://www.youtube.com/embed/1O0yazhqaxs?loop=1&amp;fs=0&amp;playlist=1O0yazhqaxs&quot;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">width</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;560&quot;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">height</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;315&quot;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">title</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;3 Second Video&quot;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">frameborder</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;0&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">iframe</span>&gt;</div></td></tr></tbody></table></div>
<p>Example: <a href="https://jsfiddle.net/x4z73rjL/" rel="noopener" target="_blank">https://jsfiddle.net/x4z73rjL/</a></p>
<hr class="spacer-large" />
<h2 id="example-breakdown">Example Breakdown</h2>
<ul>
<li><strong>Video ID</strong>: <span class="code-highlight-primary">1O0yazhqaxs</span></li>
<li><strong>Loop Parameter</strong>: <span class="code-highlight-primary">loop=1</span> (enables looping)</li>
<li><strong>Playlist Parameter</strong>: <span class="code-highlight-primary">playlist=1O0yazhqaxs</span> (repeats the same video)</li>
</ul>
<hr class="spacer-large" />
<h2 id="final-embedded-video">Final Embedded Video</h2>
<p>Here is the full example of an embedded YouTube video that loops continuously:</p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&lt;<span style="color: #000000; font-weight: bold;">iframe</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;https://www.youtube.com/embed/1O0yazhqaxs?loop=1&amp;fs=0&amp;playlist=1O0yazhqaxs&quot;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">width</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;560&quot;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">height</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;315&quot;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">title</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;3 Second Video&quot;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">frameborder</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;0&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">iframe</span>&gt;</div></td></tr></tbody></table></div>
<p>Example: <a href="https://jsfiddle.net/x4z73rjL/" rel="noopener" target="_blank">https://jsfiddle.net/x4z73rjL/</a></p>
<p>This will embed the YouTube video on your webpage, and it will loop automatically once it reaches the end.</p>
<hr class="spacer-large" />
<h2 id="additional-tips">Additional Tips</h2>
<ul>
<li><strong>Autoplay</strong>: If you want the video to start playing automatically when the page loads, you can add the <span class="code-highlight-primary">autoplay=1</span> parameter to the URL.
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&nbsp; &lt;<span style="color: #000000; font-weight: bold;">iframe</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;https://www.youtube.com/embed/1O0yazhqaxs?loop=1&amp;fs=0&amp;playlist=1O0yazhqaxs&amp;autoplay=1&quot;</span> <span style="color: #000066;">width</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;560&quot;</span> <span style="color: #000066;">height</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;315&quot;</span> <span style="color: #000066;">title</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;3 Second Video&quot;</span> <span style="color: #000066;">frameborder</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;0&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">iframe</span>&gt;</div></td></tr></tbody></table></div>
</li>
<li><strong>Remove Controls</strong>: To hide the player controls, add <span class="code-highlight-primary">controls=0</span> to the URL parameters.
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&nbsp; &lt;<span style="color: #000000; font-weight: bold;">iframe</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;https://www.youtube.com/embed/1O0yazhqaxs?loop=1&amp;fs=0&amp;playlist=1O0yazhqaxs&amp;controls=0&quot;</span> <span style="color: #000066;">width</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;560&quot;</span> <span style="color: #000066;">height</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;315&quot;</span> <span style="color: #000066;">title</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;3 Second Video&quot;</span> <span style="color: #000066;">frameborder</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;0&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">iframe</span>&gt;</div></td></tr></tbody></table></div>
</li>
</ul>
<p>By following these steps, you can easily loop embedded YouTube videos on your website, providing a seamless viewing experience for your audience.</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/general-web/embed-youtube-iframe-on-website-with-video-loop">Embed Youtube Iframe on Website with Video Loop</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/general-web/embed-youtube-iframe-on-website-with-video-loop/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Embed Youtube Iframe on Website with Auto Play</title>
		<link>https://sourcedcode.com/blog/general-web/embed-youtube-iframe-on-website-with-auto-play</link>
					<comments>https://sourcedcode.com/blog/general-web/embed-youtube-iframe-on-website-with-auto-play#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Tue, 02 Jul 2024 12:35:43 +0000</pubDate>
				<category><![CDATA[General Web]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=7141</guid>

					<description><![CDATA[<p>Embedding YouTube videos on your website can significantly enhance user engagement. One useful feature is the ability to set videos to autoplay when the page loads. It is important to note that for autoplay to work, the video must be muted. This is due to modern browser restrictions aimed at improving user experience by preventing [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/general-web/embed-youtube-iframe-on-website-with-auto-play">Embed Youtube Iframe on Website with Auto Play</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Embedding YouTube videos on your website can significantly enhance user engagement. One useful feature is the ability to set videos to autoplay when the page loads. It is important to note that for autoplay to work, the video must be muted. This is due to modern browser restrictions aimed at improving user experience by preventing unexpected audio playback.</p>
<hr class="spacer-larger" />
<h2 id="step-by-step-guide">Step-by-Step Guide</h2>
<ol>
<li>
    <strong>Basic Embed Code</strong>: Start with the basic YouTube embed code. For example:</p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&nbsp; &nbsp; &lt;<span style="color: #000000; font-weight: bold;">iframe</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;https://www.youtube.com/embed/1O0yazhqaxs&quot;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">width</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;560&quot;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">height</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;315&quot;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">title</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;3 Second Video&quot;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">frameborder</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;0&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">iframe</span>&gt;</div></td></tr></tbody></table></div>
<p><a href="https://jsfiddle.net/x4z73rjL/1/" rel="noopener" target="_blank">https://jsfiddle.net/x4z73rjL/1/</a>
  </li>
<li>
    <strong>Add Autoplay and Mute Parameters</strong>: To enable autoplay, you must also mute the video. Modern browsers restrict autoplay unless the video is muted. Add the <span class="code-highlight-primary">autoplay=1</span> and <span class="code-highlight-primary">mute=1</span> parameters to the URL.
  </li>
<li>
    <strong>Complete Embed Code</strong>: Combine these parameters to create the final embed code. Here’s the complete code to autoplay and mute the YouTube video:</p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&nbsp; &nbsp; &lt;<span style="color: #000000; font-weight: bold;">iframe</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;https://www.youtube.com/embed/1O0yazhqaxs?autoplay=1&amp;mute=1&quot;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">width</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;560&quot;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">height</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;315&quot;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">title</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;3 Second Video&quot;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">frameborder</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;0&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">iframe</span>&gt;</div></td></tr></tbody></table></div>
<p><a href="https://jsfiddle.net/x4z73rjL/2/" rel="noopener" target="_blank">https://jsfiddle.net/x4z73rjL/2/</a>
  </li>
</ol>
<hr class="spacer-larger" />
<h2 id="example-breakdown">Example Breakdown</h2>
<ul>
<li><strong>Video ID</strong>: <span class="code-highlight-primary">1O0yazhqaxs</span></li>
<li><strong>Autoplay Parameter</strong>: <span class="code-highlight-primary">autoplay=1</span> (enables autoplay)</li>
<li><strong>Mute Parameter</strong>: <span class="code-highlight-primary">mute=1</span> (mutes the video)</li>
</ul>
<hr class="spacer-larger" />
<h2 id="final-embedded-video">Final Embedded Video</h2>
<p>Here is the full example of an embedded YouTube video that autoplays and is muted:</p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&lt;<span style="color: #000000; font-weight: bold;">iframe</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;https://www.youtube.com/embed/1O0yazhqaxs?autoplay=1&amp;mute=1&quot;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">width</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;560&quot;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">height</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;315&quot;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">title</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;3 Second Video&quot;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">frameborder</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;0&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">iframe</span>&gt;</div></td></tr></tbody></table></div>
<p><a href="https://jsfiddle.net/fo3yg4w9/" rel="noopener" target="_blank">https://jsfiddle.net/fo3yg4w9/</a></p>
<p>This will embed the YouTube video on your webpage, and it will start playing automatically and be muted.</p>
<hr class="spacer-larger" />
<h2 id="additional-tips">Additional Tips</h2>
<ul>
<li>
    <strong>Show Controls</strong>: If you want to keep the player controls visible, you can add <span class="code-highlight-primary">controls=1</span> (this is the default setting, so it’s optional).</p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&nbsp; &nbsp; &lt;<span style="color: #000000; font-weight: bold;">iframe</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;https://www.youtube.com/embed/1O0yazhqaxs?autoplay=1&amp;mute=1&amp;controls=1&quot;</span> <span style="color: #000066;">width</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;560&quot;</span> <span style="color: #000066;">height</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;315&quot;</span> <span style="color: #000066;">title</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;3 Second Video&quot;</span> <span style="color: #000066;">frameborder</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;0&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">iframe</span>&gt;</div></td></tr></tbody></table></div>
</li>
<li>
    <strong>Loop the Video</strong>: To make the video loop, add <span class="code-highlight-primary">loop=1</span> and <span class="code-highlight-primary">playlist</span> with the video ID.</p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&nbsp; &nbsp; &lt;<span style="color: #000000; font-weight: bold;">iframe</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;https://www.youtube.com/embed/1O0yazhqaxs?autoplay=1&amp;mute=1&amp;loop=1&amp;playlist=1O0yazhqaxs&quot;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">width</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;560&quot;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">height</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;315&quot;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">title</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;3 Second Video&quot;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">frameborder</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;0&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">iframe</span>&gt;</div></td></tr></tbody></table></div>
<p><a href="https://jsfiddle.net/8h7vL5md/" rel="noopener" target="_blank">https://jsfiddle.net/8h7vL5md/</a>
  </li>
</ul>
<p>By following these steps, you can easily embed YouTube videos on your website with autoplay and mute enabled, enhancing the viewing experience for your audience.</p>
<p>For more details, you can refer to <a href="https://developer.chrome.com/blog/autoplay/" target="_blank" rel="noopener">Google&#8217;s Autoplay Policy</a> and <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/autoplay" target="_blank" rel="noopener">MDN Web Docs on Autoplay</a>.</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/general-web/embed-youtube-iframe-on-website-with-auto-play">Embed Youtube Iframe on Website with Auto Play</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/general-web/embed-youtube-iframe-on-website-with-auto-play/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Understanding `data-sly-attribute` in AEM Sightly (HTL)</title>
		<link>https://sourcedcode.com/blog/aem/understanding-data-sly-attribute-in-aem-sightly-htl</link>
					<comments>https://sourcedcode.com/blog/aem/understanding-data-sly-attribute-in-aem-sightly-htl#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Thu, 27 Jun 2024 05:30:13 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Sightly]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=7113</guid>

					<description><![CDATA[<p>The data-sly-attribute directive in HTL (HTML Template Language) allows developers to dynamically set one or more attributes on an HTML element. This powerful feature provides flexibility in managing HTML attributes based on the logic defined in your Sling models or Use classes. Quick Links 1. Element and Attribute Visibility 2. Attribute Value Options 3. Attribute [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/understanding-data-sly-attribute-in-aem-sightly-htl">Understanding `data-sly-attribute` in AEM Sightly (HTL)</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>The <span class="code-highlight-primary">data-sly-attribute</span> directive in HTL (HTML Template Language) allows developers to dynamically set one or more attributes on an HTML element. This powerful feature provides flexibility in managing HTML attributes based on the logic defined in your Sling models or Use classes.</p>
<div class="mention-block">
  <strong>Quick Links</strong></p>
<ul>
<li><a href="#element_and_attribute_visibility">1. Element and Attribute Visibility</a></li>
<li><a href="#attribute_value_options">2. Attribute Value Options</a></li>
<li><a href="#attribute_identifier">3. Attribute Identifier</a></li>
<li><a href="#using_data_sly_attribute">4. Using `data-sly-attribute`</a></li>
<li><a href="#injecting_multiple_attributes">5. Injecting Multiple Attributes</a></li>
<li><a href="#more_examples">6. More Examples</a></li>
<li><a href="#conclusion">Conclusion</a></li>
</ul>
</div>
<hr class="spacer-larger" />
<h2 id="element_and_attribute_visibility">1. Element and Attribute Visibility</h2>
<p>When using the <span class="code-highlight-primary">data-sly-attribute</span> directive, it&#8217;s important to understand how it affects the visibility of elements and their attributes:</p>
<p><strong>Element Visibility</strong>: The HTML element to which the <span class="code-highlight-primary">data-sly-attribute</span> directive is applied will always be rendered in the DOM. This means that the element itself will always be visible, regardless of the attributes set or not set by the directive.</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #339933;">&lt;</span>p data<span style="color: #339933;">-</span>sly<span style="color: #339933;">-</span>attribute.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;${dynamicClass}&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">This</span> is a paragraph.<span style="color: #339933;">&lt;/</span>p<span style="color: #339933;">&gt;</span><br />
<span style="color: #339933;">&lt;!--</span> Assuming dynamicClass <span style="color: #339933;">=</span> <span style="color: #0000ff;">'highlight'</span> <span style="color: #339933;">--&gt;</span><br />
<span style="color: #339933;">&lt;!--</span> Output<span style="color: #339933;">:</span> <span style="color: #339933;">--&gt;</span><br />
<span style="color: #339933;">&lt;</span>p <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;highlight&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">This</span> is a paragraph.<span style="color: #339933;">&lt;/</span>p<span style="color: #339933;">&gt;</span></div></td></tr></tbody></table></div>
<p>Even if <span class="code-highlight-primary">dynamicClass</span> is empty or undefined, the paragraph will still appear in the DOM.</p>
<p><strong>Element Content</strong>: The content inside the HTML element will also always be displayed. The <span class="code-highlight-primary">data-sly-attribute</span> directive only affects the attributes of the element, not its content. This ensures that the inner content remains intact and visible to the users.</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #339933;">&lt;</span>span data<span style="color: #339933;">-</span>sly<span style="color: #339933;">-</span>attribute.<span style="color: #006633;">id</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;${dynamicId}&quot;</span><span style="color: #339933;">&gt;</span>Content remains visible.<span style="color: #339933;">&lt;/</span>span<span style="color: #339933;">&gt;</span><br />
<span style="color: #339933;">&lt;!--</span> Assuming dynamicId <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span> <span style="color: #339933;">--&gt;</span><br />
<span style="color: #339933;">&lt;!--</span> Output<span style="color: #339933;">:</span> <span style="color: #339933;">--&gt;</span><br />
<span style="color: #339933;">&lt;</span>span<span style="color: #339933;">&gt;</span>Content remains visible.<span style="color: #339933;">&lt;/</span>span<span style="color: #339933;">&gt;</span></div></td></tr></tbody></table></div>
<p>Even if <span class="code-highlight-primary">dynamicId</span> is empty or undefined, the text &#8220;Content remains visible&#8221; will still be displayed within the span element.</p>
<hr class="spacer-larger" />
<h2 id="attribute_value_options">2. Attribute Value Options</h2>
<p>The attribute value in <span class="code-highlight-primary">data-sly-attribute</span> is optional and can be of different types:</p>
<p><strong>String</strong>: Used to set the content of the attribute.</p>
<p>Example:</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #339933;">&lt;</span>a data<span style="color: #339933;">-</span>sly<span style="color: #339933;">-</span>attribute.<span style="color: #006633;">href</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;${dynamicHref}&quot;</span><span style="color: #339933;">&gt;</span>Click here<span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;</span><br />
<span style="color: #339933;">&lt;!--</span> Assuming dynamicHref <span style="color: #339933;">=</span> <span style="color: #0000ff;">'https://www.example.com'</span> <span style="color: #339933;">--&gt;</span><br />
<span style="color: #339933;">&lt;!--</span> Output<span style="color: #339933;">:</span> <span style="color: #339933;">--&gt;</span><br />
<span style="color: #339933;">&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;https://www.example.com&quot;</span><span style="color: #339933;">&gt;</span>Click here<span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;</span></div></td></tr></tbody></table></div>
<p><strong>Boolean</strong>: Used for setting boolean attributes.</p>
<p>Example:</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #339933;">&lt;</span>input type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;checkbox&quot;</span> data<span style="color: #339933;">-</span>sly<span style="color: #339933;">-</span>attribute.<span style="color: #006633;">checked</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;${isChecked}&quot;</span> <span style="color: #339933;">/&gt;</span><br />
<span style="color: #339933;">&lt;!--</span> Assuming isChecked <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">true</span> <span style="color: #339933;">--&gt;</span><br />
<span style="color: #339933;">&lt;!--</span> Output<span style="color: #339933;">:</span> <span style="color: #339933;">--&gt;</span><br />
<span style="color: #339933;">&lt;</span>input type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;checkbox&quot;</span> checked <span style="color: #339933;">/&gt;</span></div></td></tr></tbody></table></div>
<p><strong>Object</strong>: Used for setting multiple attributes simultaneously.</p>
<p>Example:</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #339933;">&lt;</span>div data<span style="color: #339933;">-</span>sly<span style="color: #339933;">-</span>attribute<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;${attributeMap}&quot;</span><span style="color: #339933;">&gt;</span>Dynamic Attributes<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span><br />
<span style="color: #339933;">&lt;!--</span> Assuming attributeMap <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #0000ff;">'id'</span><span style="color: #339933;">:</span> <span style="color: #0000ff;">'dynamicDiv'</span>, <span style="color: #0000ff;">'class'</span><span style="color: #339933;">:</span> <span style="color: #0000ff;">'dynamicClass'</span><span style="color: #009900;">&#125;</span> <span style="color: #339933;">--&gt;</span><br />
<span style="color: #339933;">&lt;!--</span> Output<span style="color: #339933;">:</span> <span style="color: #339933;">--&gt;</span><br />
<span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;dynamicDiv&quot;</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;dynamicClass&quot;</span><span style="color: #339933;">&gt;</span>Dynamic Attributes<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span></div></td></tr></tbody></table></div>
<p>If the attribute value is omitted, the attribute will be removed.</p>
<hr class="spacer-larger" />
<h2 id="attribute_identifier">3. Attribute Identifier</h2>
<p>The attribute identifier, which is the name of the attribute, is also optional. It must be omitted only if the attribute value is an Object.</p>
<p><strong>Detailed Explanation:</strong></p>
<p>When using the <span class="code-highlight-primary">data-sly-attribute</span> directive, you can specify the name of the attribute you want to set. This is called the attribute identifier. However, when you are using an Object to set multiple attributes at once, you do not need to specify individual attribute names.</p>
<p><strong>Code Examples:</strong></p>
<p><strong>Specifying Attribute Identifier:</strong></p>
<p>When setting a single attribute, you provide the attribute name directly.</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #339933;">&lt;</span>p data<span style="color: #339933;">-</span>sly<span style="color: #339933;">-</span>attribute.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;${dynamicClass}&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">This</span> is a paragraph.<span style="color: #339933;">&lt;/</span>p<span style="color: #339933;">&gt;</span><br />
<span style="color: #339933;">&lt;!--</span> Assuming dynamicClass <span style="color: #339933;">=</span> <span style="color: #0000ff;">'highlight'</span> <span style="color: #339933;">--&gt;</span><br />
<span style="color: #339933;">&lt;!--</span> Output<span style="color: #339933;">:</span> <span style="color: #339933;">--&gt;</span><br />
<span style="color: #339933;">&lt;</span>p <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;highlight&quot;</span><span style="color: #339933;">&gt;</span><span style="color: #000000; font-weight: bold;">This</span> is a paragraph.<span style="color: #339933;">&lt;/</span>p<span style="color: #339933;">&gt;</span></div></td></tr></tbody></table></div>
<p><strong>Omitting Attribute Identifier (Using an Object):</strong></p>
<p>When setting multiple attributes simultaneously, you use an Object and omit the attribute name.</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #339933;">&lt;</span>div data<span style="color: #339933;">-</span>sly<span style="color: #339933;">-</span>attribute<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;${attributeMap}&quot;</span><span style="color: #339933;">&gt;</span>Dynamic Attributes<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span><br />
<span style="color: #339933;">&lt;!--</span> Assuming attributeMap <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #0000ff;">'id'</span><span style="color: #339933;">:</span> <span style="color: #0000ff;">'dynamicDiv'</span>, <span style="color: #0000ff;">'class'</span><span style="color: #339933;">:</span> <span style="color: #0000ff;">'dynamicClass'</span>, <span style="color: #0000ff;">'aria-label'</span><span style="color: #339933;">:</span> <span style="color: #0000ff;">'click'</span><span style="color: #009900;">&#125;</span> <span style="color: #339933;">--&gt;</span><br />
<span style="color: #339933;">&lt;!--</span> Output<span style="color: #339933;">:</span> <span style="color: #339933;">--&gt;</span><br />
<span style="color: #339933;">&lt;</span>div id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;dynamicDiv&quot;</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;dynamicClass&quot;</span> aria<span style="color: #339933;">-</span>label<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;click&quot;</span><span style="color: #339933;">&gt;</span>Dynamic Attributes<span style="color: #339933;">&lt;/</span>div<span style="color: #339933;">&gt;</span></div></td></tr></tbody></table></div>
<p>In this case, the keys of the Object (<span class="code-highlight-primary">id</span> and <span class="code-highlight-primary">class</span>) are used as attribute names, and their corresponding values (<span class="code-highlight-primary">dynamicDiv</span> and <span class="code-highlight-primary">dynamicClass</span>) are assigned to those attributes.</p>
<hr class="spacer-larger" />
<h2 id="using_data_sly_attribute">4. Using `data-sly-attribute`</h2>
<p>You can define attributes either directly through an expression or by using a <span class="code-highlight-primary">data-sly-attribute.*</span> attribute. This approach allows designers to annotate HTML without modifying the mock content.</p>
<hr class="spacer-medium" />
<h3 id="example_1_overwriting_an_attribute">Example: Overwriting an Attribute</h3>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #339933;">&lt;!--</span> <span style="color: #000000; font-weight: bold;">This</span> will overwrite the <span style="color: #000000; font-weight: bold;">class</span> attribute value <span style="color: #339933;">--&gt;</span><br />
<span style="color: #339933;">&lt;</span>tag <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;initialClass&quot;</span> data<span style="color: #339933;">-</span>sly<span style="color: #339933;">-</span>attribute.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;${dynamicClass}&quot;</span><span style="color: #339933;">&gt;&lt;/</span>tag<span style="color: #339933;">&gt;</span><br />
<span style="color: #339933;">&lt;!--</span> Assuming dynamicClass <span style="color: #339933;">=</span> <span style="color: #0000ff;">'newClass'</span> <span style="color: #339933;">--&gt;</span><br />
<span style="color: #339933;">&lt;!--</span> Output<span style="color: #339933;">:</span> <span style="color: #339933;">--&gt;</span><br />
<span style="color: #339933;">&lt;</span>tag <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;newClass&quot;</span><span style="color: #339933;">&gt;&lt;/</span>tag<span style="color: #339933;">&gt;</span></div></td></tr></tbody></table></div>
<hr class="spacer-medium" />
<h3 id="example_2_creating_a_new_attribute">Example: Creating a New Attribute</h3>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #339933;">&lt;!--</span> <span style="color: #000000; font-weight: bold;">This</span> will create a data<span style="color: #339933;">-</span>values attribute <span style="color: #339933;">--&gt;</span><br />
<span style="color: #339933;">&lt;</span>tag data<span style="color: #339933;">-</span>sly<span style="color: #339933;">-</span>attribute.<span style="color: #006633;">aria</span><span style="color: #339933;">-</span>label<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;${dynamicValues}&quot;</span><span style="color: #339933;">&gt;&lt;/</span>tag<span style="color: #339933;">&gt;</span><br />
<span style="color: #339933;">&lt;!--</span> Assuming dynamicValues <span style="color: #339933;">=</span> <span style="color: #0000ff;">'exampleValue'</span> <span style="color: #339933;">--&gt;</span><br />
<span style="color: #339933;">&lt;!--</span> Output<span style="color: #339933;">:</span> <span style="color: #339933;">--&gt;</span><br />
<span style="color: #339933;">&lt;</span>tag aria<span style="color: #339933;">-</span>label<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;exampleValue&quot;</span><span style="color: #339933;">&gt;&lt;/</span>tag<span style="color: #339933;">&gt;</span></div></td></tr></tbody></table></div>
<hr class="spacer-larger" />
<h2 id="injecting_multiple_attributes">5. Injecting Multiple Attributes</h2>
<p>The <span class="code-highlight-primary">data-sly-attribute</span> block element, when used without specifying an attribute name, allows the injection of multiple attributes that have been prepared in a map object containing key-value pairs.</p>
<hr class="spacer-medium" />
<h3 id="example_3_injecting_multiple_attributes">Example: Injecting Multiple Attributes</h3>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #339933;">&lt;</span>input data<span style="color: #339933;">-</span>sly<span style="color: #339933;">-</span>attribute<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;${attributeMap}&quot;</span> type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text&quot;</span><span style="color: #339933;">/&gt;</span><br />
<span style="color: #339933;">&lt;!--</span> Assuming attributeMap <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #0000ff;">'id'</span><span style="color: #339933;">:</span> <span style="color: #0000ff;">'dynamicId'</span>, <span style="color: #0000ff;">'class'</span><span style="color: #339933;">:</span> <span style="color: #0000ff;">'dynamicClass'</span><span style="color: #009900;">&#125;</span> <span style="color: #339933;">--&gt;</span><br />
<span style="color: #339933;">&lt;!--</span> Output<span style="color: #339933;">:</span> <span style="color: #339933;">--&gt;</span><br />
<span style="color: #339933;">&lt;</span>input id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;dynamicId&quot;</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;dynamicClass&quot;</span> type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text&quot;</span><span style="color: #339933;">/&gt;</span></div></td></tr></tbody></table></div>
<hr class="spacer-larger" />
<h2 id="more_examples">6. More Examples</h2>
<hr class="spacer-medium" />
<h3 id="example_4_setting_multiple_attributes_on_a_button">Example: Setting Multiple Attributes on a Button</h3>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #339933;">&lt;</span>button data<span style="color: #339933;">-</span>sly<span style="color: #339933;">-</span>attribute<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;${buttonAttributes}&quot;</span><span style="color: #339933;">&gt;</span>Click Me<span style="color: #339933;">&lt;/</span>button<span style="color: #339933;">&gt;</span><br />
<span style="color: #339933;">&lt;!--</span> Assuming buttonAttributes <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #0000ff;">'id'</span><span style="color: #339933;">:</span> <span style="color: #0000ff;">'submitButton'</span>, <span style="color: #0000ff;">'class'</span><span style="color: #339933;">:</span> <span style="color: #0000ff;">'btn btn-primary'</span>, <span style="color: #0000ff;">'disabled'</span><span style="color: #339933;">:</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#125;</span> <span style="color: #339933;">--&gt;</span><br />
<span style="color: #339933;">&lt;!--</span> Output<span style="color: #339933;">:</span> <span style="color: #339933;">--&gt;</span><br />
<span style="color: #339933;">&lt;</span>button id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;submitButton&quot;</span> <span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;btn btn-primary&quot;</span> disabled<span style="color: #339933;">&gt;</span>Click Me<span style="color: #339933;">&lt;/</span>button<span style="color: #339933;">&gt;</span></div></td></tr></tbody></table></div>
<hr class="spacer-medium" />
<h3 id="example_5_conditional_attribute_setting">Example: Conditional Attribute Setting</h3>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">#example<span style="color: #339933;">:</span> <span style="color: #cc66cc;">1</span><br />
<span style="color: #339933;">&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;/home&quot;</span> data<span style="color: #339933;">-</span>sly<span style="color: #339933;">-</span>attribute.<span style="color: #006633;">target</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;${openInNewTab ? '_blank' : ''}&quot;</span><span style="color: #339933;">&gt;</span>Home<span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;</span><br />
<br />
<span style="color: #339933;">&lt;!--</span> Assuming openInNewTab <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">true</span> <span style="color: #339933;">--&gt;</span><br />
<span style="color: #339933;">&lt;!--</span> Output <span style="color: #000000; font-weight: bold;">if</span> openInNewTab is <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">:</span> <span style="color: #339933;">--&gt;</span><br />
<span style="color: #339933;">&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;/home&quot;</span> target<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;_blank&quot;</span> rel<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;noopener&quot;</span><span style="color: #339933;">&gt;</span>Home<span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;</span><br />
<br />
<span style="color: #339933;">&lt;!--</span> Output <span style="color: #000000; font-weight: bold;">if</span> openInNewTab is <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">:</span> <span style="color: #339933;">--&gt;</span><br />
<span style="color: #339933;">&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;/home&quot;</span><span style="color: #339933;">&gt;</span>Home<span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;</span><br />
<br />
#example<span style="color: #339933;">:</span> <span style="color: #cc66cc;">2</span><br />
<span style="color: #339933;">&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;/example-2&quot;</span> data<span style="color: #339933;">-</span>sly<span style="color: #339933;">-</span>attribute.<span style="color: #006633;">aria</span><span style="color: #339933;">-</span>label<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;${properties.ariaLabelText}&quot;</span><span style="color: #339933;">&gt;</span>Example <span style="color: #cc66cc;">2</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;</span><br />
<br />
<span style="color: #339933;">&lt;!--</span> Assuming properties.<span style="color: #006633;">ariaLabelText</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'This is a custom aria-label'</span> <span style="color: #339933;">--&gt;</span><br />
<span style="color: #339933;">&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;/example-2&quot;</span> data<span style="color: #339933;">-</span>sly<span style="color: #339933;">-</span>attribute.<span style="color: #006633;">aria</span><span style="color: #339933;">-</span>label<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;This is a custom aria-label&quot;</span><span style="color: #339933;">&gt;</span>Example <span style="color: #cc66cc;">2</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;</span><br />
<br />
<span style="color: #339933;">&lt;!--</span> Assuming properties.<span style="color: #006633;">ariaLabelText</span> <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span> <span style="color: #339933;">--&gt;</span><br />
<span style="color: #339933;">&lt;</span>a href<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;/example-2&quot;</span><span style="color: #339933;">&gt;</span>Example <span style="color: #cc66cc;">2</span><span style="color: #339933;">&lt;/</span>a<span style="color: #339933;">&gt;</span><br />
<br />
#example<span style="color: #339933;">:</span> <span style="color: #cc66cc;">3</span><br />
<span style="color: #339933;">&lt;</span>iframe data<span style="color: #339933;">-</span>sly<span style="color: #339933;">-</span>atribute.<span style="color: #006633;">allowfullscreen</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;${properties.isAllowfullscreen}&quot;</span> src<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;https://www.youtube.com/embed/hKh0MoabKvc?si=iUCcv4JYNM2lgVpF&quot;</span> title<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;YouTube video player&quot;</span><span style="color: #339933;">&gt;&lt;/</span>iframe<span style="color: #339933;">&gt;</span><br />
<br />
<span style="color: #339933;">&lt;!--</span> Assuming properties.<span style="color: #006633;">ariaLabelText</span> <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">true</span> <span style="color: #339933;">--&gt;</span><br />
<span style="color: #339933;">&lt;</span>iframe allowfullscreen src<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;https://www.youtube.com/embed/hKh0MoabKvc?si=iUCcv4JYNM2lgVpF&quot;</span> title<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;YouTube video player&quot;</span><span style="color: #339933;">&gt;&lt;/</span>iframe<span style="color: #339933;">&gt;</span><br />
<br />
<span style="color: #339933;">&lt;!--</span> Assuming properties.<span style="color: #006633;">isAllowfullscreen</span> <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span> <span style="color: #339933;">--&gt;</span><br />
<span style="color: #339933;">&lt;</span>iframe src<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;https://www.youtube.com/embed/hKh0MoabKvc?si=iUCcv4JYNM2lgVpF&quot;</span> title<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;YouTube video player&quot;</span><span style="color: #339933;">&gt;&lt;/</span>iframe<span style="color: #339933;">&gt;</span></div></td></tr></tbody></table></div>
<hr class="spacer-larger" />
<h2 id="conclusion">Conclusion</h2>
<p>The <span class="code-highlight-primary">data-sly-attribute</span> directive in HTL provides a versatile way to manage HTML attributes dynamically. Whether you&#8217;re setting a single attribute or multiple attributes at once, this feature can help you create more dynamic and flexible web components. By leveraging <span class="code-highlight-primary">data-sly-attribute</span>, you can ensure that your HTML remains clean and maintainable, while still being able to handle complex attribute logic.</p>
<p>Feel free to explore and use these examples to enhance your AEM projects, making your components more dynamic and interactive.</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/understanding-data-sly-attribute-in-aem-sightly-htl">Understanding `data-sly-attribute` in AEM Sightly (HTL)</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/understanding-data-sly-attribute-in-aem-sightly-htl/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>AEM Multi-tenant Website: Restrict cq:tags for User Groups</title>
		<link>https://sourcedcode.com/blog/aem/aem-multi-tenant-website-restrict-cqtags-for-user-groups</link>
					<comments>https://sourcedcode.com/blog/aem/aem-multi-tenant-website-restrict-cqtags-for-user-groups#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Thu, 13 Jun 2024 06:10:35 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Permissions]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=7056</guid>

					<description><![CDATA[<p>Of most common multi-tenant websites, user groups are used to determine what AEM content authors can make changes to. The most popular requirement for a multi-tenant website is the ability to only edit tags for a specific brand. In this case, the way you can achieve this is by permissions. In this blog, we will [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/aem-multi-tenant-website-restrict-cqtags-for-user-groups">AEM Multi-tenant Website: Restrict cq:tags for User Groups</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Of most common multi-tenant websites, user groups are used to determine what AEM content authors can make changes to. The most popular requirement for a multi-tenant website is the ability to only edit tags for a specific brand. In this case, the way you can achieve this is by permissions. In this blog, we will ensure that all &#8220;WKND Members&#8221; will be able to create, read, update, and delete nodes under <span class="code-highlight-primary">/content/cq:tags/wknd-shared</span>, while these members will not be able to read any other tags listed under <span class="code-highlight-primary">/content/cq:tags/*</span>.</p>
<div class="mention-block">
    <strong>Quick Links</strong></p>
<ol>
<li><a href="#steps_to_restrict_tags_for_user_groups">Steps to Restrict Tags for User Groups in AEM</a></li>
<li><a href="#go_to_tools_security_permissions">Go to Tools > Security > Permissions</a></li>
<li><a href="#find_your_user_group">Find Your User Group</a></li>
<li><a href="#click_on_add_ace">Click on &#8220;Add ACE&#8221;</a></li>
<li><a href="#add_path_content_cq_tags">Add Path /content/cq:tags</a></li>
<li><a href="#privileges_add_jcr_read">Privileges: Add jcr:read</a></li>
<li><a href="#set_permission_type_to_deny">Set Permission Type to Deny</a></li>
<li><a href="#add_restrictions_rep_glob">Add Restrictions rep:glob=/</a></li>
<li><a href="#press_add">Press Add</a></li>
<li><a href="#allow_access_to_content_cq_tags_wknd_shared">Allow Access to /content/cq:tags/wknd-shared</a></li>
<li><a href="#click_on_add_ace_again">Click on &#8220;Add ACE&#8221;</a></li>
<li><a href="#add_path_content_cq_tags_wknd_shared">Add Path /content/cq:tags/wknd-shared</a></li>
<li><a href="#set_permission_type_to_allow">Set Permission Type to Allow</a></li>
<li><a href="#conclusion">Conclusion</a></li>
</ol>
</div>
<hr class="spacer-large"/>
<h2 id="steps_to_restrict_tags_for_user_groups">1. Steps to Restrict Tags for User Groups in AEM</h2>
<h3 id="go_to_tools_security_permissions">2. Go to Tools > Security > Permissions</h3>
<p>Navigate to the permissions section of the AEM author instance to start configuring the permissions for the user group.</p>
<hr class="spacer-large"/>
<h3 id="find_your_user_group">3. Find Your User Group</h3>
<p>Search for the user group that you want to configure. In this example, we will be using the &#8220;WKND Members&#8221; group.</p>
<hr class="spacer-large"/>
<h3 id="click_on_add_ace">4. Click on &#8220;Add ACE&#8221;</h3>
<p>Add a new Access Control Entry (ACE) to define the permissions for the group.</p>
<hr class="spacer-large"/>
<h3 id="add_path_content_cq_tags">5. Add Path <span class="code-highlight-primary">/content/cq:tags</span></h3>
<p>This will hide all the tags from the user group initially.</p>
<hr class="spacer-large"/>
<h3 id="privileges_add_jcr_read">6. Privileges: Add <span class="code-highlight-primary">jcr:read</span></h3>
<p>Grant read privileges to the path <span class="code-highlight-primary">/content/cq:tags</span>.</p>
<hr class="spacer-large"/>
<h3 id="set_permission_type_to_deny">7. Set Permission Type to Deny</h3>
<p>This will ensure that the group does not have access to read the tags by default.</p>
<hr class="spacer-large"/>
<h3 id="add_restrictions_rep_glob">8. Add Restrictions <span class="code-highlight-primary">rep:glob=/</span></h3>
<p>This restriction will hide all top-level <span class="code-highlight-primary">cq:tag</span> resources. It effectively denies access to all tags under <span class="code-highlight-primary">/content/cq:tags</span> for the specified group.</p>
<p><strong>Explanation:</strong> The <span class="code-highlight-primary">rep:glob=/</span> restriction specifies that the denial applies to all child nodes of the specified path. This means the group will not be able to see any of the tags under <span class="code-highlight-primary">/content/cq:tags</span>.</p>
<p><a href="https://sourcedcode.com/wp-content/uploads/2024/06/wknd-members-restrict-all-cq-tags-but-one-deny.png"><img decoding="async" src="https://sourcedcode.com/wp-content/uploads/2024/06/wknd-members-restrict-all-cq-tags-but-one-deny.png" alt="/content/cq:tags, deny read" width="50%" height="auto" class="alignnone size-full wp-image-7064" srcset="https://sourcedcode.com/wp-content/uploads/2024/06/wknd-members-restrict-all-cq-tags-but-one-deny.png 3040w, https://sourcedcode.com/wp-content/uploads/2024/06/wknd-members-restrict-all-cq-tags-but-one-deny-300x154.png 300w, https://sourcedcode.com/wp-content/uploads/2024/06/wknd-members-restrict-all-cq-tags-but-one-deny-1024x526.png 1024w, https://sourcedcode.com/wp-content/uploads/2024/06/wknd-members-restrict-all-cq-tags-but-one-deny-768x395.png 768w, https://sourcedcode.com/wp-content/uploads/2024/06/wknd-members-restrict-all-cq-tags-but-one-deny-1536x789.png 1536w, https://sourcedcode.com/wp-content/uploads/2024/06/wknd-members-restrict-all-cq-tags-but-one-deny-2048x1052.png 2048w, https://sourcedcode.com/wp-content/uploads/2024/06/wknd-members-restrict-all-cq-tags-but-one-deny-600x308.png 600w" sizes="(max-width: 3040px) 100vw, 3040px" /></a></p>
<hr class="spacer-large"/>
<h3 id="press_add">9. Press Add to Save</h3>
<p>Confirm and add this ACE to enforce the denial of read access.</p>
<hr class="spacer-large"/>
<h3 id="allow_access_to_content_cq_tags_wknd_shared">10. Allow Access to <span class="code-highlight-primary">/content/cq:tags/wknd-shared</span></h3>
<p>Now, we need to explicitly allow access to the specific tags we want the group to manage.</p>
<hr class="spacer-large"/>
<h3 id="click_on_add_ace_again">11. Click on &#8220;Add ACE&#8221;</h3>
<p>Add another ACE to define the permissions for the specific tags.</p>
<hr class="spacer-large"/>
<h3 id="add_path_content_cq_tags_wknd_shared">12. Add Path <span class="code-highlight-primary">/content/cq:tags/wknd-shared</span></h3>
<p>Specify the path to the tags that should be visible and editable by the group.</p>
<hr class="spacer-large"/>
<h3 id="set_permission_type_to_allow">13. Set Permission Type to Allow</h3>
<p>Ensure that the permission type is set to allow, so the group can manage these tags.</p>
<p><a href="https://sourcedcode.com/wp-content/uploads/2024/06/wknd-members-restrict-all-cq-tags-but-one-allow.png"><img decoding="async" src="https://sourcedcode.com/wp-content/uploads/2024/06/wknd-members-restrict-all-cq-tags-but-one-allow.png" alt="/content/cq:tags/wknd-shared, allow create, read, update, delete" width="auto" height="50%" class="alignnone size-full wp-image-7062" /></a></p>
<hr class="spacer-larger"/>
<h2 id="conclusion">Conclusion</h2>
<p>By following these steps, the &#8220;WKND Members&#8221; user group will be able to create, read, update, and delete nodes under <span class="code-highlight-primary">/content/cq:tags/wknd-shared</span>, while being restricted from accessing any other tags under <span class="code-highlight-primary">/content/cq:tags/*</span>.<br />
<a href="https://sourcedcode.com/wp-content/uploads/2024/06/wknd-members-test-previous.png"><img decoding="async" src="https://sourcedcode.com/wp-content/uploads/2024/06/wknd-members-test-previous.png" alt="Previously before adding permissions for the current user" width="50%" height="auto" class="alignnone size-full wp-image-7073" srcset="https://sourcedcode.com/wp-content/uploads/2024/06/wknd-members-test-previous.png 2098w, https://sourcedcode.com/wp-content/uploads/2024/06/wknd-members-test-previous-300x205.png 300w, https://sourcedcode.com/wp-content/uploads/2024/06/wknd-members-test-previous-1024x701.png 1024w, https://sourcedcode.com/wp-content/uploads/2024/06/wknd-members-test-previous-768x526.png 768w, https://sourcedcode.com/wp-content/uploads/2024/06/wknd-members-test-previous-1536x1051.png 1536w, https://sourcedcode.com/wp-content/uploads/2024/06/wknd-members-test-previous-2048x1402.png 2048w, https://sourcedcode.com/wp-content/uploads/2024/06/wknd-members-test-previous-600x411.png 600w" sizes="(max-width: 2098px) 100vw, 2098px" /></a><br />
<a href="https://sourcedcode.com/wp-content/uploads/2024/06/wknd-members-test.png"><img decoding="async" src="https://sourcedcode.com/wp-content/uploads/2024/06/wknd-members-test.png" alt="WKND Member able to see only tags, and Create Read Update Delete cq:tags as expected for the brand" width="50%" height="auto" class="alignnone size-full wp-image-7066" srcset="https://sourcedcode.com/wp-content/uploads/2024/06/wknd-members-test.png 2106w, https://sourcedcode.com/wp-content/uploads/2024/06/wknd-members-test-300x193.png 300w, https://sourcedcode.com/wp-content/uploads/2024/06/wknd-members-test-1024x659.png 1024w, https://sourcedcode.com/wp-content/uploads/2024/06/wknd-members-test-768x494.png 768w, https://sourcedcode.com/wp-content/uploads/2024/06/wknd-members-test-1536x989.png 1536w, https://sourcedcode.com/wp-content/uploads/2024/06/wknd-members-test-2048x1319.png 2048w, https://sourcedcode.com/wp-content/uploads/2024/06/wknd-members-test-600x386.png 600w" sizes="(max-width: 2106px) 100vw, 2106px" /></a></p>
<p>This approach ensures that content authors have the appropriate level of access for their specific brand without exposing unnecessary data or tags.</p>
<p>Managing permissions in a multi-tenant AEM environment is crucial for ensuring that content authors can only access and modify the resources relevant to their brand. By carefully setting up access control entries and restrictions, you can achieve a secure and efficient content authoring process.</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/aem-multi-tenant-website-restrict-cqtags-for-user-groups">AEM Multi-tenant Website: Restrict cq:tags for User Groups</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/aem-multi-tenant-website-restrict-cqtags-for-user-groups/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Base Level User Group That a New User Group in AEM Should Be Assigned</title>
		<link>https://sourcedcode.com/blog/aem/base-level-user-group-that-a-new-user-group-in-aem-should-be-assigned</link>
					<comments>https://sourcedcode.com/blog/aem/base-level-user-group-that-a-new-user-group-in-aem-should-be-assigned#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Thu, 16 May 2024 12:38:28 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Permissions]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=7034</guid>

					<description><![CDATA[<p>What is the Base Level User Group That a New User Group in AEM Should Be Assigned To? Quick Links Understanding AEM User Groups The Role of Base Level User Groups The &#8220;Contributor&#8221; Group: Your Go-To Base Level Group Steps to Assign a New User Group to the &#8220;Contributor&#8221; Group Verifying Access and Permissions Additional [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/base-level-user-group-that-a-new-user-group-in-aem-should-be-assigned">Base Level User Group That a New User Group in AEM Should Be Assigned</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>What is the Base Level User Group That a New User Group in AEM Should Be Assigned To?</p>
<div class="mention-block">
    <strong>Quick Links</strong></p>
<ol>
<li><a href="#understanding_aem_user_groups">Understanding AEM User Groups</a></li>
<li><a href="#the_role_of_base_level_user_groups">The Role of Base Level User Groups</a></li>
<li><a href="#the_contributor_group">The &#8220;Contributor&#8221; Group: Your Go-To Base Level Group</a></li>
<li><a href="#steps_to_assign_a_new_user_group_to_the_contributor_group">Steps to Assign a New User Group to the &#8220;Contributor&#8221; Group</a></li>
<li><a href="#verifying_access_and_permissions">Verifying Access and Permissions</a></li>
<li><a href="#additional_considerations">Additional Considerations</a></li>
<li><a href="#conclusion">Conclusion</a></li>
</ol>
</div>
<hr class="spacer-larger"/>
<h2 id="understanding_aem_user_groups">1. Understanding AEM User Groups</h2>
<p>AEM provides a robust user management system that allows administrators to control access to various parts of the system. User groups in AEM are collections of users who share common permissions and access levels. By assigning users to groups, administrators can efficiently manage permissions across multiple users.</p>
<hr class="spacer-larger"/>
<h2 id="the_role_of_base_level_user_groups">2. The Role of Base Level User Groups</h2>
<p>Base level user groups in AEM are pre-configured groups that come with a set of default permissions designed to provide access to the authoring tools and functionalities. These groups are essential for quickly onboarding new users and ensuring they have the necessary permissions to perform their tasks.</p>
<hr class="spacer-larger"/>
<h2 id="the_contributor_group">3. The &#8220;Contributor&#8221; Group: Your Go-To Base Level Group</h2>
<p>For most authoring needs, the <span class="code-highlight-primary">contributor</span> group is the ideal base level user group; which is out of the box with a new existing AEM environment. This group is configured with the necessary permissions to access and utilize the authoring tools in AEM. Assigning new user groups to the <span class="code-highlight-primary">contributor</span> group ensures that users have a consistent and functional access level to start with.</p>
<p><strong>Benefits of the &#8220;Contributor&#8221; Group:</strong></p>
<ul>
<li><strong>Pre-configured Permissions:</strong> The group comes with predefined permissions suitable for content authors.</li>
<li><strong>Simplified Management:</strong> Reduces the need for manual permission configuration.</li>
<li><strong>Consistency:</strong> Ensures a standardized level of access across users.</li>
</ul>
<hr class="spacer-larger"/>
<h2 id="steps_to_assign_a_new_user_group_to_the_contributor_group">4. Steps to Assign a New User Group to the &#8220;Contributor&#8221; Group</h2>
<h3 id="create_the_new_user_group">A. Create the New User Group</h3>
<ol>
<li><span>Navigate to Tools &gt; Security &gt; Groups in the AEM author instance.</span></li>
<li><span>Click on the Create button, provide a title and an ID for the new group, then click Create.</span></li>
</ol>
<p><a href="https://sourcedcode.com/wp-content/uploads/2024/06/create-new-user-group-screenshot.png"><img decoding="async" src="https://sourcedcode.com/wp-content/uploads/2024/06/create-new-user-group-screenshot.png" alt="Create new WKND Members group screenshot" width="auto" height="50%" class="alignnone size-full wp-image-7041" srcset="https://sourcedcode.com/wp-content/uploads/2024/06/create-new-user-group-screenshot.png 2112w, https://sourcedcode.com/wp-content/uploads/2024/06/create-new-user-group-screenshot-300x215.png 300w, https://sourcedcode.com/wp-content/uploads/2024/06/create-new-user-group-screenshot-1024x735.png 1024w, https://sourcedcode.com/wp-content/uploads/2024/06/create-new-user-group-screenshot-768x551.png 768w, https://sourcedcode.com/wp-content/uploads/2024/06/create-new-user-group-screenshot-1536x1103.png 1536w, https://sourcedcode.com/wp-content/uploads/2024/06/create-new-user-group-screenshot-2048x1470.png 2048w, https://sourcedcode.com/wp-content/uploads/2024/06/create-new-user-group-screenshot-600x431.png 600w" sizes="(max-width: 2112px) 100vw, 2112px" /></a></p>
<hr class="spacer-large"/>
<h3 id="assign_the_new_group_to_the_contributor_group">B. Assign the New Group to the &#8220;Contributor&#8221; Group</h3>
<ol>
<li><span>Go to the &#8220;Contributors&#8221; group settings.</span></li>
<li><span>In the Group Membership tab, add the &#8220;WKND Members&#8221; group.</span></li>
</ol>
<p><a href="https://sourcedcode.com/wp-content/uploads/2024/06/add-wknd-members-group-screenshot.png"><img decoding="async" src="https://sourcedcode.com/wp-content/uploads/2024/06/add-wknd-members-group-screenshot.png" alt="Add WKND Members to Group Screenshot" width="auto" height="50%" class="alignnone size-full wp-image-7042" srcset="https://sourcedcode.com/wp-content/uploads/2024/06/add-wknd-members-group-screenshot.png 2124w, https://sourcedcode.com/wp-content/uploads/2024/06/add-wknd-members-group-screenshot-300x216.png 300w, https://sourcedcode.com/wp-content/uploads/2024/06/add-wknd-members-group-screenshot-1024x736.png 1024w, https://sourcedcode.com/wp-content/uploads/2024/06/add-wknd-members-group-screenshot-768x552.png 768w, https://sourcedcode.com/wp-content/uploads/2024/06/add-wknd-members-group-screenshot-1536x1104.png 1536w, https://sourcedcode.com/wp-content/uploads/2024/06/add-wknd-members-group-screenshot-2048x1471.png 2048w, https://sourcedcode.com/wp-content/uploads/2024/06/add-wknd-members-group-screenshot-600x431.png 600w" sizes="(max-width: 2124px) 100vw, 2124px" /></a></p>
<hr class="spacer-large"/>
<h3 id="add_users_to_the_new_group">C. Add Users to the New Group</h3>
<ol>
<li><span>Navigate to Tools &gt; Security &gt; Users.</span></li>
<li><span>Select the users who need to be added to the new group.</span></li>
<li><span>Edit each user and add them to the new group.</span></li>
</ol>
<p><a href="https://sourcedcode.com/wp-content/uploads/2024/06/add-new-member-screenshot.png"><img decoding="async" src="https://sourcedcode.com/wp-content/uploads/2024/06/add-new-member-screenshot.png" alt="Add new member to the WKND Members group" width="auto" height="50%" class="alignnone size-full wp-image-7044" srcset="https://sourcedcode.com/wp-content/uploads/2024/06/add-new-member-screenshot.png 2106w, https://sourcedcode.com/wp-content/uploads/2024/06/add-new-member-screenshot-300x216.png 300w, https://sourcedcode.com/wp-content/uploads/2024/06/add-new-member-screenshot-1024x738.png 1024w, https://sourcedcode.com/wp-content/uploads/2024/06/add-new-member-screenshot-768x554.png 768w, https://sourcedcode.com/wp-content/uploads/2024/06/add-new-member-screenshot-1536x1107.png 1536w, https://sourcedcode.com/wp-content/uploads/2024/06/add-new-member-screenshot-2048x1476.png 2048w, https://sourcedcode.com/wp-content/uploads/2024/06/add-new-member-screenshot-600x432.png 600w" sizes="(max-width: 2106px) 100vw, 2106px" /></a></p>
<hr class="spacer-larger"/>
<h2 id="verifying_access_and_permissions">5. Verifying Access and Permissions</h2>
<p>After assigning the new user group to the <span class="code-highlight-primary">contributor</span> group, it&#8217;s important to verify that users have the expected access:</p>
<ol>
<li><strong>Login Verification:</strong> Ensure that users can log in and access the authoring interface.</li>
</ol>
<p><a href="https://sourcedcode.com/wp-content/uploads/2024/06/aem-login-contributor-group.png"><img decoding="async" src="https://sourcedcode.com/wp-content/uploads/2024/06/aem-login-contributor-group.png" alt="Screenshot of the wknd members group being a member of the contributors group" width="auto" height="50%" class="alignnone size-full wp-image-7037" srcset="https://sourcedcode.com/wp-content/uploads/2024/06/aem-login-contributor-group.png 3588w, https://sourcedcode.com/wp-content/uploads/2024/06/aem-login-contributor-group-300x167.png 300w, https://sourcedcode.com/wp-content/uploads/2024/06/aem-login-contributor-group-1024x571.png 1024w, https://sourcedcode.com/wp-content/uploads/2024/06/aem-login-contributor-group-768x429.png 768w, https://sourcedcode.com/wp-content/uploads/2024/06/aem-login-contributor-group-1536x857.png 1536w, https://sourcedcode.com/wp-content/uploads/2024/06/aem-login-contributor-group-2048x1143.png 2048w, https://sourcedcode.com/wp-content/uploads/2024/06/aem-login-contributor-group-600x335.png 600w" sizes="(max-width: 3588px) 100vw, 3588px" /></a></p>
<hr class="spacer-larger"/>
<h2 id="additional_considerations">6. Additional Considerations</h2>
<p>While the <span class="code-highlight-primary">contributor</span> group is a great starting point, you may need to customize permissions based on specific requirements:</p>
<ol>
<li><strong>Granular Permissions:</strong> If certain users need additional permissions (e.g., administrative tasks), consider creating sub-groups with elevated permissions.</li>
<li><strong>Security Best Practices:</strong> Regularly review user group memberships and permissions to maintain a secure and efficient environment.</li>
</ol>
<hr class="spacer-larger"/>
<h2 id="conclusion">7. Conclusion</h2>
<p>Assigning new user groups to a base level user group with <span class="code-highlight-primary">contributor</span> in AEM 6.5 or AEM as a Cloud Service simplifies user management and ensures that users have the necessary permissions to perform their tasks; revealing the authoring UI. By leveraging the pre-configured permissions of the <span class="code-highlight-primary">contributor</span> group, administrators can efficiently manage access and maintain a consistent authoring environment.</p>
<p>Ω</p>
<p>Remember, effective user group management is key to a secure and productive AEM instance. Start with the right base level user group and customize as needed to meet your organization&#8217;s unique requirements.</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/base-level-user-group-that-a-new-user-group-in-aem-should-be-assigned">Base Level User Group That a New User Group in AEM Should Be Assigned</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/base-level-user-group-that-a-new-user-group-in-aem-should-be-assigned/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>AEM Context-Aware Configurations in Java Backend Example Code</title>
		<link>https://sourcedcode.com/blog/aem/aem-context-aware-configurations-in-java-backend-example-code</link>
					<comments>https://sourcedcode.com/blog/aem/aem-context-aware-configurations-in-java-backend-example-code#comments</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Sat, 02 Mar 2024 04:35:58 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Development]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=6594</guid>

					<description><![CDATA[<p>AEM Context-Aware Configurations to enable developers to define adaptable application settings based on specific site or content contexts. This feature significantly simplifies the management of environment-specific configurations, allowing for dynamic application behavior adjustment without changing the core application code. In this article, we will step through how developers can incorporate and retrieve context-aware configurations from [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/aem-context-aware-configurations-in-java-backend-example-code">AEM Context-Aware Configurations in Java Backend Example Code</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>AEM Context-Aware Configurations to enable developers to define adaptable application settings based on specific site or content contexts. This feature significantly simplifies the management of environment-specific configurations, allowing for dynamic application behavior adjustment without changing the core application code.</p>
<p>In this article, we will step through how developers can incorporate and retrieve context-aware configurations from AEM backend development.</p>
<div class="mention-block">
    <strong>Quick Links</strong></p>
<ol>
<li><a href="#overview_of_context-aware_configurations">Overview of Context-Aware Configurations</a></li>
<li><a href="#accessing_configurations_via_java">Accessing Configurations via Java</a></li>
<li><a href="#configuration_interface_example">Configuration Interface Example</a></li>
<li><a href="#utilizing_the_configuration_in_an_osgi_component">Utilizing the Configuration in an OSGi Component</a></li>
</ol>
</div>
<hr class="spacer-larger"/>
<h2 id="overview_of_context-aware_configurations">1. Overview of Context-Aware Configurations</h2>
<p>Adobe Experience Manager (AEM) introduces Context-Aware Configurations to empower developers to define adaptable application settings based on the specific contexts of sites or content. This functionality simplifies configuration management across different environments, facilitating dynamic behavior adjustments of applications without necessitating changes to the core code.</p>
<hr class="spacer-large"/>
<h2 id="accessing_configurations_via_java">2. Accessing Configurations via Java</h2>
<p>To harness context-aware configurations, the process starts with fetching the relevant content resource using the <span class=“code-highlight-primary”>ResourceResolver</span>:</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">Resource contentResource <span style="color: #339933;">=</span> resourceResolver.<span style="color: #006633;">getResource</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/content/mysite/page1&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>Following resource retrieval, adapt it to a <span class=“code-highlight-primary”>ConfigurationBuilder</span> to fetch the specific configuration:</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">MyConfig config <span style="color: #339933;">=</span> contentResource.<span style="color: #006633;">adaptTo</span><span style="color: #009900;">&#40;</span>ConfigurationBuilder.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">as</span><span style="color: #009900;">&#40;</span>MyConfig.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p><span class=“code-highlight-primary”>MyConfig</span> is a developer-defined interface that encapsulates the configuration parameters influencing the application&#8217;s functionality.</p>
<hr class="spacer-large"/>
<h2 id="configuration_interface_example">4. Configuration Interface Example</h2>
<p>Define the <span class=“code-highlight-primary”>MyConfig</span> interface with configuration parameters as follows from the code below. Making sure that my code is scalable, I usually place CaConfig under the path com.sourcedcode.core.caconfig.*</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.sourcedcode.core.caconfig</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.caconfig.annotation.Configuration</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.caconfig.annotation.Property</span><span style="color: #339933;">;</span><br />
<br />
@Configuration<span style="color: #009900;">&#40;</span>label <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;My Configuration&quot;</span>, description <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Configuration example for a component&quot;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #000000; font-weight: bold;">public</span> @<span style="color: #000000; font-weight: bold;">interface</span> MyConfig <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; @Property<span style="color: #009900;">&#40;</span>label <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Feature Toggle&quot;</span>, description <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Enable or disable the feature&quot;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">boolean</span> featureEnabled<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">default</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; @Property<span style="color: #009900;">&#40;</span>label <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Feature Name&quot;</span>, description <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Specifies the feature name&quot;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #003399;">String</span> featureName<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">default</span> <span style="color: #0000ff;">&quot;defaultFeature&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<hr class="spacer-large"/>
<h2 id="utilizing_the_configuration_in_an_osgi_component">5. Utilizing the Configuration in an OSGi Component</h2>
<p>Implement the configuration within an AEM component or service as shown below:</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.resource.ResourceResolver</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.caconfig.ConfigurationBuilder</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.osgi.service.component.annotations.Component</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.osgi.service.component.annotations.Reference</span><span style="color: #339933;">;</span><br />
<br />
@<span style="color: #003399;">Component</span><span style="color: #009900;">&#40;</span>service <span style="color: #339933;">=</span> MyComponent.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MyComponent <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; @<span style="color: #003399;">Reference</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> ResourceResolver resourceResolver<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> applyConfiguration<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Resource contentResource <span style="color: #339933;">=</span> resourceResolver.<span style="color: #006633;">getResource</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/content/mysite/page1&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; MyConfig config <span style="color: #339933;">=</span> contentResource.<span style="color: #006633;">adaptTo</span><span style="color: #009900;">&#40;</span>ConfigurationBuilder.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">as</span><span style="color: #009900;">&#40;</span>MyConfig.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>config.<span style="color: #006633;">featureEnabled</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Feature is enabled: &quot;</span> <span style="color: #339933;">+</span> config.<span style="color: #006633;">featureName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>This example demonstrates the dynamic adjustment of application functionality based on retrieved configurations, highlighting the flexibility and maintainability that Context-Aware Configurations bring to AEM development.</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/aem-context-aware-configurations-in-java-backend-example-code">AEM Context-Aware Configurations in Java Backend Example Code</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/aem-context-aware-configurations-in-java-backend-example-code/feed</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
		<item>
		<title>HTL caconfig Global Variable for Context-Aware Configuration in AEM</title>
		<link>https://sourcedcode.com/blog/aem/htl-caconfig-global-variable-for-context-aware-configuration-in-aem</link>
					<comments>https://sourcedcode.com/blog/aem/htl-caconfig-global-variable-for-context-aware-configuration-in-aem#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Sat, 02 Mar 2024 04:11:10 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Development]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=6586</guid>

					<description><![CDATA[<p>Context-Aware configuration contains a Scripting Binding Values provider with automatically registeres a caconfig variable in your HTL/Sightly scripts to directly access context-aware configurations. It supports both singleton configurations and configuration lists. Please note that configuration lists are only supported when configuration metadata is present (e.g. via an annotation class). In this article we will step [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/htl-caconfig-global-variable-for-context-aware-configuration-in-aem">HTL caconfig Global Variable for Context-Aware Configuration in AEM</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Context-Aware configuration contains a Scripting Binding Values provider with automatically registeres a caconfig variable in your HTL/Sightly scripts to directly access context-aware configurations. It supports both singleton configurations and configuration lists. Please note that configuration lists are only supported when configuration metadata is present (e.g. via an annotation class).</p>
<p>In this article we will step through how to use the caconfig global variable in HTL Sightly.</p>
<div class="blog-article">
<div class="mention-block">
        <strong>Quick Links</strong></p>
<ol>
<li><a href="#accessing_singleton_configurations">Accessing Singleton Configurations</a></li>
<li><a href="#accessing_configuration_lists">Accessing Configuration Lists</a></li>
<li><a href="#accessing_nested_configurations">Accessing Nested Configurations</a></li>
<li><a href="#adding_necessary_dependencies">Adding Necessary Dependencies</a></li>
</ol></div>
<hr class="spacer-large"/>
<h2 id="accessing_singleton_configurations">1. Accessing Singleton Configurations</h2>
<p>    Singleton configurations are those that you expect to have a single instance per context or configuration resource. To access a property of a singleton configuration in HTL, you can use the caconfig variable followed by the configuration&#8217;s fully qualified name. For example, if you have a configuration named x.y.z.ConfigSample, you can access its stringParam property as follows:</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #339933;">&lt;</span>dl<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>dt<span style="color: #339933;">&gt;</span>stringParam<span style="color: #339933;">:&lt;/</span>dt<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>dd<span style="color: #339933;">&gt;</span>$<span style="color: #009900;">&#123;</span>caconfig<span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'x.y.z.ConfigSample'</span><span style="color: #009900;">&#93;</span>.<span style="color: #006633;">stringParam</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">&lt;/</span>dd<span style="color: #339933;">&gt;</span><br />
<span style="color: #339933;">&lt;/</span>dl<span style="color: #339933;">&gt;</span></div></td></tr></tbody></table></div>
<hr class="spacer-large"/>
<h2 id="accessing_configuration_lists">2. Accessing Configuration Lists</h2>
<p>    Configuration lists are useful when you have a series of similar configurations that you want to access as a collection. To access properties of configuration items in a list, you iterate over the configuration list using the data-sly-list attribute in HTL. For example, for a configuration list named x.y.z.ConfigSampleList, you can access the stringParam of each item as follows:</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #339933;">&lt;</span>ul data<span style="color: #339933;">-</span>sly<span style="color: #339933;">-</span>list.<span style="color: #006633;">item</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;${caconfig['x.y.z.ConfigSampleList']}&quot;</span><span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>li<span style="color: #339933;">&gt;</span>stringParam<span style="color: #339933;">:</span> $<span style="color: #009900;">&#123;</span>item.<span style="color: #006633;">stringParam</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">&lt;/</span>li<span style="color: #339933;">&gt;</span><br />
<span style="color: #339933;">&lt;/</span>ul<span style="color: #339933;">&gt;</span></div></td></tr></tbody></table></div>
<hr class="spacer-large"/>
<h2 id="accessing_nested_configurations">3. Accessing Nested Configurations</h2>
<p>    For nested configurations, HTL allows you to traverse the configuration hierarchy using a slash (/) as a separator. For example, to access a stringParam nested within a nestedConfig configuration, you would use:</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">$<span style="color: #009900;">&#123;</span>caconfig<span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'x.y.z.ConfigSample'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'nestedConfig/stringParam'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<hr class="spacer-large"/>
<h2 id="adding_necessary_dependencies">4. Adding Necessary Dependencies</h2>
<p>    To enable the automatic registration of the caconfig variable and the scanning of configuration annotation classes, you need to include the Context-Aware Configuration bnd plugin in your project&#8217;s build configuration. This bnd plugin scans the classpath of a bundle Maven project at build time and automatically generates a Sling-ContextAware-Configuration-Classes bundle header for all annotation classes annotated with @Configuration.</p>
<p>    Here are the configurations for the Maven Bundle Plugin and the bnd Maven Plugin:</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #339933;">&lt;</span>plugin<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>groupId<span style="color: #339933;">&gt;</span>org.<span style="color: #006633;">apache</span>.<span style="color: #006633;">felix</span><span style="color: #339933;">&lt;/</span>groupId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>artifactId<span style="color: #339933;">&gt;</span>maven<span style="color: #339933;">-</span>bundle<span style="color: #339933;">-</span>plugin<span style="color: #339933;">&lt;/</span>artifactId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>extensions<span style="color: #339933;">&gt;</span>true<span style="color: #339933;">&lt;/</span>extensions<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>configuration<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>instructions<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;!--</span> Generate bundle header containing all configuration annotation classes <span style="color: #339933;">--&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>_plugin<span style="color: #339933;">&gt;</span>org.<span style="color: #006633;">apache</span>.<span style="color: #006633;">sling</span>.<span style="color: #006633;">caconfig</span>.<span style="color: #006633;">bndplugin</span>.<span style="color: #006633;">ConfigurationClassScannerPlugin</span><span style="color: #339933;">&lt;/</span>_plugin<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>instructions<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>configuration<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>dependencies<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>dependency<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>groupId<span style="color: #339933;">&gt;</span>org.<span style="color: #006633;">apache</span>.<span style="color: #006633;">sling</span><span style="color: #339933;">&lt;/</span>groupId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>artifactId<span style="color: #339933;">&gt;</span>org.<span style="color: #006633;">apache</span>.<span style="color: #006633;">sling</span>.<span style="color: #006633;">caconfig</span>.<span style="color: #006633;">bnd</span><span style="color: #339933;">-</span>plugin<span style="color: #339933;">&lt;/</span>artifactId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>version<span style="color: #339933;">&gt;</span>1.0.2<span style="color: #339933;">&lt;/</span>version<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>dependency<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>dependencies<span style="color: #339933;">&gt;</span><br />
<span style="color: #339933;">&lt;/</span>plugin<span style="color: #339933;">&gt;</span></div></td></tr></tbody></table></div>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #339933;">&lt;</span>plugin<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>groupId<span style="color: #339933;">&gt;</span>biz.<span style="color: #006633;">aQute</span>.<span style="color: #006633;">bnd</span><span style="color: #339933;">&lt;/</span>groupId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>artifactId<span style="color: #339933;">&gt;</span>bnd<span style="color: #339933;">-</span>maven<span style="color: #339933;">-</span>plugin<span style="color: #339933;">&lt;/</span>artifactId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>configuration<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>bnd<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ...<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">-</span>plugin org.<span style="color: #006633;">apache</span>.<span style="color: #006633;">sling</span>.<span style="color: #006633;">caconfig</span>.<span style="color: #006633;">bndplugin</span>.<span style="color: #006633;">ConfigurationClassScannerPlugin</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>bnd<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>configuration<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>dependencies<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>dependency<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>groupId<span style="color: #339933;">&gt;</span>org.<span style="color: #006633;">apache</span>.<span style="color: #006633;">sling</span><span style="color: #339933;">&lt;/</span>groupId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>artifactId<span style="color: #339933;">&gt;</span>org.<span style="color: #006633;">apache</span>.<span style="color: #006633;">sling</span>.<span style="color: #006633;">caconfig</span>.<span style="color: #006633;">bnd</span><span style="color: #339933;">-</span>plugin<span style="color: #339933;">&lt;/</span>artifactId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>version<span style="color: #339933;">&gt;</span>1.0.2<span style="color: #339933;">&lt;/</span>version<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>dependency<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>dependencies<span style="color: #339933;">&gt;</span><br />
<span style="color: #339933;">&lt;/</span>plugin<span style="color: #339933;">&gt;</span></div></td></tr></tbody></table></div>
</div>
<p>References: <a href="https://sling.apache.org/documentation/bundles/context-aware-configuration/context-aware-configuration.html" rel="noopener" target="_blank">https://sling.apache.org/documentation/bundles/context-aware-configuration/context-aware-configuration.html</a></p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/htl-caconfig-global-variable-for-context-aware-configuration-in-aem">HTL caconfig Global Variable for Context-Aware Configuration in AEM</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/htl-caconfig-global-variable-for-context-aware-configuration-in-aem/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>AuthenticationSupport service missing. Cannot authenticate request.</title>
		<link>https://sourcedcode.com/blog/aem/authenticationsupport-service-missing-cannot-authenticate-request</link>
					<comments>https://sourcedcode.com/blog/aem/authenticationsupport-service-missing-cannot-authenticate-request#comments</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Wed, 28 Feb 2024 02:07:16 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Trouble Shooting]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=6561</guid>

					<description><![CDATA[<p>Encountering the &#8220;AuthenticationSupport service missing. Cannot authenticate request&#8221; OR the &#8220;HTTP ERROR 404 Not Found org.apache.felix.http.base.internal.dispatch.DispatcherServlet&#8221; errors in Adobe Experience Manager (AEM) can halt your development progress, presenting a significant obstacle. This error often points to underlying issues with the AEM instance&#8217;s ability to access or initialize critical repository services. Fortunately, there&#8217;s a practical approach [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/authenticationsupport-service-missing-cannot-authenticate-request">AuthenticationSupport service missing. Cannot authenticate request.</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Encountering the &#8220;AuthenticationSupport service missing. Cannot authenticate request&#8221; OR the &#8220;HTTP ERROR 404 Not Found org.apache.felix.http.base.internal.dispatch.DispatcherServlet&#8221; errors in Adobe Experience Manager (AEM) can halt your development progress, presenting a significant obstacle. This error often points to underlying issues with the AEM instance&#8217;s ability to access or initialize critical repository services. Fortunately, there&#8217;s a practical approach to resolving this problem, ensuring your local development environment gets back on track swiftly.</p>
<div class="mention-block">
  <strong>Follow steps below can resolve your problem:</strong></p>
<ol>
<li><a href="#root-cause-of-the-issue">Root Cause of the Issue</a></li>
<li><a href="#removing-lock-files">Removing Lock Files</a></li>
<li><a href="#clearing-repository-index-files">Clearing Repository Index Files</a></li>
<li><a href="#resetting-custom-initialization-scripts">Resetting Custom Initialization Scripts</a></li>
<li><a href="#restarting-your-aem-instance">Restarting Your AEM Instance</a></li>
<li><a href="#conclusion">Conclusion</a></li>
</ol>
</div>
<hr class="spacer-large"/>
<h2 id="root-cause-of-the-issue">1. Root Cause of the Issue</h2>
<p>This error typically arises when AEM&#8217;s repository encounters problems, either due to corrupted data, locking issues, or misconfigurations in the initialization scripts. Such issues prevent AEM from authenticating requests, leading to the aforementioned error.</p>
<hr class="spacer-large"/>
<h3 id="removing-lock-files">2. Removing Lock Files</h3>
<p>Lock files are created to ensure exclusive access to the repository by an AEM instance. However, if these files become corrupted or are not released properly upon a shutdown, they can cause startup issues.</p>
<ul>
<li><strong>Files to Delete:</strong>
<ul>
<li>crx-quickstart/repository/segmentstore/repo.lock</li>
<li>crx-quickstart/launchpad/felix/cache.lock</li>
</ul>
</li>
</ul>
<p>Deleting these lock files can free up the repository and allow the AEM instance to start correctly.</p>
<hr class="spacer-large"/>
<h3 id="clearing-repository-index-files">3. Clearing Repository Index Files</h3>
<p>Index files are essential for AEM&#8217;s search capabilities. Corruption or outdated index files can lead to significant errors, including authentication issues.</p>
<ul>
<li><strong>Paths to Clear:</strong>
<ul>
<li>crx-quickstart/repository/index/*</li>
</ul>
</li>
</ul>
<p>Removing these files prompts AEM to rebuild the indexes, potentially resolving the authentication issue.</p>
<hr class="spacer-large"/>
<h3 id="resetting-custom-initialization-scripts">4. Resetting Custom Initialization Scripts</h3>
<p>Custom repoinit scripts under the crx-quickstart/launchpad/config/org/apache/sling/jcr/repoinit directory can interfere with repository initialization, causing authentication and other services to fail.</p>
<ul>
<li><strong>Paths to Clear:</strong>
<ul>
<li>crx-quickstart/launchpad/config/org/apache/sling/jcr/repoinit/*</li>
</ul>
</li>
</ul>
<p>By deleting these scripts, you ensure that no custom initialization interferes with the repository&#8217;s proper startup process.</p>
<hr class="spacer-large"/>
<h2 id="restarting-your-aem-instance">5. Restarting Your AEM Instance</h2>
<p>After performing the above steps, restart your AEM instance. This process will initiate a clean startup sequence, allowing AEM to rebuild necessary files and indexes.</p>
<hr class="spacer-large"/>
<h2 id="conclusion">Conclusion</h2>
<p>The &#8220;AuthenticationSupport service missing. Cannot authenticate request&#8221; OR the &#8220;HTTP ERROR 404 Not Found org.apache.felix.http.base.internal.dispatch.DispatcherServlet&#8221;errors can be a daunting obstacle, but by following the outlined steps, you can swiftly return your AEM development environment to a functional state. This guide provides a comprehensive approach to troubleshooting and resolving one of the more perplexing issues in AEM development, ensuring you can continue your work with minimal interruption.</p>
<p>Remember, careful manipulation of the file system and adherence to the recommended procedures are paramount to successfully overcoming this challenge. This guide aims to empower AEM developers, particularly those in the early stages of their journey, with the knowledge to tackle such issues confidently.</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/authenticationsupport-service-missing-cannot-authenticate-request">AuthenticationSupport service missing. Cannot authenticate request.</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/authenticationsupport-service-missing-cannot-authenticate-request/feed</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
		<item>
		<title>Generate Custom Oak Indexes with the Oak Index Definition Generator</title>
		<link>https://sourcedcode.com/blog/aem/generate-custom-oak-indexes-with-the-oak-index-definition-generator</link>
					<comments>https://sourcedcode.com/blog/aem/generate-custom-oak-indexes-with-the-oak-index-definition-generator#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Mon, 26 Feb 2024 02:28:19 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Search]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=6568</guid>

					<description><![CDATA[<p>Indexing in Adobe Experience Manager is very important. It&#8217;s not just about making things faster; it totally changes how we handle and find data online. With the Oak Index Definition Generator, developers get a really handy tool to shape how searches work behind the scenes. This tool isn&#8217;t just about making indexes, it&#8217;s about making [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/generate-custom-oak-indexes-with-the-oak-index-definition-generator">Generate Custom Oak Indexes with the Oak Index Definition Generator</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Indexing in Adobe Experience Manager is very important. It&#8217;s not just about making things faster; it totally changes how we handle and find data online. With the Oak Index Definition Generator, developers get a really handy tool to shape how searches work behind the scenes. This tool isn&#8217;t just about making indexes, it&#8217;s about making them just right for each project&#8217;s specific needs. By using this tool, developers can create indexes that fit perfectly with what they&#8217;re trying to do, making searches faster and more efficient. This smart way of indexing helps AEM websites be faster and more flexible, keeping them ahead of the game in the digital world.</p>
<div class="mention-block">
    <strong>Quick Links</strong></p>
<ol>
<li><a href="#importance_of_indexing">Importance of Indexing</a></li>
<li><a href="#creating_custom_oak_indexes">Creating Custom Oak Indexes</a></li>
<li><a href="#conclusion">Conclusion</a></li>
</ol>
</div>
<hr class="spacer-large"/>
<h2 id="importance_of_indexing">Why Indexing is Important</h2>
<p>Indexing AEM is critical for optimizing performance and managing content efficiently. The Oak Index, a key feature of AEM, improves search query speed by organizing data for quicker retrieval. This not only boosts system performance but also supports customization for specific project requirements. Efficient indexing enables scalable and responsive AEM sites, ensuring they can handle growing content without compromising on speed. Understanding and utilizing the Oak Index effectively is essential for maintaining high-performance AEM projects that meet modern digital experience demands.</p>
<hr class="spacer-large"/>
<h3 id="creating_custom_oak_indexes">Using the Oak Index Definition Generator</h3>
<p><a href="https://sourcedcode.com/wp-content/uploads/2024/02/oak-index-generator-tool-screenshot.png"><img decoding="async" src="https://sourcedcode.com/wp-content/uploads/2024/02/oak-index-generator-tool-screenshot.png" alt="Oak Index Definition Generator" width="1486" height="898" class="alignnone size-full wp-image-6575" srcset="https://sourcedcode.com/wp-content/uploads/2024/02/oak-index-generator-tool-screenshot.png 1486w, https://sourcedcode.com/wp-content/uploads/2024/02/oak-index-generator-tool-screenshot-300x181.png 300w, https://sourcedcode.com/wp-content/uploads/2024/02/oak-index-generator-tool-screenshot-1024x619.png 1024w, https://sourcedcode.com/wp-content/uploads/2024/02/oak-index-generator-tool-screenshot-768x464.png 768w, https://sourcedcode.com/wp-content/uploads/2024/02/oak-index-generator-tool-screenshot-600x363.png 600w" sizes="(max-width: 1486px) 100vw, 1486px" /></a></p>
<p>Creating custom Oak indexes with the Oak Index Definition Generator is a straightforward process:</p>
<ol>
<li>Open the Oak Index Definition Generator at <a href="http://oakutils.appspot.com/generate/index" rel="noopener" target="_blank">http://oakutils.appspot.com/generate/index</a>.</li>
<li>Input your query in the Queries field.</li>
<li>Click &#8220;Generate&#8221; to create your custom Oak index.</li>
<li>Copy the XML into your AEM project for further adjustments.</li>
</ol>
<hr class="spacer-large"/>
<h4 id="conclusion">Conclusion</h4>
<p>It&#8217;s essential for developers to familiarize themselves with the AEM index definition structure to maximize the effectiveness of their custom indexes. Adobe provides resources such as a cheat sheet on AEM index definition structure, offering guidance on how to properly configure indexes for optimal performance.</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/generate-custom-oak-indexes-with-the-oak-index-definition-generator">Generate Custom Oak Indexes with the Oak Index Definition Generator</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/generate-custom-oak-indexes-with-the-oak-index-definition-generator/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Handling Http Requests, HttpClient, in AEM</title>
		<link>https://sourcedcode.com/blog/aem/handling-http-requests-httpclient-in-aem</link>
					<comments>https://sourcedcode.com/blog/aem/handling-http-requests-httpclient-in-aem#comments</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Sat, 24 Feb 2024 18:13:27 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Sling Models]]></category>
		<category><![CDATA[Sling Servlet]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=6538</guid>

					<description><![CDATA[<p>When integrating with external services or APIs from Adobe Experience Manager (AEM), utilizing the HttpClient for outbound HTTP requests is a common requirement. It&#8217;s crucial to handle these connections efficiently, securely, and in a way that is compatible with AEM&#8217;s architecture to ensure optimal performance and maintainability of your code. AEM provides a specialized factory, [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/handling-http-requests-httpclient-in-aem">Handling Http Requests, HttpClient, in AEM</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>When integrating with external services or APIs from Adobe Experience Manager (AEM), utilizing the HttpClient for outbound HTTP requests is a common requirement. It&#8217;s crucial to handle these connections efficiently, securely, and in a way that is compatible with AEM&#8217;s architecture to ensure optimal performance and maintainability of your code. </p>
<p>AEM provides a specialized factory, HttpClientFactory, designed to streamline the creation and configuration of HttpClient instances. This factory not only simplifies the process of instantiating HttpClient objects but also ensures that the instances are optimized for use within the AEM environment. </p>
<p>By leveraging HttpClientFactory, developers can take advantage of built-in connection pooling and configuration optimizations that are specifically tailored for AEM applications. Furthermore, using AEM&#8217;s HttpClientFactory significantly facilitates the <a href="https://sourcedcode.com/blog/aem/junit-5-mocking-the-httpclient-in-java" rel="noopener" target="_blank">unit testing</a> of code that makes HTTP requests, allowing for more maintainable and testable codebases.</p>
<div class="mention-block">
<strong>Quick Links</strong></p>
<ul>
<li><a href="#UtilizeAEMsHttpClientFactory">1. Utilize AEM&#8217;s HttpClientFactory</a></li>
<li><a href="#OSGiComponentsSlingServlets">1.1 OSGi Components &#038; Sling Servlets</a></li>
<li><a href="#SlingModelsWorkflows">12 Sling Models &#038; Workflows</a></li>
<li><a href="#EnsureProperResourceManagement">2. Ensure Proper Resource Management</a></li>
<li><a href="#ConfigureHttpClientSecurely">3. Configure HttpClient Securely</a></li>
<li><a href="#ReuseHttpClientInstancesWisely">4. Reuse HttpClient Instances Wisely</a></li>
<li><a href="#MonitorAndLogHttpClientActivity">5. Monitor and Log HttpClient Activity</a></li>
<ul>
</div>
<hr class="spacer-large" />
<h2 id="UtilizeAEMsHttpClientFactory">1. Utilize AEM&#8217;s HttpClientFactory</h2>
<p>Leverage AEM’s HttpClientFactory or the OSGi HttpClientBuilderFactory for creating instances of HttpClient. This ensures you benefit from connection pooling, proper configuration, and optimizations tailored for AEM. Avoid manually creating HttpClient instances as it bypasses these optimizations and can lead to resource leakage and scalability issues.</p>
<h3 id="OSGiComponentsSlingServlets">1.1 OSGi Components &#038; Sling Servlets</h3>
<p><strong>OSGi Components</strong>: Custom services, event handlers, schedulers, and any other Java class defined as an OSGi component can use this code pattern below. OSGi components are the backbone for modular development in AEM, allowing for dynamic module management within the application.</p>
<p><strong>Sling Servlets</strong>: Sling Servlets are another type of OSGi component that can use HttpClientBuilderFactory for making HTTP requests; using the code pattern below. Sling Servlets handle HTTP requests and can be used for various purposes, including interfacing with external systems.</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">@<span style="color: #003399;">Reference</span><br />
<span style="color: #000000; font-weight: bold;">private</span> HttpClientBuilderFactory httpClientBuilderFactory<span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> executeHttpRequest<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#40;</span>CloseableHttpClient httpClient <span style="color: #339933;">=</span> httpClientBuilderFactory.<span style="color: #006633;">newBuilder</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">build</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Perform HTTP operations with httpClient</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">IOException</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Handle exceptions</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<hr class="spacer-medium" />
<h3 id="SlingModelsWorkflows">1.2 Sling Models &#038; Workflows</h3>
<p><strong>Sling Models</strong>: While not typically using @Reference (as they are not OSGi components themselves), Sling Models can still access OSGi services like HttpClientBuilderFactory through the use of the @OSGiService annotation or by adapting from a Sling resource or request; using the code pattern below. This allows Sling Models to utilize services for fetching or sending data to external systems as part of their logic.</p>
<p><strong>Workflows</strong>: Custom workflow steps can interact with OSGi services, including HttpClientBuilderFactory, to perform operations like sending data to external systems or integrating with RESTful services as part of the workflow process. These custom steps are developed as OSGi components and can use the @Reference annotation to inject necessary services.</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">@Model<span style="color: #009900;">&#40;</span>adaptables <span style="color: #339933;">=</span> Resource.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ExampleSlingModel <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; @OSGiService<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> HttpClientBuilderFactory httpClientBuilderFactory<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> executeHttpRequest<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#40;</span>CloseableHttpClient httpClient <span style="color: #339933;">=</span> httpClientBuilderFactory.<span style="color: #006633;">newBuilder</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">build</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Perform HTTP operations with httpClient</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">IOException</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Handle exceptions</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<hr class="spacer-large" />
<h2 id="EnsureProperResourceManagement">2. Ensure Proper Resource Management</h2>
<p>Always close HttpClient, HttpResponse, and any InputStream or Entity objects to release system resources and avoid connection leaks. Utilize try-with-resources or finally blocks to ensure resources are closed even if exceptions occur.</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#40;</span>CloseableHttpResponse response <span style="color: #339933;">=</span> httpClient.<span style="color: #006633;">execute</span><span style="color: #009900;">&#40;</span>httpGet<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Process the response</span><br />
&nbsp; &nbsp; EntityUtils.<span style="color: #006633;">consume</span><span style="color: #009900;">&#40;</span>response.<span style="color: #006633;">getEntity</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">IOException</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Handle exceptions</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<hr class="spacer-large" />
<h2 id="ConfigureHttpClientSecurely">3. Configure HttpClient Securely</h2>
<p>Pay attention to security configurations when setting up your HttpClient. This includes setting up SSL context correctly, enabling hostname verification, and configuring timeouts to prevent attacks that target resource consumption. Avoid disabling SSL verification or other security features unless absolutely necessary and understood.</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">RequestConfig requestConfig <span style="color: #339933;">=</span> RequestConfig.<span style="color: #006633;">custom</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; .<span style="color: #006633;">setConnectTimeout</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">5000</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; .<span style="color: #006633;">setSocketTimeout</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">5000</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; .<span style="color: #006633;">build</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#40;</span>CloseableHttpClient httpClient <span style="color: #339933;">=</span> httpClientBuilderFactory.<span style="color: #006633;">newBuilder</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; .<span style="color: #006633;">setDefaultRequestConfig</span><span style="color: #009900;">&#40;</span>requestConfig<span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; .<span style="color: #006633;">build</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Securely configured HttpClient</span><br />
<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">IOException</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Handle exceptions</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<hr class="spacer-large" />
<h2 id="ReuseHttpClientInstancesWisely">4. Reuse HttpClient Instances Wisely</h2>
<p>For efficiency, reuse HttpClient instances across requests whenever possible. This approach benefits from the HTTP connection pooling managed by AEM, reducing the overhead of establishing connections for each request. However, ensure that any client-specific configurations do not unintentionally affect subsequent requests.</p>
<hr class="spacer-large" />
<h2 id="MonitorAndLogHttpClientActivity">5. Monitor and Log HttpClient Activity</h2>
<p>Implement logging and monitoring around your HTTP requests to diagnose issues, track performance, and understand dependencies on external services. Use AEM’s logging capabilities to log request details, response times, and errors. This can aid in troubleshooting and optimizing the use of HttpClient in your application.</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#40;</span>CloseableHttpResponse response <span style="color: #339933;">=</span> httpClient.<span style="color: #006633;">execute</span><span style="color: #009900;">&#40;</span>httpGet<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Log the status line</span><br />
&nbsp; &nbsp; LOG.<span style="color: #006633;">debug</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;HTTP response status: {}&quot;</span>, response.<span style="color: #006633;">getStatusLine</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">IOException</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; LOG.<span style="color: #006633;">error</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;HTTP request execution failed&quot;</span>, e<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>By adhering to these five rules, developers can ensure their AEM projects make the most out of HttpClient for external communications, balancing efficiency with robust security practices. Utilizing AEM&#8217;s HttpClientFactory not only streamlines the development process but also enhances the ease of <a href="https://sourcedcode.com/blog/aem/junit-5-mocking-the-httpclient-in-java" rel="noopener" target="_blank">unit testing</a>, making it an indispensable practice for AEM development.</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/handling-http-requests-httpclient-in-aem">Handling Http Requests, HttpClient, in AEM</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/handling-http-requests-httpclient-in-aem/feed</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>Differences Between Using Free ChatGPT 3.5 vs AEM Developer GPT</title>
		<link>https://sourcedcode.com/blog/aem/differences-between-using-free-chatgpt-3-5-vs-aem-developer-gpt</link>
					<comments>https://sourcedcode.com/blog/aem/differences-between-using-free-chatgpt-3-5-vs-aem-developer-gpt#comments</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Fri, 23 Feb 2024 17:43:53 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Tools]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=6525</guid>

					<description><![CDATA[<p>When comparing ChatGPT 3.5 with the AEM Developer GPT (OpenAI ChatGPT Plus), the key differences lie in their breadth of knowledge, specialization, and the ability to stay current with the latest technologies. ChatGPT 3.5, while impressively versatile, is grounded in a wide array of knowledge that spans up to its last training cut-off in 2021, [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/differences-between-using-free-chatgpt-3-5-vs-aem-developer-gpt">Differences Between Using Free ChatGPT 3.5 vs AEM Developer GPT</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>When comparing ChatGPT 3.5 with the AEM Developer GPT (OpenAI ChatGPT Plus), the key differences lie in their breadth of knowledge, specialization, and the ability to stay current with the latest technologies. ChatGPT 3.5, while impressively versatile, is grounded in a wide array of knowledge that spans up to its last training cut-off in 2021, covering countless topics across both general and technical domains. On the other hand, the AEM Developer GPT is a specialized tool designed explicitly for Adobe Experience Manager (AEM) development, equipped with the unique capability to continuously learn and integrate the latest AEM technologies, tutorials, documentation, and coding best practices. This ensures that it remains up-to-date with the most recent advancements in the AEM ecosystem.</p>
<hr class="spacer-large" />
<h2>ChatGPT 3.5:</h2>
<ul>
<li><strong>General Knowledge Base:</strong> ChatGPT 3.5 is a jack-of-all-trades, offering insights and generating content across a myriad of subjects, including technical topics. Its expertise is based on data up until 2021, which may not always reflect the newest trends or developments in technologies, especially those specific to AEM.</li>
<li><strong>Broad Technical Insights:</strong> It provides general technical advice and coding suggestions, but these may not align with the latest or most efficient practices specific to AEM development due to its broader focus.</li>
<li><strong>Universal Approach:</strong> ChatGPT 3.5 lacks specialization in any one technology, limiting its effectiveness for deep technical discussions or solving advanced problems in areas like AEM development.</li>
</ul>
<hr class="spacer-large" />
<h2>AEM Developer GPT:</h2>
<ul>
<li><strong>Focused AEM Expertise:</strong> Tailored for Adobe Experience Manager, the AEM Developer GPT excels in offering detailed support, code examples, best practices, and problem-solving solutions specifically for AEM development. It is programmed to stay abreast of the latest AEM technologies, ensuring its guidance is always relevant and up-to-date.</li>
<li><strong>Continuous Learning Capability:</strong> This GPT distinguishes itself by its commitment to continuous learning, regularly updating its knowledge base with the newest AEM technologies, tutorials, and documentation. This ensures it always operates with the latest coding standards and best practices in mind, positioning it as a cutting-edge resource for AEM developers.</li>
<li><strong>Specialized Resources:</strong> It provides direct access to the most current and authoritative AEM resources, including documentation, forums, blogs, and video tutorials, ensuring developers have access to the best information possible.</li>
<li><strong>Advanced Coding and Testing Support:</strong> With a focus on Java 11 and JUnit 5, the AEM Developer GPT offers specialized guidance on writing AEM code and conducting unit testing, tailored specifically to the AEM development environment.</li>
</ul>
<div class="mention-block">
Try out the free tool today* &#8211; <a href="https://bit.ly/aem-developer-gpt-b" rel="noopener" target="_blank">https://bit.ly/aem-developer-gpt-b</a>
</div>
<hr class="spacer-large" />
<h2>Summary:</h2>
<p>The AEM Developer GPT stands in stark contrast to ChatGPT 3.5 by offering a specialized, continuously updated knowledge base focused solely on AEM development. While ChatGPT 3.5 provides broad, generalist knowledge up until 2021, the AEM Developer GPT excels in delivering the latest, most accurate AEM-specific advice, coding best practices, and standards. This specialization makes the AEM Developer GPT an invaluable asset for developers seeking to navigate the complexities of AEM development with the most current information and best practices available.</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/differences-between-using-free-chatgpt-3-5-vs-aem-developer-gpt">Differences Between Using Free ChatGPT 3.5 vs AEM Developer GPT</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/differences-between-using-free-chatgpt-3-5-vs-aem-developer-gpt/feed</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>ChatGPT for AEM Developers, AEM Developer GPT</title>
		<link>https://sourcedcode.com/blog/aem/chatgpt-for-aem-developers-aem-developer-gpt</link>
					<comments>https://sourcedcode.com/blog/aem/chatgpt-for-aem-developers-aem-developer-gpt#comments</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Fri, 23 Feb 2024 05:58:46 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Tools]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=6508</guid>

					<description><![CDATA[<p>When working on Adobe Experience Manager (AEM) projects, finding the right support for coding can be a game-changer. That&#8217;s where AEM Developer GPT comes in – a dedicated generative AI tool designed specifically for AEM developers. It&#8217;s here to make your life easier, whether you&#8217;re looking to generate code examples quickly or seeking answers to [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/chatgpt-for-aem-developers-aem-developer-gpt">ChatGPT for AEM Developers, AEM Developer GPT</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>When working on Adobe Experience Manager (AEM) projects, finding the right support for coding can be a game-changer. That&#8217;s where AEM Developer GPT comes in – a dedicated generative AI tool designed specifically for AEM developers. It&#8217;s here to make your life easier, whether you&#8217;re looking to generate code examples quickly or seeking answers to your AEM-related questions.</p>
<div class="mention-block">
<strong>Use Chat GPT for FREE: </strong>OpenAI’s custom GPT Store became accessible to all users, including free users, on May 14, 2024. This expansion allowed free users to interact with various custom-built GPTs available in the store.</em><br />
<a href="https://bit.ly/aem-developer-gpt-b" rel="noopener" target="_blank">https://bit.ly/aem-developer-gpt-b</a>
</div>
<div class="mention-block--gold">
<strong>Author Recommendation</strong><br />
I recommend you to read this blog article: <a href="https://sourcedcode.com/blog/aem/differences-between-using-free-chatgpt-3-5-vs-aem-developer-gpt" rel="noopener" target="_blank">Differences Between Using Free ChatGPT 3.5 vs AEM Developer GPT</a>
</div>
<hr class="spacer-large" />
<p>At its core, AEM Developer GPT is more than just a question-and-answer tool. Whether you&#8217;re grappling with complex Java coding challenges, seeking best practices for Sling Model implementations, or need guidance on the latest AEM project archetype, this AI assistant has you covered. By leveraging real-time updates from primary sources such as Adobe&#8217;s official documentation, forums, and leading AEM content platforms, it ensures the advice you receive is not just accurate but also cutting-edge.</p>
<p>Try out the free tool today* &#8211; <a href="https://bit.ly/aem-developer-gpt-b" rel="noopener" target="_blank">https://bit.ly/aem-developer-gpt-b</a></p>
<hr class="spacer-large" />
<h3>2. Why Choose AEM Developer GPT?</h3>
<p>Choosing AEM Developer GPT means opting for a tool that understands the nuances of AEM development. Its capabilities are not just about accelerating your workflow but also about ensuring you&#8217;re always in tune with the latest AEM trends, techniques, and best practices. And perhaps most importantly, it fosters a community-driven approach to AI, where each interaction helps make the GPT smarter—all at no cost.</p>
<p>Try out the free tool today* &#8211; <a href="https://bit.ly/aem-developer-gpt-b" rel="noopener" target="_blank">https://bit.ly/aem-developer-gpt-b</a></p>
<hr class="spacer-large" />
<h3>3. Relevant AEM Content &#038; Adobe Documentation Response</h3>
<p>At its core, AEM Developer GPT is more than just a question-and-answer tool. Whether you&#8217;re grappling with complex Java coding challenges, seeking best practices for Sling Model implementations, or need guidance on the latest AEM project archetype, this AI assistant has you covered. By leveraging real-time updates from primary sources such as Adobe&#8217;s official documentation, forums, and leading AEM content platforms, it ensures the advice you receive is not just accurate but also cutting-edge.</p>
<p>Try out the free tool today* &#8211; <a href="https://bit.ly/aem-developer-gpt-b" rel="noopener" target="_blank">https://bit.ly/aem-developer-gpt-b</a></p>
<hr class="spacer-large" />
<h3>4. From Concept to Code: Supporting AEM Developers at Every Step</h3>
<p>The journey from a concept to a fully functional AEM component is fraught with challenges. AEM Developer GPT simplifies this journey by providing detailed coding examples, troubleshooting advice, and best practices for unit testing with JUNIT5, ensuring your projects adhere to the highest standards of quality and efficiency.</p>
<p>Try out the free tool today* &#8211; <a href="https://bit.ly/aem-developer-gpt-b" rel="noopener" target="_blank">https://bit.ly/aem-developer-gpt-b</a></p>
<div align="center"><a href="https://bit.ly/chatgpt-aem-developer-course-side-p" target="_blank" rel="noopener"><img width="65%" decoding="async" src="https://sourcedcode.com/storage/2024/04/aem-development-with-chat-gpt-3-5-and-4-0-course-learn-more.jpeg" alt="Learn to code with ChatGPT 3.5 and 4.0" width="100%"></a></div>
<hr class="spacer-large" />
<h3>5. Unit Testing: The Cornerstone of Reliable AEM Development</h3>
<p>Recognizing the critical role of unit testing in software development, AEM Developer GPT places a strong emphasis on guiding developers through the intricacies of writing effective tests using the wcm.io AEMContext. This focus on quality assurance underscores the tool&#8217;s commitment to supporting developers in delivering robust, error-free code.</p>
<p>Try out the free tool today* &#8211; <a href="https://bit.ly/aem-developer-gpt-b" rel="noopener" target="_blank">https://bit.ly/aem-developer-gpt-b</a></p>
<hr class="spacer-large" />
<h3>6. A Call to Join the Community</h3>
<p>As we continue to evolve AEM Developer GPT, we invite you, the AEM development community, to join us in this journey. Your questions, feedback, and contributions are not just welcomed but are essential in shaping the future of AEM development. Together, we can ensure that AEM Developer GPT remains a vital resource for developers looking to achieve excellence in their AEM projects.</p>
<p>Try out the free tool today* &#8211; <a href="https://bit.ly/aem-developer-gpt-b" rel="noopener" target="_blank">https://bit.ly/aem-developer-gpt-b</a></p>
<hr class="spacer-large" />
<h3>7. Conclusion</h3>
<p>AEM Developer GPT stands as a testament to the power of AI in revolutionizing AEM development. By providing instant access to expert knowledge, facilitating smoother workflows, and fostering a vibrant community of developers,</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/chatgpt-for-aem-developers-aem-developer-gpt">ChatGPT for AEM Developers, AEM Developer GPT</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/chatgpt-for-aem-developers-aem-developer-gpt/feed</wfw:commentRss>
			<slash:comments>10</slash:comments>
		
		
			</item>
		<item>
		<title>AEM 6.5.5 Not Indexing Problem *Fixed*</title>
		<link>https://sourcedcode.com/blog/aem/aem-6-5-5-not-indexing-problem-fixed</link>
					<comments>https://sourcedcode.com/blog/aem/aem-6-5-5-not-indexing-problem-fixed#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Sat, 16 Dec 2023 20:00:01 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Search]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=6376</guid>

					<description><![CDATA[<p>In the course of establishing a new multitenant website, we opted to re-use the search mechanism for both site1 and site2. However, following the deployment of our code to the cloud QA environment, a significant hurdle surfaced: site2&#8217;s search consistently failed to produce results. This revelation made us to invest considerable effort in a detailed [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/aem-6-5-5-not-indexing-problem-fixed">AEM 6.5.5 Not Indexing Problem *Fixed*</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<section>
In the course of establishing a new multitenant website, we opted to re-use the search mechanism for both site1 and site2. However, following the deployment of our code to the cloud QA environment, a significant hurdle surfaced: site2&#8217;s search consistently failed to produce results. This revelation made us to invest considerable effort in a detailed debugging journey.</p>
<p>Follow this step-by-step guide below as we transparently outline each phase of our process to resolve this issue.</p>
<div class="mention-block">
Navigating the challenges posed by the AEM 6.5.5 indexing problem, we&#8217;ve acquired invaluable insights that we believe will prove highly beneficial to the broader community. It&#8217;s crucial to emphasize that the focus of this article is specifically on the on-premises AEM 6.5.5 solution, distinct from the AEMaaCS solution.
</div>
</section>
<hr class="spacer-large"/>
<section>
<h2>Step 1: Identifying the Issue with the Query Performance Tool</h2>
<p>Our initial step involved using the query performance tool provided by AEM 6.5.5: <span class="code-highlight-secodary">/libs/granite/operations/content/diagnosistools/queryPerformance.html</span>. This tool allowed us to pinpoint the queries in use. As we focused on the search entry for site2, we discovered that the Lucene index was incorrectly utilizing the index intended for site1. This realization prompted us to proceed to the next step.</p>
</section>
<hr class="spacer-large"/>
<section>
<h2>Step 2: Updating Lucene Index Properties</h2>
<p>In the second step, we accessed <span class="code-highlight-secodary">crx/de</span> and located the Lucene index entry under <span class="code-highlight-secodary">/oak:index/*</span>. After finding the node, we updated the node properties, setting <span class="code-highlight-secodary">resync = false</span>. Monitoring the indexing logs, we confirmed a successful reindex. Despite obtaining the exact query for site2&#8217;s request, using the explain query tool revealed that the results were not as expected. Undeterred, we proceeded to the next step.</p>
</section>
<hr class="spacer-large"/>
<section>
<h2>Step 3: Deleting and Remaking %_TARGET_FOLDER_%</h2>
<p>With the issue persisting, we decided to take more decisive action in the third step. We shut down AEM, deleted <span class="code-highlight-secodary">./crx-quickstart/repository/index/%_TARGET_FOLDER_%</span>, and restarted the environment. After waiting for 5-10 minutes, the logs indicated that the <span class="code-highlight-secodary">%_TARGET_FOLDER_%</span> had been remade. Unfortunately, using the explain query tool still showed unexpected results, prompting us to move on to the next approach.</p>
</section>
<hr class="spacer-large"/>
<section>
<h2>Step 4: Complete Index Folder Deletion</h2>
<p>For the fourth step, we took a more extensive approach by shutting down AEM and deleting the entire index folder: <span class="code-highlight-secodary">./crx-quickstart/repository/index/*</span>. After restarting and patiently waiting for 10-30 minutes, the logs confirmed the successful recreation of the index folder. However, the query results were still not meeting our expectations.</p>
</section>
<hr class="spacer-large"/>
<section>
<h2>Step 5: Unconventional Solution</h2>
<p>By the fifth step, conventional options exhausted, we attempted an unconventional approach. Authorizing into <span class="code-highlight-secodary">crx/de</span>, we forcefully deleted both site1 and site2&#8217;s <span class="code-highlight-secodary">oak:index</span> rules. Subsequently, we reinstalled the rules for both sites. The result? A surprising success, with site2&#8217;s search now functioning as expected.</p>
</section>
<hr class="spacer-large"/>
<section>
<h2>Conclusion</h2>
<p>Navigating the intricacies of AEM 6.5.5&#8217;s indexing system can be challenging. However, with a systematic approach and a willingness to explore unconventional solutions, it&#8217;s possible to overcome seemingly insurmountable issues. By sharing our step-by-step journey, we hope this article proves valuable to others facing similar challenges in the realm of AEM development.</p>
</section>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/aem-6-5-5-not-indexing-problem-fixed">AEM 6.5.5 Not Indexing Problem *Fixed*</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/aem-6-5-5-not-indexing-problem-fixed/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Chrome Reset with the Outline CSS Property</title>
		<link>https://sourcedcode.com/blog/css/chrome-reset-with-the-outline-css-property</link>
					<comments>https://sourcedcode.com/blog/css/chrome-reset-with-the-outline-css-property#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Fri, 15 Dec 2023 14:22:06 +0000</pubDate>
				<category><![CDATA[CSS]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=6386</guid>

					<description><![CDATA[<p>Let&#8217;s delve into an approach to reset the Chrome outline CSS property. Our focus will be on two key declarations: outline-color: auto; and outline-color: -webkit-focus-ring-color;. Quick Links Understanding the Accessibility-Driven Outline CSS Property Resetting Chrome for Accessibility with outline-color Resetting Chrome with Browser-Specific Accessibility: outline-color: -webkit-focus-ring-color; Code Example, Together Conclusion 1. Understanding the Accessibility-Driven Outline [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/css/chrome-reset-with-the-outline-css-property">Chrome Reset with the Outline CSS Property</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<section>
<p>Let&#8217;s delve into an approach to reset the Chrome <span class="code-highlight-secondary">outline</span> CSS property. Our focus will be on two key declarations: <span class="code-highlight-secondary">outline-color: auto;</span> and <span class="code-highlight-secondary">outline-color: -webkit-focus-ring-color;</span>.</p>
</section>
<div class="mention-block">
    <strong>Quick Links</strong></p>
<ol>
<li><a href="#section-1">Understanding the Accessibility-Driven Outline CSS Property</a></li>
<li><a href="#section-2">Resetting Chrome for Accessibility with outline-color</a></li>
<li><a href="#section-3">Resetting Chrome with Browser-Specific Accessibility: outline-color: -webkit-focus-ring-color;</a></li>
<li><a href="#section-4">Code Example, Together</a></li>
<li><a href="#section-5">Conclusion</a></li>
</ol>
</div>
<hr class="spacer-large"/>
<section id="section-1">
<h2>1. Understanding the Accessibility-Driven Outline CSS Property:</h2>
<p>Before we explore the accessibility benefits, let&#8217;s grasp the significance of the <span class="code-highlight-secondary">outline</span> property in CSS. This versatile tool empowers us to refine the visual representation of elements without compromising the page layout—an essential consideration in creating inclusive and accessible websites.</p>
</section>
<hr class="spacer-large"/>
<section id="section-2">
<h2>2. Resetting Chrome for Accessibility with <span class="code-highlight-secondary">outline-color: auto;</span>:</h2>
<p>Our first directive aligns with accessibility principles: empower the browser to make a thoughtful choice. By implementing <span class="code-highlight-secondary">outline-color: auto;</span>, we allow Chrome to determine the outline color based on its default settings. This fosters a consistent and inclusive appearance across diverse devices and user preferences.</p>
<div class="codecolorer-container css default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br /></div></td><td><div class="css codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #6666ff;">.element</span> <span style="color: #00AA00;">&#123;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">outline-color</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span><br />
<span style="color: #00AA00;">&#125;</span></div></td></tr></tbody></table></div>
</section>
<hr class="spacer-large"/>
<section id="section-3">
<h2>3. Resetting Chrome with Browser-Specific Accessibility: <span class="code-highlight-secondary">outline-color: -webkit-focus-ring-color;</span>:</h2>
<p>To cater to Chrome&#8217;s unique accessibility features, we leverage the WebKit focus ring color with <span class="code-highlight-secondary">outline-color: -webkit-focus-ring-color;</span>. This declaration ensures that our outline color aligns with Chrome&#8217;s default focus ring, enhancing the accessibility experience without relying on <span class="code-highlight-secondary">!important</span>.</p>
<div class="codecolorer-container css default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br /></div></td><td><div class="css codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #6666ff;">.element</span> <span style="color: #00AA00;">&#123;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">outline-color</span><span style="color: #00AA00;">:</span> -webkit-focus-ring-color<span style="color: #00AA00;">;</span><br />
<span style="color: #00AA00;">&#125;</span></div></td></tr></tbody></table></div>
</section>
<hr class="spacer-large"/>
<section id="section-4">
<h2>4. Code Example, together</h2>
<p>Together, these declarations exemplify a thoughtful approach to styling outlines, prioritizing accessibility and visual cohesion in web design. The flexibility offered accommodates both the browser&#8217;s default styling and browser-specific optimizations, contributing to a seamless and inclusive user experience.</p>
<div class="codecolorer-container css default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="css codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #6666ff;">.element</span> <span style="color: #00AA00;">&#123;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">outline-color</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">outline-color</span><span style="color: #00AA00;">:</span> -webkit-focus-ring-color<span style="color: #00AA00;">;</span><br />
<span style="color: #00AA00;">&#125;</span></div></td></tr></tbody></table></div>
</section>
<hr class="spacer-large"/>
<section id="section-5">
<h2>5. Conclusion:</h2>
<p>In the pursuit of optimal web design, accessibility is non-negotiable. By harnessing the potential of the <span class="code-highlight-secondary">outline</span> CSS property and its <span class="code-highlight-secondary">outline-color</span> declarations, we&#8217;ve explored a thoughtful approach to reset Chrome with accessibility in mind. Whether entrusting the browser to decide with <span class="code-highlight-secondary">outline-color: auto;</span> or tailoring our outline to Chrome&#8217;s focus ring with <span class="code-highlight-secondary">outline-color: -webkit-focus-ring-color;</span>, these considerations contribute to a more accessible and user-friendly online experience. Elevate your web design by prioritizing accessibility and embracing the versatility of the outline.</p>
</section>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/css/chrome-reset-with-the-outline-css-property">Chrome Reset with the Outline CSS Property</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/css/chrome-reset-with-the-outline-css-property/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>AEM Chrome Extension for Content Authors, Developers, and CMS Admins Across All AEM Versions</title>
		<link>https://sourcedcode.com/blog/aem/aem-chrome-extension-for-content-authors-developers-and-cms-admins-across-all-aem-versions</link>
					<comments>https://sourcedcode.com/blog/aem/aem-chrome-extension-for-content-authors-developers-and-cms-admins-across-all-aem-versions#comments</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Mon, 11 Dec 2023 05:21:28 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Tools]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=6339</guid>

					<description><![CDATA[<p>Navigating Adobe Experience Manager (AEM) can often feel like a repetitive dance for content authors, developers, and administrators. Moving between pages, Touch UI editor, Classic UI editor, page properties, and CRXDE Lite involves the manual hassle of copying URLs and making adjustments – a time-consuming chore that needs a fresh approach. Enter the AEM Chrome [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/aem-chrome-extension-for-content-authors-developers-and-cms-admins-across-all-aem-versions">AEM Chrome Extension for Content Authors, Developers, and CMS Admins Across All AEM Versions</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<br />
<section>
Navigating Adobe Experience Manager (AEM) can often feel like a repetitive dance for content authors, developers, and administrators. Moving between pages, Touch UI editor, Classic UI editor, page properties, and CRXDE Lite involves the manual hassle of copying URLs and making adjustments – a time-consuming chore that needs a fresh approach. Enter the <a href="https://bit.ly/aem-chromeextension" rel="noopener" target="_blank">AEM Chrome Extension</a>, a tool designed to be your time-saving ally and revolutionize your AEM navigation.</p>
<p>Notably, the <a href="https://bit.ly/aem-chromeextension" rel="noopener" target="_blank">AEM Chrome Extension</a> has garnered popularity with around 1700 daily users. More than just an extension, it&#8217;s become a game-changer, significantly boosting users&#8217; speed and efficiency in navigating the AEM environment. Across the board, users are discovering the advantages of streamlined workflows, making their AEM experience smoother than ever.</p>
<p>If you&#8217;re tired of the manual navigation dance, the <a href="https://bit.ly/aem-chromeextension" rel="noopener" target="_blank">AEM Chrome Extension</a> is your answer. This tool lets you navigate AEM seamlessly – from Touch UI editor to Classic UI editor, page properties, and CRXDE Lite – all with just a click or a convenient hotkey. Say farewell to the tedious manual approach and welcome a more efficient way to glide through the AEM console. It&#8217;s not just about saving time; it&#8217;s about making your AEM journey a breeze.</p>
<div class="mention-block">
<strong>Quick Links</strong></p>
<ol>
<li><a href="#section-2">Key Features</a></li>
<li><a href="#section-3">Additional Features for Enhanced User Experience</a></li>
<li><a href="#section-4">Release Notes</a></li>
<li><a href="#section-5">Instructions: How to Use the Tool? (Video)</a></li>
<li><a href="#section-6">Feedback, Bugs, and Tool Enhancements</a></li>
<li><a href="#section-7"><strong>Install to AEM Chrome Extension Now</strong></a></li>
</ol>
</div>
</section>
<hr class="spacer-larger">
<section>
<h2 id="section-2">1. Key Features</h2>
<ul>
<li style="margin-bottom: 20px;">
        <strong>Dynamic Quick Links</strong></p>
<p>From any page under <strong class="code-highlight-primary">/content/*</strong>, the <a href="https://bit.ly/aem-chromeextension" rel="noopener" target="_blank">AEM Chrome Extension</a> empowers you to swiftly navigate to Touch UI<br />
          editor, Classic UI editor, page properties, disabled mode, debug clientlib mode, and CRXDE Lite. On other pages,<br />
          a quick hop to CRXDE Lite takes you directly to your targeted page or node.</p>
<ul>
<li>Switches the current context to editor.html for Touch UI.</li>
<li>Switches the current context to editor for Classic AEM.</li>
<li>Switches the current context to CRX/DE console.</li>
<li>Switches the current context to pageProperties editor page.</li>
<li>Switches the current context to disabled mode for XF and Sites Content.</li>
<li>Switches the current context to Sites or XF folder.</li>
<li>Switches the current context to DAM folder (while inside a DAM asset) – just<br />
              because.</li>
</ul>
</li>
<li style="margin-bottom: 20px;">
        <strong>Dynamic Quick Links (Hotkey)</strong></p>
<p>Efficiency is at your fingertips with hotkeys for quick navigation:</p>
<ul>
<li><strong>&#8220;e&#8221;</strong>: Switches the current context to editor.html for Touch UI.</li>
<li><strong>&#8220;w&#8221;</strong>: Switches the current context to editor for Classic AEM.</li>
<li><strong>&#8220;c&#8221;</strong>: Switches the current context to CRX/DE console.</li>
<li><strong>&#8220;p&#8221;</strong>: Switches the current context to pageProperties editor page.</li>
<li><strong>&#8220;d&#8221;</strong>: Switches the current context to disabled mode for XF and Sites Content.</li>
<li><strong>&#8220;s&#8221;</strong>: Switches the current context to Sites or XF folder.</li>
<li><strong>&#8220;a&#8221;</strong>: Switches the current context to DAM folder (while inside a DAM asset) – just<br />
              because.</li>
</ul>
</li>
<li>
        <strong>Bookmarks Quick Links</strong></p>
<p>The <a href="https://bit.ly/aem-chromeextension" rel="noopener" target="_blank">AEM Chrome Extension</a> offers a plethora of useful bookmarks, facilitating swift navigation through AEM.<br />
          Bookmark links are relative paths from the active Google, and you can set the Author Url Origin for designated<br />
          author environments.</p>
</li>
</ul>
</section>
<hr class="spacer-larger">
<section>
<h2 id="section-3">2. Additional Features for Enhanced User Experience</h2>
<ul>
<li>
        <strong>+ Open New Tab</strong></p>
<p>Enable this option to ensure that all quick links clicked open in a new tab within the browser, enhancing<br />
          multitasking capabilities.</p>
</li>
<li>
        <strong>+ Hide Hints</strong></p>
<p>For a cleaner layout while using the <a href="https://bit.ly/aem-chromeextension" rel="noopener" target="_blank">AEM Chrome Extension</a> tool, enable this option to hide the hinted text in<br />
          the Chrome extension.</p>
</li>
</ul>
</section>
<hr class="spacer-larger">
<section>
<h2 id="section-4">3. Releases Notes</h2>
<ul>
<li><strong>Release V 0.0.7</strong>
<ul>
<li>Hotkeys are now visible by default – no need to click &#8220;show hints.&#8221;</li>
<li>Bug fixes.</li>
<li>Performance enhancements.</li>
</ul>
</li>
<li><strong>Release V 0.0.6</strong>
<ul>
<li>Hotkeys supported (in show hints).</li>
<li>New quick links providing quick reference to out-of-the-box features from AEM.</li>
<li>Indicator when the &#8220;origin&#8221; has been set.</li>
<li>Bug fixes.</li>
<li>Performance improvements.</li>
</ul>
</li>
<li><strong>Release V 0.0.5</strong>
<ul>
<li>Bug fixes.</li>
<li>Performance enhancements.</li>
</ul>
</li>
<li><strong>Release V 0.0.4</strong>
<ul>
<li>Updated name of the extension from &#8220;AEM Quick Links&#8221; to &#8220;<a href="https://bit.ly/aem-chromeextension" rel="noopener" target="_blank">AEM Chrome Extension &#8211; SourcedCode</a>.&#8221;</li>
<li>Added version indicator.</li>
<li>Bug fixes.</li>
<li>Performance improvements.</li>
</ul>
</li>
<li><strong>Release V 0.0.3</strong>
<ul>
<li>DAM navigation support in CRXDE.</li>
<li>In CRXDE /content/dam assets with file extension, can open properties page.</li>
<li>In CRXDE /content/dam assets with file extension, can navigate to DAM parent folder.</li>
<li>In CRXDE /content/dam folder, can navigate to DAM parent folder.</li>
<li>In AEM console, from properties page, can navigate to CRXDE console.</li>
<li>In AEM console, from properties page, can navigate to DAM parent folder.</li>
<li>(CTRL + Click) or (CMD + Click) for open new tab support.</li>
<li>Bug fixes.</li>
<li>Performance improvements.</li>
</ul>
</li>
</ul>
</section>
<hr class="spacer-larger">
<h2 id="section-5">4. Instructions: How to Use the Tool? (Video)</h2>
<p>Learn how to make the most of the <a href="https://bit.ly/aem-chromeextension" rel="noopener" target="_blank">AEM Chrome Extension</a> with our step-by-step video guide. Watch the video below to discover tips and tricks for seamless navigation within Adobe Experience Manager.</p>
<style>.embedtool {position: relative;height: 0;padding-top: 56%;overflow: hidden;max-width: 100%;} .embedtool iframe, .embedtool object, .embedtool embed { position: absolute; top: 0; left: 0; width: 100%; height: 100%; } .embedtool .fluid-vids {position: initial !important}</style>
<div class="embedtool"><iframe src="https://www.youtube.com/embed/yq-igYg4d_s" frameborder="0" allowfullscreen></iframe></div>
<hr class="spacer-larger">
<section>
<h2 id="section-6">5. Feedback, Bugs, and Tool Enhancements</h2>
<p>I value your input! If you have any suggestions, ideas, or come across any bugs while using the <a href="https://bit.ly/aem-chromeextension" rel="noopener" target="_blank">AEM Chrome Extension</a>, we encourage you to reach out. Your feedback is invaluable in our commitment to enhancing and refining the tool for an even better user experience.</p>
<p>Feel free to contact me at <a href="mailto:contact@sourcedcode.com">contact@sourcedcode.com</a> or connect with me on <a href="https://www.linkedin.com/in/briankasingli" rel="noopener" target="_blank">LinkedIn</a>. Whether it&#8217;s a feature you&#8217;d love to see added or a bug that needs squashing, your insights play a crucial role in shaping the future of this tool.</p>
<p>Let&#8217;s collaborate to make the <a href="https://bit.ly/aem-chromeextension" rel="noopener" target="_blank">AEM Chrome Extension</a> the best on the market. Together, we can ensure it meets and exceeds your expectations, making your AEM navigation smoother and more efficient than ever before. Your contributions are key to our continuous improvement, and we appreciate your dedication to making this tool top-notch.<br />
  </section>
<hr class="spacer-larger">
<section>
<h2 id="section-7">6. Install to AEM Chrome Extension Now</h2>
<p>Make your AEM navigation as efficient as your workflow – Install the <a href="https://bit.ly/aem-chromeextension" rel="noopener" target="_blank">AEM Chrome Extension</a> today and experience a<br />
      new era of seamless navigation within AEM!</p>
</section>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/aem-chrome-extension-for-content-authors-developers-and-cms-admins-across-all-aem-versions">AEM Chrome Extension for Content Authors, Developers, and CMS Admins Across All AEM Versions</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/aem-chrome-extension-for-content-authors-developers-and-cms-admins-across-all-aem-versions/feed</wfw:commentRss>
			<slash:comments>18</slash:comments>
		
		
			</item>
		<item>
		<title>Execute JavaScript in the Author Environment for AEM Components AEM 6.5+</title>
		<link>https://sourcedcode.com/blog/aem/execute-javascript-in-the-author-environment-for-aem-components-aem-6-5</link>
					<comments>https://sourcedcode.com/blog/aem/execute-javascript-in-the-author-environment-for-aem-components-aem-6-5#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Fri, 08 Dec 2023 00:47:15 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Client Libraries]]></category>
		<category><![CDATA[JavaScript]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=6322</guid>

					<description><![CDATA[<p>To execute JavaScript specifically for the AEM Author Environment, developers can add a condition to check for a Cookie stored in the browser, &#8216;cq-authoring-mode&#8217;; this works on AEM 6.5+. When the Cookie of &#8216;cq-authoring-mode&#8217; exists, then execute JavaScript during authoring on the editor.html. Only in the Author Environment, the Cookie, &#8216;cq-authoring-mode&#8217;, will exist. Below is [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/execute-javascript-in-the-author-environment-for-aem-components-aem-6-5">Execute JavaScript in the Author Environment for AEM Components AEM 6.5+</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>To execute JavaScript specifically for the AEM <strong>Author Environment</strong>, developers can add a condition to check for a Cookie stored in the browser, &#8216;cq-authoring-mode&#8217;; this works on AEM 6.5+. When the Cookie of <strong class="code-highlight-primary">&#8216;cq-authoring-mode&#8217;</strong> exists, then execute JavaScript during authoring on the editor.html. Only in the Author Environment, the Cookie, <strong class="code-highlight-primary">&#8216;cq-authoring-mode&#8217;</strong>, will exist. Below is a code snippet demonstrating how to check for the existence of the <strong class="code-highlight-primary">&#8216;cq-authoring-mode&#8217;</strong> key in the cookies and gracefully exit the JavaScript logic if the key is found (targeting only the Author Environment, which means run-mode=author):</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #006600; font-style: italic;">// Import the necessary modules</span><br />
<span style="color: #FF0000;">import</span> Cookies from <span style="color: #3366CC;">'js-cookie'</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #006600; font-style: italic;">// Check if the 'cq-authoring-mode' key exists in cookies</span><br />
<span style="color: #000066; font-weight: bold;">const</span> authoringModeCookie <span style="color: #339933;">=</span> Cookies.<span style="color: #000066; font-weight: bold;">get</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'cq-authoring-mode'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>authoringModeCookie<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; <span style="color: #006600; font-style: italic;">// Exit the JavaScript logic if the key is found</span><br />
&nbsp; console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Authoring mode cookie found. Exiting JavaScript logic.'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; <span style="color: #006600; font-style: italic;">// Continue with your JavaScript logic for AEM Author Environment</span><br />
&nbsp; console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Authoring mode cookie not found. Proceeding with JavaScript logic.'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #006600; font-style: italic;">// Add your custom functionality here</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>In this example, we use the &#8216;js-cookie&#8217; library to handle cookies in a simplified manner. The Cookies.get(<strong class="code-highlight-primary">&#8216;cq-authoring-mode&#8217;</strong>) function retrieves the value of the <strong class="code-highlight-primary">&#8216;cq-authoring-mode&#8217;</strong> key from cookies. If the key exists, the JavaScript logic exits gracefully. Otherwise, you can proceed with implementing your custom functionality.</p>
<hr class="spacer-large">
<h2>Benefits of Customized JavaScript in AEM Editor</h2>
<ol>
<li><strong>Context-Aware Functionality: </strong>By checking for specific conditions, such as the presence of a key in cookies, developers can implement context-aware functionality tailored to the AEM authoring environment.</li>
<li><strong>Enhanced Authoring Experience: </strong>Custom JavaScript allows for the augmentation of the authoring experience by introducing features that streamline workflows and improve usability for content authors.</li>
<li><strong>Graceful Handling of Conditions:</strong> Checking for the existence of keys in cookies enables developers to gracefully handle conditions, ensuring that the JavaScript logic behaves appropriately in different scenarios.</li>
</ol>
<hr class="spacer-large">
<h2>Conclusion</h2>
<p>Mastering the art of writing JavaScript for the AEM Author Environment empowers developers to create a tailored experience purely for the authoring environment. By incorporating checks for specific conditions, such as cookie existence, developers can introduce intelligent and context-aware functionalities that enhance the content creation process. The provided code snippet serves as a starting point for customizing JavaScript in the AEM Author Environment, offering a foundation for further innovation and optimization.</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/execute-javascript-in-the-author-environment-for-aem-components-aem-6-5">Execute JavaScript in the Author Environment for AEM Components AEM 6.5+</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/execute-javascript-in-the-author-environment-for-aem-components-aem-6-5/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Targeting CSS in the Editor.html for AEM Components for AEMaaCS</title>
		<link>https://sourcedcode.com/blog/aem/targeting-css-in-the-editor-html-for-aem-components-for-aemaacs</link>
					<comments>https://sourcedcode.com/blog/aem/targeting-css-in-the-editor-html-for-aem-components-for-aemaacs#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Fri, 08 Dec 2023 00:31:46 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Development]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=6307</guid>

					<description><![CDATA[<p>Sometimes as developers, we would need to inject some CSS into our pages in the edit-modes to enhance the experience of our authors. One key skill as an AEM developer knowing how to customize the authoring experience in the editor.html (while content authors are editing the page). This article explores the techniques of targeting CSS [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/targeting-css-in-the-editor-html-for-aem-components-for-aemaacs">Targeting CSS in the Editor.html for AEM Components for AEMaaCS</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Sometimes as developers, we would need to inject some CSS into our pages in the edit-modes to enhance the experience of our authors. One key skill as an AEM developer knowing how to customize the authoring experience in the editor.html (while content authors are editing the page). This article explores the techniques of targeting CSS for AEM components in various authoring modes to optimize the content creation process.</p>
<p><strong style="code-highlight-primary">This has only been tested on AEMaaCS.</strong></p>
<div class="mention-block">
  <strong>Quick Links</strong></p>
<ol>
<li><a href="#understanding-authoring-modes">Understanding Authoring Modes in AEM</a></li>
<li><a href="#targeting-components">Targeting Components in Different Authoring Modes</a></li>
<li><a href="#benefits-of-targeting-css">Benefits of Targeting CSS in AEM Editor</a></li>
<li><a href="#conclusion">Conclusion</a></li>
</ol>
</div>
<hr class="spacer-large" />
<h2 id="understanding-authoring-modes">1. Understanding Authoring Modes in AEM:</h2>
<p>AEM&#8217;s editor.html supports multiple authoring modes, each serving a specific purpose in the content creation workflow. These modes include edit mode, preview mode, layout mode, developer mode, MSM (Multi-Site Manager) mode, and time warp mode. To enhance the authoring experience, it&#8217;s crucial to apply targeted CSS to components based on the current authoring mode.</p>
<p><a href="https://sourcedcode.com/wp-content/uploads/2023/12/authoring-modes.png"><img decoding="async" src="https://sourcedcode.com/wp-content/uploads/2023/12/authoring-modes.png" alt="edit mode, preview mode, layout mode, developer mode, MSM (Multi-Site Manager) mode, and time warp mode" width="305" height="297" class="alignnone size-full wp-image-6317" srcset="https://sourcedcode.com/wp-content/uploads/2023/12/authoring-modes.png 305w, https://sourcedcode.com/wp-content/uploads/2023/12/authoring-modes-300x292.png 300w" sizes="(max-width: 305px) 100vw, 305px" /></a></p>
<hr class="spacer-large" />
<h2 id="targeting-components">2. Targeting Components in Different Authoring Modes:</h2>
<p>To achieve a seamless authoring experience, developers can leverage specific CSS classes associated with each authoring mode in AEM. The following example demonstrates how to target a custom component called &#8220;.my-component&#8221; in different authoring modes:</p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #66cc66;">/</span>* Edit Mode *<span style="color: #66cc66;">/</span><br />
.aem-AuthorLayer-Edit .my-component <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #000066;">background</span>: red;<br />
<span style="color: #66cc66;">&#125;</span><br />
<br />
<span style="color: #66cc66;">/</span>* Preview Mode *<span style="color: #66cc66;">/</span><br />
.aem-AuthorLayer-Preview .my-component <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #000066;">background</span>: blue;<br />
<span style="color: #66cc66;">&#125;</span><br />
<br />
<span style="color: #66cc66;">/</span>* Layout Mode *<span style="color: #66cc66;">/</span><br />
.aem-AuthorLayer-Layouting .my-component <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #000066;">background</span>: green;<br />
<span style="color: #66cc66;">&#125;</span><br />
<br />
<span style="color: #66cc66;">/</span>* Developer Mode *<span style="color: #66cc66;">/</span><br />
.aem-AuthorLayer-Developer .my-component <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #000066;">border</span>: 2px solid yellow;<br />
<span style="color: #66cc66;">&#125;</span><br />
<br />
<span style="color: #66cc66;">/</span>* Time Warp Mode *<span style="color: #66cc66;">/</span><br />
.aem-AuthorLayer-Timewarp .my-component <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp;opacity: <span style="color: #cc66cc;">0.7</span>;<br />
<span style="color: #66cc66;">&#125;</span><br />
<br />
<span style="color: #66cc66;">/</span>* MSM Mode *<span style="color: #66cc66;">/</span><br />
.aem-AuthorLayer-MSM .my-component <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #000066;">background</span>: purple;<br />
<span style="color: #66cc66;">&#125;</span></div></td></tr></tbody></table></div>
<p>In the above example, each CSS rule targets the &#8220;.my-component&#8221; class in a specific authoring mode, applying distinct styles to improve visibility or provide context for authors working in that mode.</p>
<hr class="spacer-large" />
<h2 id="benefits-of-targeting-css">3. Benefits of Targeting CSS in AEM Editor:</h2>
<ol>
<li><strong>Improved Visibility: </strong>By applying different background colors or borders in various authoring modes, developers can enhance the visibility of components, making it easier for authors to identify and manipulate them.</li>
<li><strong>Contextual Styling: </strong>Tailoring styles based on the authoring mode provides contextual information to content authors. For instance, applying a distinctive style in developer mode can signify that the component is currently being modified at a code level.<br />
Optimized Workflows:</li>
<li><strong>Optimized Workflows: </strong>Targeted CSS in the editor.html file optimizes authoring workflows by reducing confusion and streamlining the content creation process. Authors can quickly grasp the current mode and focus on the relevant tasks.
</li>
</ol>
<hr class="spacer-large" />
<h2 id="conclusion">4. Conclusion:</h2>
<p>Customizing the authoring experience in AEM by targeting CSS in the editor.html file is a powerful way to enhance usability and streamline content creation workflows. By understanding and leveraging the specific CSS classes associated with each authoring mode, developers can provide a more intuitive and visually informative environment for content authors using AEMaaCS.</p>
<p><em>And one more last thing to note is, please ensure that these rules are added into your clientlibs.author structure, so that these rules will never be exposed on production.</em></p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/targeting-css-in-the-editor-html-for-aem-components-for-aemaacs">Targeting CSS in the Editor.html for AEM Components for AEMaaCS</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/targeting-css-in-the-editor-html-for-aem-components-for-aemaacs/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>All Aria Attributes for Web Development Accessibility &#8211; Library</title>
		<link>https://sourcedcode.com/blog/web-accessibility/all-aria-attributes-for-web-development-accessibility-library</link>
					<comments>https://sourcedcode.com/blog/web-accessibility/all-aria-attributes-for-web-development-accessibility-library#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Sun, 03 Dec 2023 20:39:52 +0000</pubDate>
				<category><![CDATA[Web Accessibility]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=6288</guid>

					<description><![CDATA[<p>In the world of web development, ensuring universal access is required. ARIA (Accessible Rich Internet Applications) attributes are key players in this mission. This blog is your go-to library, offering developers a swift reference for essential ARIA attributes, quick descriptions, code examples, code snippets for easy implementation. Why ARIA Attributes Matter: Accessibility isn&#8217;t just a [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/web-accessibility/all-aria-attributes-for-web-development-accessibility-library">All Aria Attributes for Web Development Accessibility &#8211; Library</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>In the world of web development, ensuring universal access is required. ARIA (Accessible Rich Internet Applications) attributes are key players in this mission. This blog is your go-to library, offering developers a swift reference for essential ARIA attributes, quick descriptions, code examples, code snippets for easy implementation.</p>
<p><strong>Why ARIA Attributes Matter</strong>: Accessibility isn&#8217;t just a choice; it&#8217;s a legal requirement. Using ARIA attributes is crucial for inclusive web applications, especially for users relying on assistive tools like screen readers. Compliance with accessibility standards is increasingly enforced, with penalties for major sector websites failing to meet these requirements.</p>
<p><strong>What to Expect: </strong>In this blog article, we will provide a quick reference to all ARIA attributes, offering brief descriptions for each and accompanying code snippets. Explore a curated list of ARIA attributes designed to enhance user experience. With this guide, developers can seamlessly integrate ARIA attributes, promoting a digital landscape where everyone, regardless of ability, can engage effortlessly.</p>
<p>Embark on this journey to harness the power of ARIA attributes, creating a web space that truly belongs to all.</p>
<p><!-- Quick Links Section --></p>
<div class="mention-block">
    <strong>Quick Links</strong></p>
<ol>
<li><a href="#aria-atomic">aria-atomic</a></li>
<li><a href="#aria-busy">aria-busy</a></li>
<li><a href="#aria-checked">aria-checked</a></li>
<li><a href="#aria-describedby">aria-describedby</a></li>
<li><a href="#aria-disabled">aria-disabled</a></li>
<li><a href="#aria-dropeffect">aria-dropeffect</a></li>
<li><a href="#aria-expanded">aria-expanded</a></li>
<li><a href="#aria-haspopup">aria-haspopup</a></li>
<li><a href="#aria-hidden">aria-hidden</a></li>
<li><a href="#aria-invalid">aria-invalid</a></li>
<li><a href="#aria-label">aria-label</a></li>
<li><a href="#aria-labelledby">aria-labelledby</a></li>
<li><a href="#aria-live">aria-live</a></li>
<li><a href="#aria-multiline">aria-multiline</a></li>
<li><a href="#aria-multiselectable">aria-multiselectable</a></li>
<li><a href="#aria-orientation">aria-orientation</a></li>
<li><a href="#aria-pressed">aria-pressed</a></li>
<li><a href="#aria-readonly">aria-readonly</a></li>
<li><a href="#aria-required">aria-required</a></li>
<li><a href="#aria-selected">aria-selected</a></li>
<li><a href="#aria-sort">aria-sort</a></li>
<li><a href="#aria-valuemax">aria-valuemax</a></li>
<li><a href="#aria-valuemin">aria-valuemin</a></li>
<li><a href="#aria-valuenow">aria-valuenow</a></li>
<li><a href="#aria-valuetext">aria-valuetext</a></li>
</ol>
</div>
<p><!-- 1. aria-atomic --></p>
<hr class="spacer-large" />
<div id="aria-atomic">
<h2>1. aria-atomic:</h2>
<p>When dynamic updates occur, set <strong class="code-highlight-primary">&#8220;aria-atomic&#8221;</strong> to &#8220;true&#8221; to treat the entire region as a single unit. This ensures that screen readers announce changes cohesively, providing a seamless and comprehensible experience.</p>
<p>The <strong class="code-highlight-primary">&#8220;aria-atomic&#8221;</strong> attribute is particularly useful when there are updates within a container, and you want screen readers to perceive the changes as a whole, preventing disjointed announcements.</p>
<p>This attribute is beneficial in scenarios where partial updates might lead to confusion, and you want to ensure that assistive technologies convey the information in a way that makes sense to users.</p>
<p>For example, if you have a live region with dynamically changing content, applying <strong class="code-highlight-primary">&#8220;aria-atomic=&#8217;true'&#8221;</strong> ensures that the entire content is treated as a single update, providing a more cohesive experience for users relying on screen readers.</p>
<p>Remember, judicious use of <strong class="code-highlight-primary">&#8220;aria-atomic&#8221;</strong> contributes to a more inclusive and user-friendly web experience for everyone.</p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&nbsp; &nbsp; &lt;<span style="color: #000000; font-weight: bold;">div</span> aria-atomic<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;true&quot;</span>&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;!-- <span style="color: #000066;">Content</span> that updates dynamically --&gt;<br />
&nbsp; &nbsp; &lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</div></td></tr></tbody></table></div>
</div>
<p><!-- 2. aria-busy --></p>
<hr class="spacer-large" />
<div id="aria-busy">
<h2>2. aria-busy:</h2>
<p>To give users insight into ongoing operations, use <strong class="code-highlight-primary">&#8220;aria-busy&#8221;</strong> to indicate when an element is busy or loading. This attribute enhances user feedback and overall experience.</p>
<p>The <strong class="code-highlight-primary">&#8220;aria-busy&#8221;</strong> attribute is crucial for providing users with information about background processes, ensuring transparency and a more engaging user experience.</p>
<p>When an element is marked as <strong class="code-highlight-primary">&#8220;aria-busy=&#8217;true'&#8221;</strong>, assistive technologies can convey to users that the associated content is currently being loaded, processed, or is in a state of activity.</p>
<p>This attribute is especially beneficial for asynchronous operations, such as fetching data from a server or performing complex calculations. It helps users understand that the application is actively working on their request.</p>
<p>By incorporating <strong class="code-highlight-primary">&#8220;aria-busy&#8221;</strong> appropriately, you contribute to a more transparent and inclusive web experience for users across various abilities.</p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&nbsp; &nbsp; &lt;<span style="color: #000000; font-weight: bold;">div</span> aria-busy<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;true&quot;</span>&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;!-- <span style="color: #000066;">Content</span> being loaded or processed --&gt;<br />
&nbsp; &nbsp; &lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</div></td></tr></tbody></table></div>
</div>
<p><!-- 3. aria-checked --></p>
<hr class="spacer-large" />
<div id="aria-checked">
<h2>3. aria-checked:</h2>
<p>Optimize the accessibility of checkboxes, radio buttons, and widgets by employing <strong class="code-highlight-primary">&#8220;aria-checked&#8221;</strong> to convey their current &#8220;checked&#8221; state to assistive technologies.</p>
<p>The <strong class="code-highlight-primary">&#8220;aria-checked&#8221;</strong> attribute is essential for conveying the status of checkboxes and radio buttons to users relying on screen readers or other assistive technologies.</p>
<p>By setting <strong class="code-highlight-primary">&#8220;aria-checked=&#8217;true'&#8221;</strong> or <strong class="code-highlight-primary">&#8220;aria-checked=&#8217;false'&#8221;</strong>, you provide a clear indication of whether an option is selected or not, ensuring that users receive accurate information about the state of interactive elements.</p>
<p>Use <strong class="code-highlight-primary">&#8220;aria-checked&#8221;</strong> in conjunction with checkboxes and radio buttons to create an inclusive and user-friendly experience, allowing all users to interact with and understand the status of selectable options.</p>
<p>Consider the context of your application and use <strong class="code-highlight-primary">&#8220;aria-checked&#8221;</strong> judiciously to enhance the overall accessibility of your interface.</p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&nbsp; &nbsp; &lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;checkbox&quot;</span> aria-<span style="color: #000066;">checked</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;true&quot;</span>&gt;</div></td></tr></tbody></table></div>
</div>
<p><!-- 4. aria-describedby --></p>
<hr class="spacer-large" />
<div id="aria-describedby">
<h2>4. aria-describedby:</h2>
<p>Create a seamless flow of information by linking elements to additional descriptions with <strong class="code-highlight-primary">&#8220;aria-describedby&#8221;</strong>. This example associates a button with a tooltip, providing supplementary information.</p>
<p>The <strong class="code-highlight-primary">&#8220;aria-describedby&#8221;</strong> attribute establishes a relationship between an element and a description, enhancing the accessibility of your interface by providing additional context or information.</p>
<p>When a user interacts with an element, the content referenced by the <strong class="code-highlight-primary">&#8220;aria-describedby&#8221;</strong> attribute is announced by assistive technologies, giving users more information about the purpose or function of the element.</p>
<p>For example, if you have a button with associated help text, you can use <strong class="code-highlight-primary">&#8220;aria-describedby&#8221;</strong> to connect the button to the additional information, ensuring that users receive comprehensive details about the button&#8217;s functionality.</p>
<p>Integrating <strong class="code-highlight-primary">&#8220;aria-describedby&#8221;</strong> thoughtfully contributes to a more inclusive and user-friendly experience, particularly for users who may benefit from additional context or clarification.</p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&nbsp; &nbsp; &lt;<span style="color: #000000; font-weight: bold;">button</span> aria-describedby<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;tooltip1&quot;</span>&gt;Click me&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">button</span>&gt;<br />
&nbsp; &nbsp; &lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;tooltip1&quot;</span>&gt;Additional information <span style="color: #000066;">for</span> the button&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</div></td></tr></tbody></table></div>
</div>
<p><!-- 5. aria-disabled --></p>
<hr class="spacer-large" />
<div id="aria-disabled">
<h2>5. aria-disabled:</h2>
<p>Clearly communicate the disabled state of an element with <strong class="code-highlight-primary">&#8220;aria-disabled&#8221;</strong>, ensuring a consistent user experience, especially for interactive elements.</p>
<p>The <strong class="code-highlight-primary">&#8220;aria-disabled&#8221;</strong> attribute is essential for conveying the disabled status of interactive elements to users of assistive technologies, preventing confusion and ensuring a consistent experience.</p>
<p>When an element is marked as <strong class="code-highlight-primary">&#8220;aria-disabled=&#8217;true'&#8221;</strong>, it signals to users that the associated functionality is currently unavailable or inactive.</p>
<p>Use <strong class="code-highlight-primary">&#8220;aria-disabled&#8221;</strong> with buttons, form elements, or other interactive components to provide clear feedback to users, especially in situations where certain features or actions are temporarily disabled.</p>
<p>By incorporating <strong class="code-highlight-primary">&#8220;aria-disabled&#8221;</strong> appropriately, you contribute to a more predictable and accessible web experience for users with varying abilities.</p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&nbsp; &nbsp; &lt;<span style="color: #000000; font-weight: bold;">button</span> aria-<span style="color: #000066;">disabled</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;true&quot;</span>&gt;<span style="color: #000066;">Disabled</span> Button&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">button</span>&gt;</div></td></tr></tbody></table></div>
</div>
<p><!-- 6. aria-dropeffect --></p>
<hr class="spacer-large" />
<div id="aria-dropeffect">
<h2>6. aria-dropeffect:</h2>
<p>Facilitate accessible drag-and-drop interactions by using <strong class="code-highlight-primary">&#8220;aria-dropeffect&#8221;</strong> to describe the effect when a dragged object is released.</p>
<p>The <strong class="code-highlight-primary">&#8220;aria-dropeffect&#8221;</strong> attribute enhances the usability of drag-and-drop interfaces by indicating the possible outcomes when a dragged object is released over a drop target.</p>
<p>For example, if you have a container that accepts dropped content and you want to communicate that the content will be copied, use <strong class="code-highlight-primary">&#8220;aria-dropeffect=&#8217;copy'&#8221;</strong>.</p>
<p>Integrating <strong class="code-highlight-primary">&#8220;aria-dropeffect&#8221;</strong> appropriately provides valuable information to users interacting with drag-and-drop functionality, creating a more accessible and predictable experience.</p>
<p>Consider the specific drag-and-drop interactions in your application and use <strong class="code-highlight-primary">&#8220;aria-dropeffect&#8221;</strong> to communicate the potential outcomes to all users.</p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&nbsp; &nbsp; &lt;<span style="color: #000000; font-weight: bold;">div</span> aria-dropeffect<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;copy&quot;</span>&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;!-- <span style="color: #000066;">Content</span> that accepts drop operations --&gt;<br />
&nbsp; &nbsp; &lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</div></td></tr></tbody></table></div>
</div>
<p><!-- 7. aria-expanded --></p>
<hr class="spacer-large" />
<div id="aria-expanded">
<h2>7. aria-expanded:</h2>
<p>Improve the accessibility of widgets like tree views by using <strong class="code-highlight-primary">&#8220;aria-expanded&#8221;</strong> to indicate whether they are expanded or collapsed.</p>
<p>The <strong class="code-highlight-primary">&#8220;aria-expanded&#8221;</strong> attribute is valuable for conveying the state of expandable/collapsible elements, such as tree view nodes or dropdown menus.</p>
<p>When an element is expanded, set <strong class="code-highlight-primary">&#8220;aria-expanded=&#8217;true'&#8221;</strong>, and when it&#8217;s collapsed, set <strong class="code-highlight-primary">&#8220;aria-expanded=&#8217;false'&#8221;</strong>.</p>
<p>Users relying on assistive technologies can then understand and navigate the hierarchy of your interface with clarity.</p>
<p>Ensure to use <strong class="code-highlight-primary">&#8220;aria-expanded&#8221;</strong> judiciously to accurately reflect the state of expandable elements and enhance the overall accessibility of your user interface.</p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&nbsp; &nbsp; &lt;<span style="color: #000000; font-weight: bold;">button</span> aria-expanded<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;true&quot;</span> aria-controls<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;collapse-content&quot;</span>&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; Toggle <span style="color: #000066;">Content</span><br />
&nbsp; &nbsp; &lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">button</span>&gt;</div></td></tr></tbody></table></div>
</div>
<p><!-- 8. aria-haspopup --></p>
<hr class="spacer-large" />
<div id="aria-haspopup">
<h2>8. aria-haspopup:</h2>
<p>Elevate the user experience by utilizing <strong class="code-highlight-primary">&#8220;aria-haspopup&#8221;</strong> to indicate that an element triggers a popup menu, dialog, or tooltip when interacted with. This attribute aids in providing users with valuable context about interactive elements.</p>
<p>The <strong class="code-highlight-primary">&#8220;aria-haspopup&#8221;</strong> attribute is beneficial for signaling to users that activating an element will result in the display of additional content, such as a menu or dialog.</p>
<p>When an element has a popup associated with it, set <strong class="code-highlight-primary">&#8220;aria-haspopup=&#8217;true'&#8221;</strong> to inform users about the interactive behavior.</p>
<p>Use <strong class="code-highlight-primary">&#8220;aria-controls&#8221;</strong> in conjunction with <strong class="code-highlight-primary">&#8220;aria-haspopup&#8221;</strong> to establish a relationship between the triggering element and the popup content.</p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&nbsp; &nbsp; &lt;<span style="color: #000000; font-weight: bold;">button</span> aria-haspopup<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;true&quot;</span> aria-controls<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;popup-menu&quot;</span>&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; Open Menu<br />
&nbsp; &nbsp; &lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">button</span>&gt;<br />
&nbsp; &nbsp; &lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;popup-menu&quot;</span>&gt; &lt;!-- Popup menu <span style="color: #000066;">content</span> --&gt; &lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</div></td></tr></tbody></table></div>
</div>
<p><!-- 9. aria-hidden --></p>
<hr class="spacer-large" />
<div id="aria-hidden">
<h2>9. aria-hidden:</h2>
<p>Control the visibility of elements to assistive technologies with <strong class="code-highlight-primary">&#8220;aria-hidden&#8221;</strong>. This attribute is valuable when you need to hide decorative or redundant content from screen readers while still maintaining its visual presence.</p>
<p>The <strong class="code-highlight-primary">&#8220;aria-hidden&#8221;</strong> attribute allows you to control whether an element should be announced by screen readers or not.</p>
<p>Set <strong class="code-highlight-primary">&#8220;aria-hidden=&#8217;true'&#8221;</strong> to hide an element from assistive technologies, and <strong class="code-highlight-primary">&#8220;aria-hidden=&#8217;false'&#8221;</strong> to make it accessible.</p>
<p>This attribute is useful for decorative elements, icons, or other content that may not contribute meaningfully to the user experience when read aloud.</p>
<p>Use <strong class="code-highlight-primary">&#8220;aria-hidden&#8221;</strong> responsibly to balance visual design with accessibility requirements.</p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&nbsp; &nbsp; &lt;<span style="color: #000000; font-weight: bold;">div</span> aria-hidden<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;true&quot;</span>&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;!-- Decorative or redundant <span style="color: #000066;">content</span> not announced by screen readers --&gt;<br />
&nbsp; &nbsp; &lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</div></td></tr></tbody></table></div>
</div>
<p><!-- 10. aria-invalid --></p>
<hr class="spacer-large" />
<div id="aria-invalid">
<h2>10. aria-invalid:</h2>
<p>Improve user interaction by utilizing <strong class="code-highlight-primary">&#8220;aria-invalid&#8221;</strong> to indicate whether the user input for a form element is valid. This attribute is particularly useful for alerting users to errors in real-time.</p>
<p>The <strong class="code-highlight-primary">&#8220;aria-invalid&#8221;</strong> attribute is essential for enhancing the accessibility of form validation feedback, especially for users relying on screen readers.</p>
<p>When user input is invalid, set <strong class="code-highlight-primary">&#8220;aria-invalid=&#8217;true'&#8221;</strong> on the form field, and associate a relevant error message using <strong class="code-highlight-primary">&#8220;aria-describedby&#8221;</strong>.</p>
<p>By doing so, you provide clear and timely information to users about the nature of the error, fostering a more inclusive user experience.</p>
<p>Always ensure that error messages are concise, descriptive, and assist users in correcting their input.</p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&nbsp; &nbsp; &lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> aria-invalid<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;true&quot;</span> aria-describedby<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;error-message&quot;</span>&gt;<br />
&nbsp; &nbsp; &lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;error-message&quot;</span>&gt;Please enter a valid <span style="color: #000066;">value</span>.&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</div></td></tr></tbody></table></div>
</div>
<p><!-- 11. aria-label --></p>
<hr class="spacer-large" />
<div id="aria-label">
<h2>11. aria-label:</h2>
<p>Enhance accessibility by providing a concise label for an element when a visible label is not present. Use <strong class="code-highlight-primary">&#8220;aria-label&#8221;</strong> to ensure that users with assistive technologies receive meaningful information.</p>
<p>The <strong class="code-highlight-primary">&#8220;aria-label&#8221;</strong> attribute is crucial for elements that require a label but do not have visible text content.</p>
<p>When using <strong class="code-highlight-primary">&#8220;aria-label&#8221;</strong>, provide a succinct and descriptive label that conveys the purpose or function of the element to users relying on screen readers.</p>
<p>Common use cases for <strong class="code-highlight-primary">&#8220;aria-label&#8221;</strong> include icon buttons, custom controls, or standalone interactive elements.</p>
<p>Ensure that the label you provide through <strong class="code-highlight-primary">&#8220;aria-label&#8221;</strong> is equivalent to what a sighted user would understand from the visible content.</p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&nbsp; &nbsp; &lt;<span style="color: #000000; font-weight: bold;">button</span> aria-<span style="color: #000066;">label</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Close&quot;</span>&gt;X&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">button</span>&gt;</div></td></tr></tbody></table></div>
</div>
<p><!-- 12. aria-labelledby --></p>
<hr class="spacer-large" />
<div id="aria-labelledby">
<h2>12. aria-labelledby:</h2>
<p>Establish a relationship between an element and its label by employing <strong class="code-highlight-primary">&#8220;aria-labelledby&#8221;</strong>. This attribute points to the IDs of elements that serve as labels, ensuring a clear association.</p>
<p>The <strong class="code-highlight-primary">&#8220;aria-labelledby&#8221;</strong> attribute is particularly useful when an element&#8217;s label is provided by one or more visible or invisible elements on the page.</p>
<p>Set <strong class="code-highlight-primary">&#8220;aria-labelledby&#8221;</strong> with the IDs of the labeling elements, and screen readers will announce the content of those elements as the label for the associated element.</p>
<p>This attribute enhances the accessibility of complex interfaces with multiple pieces of related information or descriptive content.</p>
<p>Always ensure that the labeled elements have semantic relevance to the associated element to provide meaningful context to users.</p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&nbsp; &nbsp; &lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;title&quot;</span>&gt;Product Details&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;<br />
&nbsp; &nbsp; &lt;<span style="color: #000000; font-weight: bold;">div</span> aria-labelledby<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;title&quot;</span>&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;!-- <span style="color: #000066;">Content</span> related to product details --&gt;<br />
&nbsp; &nbsp; &lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</div></td></tr></tbody></table></div>
</div>
<p><!-- 13. aria-live --></p>
<hr class="spacer-large" />
<div id="aria-live">
<h2>13. aria-live:</h2>
<p>Enable dynamic content updates to be announced to users by using <strong class="code-highlight-primary">&#8220;aria-live&#8221;</strong>. This attribute is particularly valuable when content changes dynamically, ensuring that users receive timely information.</p>
<p>The value of <strong class="code-highlight-primary">&#8220;aria-live&#8221;</strong> can be set to different values based on the urgency of the content updates. For example, &#8220;off&#8221; indicates that updates should not be announced, &#8220;polite&#8221; requests that user agents announce updates at the next convenient time, and &#8220;assertive&#8221; instructs user agents to announce updates immediately.</p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&nbsp; &nbsp; &lt;<span style="color: #000000; font-weight: bold;">div</span> aria-live<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;assertive&quot;</span>&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;!-- Dynamic <span style="color: #000066;">content</span> updates announced immediately --&gt;<br />
&nbsp; &nbsp; &lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</div></td></tr></tbody></table></div>
</div>
<p><!-- 14. aria-multiline --></p>
<hr class="spacer-large" />
<div id="aria-multiline">
<h2>14. aria-multiline:</h2>
<p>Facilitate user input by indicating whether a text box or similar element should support multiple lines of input. Use <strong class="code-highlight-primary">&#8220;aria-multiline&#8221;</strong> to enhance the user experience of multiline text areas.</p>
<p>This attribute is particularly useful when dealing with text areas where users are expected to input longer portions of text. Setting <strong class="code-highlight-primary">&#8220;aria-multiline&#8221;</strong> to &#8220;true&#8221; informs assistive technologies that the input can span multiple lines.</p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&nbsp; &nbsp; &lt;<span style="color: #000000; font-weight: bold;">textarea</span> aria-multiline<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;true&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">textarea</span>&gt;</div></td></tr></tbody></table></div>
</div>
<p><!-- 15. aria-multiselectable --></p>
<hr class="spacer-large" />
<div id="aria-multiselectable">
<h2>15. aria-multiselectable:</h2>
<p>Enhance the functionality of lists or grids by specifying whether multiple items can be selected simultaneously. Utilize <strong class="code-highlight-primary">&#8220;aria-multiselectable&#8221;</strong> to create more versatile and user-friendly interfaces.</p>
<p>For lists or grids where users can make multiple selections at the same time, set <strong class="code-highlight-primary">&#8220;aria-multiselectable&#8221;</strong> to &#8220;true.&#8221; This allows users to interact with and select multiple items concurrently.</p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&nbsp; &nbsp; &lt;<span style="color: #000000; font-weight: bold;">ul</span> role<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;listbox&quot;</span> aria-multiselectable<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;true&quot;</span>&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;!-- List items that can be <span style="color: #000066;">selected</span> simultaneously --&gt;<br />
&nbsp; &nbsp; &lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">ul</span>&gt;</div></td></tr></tbody></table></div>
</div>
<p><!-- 16. aria-orientation --></p>
<hr class="spacer-large" />
<div id="aria-orientation">
<h2>16. aria-orientation:</h2>
<p>Tailor the experience of sliders or scrollbars by defining their orientation with <strong class="code-highlight-primary">&#8220;aria-orientation&#8221;</strong>. This attribute informs assistive technologies whether the slider or scrollbar is horizontal or vertical, enhancing user understanding.</p>
<p>When implementing sliders or scrollbars, use <strong class="code-highlight-primary">&#8220;aria-orientation&#8221;</strong> to convey whether the element is oriented horizontally or vertically. This information assists users in navigating and interacting with the content.</p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&nbsp; &nbsp; &lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;range&quot;</span> aria-orientation<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;vertical&quot;</span>&gt;</div></td></tr></tbody></table></div>
</div>
<p><!-- 17. aria-pressed --></p>
<hr class="spacer-large" />
<div id="aria-pressed">
<h2>17. aria-pressed:</h2>
<p>Enhance the accessibility of toggle buttons by using <strong class="code-highlight-primary">&#8220;aria-pressed&#8221;</strong> to indicate their current &#8220;pressed&#8221; state. This attribute is valuable for conveying the status of toggleable elements.</p>
<p>For buttons that can be toggled on or off, set <strong class="code-highlight-primary">&#8220;aria-pressed&#8221;</strong> to &#8220;true&#8221; when the button is pressed or in the active state. This provides users with clear feedback about the current status of the button.</p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&nbsp; &nbsp; &lt;<span style="color: #000000; font-weight: bold;">button</span> aria-pressed<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;true&quot;</span>&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; Toggle On<br />
&nbsp; &nbsp; &lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">button</span>&gt;</div></td></tr></tbody></table></div>
</div>
<p><!-- 18. aria-readonly --></p>
<hr class="spacer-large" />
<div id="aria-readonly">
<h2>18. aria-readonly:</h2>
<p>Communicate whether an element is in a read-only state with <strong class="code-highlight-primary">&#8220;aria-readonly&#8221;</strong>. This attribute is particularly useful for informing users when they cannot modify the content of an element.</p>
<p>When presenting content that users can view but not modify, set <strong class="code-highlight-primary">&#8220;aria-readonly&#8221;</strong> to &#8220;true.&#8221; This alerts users that the content is read-only and helps in managing user expectations.</p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&nbsp; &nbsp; &lt;<span style="color: #000000; font-weight: bold;">textarea</span> aria-<span style="color: #000066;">readonly</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;true&quot;</span>&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;!-- Read-only <span style="color: #000066;">text</span> <span style="color: #000066;">content</span> --&gt;<br />
&nbsp; &nbsp; &lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">textarea</span>&gt;</div></td></tr></tbody></table></div>
</div>
<p><!-- 19. aria-required --></p>
<hr class="spacer-large" />
<div id="aria-required">
<h2>19. aria-required:</h2>
<p>Use <strong class="code-highlight-primary">&#8220;aria-required&#8221;</strong> to indicate that user input is mandatory on an element. This attribute is crucial for providing clear instructions to users and promoting form completion.</p>
<p>When designing forms, set <strong class="code-highlight-primary">&#8220;aria-required&#8221;</strong> to &#8220;true&#8221; for input fields that require user input. This informs users that the associated input is mandatory for successful form submission.</p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&nbsp; &nbsp; &lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> aria-required<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;true&quot;</span>&gt;</div></td></tr></tbody></table></div>
</div>
<p><!-- 20. aria-selected --></p>
<hr class="spacer-large" />
<div id="aria-selected">
<h2>20. aria-selected:</h2>
<p>Optimize the accessibility of selectable elements within lists by utilizing <strong class="code-highlight-primary">&#8220;aria-selected&#8221;</strong>. This attribute indicates whether an option or item in a list is currently selected.</p>
<p>When dealing with lists where users can make selections, set <strong class="code-highlight-primary">&#8220;aria-selected&#8221;</strong> to &#8220;true&#8221; for the items that are currently selected. This provides users with a clear visual indication of their choices.</p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&nbsp; &nbsp; &lt;<span style="color: #000000; font-weight: bold;">li</span> role<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;option&quot;</span> aria-<span style="color: #000066;">selected</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;true&quot;</span>&gt;Item <span style="color: #cc66cc;">1</span>&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span><br />
<br />
&gt;</div></td></tr></tbody></table></div>
</div>
<p><!-- 21. aria-sort --></p>
<hr class="spacer-large" />
<div id="aria-sort">
<h2>21. aria-sort:</h2>
<p>Enhance the usability of sortable table columns by defining the sort order with <strong class="code-highlight-primary">&#8220;aria-sort&#8221;</strong>. This attribute communicates whether a column is currently sorted and the sorting direction.</p>
<p>For tables with sortable columns, set <strong class="code-highlight-primary">&#8220;aria-sort&#8221;</strong> to indicate the current sorting status. Values like &#8220;ascending,&#8221; &#8220;descending,&#8221; and &#8220;none&#8221; can be used to convey the sorting direction.</p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&nbsp; &nbsp; &lt;<span style="color: #000000; font-weight: bold;">th</span> aria-sort<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;ascending&quot;</span>&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; Column Header<br />
&nbsp; &nbsp; &lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">th</span>&gt;</div></td></tr></tbody></table></div>
</div>
<p><!-- 22. aria-valuemax --></p>
<hr class="spacer-large" />
<div id="aria-valuemax">
<h2>22. aria-valuemax:</h2>
<p>Define the maximum allowed value for range widgets with <strong class="code-highlight-primary">&#8220;aria-valuemax&#8221;</strong>. This attribute is essential for providing information about the upper limit of a range.</p>
<p>When working with range inputs, set <strong class="code-highlight-primary">&#8220;aria-valuemax&#8221;</strong> to specify the maximum allowed value. This assists users in understanding the range and setting appropriate values.</p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&nbsp; &nbsp; &lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;range&quot;</span> aria-valuemax<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;100&quot;</span>&gt;</div></td></tr></tbody></table></div>
</div>
<p><!-- 23. aria-valuemin --></p>
<hr class="spacer-large" />
<div id="aria-valuemin">
<h2>23. aria-valuemin:</h2>
<p>Set the minimum allowed value for range widgets using <strong class="code-highlight-primary">&#8220;aria-valuemin&#8221;</strong>. This attribute communicates the lower limit of the range.</p>
<p>Similarly, for range inputs, use <strong class="code-highlight-primary">&#8220;aria-valuemin&#8221;</strong> to define the minimum allowed value. This information guides users in understanding the range and making appropriate selections.</p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&nbsp; &nbsp; &lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;range&quot;</span> aria-valuemin<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;0&quot;</span>&gt;</div></td></tr></tbody></table></div>
</div>
<p><!-- 24. aria-valuenow --></p>
<hr class="spacer-large" />
<div id="aria-valuenow">
<h2>24. aria-valuenow:</h2>
<p>Dynamically communicate the current value of range widgets with <strong class="code-highlight-primary">&#8220;aria-valuenow&#8221;</strong>. This attribute ensures that users are informed about the current position or setting.</p>
<p>When dealing with range inputs that can be adjusted by users, set <strong class="code-highlight-primary">&#8220;aria-valuenow&#8221;</strong> to indicate the current value. This provides real-time feedback on the selected position.</p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&nbsp; &nbsp; &lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;range&quot;</span> aria-valuenow<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;50&quot;</span>&gt;</div></td></tr></tbody></table></div>
</div>
<p><!-- 25. aria-valuetext --></p>
<hr class="spacer-large" />
<div id="aria-valuetext">
<h2>25. aria-valuetext:</h2>
<p>Enhance the accessibility of range widgets by providing a human-readable text alternative for the current value with <strong class="code-highlight-primary">&#8220;aria-valuetext&#8221;</strong>. This attribute is particularly beneficial for conveying complex or non-numeric values.</p>
<p>When dealing with ranges where numeric values might not fully convey meaning, use <strong class="code-highlight-primary">&#8220;aria-valuetext&#8221;</strong> to provide a descriptive, human-readable alternative. This ensures a more inclusive user experience.</p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&nbsp; &nbsp; &lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;range&quot;</span> aria-valuetext<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Medium&quot;</span>&gt;</div></td></tr></tbody></table></div>
</div>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/web-accessibility/all-aria-attributes-for-web-development-accessibility-library">All Aria Attributes for Web Development Accessibility &#8211; Library</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/web-accessibility/all-aria-attributes-for-web-development-accessibility-library/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Benefits of SlingSafeMethodsServlet with Code Examples</title>
		<link>https://sourcedcode.com/blog/aem/benefits-of-slingsafemethodsservlet-with-code-examples</link>
					<comments>https://sourcedcode.com/blog/aem/benefits-of-slingsafemethodsservlet-with-code-examples#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Sat, 02 Dec 2023 19:34:29 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Sling Servlet]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=6275</guid>

					<description><![CDATA[<p>A robust security strategy is pivotal to safeguarding applications. As an AEM developer, we must really understand the SlingSafeMethodsServlet, an invaluable feature within the Apache Sling framework. This article explores the core concepts, practical benefits, and the heightened security it brings to servlet development. The org.apache.sling.api.servlets.SlingSafeMethodsServlet is an extension of the trusted HttpServlet in Apache [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/benefits-of-slingsafemethodsservlet-with-code-examples">Benefits of SlingSafeMethodsServlet with Code Examples</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<section>
<p>A robust security strategy is pivotal to safeguarding applications. As an AEM developer, we must really understand the <strong>SlingSafeMethodsServlet</strong>, an invaluable feature within the Apache Sling framework. This article explores the core concepts, practical benefits, and the heightened security it brings to servlet development.</p>
<p>The <strong>org.apache.sling.api.servlets.SlingSafeMethodsServlet</strong> is an extension of the trusted HttpServlet in Apache Sling, introduces a focused approach to reinforcing security by limiting HTTP methods to read-only operations. This deep dive into its functionality unveils the foundation upon which secure servlets can be built.</p>
</section>
<div class="mention-block">
<strong>Quick Links</strong></p>
<ol>
<li><a href="#advanntages">Advantages of SlingSafeMethodsServlet</a></li>
<li><a href="#code-sample">SlingSafeMethodsServlet in Action: Example Use Case</a></li>
</ol>
</div>
<hr class="spacer-larger"/>
<section>
<h2 id="advanntages">Advantages of SlingSafeMethodsServlet</h2>
<ol>
<li>
                <strong>Read-Only Operations:</strong></p>
<p>At its core, SlingSafeMethodsServlet champions a read-only paradigm. This deliberate limitation ensures that servlets exclusively respond to safe HTTP methods, fortifying applications against unintentional data modifications.</p>
</li>
<li>
                <strong>Guard Against CSRF Attacks:</strong></p>
<p>By constraining actions to safe methods, SlingSafeMethodsServlet provides an inherent defense against Cross-Site Request Forgery (CSRF) attacks. This proactive measure significantly reduces the risk of unauthorized manipulations.</p>
</li>
<li>
                <strong>Built-In Support for Idempotent Methods:</strong></p>
<p>The servlet seamlessly integrates with idempotent methods like GET and HEAD, aligning with industry best practices. This default behavior enhances the predictability and reliability of request handling.</p>
</li>
<li>
                <strong>Resource-Based Permissions:</strong></p>
<p>Leveraging Sling&#8217;s resource resolution capabilities, SlingSafeMethodsServlet dynamically inherits permissions tied to resolved resources. This ensures a granular and secure access control model.</p>
</li>
</ol>
</section>
<hr class="spacer-larger"/>
<h2 id="code-sample">SlingSafeMethodsServlet in Action: Example Use Case</h2>
<p>In this practical example, the <span class="code-highlight-primary">ContentDisplayServlet:line17</span> showcases the seamless integration of SlingSafeMethodsServlet. The provided code exemplifies its application in retrieving and securely rendering content, encapsulating the essence of secure servlet development.</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.SlingHttpServletRequest</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.SlingHttpServletResponse</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.servlets.SlingSafeMethodsServlet</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.osgi.service.component.annotations.Component</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.json.JSONObject</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.servlet.ServletException</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.IOException</span><span style="color: #339933;">;</span><br />
<br />
@<span style="color: #003399;">Component</span><span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; service <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>javax.<span style="color: #006633;">servlet</span>.<span style="color: #006633;">Servlet</span>.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#125;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; property <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;sling.servlet.resourceTypes=yourapp/components/content&quot;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;sling.servlet.methods=GET&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#41;</span><br />
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ContentDisplayServlet <span style="color: #000000; font-weight: bold;">extends</span> SlingSafeMethodsServlet <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; @Override<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> doGet<span style="color: #009900;">&#40;</span>SlingHttpServletRequest request, SlingHttpServletResponse response<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> ServletException, <span style="color: #003399;">IOException</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Fetch and render content</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// ...</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Send JSON response</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; JSONObject jsonResponse <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> JSONObject<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; jsonResponse.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;success&quot;</span>, <span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; response.<span style="color: #006633;">setContentType</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;application/json&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; response.<span style="color: #006633;">setCharacterEncoding</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;UTF-8&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; response.<span style="color: #006633;">getWriter</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">write</span><span style="color: #009900;">&#40;</span>jsonResponse.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/benefits-of-slingsafemethodsservlet-with-code-examples">Benefits of SlingSafeMethodsServlet with Code Examples</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/benefits-of-slingsafemethodsservlet-with-code-examples/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Why a Self-Praise Document is Your Ticket to Promotion</title>
		<link>https://sourcedcode.com/blog/career-tips/why-a-self-praise-document-is-your-ticket-to-promotion</link>
					<comments>https://sourcedcode.com/blog/career-tips/why-a-self-praise-document-is-your-ticket-to-promotion#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Mon, 27 Nov 2023 01:40:30 +0000</pubDate>
				<category><![CDATA[Career Tips]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=6253</guid>

					<description><![CDATA[<p>It&#8217;s easy to lose track of the incredible milestones and accomplishments that shape our professional journey. That&#8217;s where the often-overlooked but incredibly powerful tool, the &#8220;Self-Praise Document,&#8221; comes into play. If you don&#8217;t already have one, let&#8217;s explore why creating a self-praise document might be the game-changer you need for a quicker path to promotion. [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/career-tips/why-a-self-praise-document-is-your-ticket-to-promotion">Why a Self-Praise Document is Your Ticket to Promotion</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>It&#8217;s easy to lose track of the incredible milestones and accomplishments that shape our professional journey. That&#8217;s where the often-overlooked but incredibly powerful tool, the &#8220;Self-Praise Document,&#8221; comes into play. If you don&#8217;t already have one, let&#8217;s explore why creating a self-praise document might be the game-changer you need for a quicker path to promotion.</p>
<div class="mention-block">
        <strong>Summary:</strong></p>
<ol>
<li><a href="#section-1">Why a Self-Praise Document is Your Ticket to Promotion</a></li>
<li><a href="#section-2">How to Create Your Self-Praise Document for Promotion Success</a></li>
<ol>
<li><a href="#subsection-2.1">Choose Your Platform</a></li>
<li><a href="#subsection-2.2">Identify Impactful Achievements</a></li>
<li><a href="#subsection-2.3">Include Specifics</a></li>
</ol>
<li><a href="#section-3">Balancing Act: Quality Over Quantity for Promotion Success</a></li>
<li><a href="#section-4">The Future You, Promoted and Thankful</a></li>
</ol></div>
<hr class="spacer-larger" />
<h2 id="section-1">1. Why a Self-Praise Document is Your Ticket to Promotion</h2>
<p>Imagine this scenario: It&#8217;s the end of the year, and you&#8217;re sitting down for your annual review or contemplating updating your resume for that coveted promotion. Your mind draws a blank, struggling to recall all the fantastic projects you&#8217;ve spearheaded, the challenges you&#8217;ve conquered, and the positive impact you&#8217;ve had on your team and the company. Enter the self-praise document.</p>
<p>A self-praise document is not just a personal pat on the back; it&#8217;s a strategic tool to propel your career forward. It&#8217;s a curated list of your professional accomplishments and noteworthy moments, serving as a quick reference guide for those times when you need to showcase your achievements to secure that well-deserved promotion.</p>
<hr class="spacer-larger" />
<h2 id="section-2">2. How to Create Your Self-Praise Document for Promotion Success</h2>
<div class="mention-block--gold">
<strong>Quick Links</strong></p>
<ol>
<li><a href="#subsection-2.1">Choose Your Platform</a></li>
<li><a href="#subsection-2.2">Identify Impactful Achievements</a></li>
<li><a href="#subsection-2.3">Include Specifics</a></li>
</ol>
</div>
<h3 id="subsection-2.1" style="margin-top: 60px;">2.1 Choose Your Platform</h3>
<p>Whether it&#8217;s Notion, Evernote, Google Docs, or any other cloud-based tool, the key is to have your self-praise document easily accessible. This ensures you won&#8217;t lose your valuable insights, even if you switch jobs or face unexpected computer crashes.</p>
<h3 id="subsection-2.2" style="margin-top: 60px;">2.2 Identify Impactful Achievements</h3>
<p>Focus on entries that made a significant difference in your work or for your team. Did you go above and beyond in a project? Were you instrumental in implementing a new process that saved the company money? These are the details that will set you apart and make a compelling case for promotion.</p>
<p><strong>Examples:</strong><br />
<em>Bad (Basic) Entry: </em>&#8220;Led a successful marketing campaign.&#8221;</p>
<p><em>Good (Enhanced) Entry: </em>&#8220;Drove a highly successful marketing campaign that exceeded projected ROI by 25%. Through strategic audience targeting and collaboration with cross-functional teams, we not only achieved our sales targets but also enhanced brand visibility, positioning the company as an industry </p>
<h3 id="subsection-2.3" style="margin-top: 60px;">2.3 Include Specifics</h3>
<p>Don&#8217;t just jot down a general accomplishment; provide enough details to recreate the scenario later. Your future self will thank you when you&#8217;re able to recall the specific challenges you overcame and the impact you had.</p>
<p><strong>Examples:</strong></p>
<p><em>Bad (Basic) Entry: </em>&#8220;Led team to implement project management system for improved efficiency.&#8221;</p>
<p><em>Better (Enhanced) Entry:</em> &#8220;As project lead, orchestrated cross-functional team in the seamless integration of an advanced project management system. Overcame challenges like software glitches and team resistance through proactive communication and support. Resulted in a 30% reduction in project timelines, boosting overall team productivity and fostering a culture of collaboration.&#8221;</p>
<p>This concise yet detailed approach ensures your future self can vividly recall the specific challenges you conquered and the impactful outcomes of your efforts.</p>
<hr class="spacer-larger" />
<h2 id="section-3">3. Balancing Act: Quality Over Quantity for Promotion Success</h2>
<p>While it&#8217;s essential to document your achievements, striking the right balance is crucial, especially when eyeing that promotion. Avoid going overboard with every minor success; instead, focus on the accomplishments that truly showcase your skills and contributions. The goal is not just to list achievements but to highlight your capacity to make a meaningful impact and contribute to the company&#8217;s growth.</p>
<hr class="spacer-larger" />
<h2 id="section-4">4. The Future You, Promoted and Thankful</h2>
<p>Think of your self-praise document as a promotion roadmap. When future opportunities arise, whether it&#8217;s a new job, a promotion, or updating your resume, you&#8217;ll have a comprehensive and easily accessible record to draw from. Past Steve&#8217;s foresight in creating the self-praise document becomes a gift to future Steve, who is not just climbing the career ladder but doing it faster.</p>
<p>So, take a moment to start your self-praise document today with an eye on that promotion. Your career trajectory might just thank you for it. And if you&#8217;re looking for inspiration or curious to see what an actual self-praise document looks like, check out my channel for more high-leverage techniques and an inside look at my personal self-praise document. Because success is not just about doing great things; it&#8217;s about remembering them when it matters most, especially when promotion season arrives.</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/career-tips/why-a-self-praise-document-is-your-ticket-to-promotion">Why a Self-Praise Document is Your Ticket to Promotion</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/career-tips/why-a-self-praise-document-is-your-ticket-to-promotion/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Try-With-Resources: Ensuring Session Closure, AEM Code Example</title>
		<link>https://sourcedcode.com/blog/aem/try-with-resources-ensuring-session-closure-aem-code-example</link>
					<comments>https://sourcedcode.com/blog/aem/try-with-resources-ensuring-session-closure-aem-code-example#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Wed, 22 Nov 2023 05:53:06 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Development]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=6239</guid>

					<description><![CDATA[<p>In the dynamic realm of Java programming in AEM, effective resource management is a cornerstone of writing robust and reliable code. The &#8220;try-with-resources&#8221; statement, introduced in Java 7, emerges as a powerful ally in simplifying resource handling. This article delves into the practical implementation of &#8220;Try-With-Resources&#8221; within the context of a specific code snippet, emphasizing [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/try-with-resources-ensuring-session-closure-aem-code-example">Try-With-Resources: Ensuring Session Closure, AEM Code Example</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>In the dynamic realm of Java programming in AEM, effective resource management is a cornerstone of writing robust and reliable code. The &#8220;try-with-resources&#8221; statement, introduced in Java 7, emerges as a powerful ally in simplifying resource handling. This article delves into the practical implementation of &#8220;Try-With-Resources&#8221; within the context of a specific code snippet, emphasizing the importance of never forgetting to close the session.</p>
<p>The adoption of &#8220;Try-With-Resources&#8221; in your code exemplifies a commitment to clean, efficient, and error-resistant Java programming. By embracing this feature, you not only reduce boilerplate code but also mitigate the risk of resource leaks, ensuring the reliable closure of the session. The article underscores the significance of &#8220;Try-With-Resources&#8221; within the broader theme of never forgetting to close the session, offering developers valuable insights into crafting resilient and maintainable code.</p>
<hr class="spacer-large" />
<h2>Try-With-Resources AEM Example Code</h3>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #000000; font-weight: bold;">final</span> Map<span style="color: #339933;">&lt;</span><span style="color: #003399;">String</span>, Object<span style="color: #339933;">&gt;</span> authInfo <span style="color: #339933;">=</span> <span style="color: #003399;">Collections</span>.<span style="color: #006633;">singletonMap</span><span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; ResourceResolverFactory.<span style="color: #006633;">SUBSERVICE</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;sourcedCodeSystemUser&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#40;</span>ResourceResolver resolver <span style="color: #339933;">=</span> factory.<span style="color: #006633;">getServiceResourceResolver</span><span style="color: #009900;">&#40;</span>authInfo<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; Session session <span style="color: #339933;">=</span> resolver.<span style="color: #006633;">adaptTo</span><span style="color: #009900;">&#40;</span>Session.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; Node contentNode <span style="color: #339933;">=</span> session.<span style="color: #006633;">getNode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/content/sourcedcode/jcr:content&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>Objects.<span style="color: #006633;">nonNull</span><span style="color: #009900;">&#40;</span>contentNode<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; contentNode.<span style="color: #006633;">setProperty</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;newProperty&quot;</span>, <span style="color: #0000ff;">&quot;value&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; contentNode.<span style="color: #006633;">setProperty</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;existingProperty&quot;</span>, <span style="color: #0000ff;">&quot;value&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; contentNode.<span style="color: #006633;">setProperty</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;existingProperty&quot;</span>, <span style="color: #009900;">&#40;</span>Value<span style="color: #009900;">&#41;</span><span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Remove property</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; session.<span style="color: #006633;">save</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; e.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>In the spirit of &#8220;Try-With-Resources,&#8221; your code exemplifies the essence of effective resource management. The central focus is on ensuring the closure of the session resource, a critical component in Java Content Repository (JCR) operations.</p>
<div class="mention-block">
<strong>Exploring AEM Service Users: A Simple Setup Guide</strong><br />
Dive into the world of Adobe Experience Manager with our blog post, &#8220;Exploring AEM Service Users.&#8221; Whether you&#8217;re on AEMaaCS or AEM 6.5.4+, we&#8217;ve got you covered with an easy-to-follow guide on setting up a system user. No jargon, just straightforward steps to demystify the AEM service user. Enhance your AEM experience effortlessly – check out our blog and learn today -> <a href="https://sourcedcode.com/blog/aem/create-system-service-users-in-aem-6-5-with-code-configurations">https://sourcedcode.com/blog/aem/create-system-service-users-in-aem-6-5-with-code-configurations</a>
</div>
<hr class="spacer-large" />
<h3>Understanding the Code:</h3>
<p>Within the try block, the &#8220;ResourceResolver&#8221; and its associated &#8220;Session&#8221; resource are declared using &#8220;Try-With-Resources.&#8221; The factory object, presumably an instance of a ResourceResolverFactory, facilitates obtaining a service resource resolver with specific authentication information (authInfo). The resolver is seamlessly adapted to a session, streamlining the process.</p>
<p>As the code interacts with the JCR node located at &#8220;/content/sourcedcode/jcr:content,&#8221; the session enables the manipulation of node properties. The try-with-resources statement guarantees that both the &#8220;ResourceResolver&#8221; and the &#8220;Session&#8221; are automatically closed at the conclusion of the block, eliminating the need for explicit closure statements.</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/try-with-resources-ensuring-session-closure-aem-code-example">Try-With-Resources: Ensuring Session Closure, AEM Code Example</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/try-with-resources-ensuring-session-closure-aem-code-example/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Brian Li AEM Enthusiast and AEM Technical Lead in Vancouver</title>
		<link>https://sourcedcode.com/blog/aem/brian-li-aem-enthusiast-and-aem-technical-lead-in-vancouver</link>
					<comments>https://sourcedcode.com/blog/aem/brian-li-aem-enthusiast-and-aem-technical-lead-in-vancouver#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Tue, 21 Nov 2023 06:44:35 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=6220</guid>

					<description><![CDATA[<p>Welcome to my blog! I&#8217;m Brian Li, an enthusiastic AEM technical explorer based in Vancouver(BC, Canada) &#038; of course your AEM Champion 2024-2025. Within my blog, I invite you to join me on a journey through the fascinating world of Adobe Experience Manager (AEM). From the intricacies of AJAX, Java, JavaScript, and HTML to the [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/brian-li-aem-enthusiast-and-aem-technical-lead-in-vancouver">Brian Li AEM Enthusiast and AEM Technical Lead in Vancouver</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Welcome to my blog! </p>
<p>I&#8217;m Brian Li, an enthusiastic AEM technical explorer based in Vancouver(BC, Canada) &#038; of course your <a href="https://business.adobe.com/blog/the-latest/introducing-the-adobe-champion-class-of-2024-2025" rel="noopener" target="_blank">AEM Champion 2024-2025</a>. Within my blog, I invite you to join me on a journey through the fascinating world of Adobe Experience Manager (AEM). From the intricacies of AJAX, Java, JavaScript, and HTML to the dynamic landscape of crafting digital experiences, I&#8217;m here to share insights, experiences, and the latest developments in the AEM realm.</p>
<p>Before diving into the technical nuances, let me give you a glimpse into my professional adventure. As the AEM Solutions Architect &#038; AEM Technical Lead at MNP Digital, I immerse myself in the creative process of seamlessly integrating cutting-edge AEM requirements. My journey has taken me through roles such as AEM Technical Lead and Lead Software Full Stack Engineer at Finning, where I transformed conceptual ideas into tangible tech realities.</p>
<p>Beyond the borders of Vancouver(BC, Canada), my exploration extended to London(United Kingdom) with Whitbread and HSBC, where I proudly served as the Lead/Senior Software Engineer for four years. During this time, I not only contributed to cutting-edge digital experiences but also pioneered the development of an AEM white label framework—simplifying the creation of new AEM websites for enterprise giants.</p>
<p>In addition to my professional ventures, I actively contribute to the <a href="https://experienceleaguecommunities.adobe.com/t5/user/viewprofilepage/user-id/879119" rel="noopener" target="_blank">AEM Community Forum</a>. I&#8217;ve developed a widely-utilized <a href="https://chromewebstore.google.com/detail/aem-chrome-extension-sour/ebhapiodakbafkjhegnfcmohjccfedkm?pli=1" rel="noopener" target="_blank">AEM Chrome extension</a>, making a daily impact on 2800 users globally. My blog, a hub for tech enthusiasts, attracts around 200,000 visitors each year. Holding the <a href="https://experienceleaguecommunities.adobe.com/t5/user/viewprofilepage/user-id/879119" rel="noopener" target="_blank">AEM Community Advisor Coach Badge</a>, <a href="https://certification.adobe.com/credential/verify/166a093c-3882-11f0-9b2a-42010a400fc3" rel="noopener" target="_blank">the Adobe Experience Manager Sites Architect Master Certification</a>, <a href="https://www.credly.com/users/briankasingli/badges#credly" rel="noopener" target="_blank">the Adobe Experience Manager Sites Lead Developer Certification</a>, <a href="https://www.credly.com/users/briankasingli/badges#credly" rel="noopener" target="_blank">the Adobe Experience Manager Sites Expert Developer Certification</a>, I&#8217;m dedicated to sharing valuable insights on this blog. </p>
<p>I&#8217;m also the creator of the <a href="https://chatgpt.com/g/g-Vm2dc9HlL-aem-developer-gpt-by-sourcedcode-com" rel="noopener" target="_blank">AEM Developer GPT AI tool</a>, which empowers over 25,000 active users with AI-assisted development capabilities. </p>
<p>Education is another facet of my journey—I&#8217;m a private <a href="https://www.codementor.io/@briankasingli" rel="noopener" target="_blank">AEM instructor</a>, passionate about propelling AEM developers to new levels of expertise. Through this, I aim to empower fellow enthusiasts with the skills necessary to thrive in the ever-evolving AEM landscape.</p>
<p>So, welcome to this digital exploration! Whether you&#8217;re a seasoned tech professional or a curious newcomer, I hope this blog becomes a valuable resource for insights, learning, and collaboration. If you&#8217;re seeking a passionate and experienced collaborator, I&#8217;m here and ready to connect. Let&#8217;s work together!</p>
<hr class="spacer-large"/>
<h3>Brian&#8217;s Links</h3>
<p><strong>Mentor Me on CodeMentor!<br /></strong><a title="codementor" href="https://bit.ly/3xXpUeA" target="_blank" rel="noopener">https://www.codementor.io/@briankasingli</a></p>
<p><strong>Linkedin</strong> (follow me) <br /><a title="Briankasingli's linkedin Profile URL" href="https://bit.ly/3cqMNiT" target="_blank" rel="noopener">https://www.linkedin.com/in/briankasingli</a></p>
<p><strong>SourcedCode Premium Tool</strong><br /><a title="AEM Chrome Extension (Chromium Extension) link" href="https://bit.ly/3CwOvKe" target="_blank" rel="noopener">AEM Chrome Extension</a></p>
<p><strong>AEM Developer GPT AI Tool</strong><br /><a title="AEM Developer GPT AI Tool" href="https://chatgpt.com/g/g-Vm2dc9HlL-aem-developer-gpt-by-sourcedcode-com" target="_blank" rel="noopener">AEM Developer GPT AI Tool</a></p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/brian-li-aem-enthusiast-and-aem-technical-lead-in-vancouver">Brian Li AEM Enthusiast and AEM Technical Lead in Vancouver</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/brian-li-aem-enthusiast-and-aem-technical-lead-in-vancouver/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>AEM Convert Excel to JSON Simple Servlet Example</title>
		<link>https://sourcedcode.com/blog/aem/aem-convert-excel-to-json-simple-servlet-example</link>
					<comments>https://sourcedcode.com/blog/aem/aem-convert-excel-to-json-simple-servlet-example#comments</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Thu, 02 Nov 2023 01:28:53 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Short Post]]></category>
		<category><![CDATA[Sling Servlet]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=6192</guid>

					<description><![CDATA[<p>In this article, I present a straightforward yet powerful solution that demonstrates how to seamlessly convert Excel data into JSON format using Adobe Experience Manager (AEM). By implementing a custom servlet, I will illustrate the process of converting an Excel sheet named &#8216;example.xlsx&#8217; into structured JSON data; it can be downloaded below for you following [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/aem-convert-excel-to-json-simple-servlet-example">AEM Convert Excel to JSON Simple Servlet Example</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>In this article, I present a straightforward yet powerful solution that demonstrates how to seamlessly convert Excel data into JSON format using Adobe Experience Manager (AEM). By implementing a custom servlet, I will illustrate the process of converting an Excel sheet named &#8216;example.xlsx&#8217; into structured JSON data; it can be downloaded below for you following this tutorial. This tutorial is validated on both AEM 6.5 with the latest Service Pack and AEM as a Cloud Service (AEMaaCS), ensuring its compatibility with diverse AEM environments.</p>
<p><strong>Resource File:</strong><br />
<a href="https://sourcedcode.com/blog/aem/aem-convert-excel-to-json-simple-servlet-example/attachment/example" rel="attachment wp-att-6196">example.xlsx</a></p>
<hr class="spacer-large"/>
<p><strong>Request URI:</strong><br />
The request URI for accessing the JSON output through the ExampleServlet that we&#8217;ve been discussing would typically look like this:</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//localhost:4502/bin/exportexcelfortext.json</span></div></td></tr></tbody></table></div>
<hr class="spacer-large"/>
<p><strong>JSON Output:</strong></p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #009900;">&#123;</span><br />
&nbsp; <span style="color: #0000ff;">&quot;people&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span> <span style="color: #0000ff;">&quot;name&quot;</span><span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;Brian&quot;</span>, <span style="color: #0000ff;">&quot;age&quot;</span><span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;100&quot;</span> <span style="color: #009900;">&#125;</span>,<br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span> <span style="color: #0000ff;">&quot;name&quot;</span><span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;Doris&quot;</span>, <span style="color: #0000ff;">&quot;age&quot;</span><span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;20&quot;</span> <span style="color: #009900;">&#125;</span>,<br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span> <span style="color: #0000ff;">&quot;name&quot;</span><span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;Stuart&quot;</span>, <span style="color: #0000ff;">&quot;age&quot;</span><span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;103&quot;</span> <span style="color: #009900;">&#125;</span>,<br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span> <span style="color: #0000ff;">&quot;name&quot;</span><span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;David&quot;</span>, <span style="color: #0000ff;">&quot;age&quot;</span><span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;5&quot;</span> <span style="color: #009900;">&#125;</span><br />
&nbsp; <span style="color: #009900;">&#93;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<hr class="spacer-large"/>
<p><strong>Servlet Implementation ExcelExampleServlet.java:</strong></p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br />78<br />79<br />80<br />81<br />82<br />83<br />84<br />85<br />86<br />87<br />88<br />89<br />90<br />91<br />92<br />93<br />94<br />95<br />96<br />97<br />98<br />99<br />100<br />101<br />102<br />103<br />104<br />105<br />106<br />107<br />108<br />109<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.sourcedcode.core.servlets</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.fasterxml.jackson.databind.ObjectMapper</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.poi.ss.usermodel.*</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.poi.xssf.usermodel.XSSFWorkbook</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.SlingHttpServletRequest</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.SlingHttpServletResponse</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.resource.Resource</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.resource.ResourceResolver</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.servlets.SlingSafeMethodsServlet</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.osgi.service.component.annotations.Component</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.servlet.Servlet</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.servlet.http.HttpServletResponse</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.IOException</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.InputStream</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.ArrayList</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.LinkedHashMap</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.List</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Map</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Objects</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.day.cq.dam.api.Asset</span><span style="color: #339933;">;</span><br />
<br />
@<span style="color: #003399;">Component</span><span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; service <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span> Servlet.<span style="color: #000000; font-weight: bold;">class</span> <span style="color: #009900;">&#125;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; property <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;sling.servlet.paths=/bin/exportexcelfortext&quot;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;sling.servlet.extensions=json&quot;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;sling.servlet.methods=GET&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#41;</span><br />
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ExcelExampleServlet <span style="color: #000000; font-weight: bold;">extends</span> SlingSafeMethodsServlet <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; @Override<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> doGet<span style="color: #009900;">&#40;</span>SlingHttpServletRequest request, SlingHttpServletResponse response<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">IOException</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Get the Excel file path in DAM</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">String</span> excelFilePath <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;/content/dam/example/example.xlsx&quot;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Get the resource resolver</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ResourceResolver resourceResolver <span style="color: #339933;">=</span> request.<span style="color: #006633;">getResourceResolver</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Check if the Excel file exists</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Resource excelResource <span style="color: #339933;">=</span> resourceResolver.<span style="color: #006633;">getResource</span><span style="color: #009900;">&#40;</span>excelFilePath<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>excelResource <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; response.<span style="color: #006633;">setStatus</span><span style="color: #009900;">&#40;</span>HttpServletResponse.<span style="color: #006633;">SC_NOT_FOUND</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Adapt the resource to an Asset</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Asset asset <span style="color: #339933;">=</span> Objects.<span style="color: #006633;">requireNonNull</span><span style="color: #009900;">&#40;</span>excelResource<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">adaptTo</span><span style="color: #009900;">&#40;</span>Asset.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>asset <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; response.<span style="color: #006633;">setStatus</span><span style="color: #009900;">&#40;</span>HttpServletResponse.<span style="color: #006633;">SC_INTERNAL_SERVER_ERROR</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Get an InputStream from the Asset's original</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">InputStream</span> excelInputStream <span style="color: #339933;">=</span> Objects.<span style="color: #006633;">requireNonNull</span><span style="color: #009900;">&#40;</span>asset<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getOriginal</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getStream</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Process the Excel content and convert it to JSON</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Workbook workbook <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> XSSFWorkbook<span style="color: #009900;">&#40;</span>excelInputStream<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; List<span style="color: #339933;">&lt;</span>Map<span style="color: #339933;">&lt;</span><span style="color: #003399;">String</span>, String<span style="color: #339933;">&gt;&gt;</span> jsonData <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ArrayList<span style="color: #339933;">&lt;&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Iterate through the Excel rows and columns</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Sheet sheet <span style="color: #339933;">=</span> workbook.<span style="color: #006633;">getSheetAt</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Assuming it's the first sheet</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Row headerRow <span style="color: #339933;">=</span> sheet.<span style="color: #006633;">getRow</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Assuming the first row is the header row</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">int</span> totalColumns <span style="color: #339933;">=</span> headerRow.<span style="color: #006633;">getLastCellNum</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> sheet.<span style="color: #006633;">getPhysicalNumberOfRows</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Row dataRow <span style="color: #339933;">=</span> sheet.<span style="color: #006633;">getRow</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Map<span style="color: #339933;">&lt;</span><span style="color: #003399;">String</span>, String<span style="color: #339933;">&gt;</span> rowMap <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> LinkedHashMap<span style="color: #339933;">&lt;&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> j <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> j <span style="color: #339933;">&lt;</span> totalColumns<span style="color: #339933;">;</span> j<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Cell headerCell <span style="color: #339933;">=</span> headerRow.<span style="color: #006633;">getCell</span><span style="color: #009900;">&#40;</span>j<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Cell dataCell <span style="color: #339933;">=</span> dataRow.<span style="color: #006633;">getCell</span><span style="color: #009900;">&#40;</span>j<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>headerCell <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span> <span style="color: #339933;">&amp;&amp;</span> dataCell <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Check the cell type to handle numeric and string values</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>dataCell.<span style="color: #006633;">getCellType</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> CellType.<span style="color: #006633;">STRING</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rowMap.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span>headerCell.<span style="color: #006633;">getStringCellValue</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, dataCell.<span style="color: #006633;">getStringCellValue</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>dataCell.<span style="color: #006633;">getCellType</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> CellType.<span style="color: #006633;">NUMERIC</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Handle numeric values as integers (remove decimals)</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">int</span> age <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#41;</span> dataCell.<span style="color: #006633;">getNumericCellValue</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rowMap.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span>headerCell.<span style="color: #006633;">getStringCellValue</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, <span style="color: #003399;">String</span>.<span style="color: #006633;">valueOf</span><span style="color: #009900;">&#40;</span>age<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jsonData.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>rowMap<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Prepare the JSON response</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; List<span style="color: #339933;">&lt;</span>Map<span style="color: #339933;">&lt;</span><span style="color: #003399;">String</span>, String<span style="color: #339933;">&gt;&gt;</span> peopleList <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ArrayList<span style="color: #339933;">&lt;&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>Map<span style="color: #339933;">&lt;</span><span style="color: #003399;">String</span>, String<span style="color: #339933;">&gt;</span> personData <span style="color: #339933;">:</span> jsonData<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Map<span style="color: #339933;">&lt;</span><span style="color: #003399;">String</span>, String<span style="color: #339933;">&gt;</span> person <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> LinkedHashMap<span style="color: #339933;">&lt;&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; person.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;name&quot;</span>, personData.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Name&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; person.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;age&quot;</span>, personData.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Age&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; peopleList.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>person<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Map<span style="color: #339933;">&lt;</span><span style="color: #003399;">String</span>, List<span style="color: #339933;">&lt;</span>Map<span style="color: #339933;">&lt;</span><span style="color: #003399;">String</span>, String<span style="color: #339933;">&gt;&gt;&gt;</span> jsonResponse <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> LinkedHashMap<span style="color: #339933;">&lt;&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jsonResponse.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;people&quot;</span>, peopleList<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Set response content type and write JSON content to the response</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; response.<span style="color: #006633;">setContentType</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;application/json&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; response.<span style="color: #006633;">getWriter</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">write</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> ObjectMapper<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">writeValueAsString</span><span style="color: #009900;">&#40;</span>jsonResponse<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; response.<span style="color: #006633;">setStatus</span><span style="color: #009900;">&#40;</span>HttpServletResponse.<span style="color: #006633;">SC_INTERNAL_SERVER_ERROR</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<hr class="spacer-large"/>
<p><strong>Servlet Depdendencies:</strong></p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #339933;">&lt;</span>dependencies<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;!--</span> Apache POI <span style="color: #000000; font-weight: bold;">for</span> Excel processing <span style="color: #339933;">--&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>dependency<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>groupId<span style="color: #339933;">&gt;</span>org.<span style="color: #006633;">apache</span>.<span style="color: #006633;">poi</span><span style="color: #339933;">&lt;/</span>groupId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>artifactId<span style="color: #339933;">&gt;</span>poi<span style="color: #339933;">&lt;/</span>artifactId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>version<span style="color: #339933;">&gt;</span>5.2.3<span style="color: #339933;">&lt;/</span>version<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>dependency<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>dependency<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>groupId<span style="color: #339933;">&gt;</span>org.<span style="color: #006633;">apache</span>.<span style="color: #006633;">poi</span><span style="color: #339933;">&lt;/</span>groupId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>artifactId<span style="color: #339933;">&gt;</span>poi<span style="color: #339933;">-</span>ooxml<span style="color: #339933;">&lt;/</span>artifactId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>version<span style="color: #339933;">&gt;</span>5.2.3<span style="color: #339933;">&lt;/</span>version<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>dependency<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;!--</span> Jackson <span style="color: #000000; font-weight: bold;">for</span> JSON processing <span style="color: #339933;">--&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>dependency<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>groupId<span style="color: #339933;">&gt;</span>com.<span style="color: #006633;">fasterxml</span>.<span style="color: #006633;">jackson</span>.<span style="color: #006633;">core</span><span style="color: #339933;">&lt;/</span>groupId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>artifactId<span style="color: #339933;">&gt;</span>jackson<span style="color: #339933;">-</span>core<span style="color: #339933;">&lt;/</span>artifactId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>version<span style="color: #339933;">&gt;</span>2.13.0<span style="color: #339933;">&lt;/</span>version<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>dependency<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>dependency<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>groupId<span style="color: #339933;">&gt;</span>com.<span style="color: #006633;">fasterxml</span>.<span style="color: #006633;">jackson</span>.<span style="color: #006633;">core</span><span style="color: #339933;">&lt;/</span>groupId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>artifactId<span style="color: #339933;">&gt;</span>jackson<span style="color: #339933;">-</span>databind<span style="color: #339933;">&lt;/</span>artifactId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>version<span style="color: #339933;">&gt;</span>2.13.0<span style="color: #339933;">&lt;/</span>version<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>dependency<span style="color: #339933;">&gt;</span><br />
<span style="color: #339933;">&lt;/</span>dependencies<span style="color: #339933;">&gt;</span></div></td></tr></tbody></table></div>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/aem-convert-excel-to-json-simple-servlet-example">AEM Convert Excel to JSON Simple Servlet Example</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/aem-convert-excel-to-json-simple-servlet-example/feed</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>JCR SQL2 ISDESCENDANTNODE Multiple Paths Example</title>
		<link>https://sourcedcode.com/blog/aem/jcr-sql2-isdescendantnode-multiple-paths-example</link>
					<comments>https://sourcedcode.com/blog/aem/jcr-sql2-isdescendantnode-multiple-paths-example#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Wed, 18 Oct 2023 02:01:56 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Search]]></category>
		<category><![CDATA[Sling Servlet]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=6203</guid>

					<description><![CDATA[<p>While working with the JCR SQL2 Queries, you may encounter scenarios where content is distributed across various branches of the repository. Querying these branches efficiently is key to implement features to capture requirements. In this article, we will focus o how to collect and query for distributed across various branches of the repository. Using the [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/jcr-sql2-isdescendantnode-multiple-paths-example">JCR SQL2 ISDESCENDANTNODE Multiple Paths Example</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>While working with the JCR SQL2 Queries, you may encounter scenarios where content is distributed across various branches of the repository. Querying these branches efficiently is key to implement features to capture requirements. In this article, we will focus o how to collect and query for distributed across various branches of the repository. Using the ISDESCENDANTNODE feature of the JCR SQL Query proves it possible.</p>
<p><strong>Understanding ISDESCENDANTNODE</strong></p>
<p>ISDESCENDANTNODE is a condition in JCR SQL2 that checks if a node is a descendant of another, based on their paths. It is particularly beneficial for querying content hierarchies. Imagine you have content in different branches (content tree) of your AEM repository. You want to search across these branches simultaneously, without running separate queries. This is where ISDESCENDANTNODE shines.</p>
<p>By specifying multiple paths within the ISDESCENDANTNODE condition, you can search for content across these paths concurrently, streamlining your queries. This powerful feature simplifies and optimizes the content retrieval process in AEM.</p>
<hr class="spacer-large" />
<p><strong>Finding all cq:Pages under 1 path</strong><br />
with the jcr:content/jcr:title CONTAINS %terms%</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">SELECT <span style="color: #339933;">*</span> FROM <span style="color: #009900;">&#91;</span>cq<span style="color: #339933;">:</span>Page<span style="color: #009900;">&#93;</span><br />
WHERE ISDESCENDANTNODE<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/content/sourcedcode/us/'</span><span style="color: #009900;">&#41;</span><br />
AND CONTAINS<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span>jcr<span style="color: #339933;">:</span>content<span style="color: #339933;">/</span>jcr<span style="color: #339933;">:</span>title<span style="color: #009900;">&#93;</span>, <span style="color: #0000ff;">'terms'</span><span style="color: #009900;">&#41;</span></div></td></tr></tbody></table></div>
<hr class="spacer-large" />
<p><strong>Finding all cq:Pages under 2 paths</strong><br />
with the jcr:content/jcr:title CONTAINS %terms%</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">SELECT <span style="color: #339933;">*</span> FROM <span style="color: #009900;">&#91;</span>cq<span style="color: #339933;">:</span>Page<span style="color: #009900;">&#93;</span><br />
WHERE <span style="color: #009900;">&#40;</span>ISDESCENDANTNODE<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/content/sourcedcode/us/'</span><span style="color: #009900;">&#41;</span> <br />
OR ISDESCENDANTNODE<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/content/sourcedcode/ca/'</span><span style="color: #009900;">&#41;</span> <br />
AND CONTAINS<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span>jcr<span style="color: #339933;">:</span>content<span style="color: #339933;">/</span>jcr<span style="color: #339933;">:</span>title<span style="color: #009900;">&#93;</span>, <span style="color: #0000ff;">'terms'</span><span style="color: #009900;">&#41;</span></div></td></tr></tbody></table></div>
<hr class="spacer-large" />
<p><strong>Finding all cq:Pages under 3 paths</strong><br />
with the jcr:content/jcr:title CONTAINS %terms%</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">SELECT <span style="color: #339933;">*</span> FROM <span style="color: #009900;">&#91;</span>cq<span style="color: #339933;">:</span>Page<span style="color: #009900;">&#93;</span><br />
WHERE <span style="color: #009900;">&#40;</span>ISDESCENDANTNODE<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/content/sourcedcode/us/'</span><span style="color: #009900;">&#41;</span> <br />
OR ISDESCENDANTNODE<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/content/sourcedcode/ca/'</span><span style="color: #009900;">&#41;</span> <br />
OR ISDESCENDANTNODE<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/content/sourcedcode/pl/'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
AND CONTAINS<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span>jcr<span style="color: #339933;">:</span>content<span style="color: #339933;">/</span>jcr<span style="color: #339933;">:</span>title<span style="color: #009900;">&#93;</span>, <span style="color: #0000ff;">'terms'</span><span style="color: #009900;">&#41;</span></div></td></tr></tbody></table></div>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/jcr-sql2-isdescendantnode-multiple-paths-example">JCR SQL2 ISDESCENDANTNODE Multiple Paths Example</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/jcr-sql2-isdescendantnode-multiple-paths-example/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>AEM User Story Example: Accordion Component</title>
		<link>https://sourcedcode.com/blog/aem/aem-user-story-example-accordion-component</link>
					<comments>https://sourcedcode.com/blog/aem/aem-user-story-example-accordion-component#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Wed, 13 Sep 2023 05:18:55 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=6117</guid>

					<description><![CDATA[<p>Being an AEM tech lead, I&#8217;ve sat through countless meetings about ticket creation. One thing that keeps popping up? The struggle to create that &#8216;perfect&#8217; ticket. You know, the one where everything&#8217;s clear, and nobody has to ping you with a dozen follow-up questions. So, I took a shot at crafting a solid example of [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/aem-user-story-example-accordion-component">AEM User Story Example: Accordion Component</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Being an AEM tech lead, I&#8217;ve sat through countless meetings about ticket creation. One thing that keeps popping up? The struggle to create that &#8216;perfect&#8217; ticket. You know, the one where everything&#8217;s clear, and nobody has to ping you with a dozen follow-up questions.</p>
<p>So, I took a shot at crafting a solid example of a user story. For this one, I&#8217;m diving into making a new Accordion Component. It&#8217;s gotta be user-friendly, look good, be accessible to everyone, and make life easy for our content authors.</p>
<p><strong>I tried to extend this User Story will a lot of extended requirements and details. It captures:</strong></p>
<ol>
<li>Business Requirements</li>
<li>Author Requirements</li>
<li>Accessibility Requirements</li>
</ol>
<p>Curious? Check out my take below. Maybe it&#8217;ll help you out the next time you&#8217;re scratching your head over a ticket!</p>
<hr class="spacer-larger" />
<h3><span class="code-highlight-primary">Epic: Component Development</span></h3>
<h3><span class="code-highlight-primary">Story Title: Accordion Component</span></h3>
<div class="spacer-large"></div>
<h4>User Story:</h4>
<p><strong>As</strong> a content author,<br />
<strong>I</strong> want to create an accordion component,<br />
<strong>So</strong> that I can showcase content in an organized, collapsible format that&#8217;s inclusive to all users, including those with accessibility needs.</p>
<div class="spacer-large"></div>
<h4>Description:</h4>
<p>We&#8217;re gearing up to develop an accordion component that&#8217;s not just visually appealing and user-friendly but is also deeply rooted in accessibility principles. This isn&#8217;t just a collapsible tool for content, but a beacon of inclusivity, especially for users relying on assistive technologies.</p>
<div class="spacer-large"></div>
<h4>Designs:</h4>
<p>[Figma Link or attach mock-ups or wireframes for the Accordion Component.]</p>
<div class="spacer-large"></div>
<h4>Dependencies:</h4>
<ul>
<li>Collaboration with the QA team is essential for extensive testing across browsers and in terms of accessibility.</li>
</ul>
<hr class="spacer-large"/>
<h4>Requirements:</h4>
<ul>
<li>The accordion component should support a hierarchy with headers and corresponding content sections.</li>
<li>Headers must be clickable, triggering the expansion or collapse of their related content.</li>
<li>The accordion should have a default style but should also be customizable to fit various website themes.</li>
<li>Animated transitions for expanding and collapsing sections would enhance the user experience.</li>
<li>Responsive behavior is essential; the accordion should adapt seamlessly to various screen sizes, including mobile, tablet, and desktop.</li>
<li>It should be lightweight, ensuring that it doesn&#8217;t significantly affect page load times.</li>
<li>Support for nesting accordions (accordion within an accordion) should be considered.</li>
<li>An option to search or filter items within the accordion would be a useful feature for content-heavy implementations.</li>
</ul>
<div class="spacer-large"></div>
<h4>Author Requirements:</h4>
<ul>
<li>The Touch UI interface should display clear labels or icons indicating functionality, like &#8220;Add&#8221;, &#8220;Re-order&#8221;, or &#8220;Delete Accordion Item.&#8221;</li>
<li>The Touch UI interface should allow content author&#8217;s to customize the accordion title; each accordion title added under the multi-field list will render an accordion content area (accordion body) on the editor.html page.</li>
<li>Each accordion content area should allow author&#8217;s to drag and drop any amount of &#8220;Sourced Code Content&#8221; Components, allowing for diverse rich content options.</li>
<li>A preview option should allow authors to view their changes in real-time before saving or publishing.</li>
<li>Expected Touch UI interface:
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #339933;">============================================================</span><br />
Tab1<span style="color: #339933;">:</span> Items<br />
<span style="color: #339933;">============================================================</span><br />
<span style="color: #009900;">&#91;</span>multifield<span style="color: #009900;">&#93;</span><br />
<span style="color: #339933;">--</span> <span style="color: #000000; font-weight: bold;">default</span><span style="color: #339933;">:</span> EMPTY<br />
<span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">default</span><span style="color: #009900;">&#41;</span> componentType <span style="color: #339933;">=</span> <span style="color: #0000ff;">'container'</span><br />
<span style="color: #339933;">+</span> accordion title label<br />
<br />
<span style="color: #339933;">============================================================</span><br />
Tab2<span style="color: #339933;">:</span> <span style="color: #003399;">Properties</span><br />
<span style="color: #339933;">============================================================</span><br />
<span style="color: #009900;">&#91;</span>checkbox<span style="color: #009900;">&#93;</span> Single Item Expansion <br />
<span style="color: #339933;">--</span> <span style="color: #000000; font-weight: bold;">default</span><span style="color: #339933;">:</span> unchecked<br />
<span style="color: #339933;">--</span> help<span style="color: #339933;">:</span> Forces a single accordion item to be expanded at a time. <span style="color: #006633;">Expanding</span> one item will collapse all others.<br />
<br />
<span style="color: #009900;">&#91;</span>dropdown<span style="color: #339933;">-</span>multi<span style="color: #339933;">-</span>select<span style="color: #009900;">&#93;</span> Expanded Items<br />
<span style="color: #339933;">--</span> <span style="color: #000000; font-weight: bold;">default</span><span style="color: #339933;">:</span> Select<br />
<span style="color: #339933;">--</span> help<span style="color: #339933;">:</span> The items that are expanded by <span style="color: #000000; font-weight: bold;">default</span>.<br />
<br />
<span style="color: #009900;">&#91;</span>text<span style="color: #339933;">-</span>field<span style="color: #009900;">&#93;</span> ID<br />
<span style="color: #339933;">--</span> <span style="color: #000000; font-weight: bold;">default</span><span style="color: #339933;">:</span> EMPTY<br />
<span style="color: #339933;">--</span> help<span style="color: #339933;">:</span> <span style="color: #003399;">HTML</span> ID attribute to apply to the component.</div></td></tr></tbody></table></div>
</li>
</ul>
<div class="spacer-large"></div>
<h4>Accessibility Requirements:</h4>
<ul>
<li>ARIA landmarks, roles, and states (like `aria-expanded`) should be implemented for the accordion to convey its status and function to assistive technologies.</li>
<li>Logical tab order should be maintained, ensuring that keyboard users navigate through accordion elements in a coherent sequence.</li>
<li>A &#8220;skip to content&#8221; link should be available, permitting users to bypass the accordion if they don&#8217;t wish to interact with it.</li>
</ul>
<hr class="spacer-large"></hr>
<h4>Acceptance Criteria:</h4>
<ul>
<li>The accordion should be responsive, ensuring usability across devices from mobile to desktop.</li>
<li>Users must be able to expand or collapse content by clicking/tapping the accordion header.</li>
<li>Clear visual indicators, like &#8216;+&#8217; for collapsed and &#8216;−&#8217; for expanded sections, should be present.</li>
<li>Accordion design should permit a minimum of one item and a maximum of ten items.</li>
<li>By default, accordion content should remain collapsed unless an author configures it otherwise.</li>
<li>As styled per Figma.</li>
</ul>
<div class="spacer-large"></div>
<h4>Author Acceptance Criteria:</h4>
<ul>
<li>Content authors should be able to drag the accordion component from the component panel and drop it into their desired page location.</li>
<li>Authors should find easy-to-identify areas or placeholders within the accordion where they can add text, images, videos, or other content types, from the accordion content area.</li>
<li>Rearranging should involve simple drag-and-drop mechanics from the Touch UI interface. If an author wants to move the third accordion item to the first position, they should be able to do this intuitively.</li>
<li>Configuration options must be present, allowing authors to set which accordion items are expanded when the page loads, mechanics from the Touch UI interface.</li>
<li>An easy-to-spot toggle option should let authors expand or collapse all accordion items with a single click, mechanics from the Touch UI interface.</li>
</ul>
<div class="spacer-large"></div>
<h4>Accessibility Acceptance Criteria:</h4>
<ul>
<li>Keyboard focus should move sequentially through accordion headers using the Tab key. Reverse navigation should be facilitated with Shift+Tab.</li>
<li>When focused on an accordion header, pressing Enter should change its state from collapsed to expanded or vice-versa.</li>
<li>Screen readers should provide feedback on the accordion&#8217;s state and content, such as &#8220;Item 1 expanded&#8221; or &#8220;Item 2 collapsed.&#8221;</li>
<li>Text-to-background contrast ratios must adhere to WCAG guidelines, ensuring content is discernible for users with visual challenges.</li>
<li>Testing should confirm compatibility with widely-used assistive technologies like JAWS and NVDA.</li>
</ul>
<div class="spacer-large"></div>
<h4>Notes:</h4>
<p>In developing the accordion component, it&#8217;s paramount to blend aesthetics, functionality, and accessibility. This component reflects our dedication to crafting user-centric and inclusive digital experiences.</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/aem-user-story-example-accordion-component">AEM User Story Example: Accordion Component</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/aem-user-story-example-accordion-component/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Optimizing &#038; Debugging Search Queries, Explain Query Tool AEM</title>
		<link>https://sourcedcode.com/blog/aem/optimizing-debugging-search-queries-explain-query-tool-aem</link>
					<comments>https://sourcedcode.com/blog/aem/optimizing-debugging-search-queries-explain-query-tool-aem#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Sat, 09 Sep 2023 03:29:56 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Search]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=6092</guid>

					<description><![CDATA[<p>The &#8220;Explain Query Tool&#8221; tool assists developers in understanding, optimizing, and debugging search queries, which are crucial for the AEM&#8217;s performance and accurate content delivery. Understanding the Explain Query Tool The Explain Query Tool essentially breaks down and explains the steps and processes a query goes through in AEM. Think of it as a &#8216;debug [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/optimizing-debugging-search-queries-explain-query-tool-aem">Optimizing &#038; Debugging Search Queries, Explain Query Tool AEM</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>The &#8220;Explain Query Tool&#8221; tool assists developers in understanding, optimizing, and debugging search queries, which are crucial for the AEM&#8217;s performance and accurate content delivery.</p>
<hr class="spacer-larger"/>
<h2>Understanding the Explain Query Tool</h2>
<p>The Explain Query Tool essentially breaks down and explains the steps and processes a query goes through in AEM. Think of it as a &#8216;debug mode&#8217; for your search queries. It provides insights into how the system interprets the query, the indexes it leverages, the estimated cost of the query, and other essential metrics.</p>
<hr class="spacer-larger"/>
<h2>Benefits of Using the Explain Query Tool:</h2>
<ul>
<li><strong>Performance Analysis</strong>: By revealing how the system interprets and executes the query, developers can identify bottlenecks or inefficiencies.</li>
<li><strong>Better Indexing</strong>: Developers can understand which indexes are being used and optimize or create new ones accordingly.</li>
<li><strong>Debugging</strong>: It becomes easier to pinpoint issues in complex queries when developers can visualize each step.</li>
</ul>
<hr class="spacer-larger"/>
<h2>Using Explain Query Tool with Different AEM Backend Search APIs</h2>
<h3>1. SQL2:</h3>
<p>SQL2 is the SQL-like query language used in AEM, and it&#8217;s one of the primary ways developers retrieve data from the JCR (Java Content Repository).</p>
<h4>How to Use:</h4>
<p>Navigate to the AEM Query Performance Tool, and select on the &#8220;Explain Query&#8221; tab. Choose the &#8220;Language&#8221; drop down to be SQL-JCR2, and input the JCR-SQL2 query that you are trying to test. Now click on explain, and you&#8217;ll see a breakdown of the query&#8217;s interpretation and execution.</p>
<p>AEM Query Performance Tool<br />
<a href="http://localhost:4502/libs/granite/operations/content/diagnosistools/queryPerformance.html" rel="noopener" target="_blank">http://localhost:4502/libs/granite/operations/content/diagnosistools/queryPerformance.html</a></p>
<hr class="spacer-large"/>
<h3>2. Query Builder API:</h3>
<p>Query Builder API allows developers to build search queries programmatically using a more intuitive map-based syntax. It abstracts some complexities of the JCR, offering a more accessible way to retrieve content.</p>
<h4>How to Use:</h4>
<p>Navigate to the AEM Query Performance Tool, and select on the &#8220;Explain Query&#8221; tab. Choose the &#8220;Language&#8221; drop down to be Query Builder, and input your Query Builder query that you are trying to test. Now click on explain, and you&#8217;ll see a breakdown of the query&#8217;s interpretation and execution.</p>
<div class="mention-block--gold">
<strong>Note</strong><br />
For Query Builder queries, only the generated XPath is included in the explanation and result counts. For an in-depth analysis (including filtering and facets extraction), use the <a href="http://localhost:4502/libs/cq/search/content/querydebug.html" rel="noopener" target="_blank">Query Builder Debugger tool</a>.
</div>
<p>AEM Query Performance Tool<br />
<a href="http://localhost:4502/libs/granite/operations/content/diagnosistools/queryPerformance.html" rel="noopener" target="_blank">http://localhost:4502/libs/granite/operations/content/diagnosistools/queryPerformance.html</a></p>
<hr class="spacer-large"/>
<h3>3. XPath:</h3>
<p>XPath is another way of querying the JCR in AEM. While it&#8217;s less commonly used than SQL2, it can be more expressive and powerful for certain hierarchical data structures.</p>
<h4>How to Use:</h4>
<p>Navigate to the AEM Query Performance Tool, and select on the &#8220;Explain Query&#8221; tab. Choose the &#8220;Language&#8221; drop down to be XPath, and input the XPath Query that you are trying to test. Now click on explain, and you&#8217;ll see a breakdown of the query&#8217;s interpretation and execution.</p>
<p>AEM Query Performance Tool<br />
<a href="http://localhost:4502/libs/granite/operations/content/diagnosistools/queryPerformance.html" rel="noopener" target="_blank">http://localhost:4502/libs/granite/operations/content/diagnosistools/queryPerformance.html</a></p>
<hr class="spacer-larger"/>
<h2>Other Options for the AEM Query Performance Tool</h2>
<ol>
<li><strong>Include Execution Time</strong>: Execution time will be reported after running the query. Please note that long running queries will report an explanation with a delay.</li>
<li><strong>Read first page of results</strong>: The first 20 results will be read after running the query.  Please note that long running queries will report an explanation with a delay, and the overall execution will timeout after 60 seconds.</li>
<li><strong>Include Node Count</strong>: The node count is calculated by iterating the full result set of the query. Please note that long running queries will report an explanation with a delay, and the overall execution will timeout after 60 seconds.</li>
</ol>
<p>AEM Query Performance Tool<br />
<a href="http://localhost:4502/libs/granite/operations/content/diagnosistools/queryPerformance.html" rel="noopener" target="_blank">http://localhost:4502/libs/granite/operations/content/diagnosistools/queryPerformance.html</a></p>
<hr class="spacer-larger"/>
<h2>Conclusion</h2>
<p>The Explain Query Tool in AEM is a powerful ally for developers, especially those heavily invested in ensuring the performance and accuracy of their search queries. By familiarizing oneself with this tool across the various backend search APIs, developers can optimize their AEM platform for both performance and maintainability, ensuring that the content delivery is swift and relevant.</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/optimizing-debugging-search-queries-explain-query-tool-aem">Optimizing &#038; Debugging Search Queries, Explain Query Tool AEM</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/optimizing-debugging-search-queries-explain-query-tool-aem/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Retrieving the Current Page in an AEM Servlet via ResourceType</title>
		<link>https://sourcedcode.com/blog/aem/retrieving-the-current-page-in-an-aem-servlet-via-resourcetype</link>
					<comments>https://sourcedcode.com/blog/aem/retrieving-the-current-page-in-an-aem-servlet-via-resourcetype#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Wed, 06 Sep 2023 03:48:43 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Quick Reference]]></category>
		<category><![CDATA[Sling Servlet]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=6104</guid>

					<description><![CDATA[<p>In the context of &#8220;Retrieving the Current Page in an AEM Servlet via ResourceType&#8221;, it is great to understand how this is done. This guide provides a simplified walkthrough on how you can adeptly achieve this. In the code example, we will associating the servlet with a resourceType. 123456789101112131415161718192021222324252627282930313233343536373839package com.example.aem.servlets; import org.apache.sling.api.SlingHttpServletRequest; import org.apache.sling.api.SlingHttpServletResponse; import [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/retrieving-the-current-page-in-an-aem-servlet-via-resourcetype">Retrieving the Current Page in an AEM Servlet via ResourceType</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>In the context of &#8220;Retrieving the Current Page in an AEM Servlet via ResourceType&#8221;, it is great to understand how this is done. This guide provides a simplified walkthrough on how you can adeptly achieve this. In the code example, we will associating the servlet with a resourceType.</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.example.aem.servlets</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.SlingHttpServletRequest</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.SlingHttpServletResponse</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.servlets.SlingAllMethodsServlet</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.models.annotations.injectorspecific.Self</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.osgi.service.component.annotations.Component</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.resource.ResourceResolver</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.day.cq.wcm.api.Page</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.day.cq.wcm.api.PageManager</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.servlet.Servlet</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.IOException</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Optional</span><span style="color: #339933;">;</span><br />
<br />
@<span style="color: #003399;">Component</span><span style="color: #009900;">&#40;</span>service <span style="color: #339933;">=</span> Servlet.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><br />
@SlingServletResourceTypes<span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; resourceTypes<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;example/components/content/mycomponent&quot;</span>,<br />
&nbsp; &nbsp; methods<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;GET&quot;</span>,<br />
&nbsp; &nbsp; extensions<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;html&quot;</span><br />
<span style="color: #009900;">&#41;</span><br />
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ResourceTypeServlet <span style="color: #000000; font-weight: bold;">extends</span> SlingAllMethodsServlet <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; @Self<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> SlingHttpServletRequest request<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; @Override<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> doGet<span style="color: #009900;">&#40;</span>SlingHttpServletRequest request, SlingHttpServletResponse response<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">IOException</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Page currentPage <span style="color: #339933;">=</span> Optional.<span style="color: #006633;">ofNullable</span><span style="color: #009900;">&#40;</span>request.<span style="color: #006633;">getResourceResolver</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">adaptTo</span><span style="color: #009900;">&#40;</span>PageManager.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;.<span style="color: #006633;">map</span><span style="color: #009900;">&#40;</span>pm <span style="color: #339933;">-&gt;</span> pm.<span style="color: #006633;">getContainingPage</span><span style="color: #009900;">&#40;</span>request.<span style="color: #006633;">getResource</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;.<span style="color: #006633;">orElse</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>currentPage <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; response.<span style="color: #006633;">getWriter</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">write</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Gotcha! Current page is: &quot;</span> <span style="color: #339933;">+</span> currentPage.<span style="color: #006633;">getPath</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; response.<span style="color: #006633;">getWriter</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">write</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Oops, couldn't find the current page.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<hr class="spacer-larger" />
<h2>Understanding the AEM Code Snippet</h2>
<h3>1. <span class="code-highlight-secondary">request.getResourceResolver().adaptTo(PageManager.class)</span>:</h3>
<p><span class="code-highlight-secondary">request.getResourceResolver()</span>: This fetches a <span class="code-highlight-secondary">ResourceResolver</span> from the servlet&#8217;s request. A <span class="code-highlight-secondary">ResourceResolver</span> in AEM assists in translating resource paths to actual resources.</p>
<p><span class="code-highlight-secondary">.adaptTo(PageManager.class)</span>: This method tries to adapt or convert the <span class="code-highlight-secondary">ResourceResolver</span> into another type, specifically a <span class="code-highlight-secondary">PageManager</span>. The <span class="code-highlight-secondary">PageManager</span> in AEM offers utilities for working with pages, such as fetching, creating, or deleting pages.</p>
<hr class="spacer-large" />
<h3>2. <span class="code-highlight-secondary">Optional.ofNullable(&#8230;)</span></h3>
<p>This wraps the value returned by the preceding code (which might be a <span class="code-highlight-secondary">PageManager</span> object or <span class="code-highlight-secondary">null</span> if the adaptation failed) within an <span class="code-highlight-secondary">Optional</span> object. <span class="code-highlight-secondary">Optional</span> is a container that may or may not contain a value.</p>
<hr class="spacer-large" />
<h3>3. <span class="code-highlight-secondary">.map(pm -> pm.getContainingPage(request.getResource()))</span></h3>
<p>If the <span class="code-highlight-secondary">Optional</span> contains a non-null <span class="code-highlight-secondary">PageManager</span> value, the <span class="code-highlight-secondary">.map</span> method applies the given function to it. Here, it uses the <span class="code-highlight-secondary">PageManager</span> (denoted as <span class="code-highlight-secondary">pm</span> in the lambda) to retrieve the containing page of the present resource.</p>
<p><span class="code-highlight-secondary">pm.getContainingPage(request.getResource())</span>: This extracts the AEM Page that encompasses the current resource.</p>
<hr class="spacer-large" />
<h3>4. <span class="code-highlight-secondary">.orElse(null)</span></h3>
<p>Lastly, if any prior steps don&#8217;t succeed (i.e., if the adaptation to <span class="code-highlight-secondary">PageManager</span> was unsuccessful or if no containing page for the resource exists), the <span class="code-highlight-secondary">orElse</span> method ensures <span class="code-highlight-secondary">currentPage</span> is set to <span class="code-highlight-secondary">null</span>.</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/retrieving-the-current-page-in-an-aem-servlet-via-resourcetype">Retrieving the Current Page in an AEM Servlet via ResourceType</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/retrieving-the-current-page-in-an-aem-servlet-via-resourcetype/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>AEM 6.5 On-Prem, Embed AEM Core Component&#8217;s to the Project</title>
		<link>https://sourcedcode.com/blog/aem/aem-6-5-on-prem-embed-aem-core-components-to-the-project</link>
					<comments>https://sourcedcode.com/blog/aem/aem-6-5-on-prem-embed-aem-core-components-to-the-project#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Thu, 31 Aug 2023 03:25:57 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Development]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=6058</guid>

					<description><![CDATA[<p>The AEMaaCS platform contains the Adobe AEM Core Components pre-installed into the /libs folder, but however, AEM 6.5 on-prem does automatically contain this; we must install it manually. For legacy AEM 6.5 project utilizing the Adobe AEM Core Components, they must configure &#038; install this library to each environment (authors, publishers) with the correct version. [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/aem-6-5-on-prem-embed-aem-core-components-to-the-project">AEM 6.5 On-Prem, Embed AEM Core Component&#8217;s to the Project</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>The AEMaaCS platform contains the <a href="https://github.com/adobe/aem-core-wcm-components" rel="noopener" target="_blank">Adobe AEM Core Components</a> pre-installed into the /libs folder, but however, AEM 6.5 on-prem does automatically contain this; we must install it manually. For legacy AEM 6.5 project utilizing the <a href="https://github.com/adobe/aem-core-wcm-components" rel="noopener" target="_blank">Adobe AEM Core Components</a>, they must configure &#038; install this library to each environment (authors, publishers) with the correct version. Manual installation is teedius and prone to errors, so its best practice to automatically install the correct versions. </p>
<p>In this article we will walk through step by step how to embed the <a href="https://github.com/adobe/aem-core-wcm-components" rel="noopener" target="_blank">Adobe AEM Core Components</a> into your project, so when your code is built via maven, your maven module will contain instructions for your AEM environment to install the <a href="https://github.com/adobe/aem-core-wcm-components" rel="noopener" target="_blank">Adobe AEM Core Components</a> as expected.</p>
<div class="mention-block--gold">
<strong>Important!</strong><br />
Specific versions of Adobe Core Components only support specific AEM 6.5 service pack versions, so please take a look at Adobe&#8217;s documentation to understand exactly which version you need. <a href="https://experienceleague.adobe.com/docs/experience-manager-core-components/using/versions.html?lang=en" rel="noopener" target="_blank">Check Version</a>.
</div>
<div class="mention-block">
<strong>Quick Links</strong></p>
<ol>
<li><a href="#step-1">Add dependencies to parent pom.xml</a></li>
<li><a href="#step-2">Add dependencies to your target maven module</a></li>
<li><a href="#step-3">Configure com.day.jcr.vault&#8217;s &lt;embeded&gt; to target maven module</a></li>
<li><a href="#step-4">Add template to create and manage wcm.io caConfigs</a></li>
</ol>
</div>
<hr class="spacer-larger" />
<h3 id="step-1">1. Add dependencies to parent pom.xml</h3>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #339933;">&lt;</span>dependencyManagement<span style="color: #339933;">&gt;</span><br />
&nbsp; <span style="color: #339933;">&lt;</span>dependencies<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; ...<br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>dependency<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>groupId<span style="color: #339933;">&gt;</span>com.<span style="color: #006633;">adobe</span>.<span style="color: #006633;">cq</span><span style="color: #339933;">&lt;/</span>groupId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>artifactId<span style="color: #339933;">&gt;</span>core.<span style="color: #006633;">wcm</span>.<span style="color: #006633;">components</span>.<span style="color: #006633;">all</span><span style="color: #339933;">&lt;/</span>artifactId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>type<span style="color: #339933;">&gt;</span>zip<span style="color: #339933;">&lt;/</span>type<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>version<span style="color: #339933;">&gt;</span>2.20.0<span style="color: #339933;">&lt;/</span>version<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>dependency<span style="color: #339933;">&gt;</span><br />
&nbsp; <span style="color: #339933;">&lt;/</span>dependencies<span style="color: #339933;">&gt;</span><br />
<span style="color: #339933;">&lt;/</span>dependencyManagement<span style="color: #339933;">&gt;</span></div></td></tr></tbody></table></div>
<hr class="spacer-larger" />
<h3 id="step-2">2. Add dependencies to your target maven module</h3>
<p>In this example, we will target all/pom.xml</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #339933;">&lt;</span>dependencies<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; ...<br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>dependency<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>groupId<span style="color: #339933;">&gt;</span>com.<span style="color: #006633;">adobe</span>.<span style="color: #006633;">cq</span><span style="color: #339933;">&lt;/</span>groupId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>artifactId<span style="color: #339933;">&gt;</span>core.<span style="color: #006633;">wcm</span>.<span style="color: #006633;">components</span>.<span style="color: #006633;">core</span><span style="color: #339933;">&lt;/</span>artifactId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>scope<span style="color: #339933;">&gt;</span>provided<span style="color: #339933;">&lt;/</span>scope<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>dependency<span style="color: #339933;">&gt;</span><br />
<span style="color: #339933;">&lt;/</span>dependencies<span style="color: #339933;">&gt;</span></div></td></tr></tbody></table></div>
<hr class="spacer-larger" />
<h3 id="step-3">3. Configure com.day.jcr.vault&#8217;s &lt;subPackages&gt;&lt;subPackage&gt; to target maven module</h3>
<p>In this example, we will target all/pom.xml</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #339933;">&lt;</span>plugin<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>groupId<span style="color: #339933;">&gt;</span>com.<span style="color: #006633;">day</span>.<span style="color: #006633;">jcr</span>.<span style="color: #006633;">vault</span><span style="color: #339933;">&lt;/</span>groupId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>artifactId<span style="color: #339933;">&gt;</span>content<span style="color: #339933;">-</span>package<span style="color: #339933;">-</span>maven<span style="color: #339933;">-</span>plugin<span style="color: #339933;">&lt;/</span>artifactId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>extensions<span style="color: #339933;">&gt;</span>true<span style="color: #339933;">&lt;/</span>extensions<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>configuration<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; ...<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>subPackages<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>subPackage<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>groupId<span style="color: #339933;">&gt;</span>com.<span style="color: #006633;">adobe</span>.<span style="color: #006633;">cq</span><span style="color: #339933;">&lt;/</span>groupId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>artifactId<span style="color: #339933;">&gt;</span>core.<span style="color: #006633;">wcm</span>.<span style="color: #006633;">components</span>.<span style="color: #006633;">all</span><span style="color: #339933;">&lt;/</span>artifactId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>filter<span style="color: #339933;">&gt;</span>true<span style="color: #339933;">&lt;/</span>filter<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>subPackage<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>subPackages<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>targetURL<span style="color: #339933;">&gt;</span>http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//${crx.host}:${crx.port}/crx/packmgr/service.jsp&lt;/targetURL&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>configuration<span style="color: #339933;">&gt;</span><br />
<span style="color: #339933;">&lt;/</span>plugin<span style="color: #339933;">&gt;</span></div></td></tr></tbody></table></div>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/aem-6-5-on-prem-embed-aem-core-components-to-the-project">AEM 6.5 On-Prem, Embed AEM Core Component&#8217;s to the Project</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/aem-6-5-on-prem-embed-aem-core-components-to-the-project/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to Embed wcm.io Context-Aware Configuration Editor</title>
		<link>https://sourcedcode.com/blog/aem/how-to-embed-wcm-io-context-aware-configuration-editor</link>
					<comments>https://sourcedcode.com/blog/aem/how-to-embed-wcm-io-context-aware-configuration-editor#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Tue, 29 Aug 2023 03:11:53 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Development]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=6050</guid>

					<description><![CDATA[<p>This blog article serves as your guide to seamlessly integrate and deploy the wcm.io Context-Aware Configuration Editor – a powerful tool that streamlines configuration management within AEM projects. Throughout this article, we will delve into the step-by-step process of configuring, installing, embedding, and deploying the wcm.io Context-Aware Configuration Editor. By following these instructions, you&#8217;ll be [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/how-to-embed-wcm-io-context-aware-configuration-editor">How to Embed wcm.io Context-Aware Configuration Editor</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>This blog article serves as your guide to seamlessly integrate and deploy the wcm.io Context-Aware Configuration Editor – a powerful tool that streamlines configuration management within AEM projects.</p>
<p>Throughout this article, we will delve into the step-by-step process of configuring, installing, embedding, and deploying the wcm.io Context-Aware Configuration Editor. By following these instructions, you&#8217;ll be able to harness the capabilities of this editor to automatically install configuration changes across all environments when your code is built via Maven and deployed to AEM. When it comes to deploying the wcm.io Context-Aware Configuration Editor, automation is key.</p>
<div class="mention-block">
<strong>Quick Links</strong></p>
<ol>
<li><a href="#step-1">Add dependencies to parent pom.xml</a></li>
<li><a href="#step-2">Add dependencies to your target maven module</a></li>
<li><a href="#step-3">Configure com.day.jcr.vault&#8217;s &lt;embeded&gt; to target maven module</a></li>
<li><a href="#step-4">Add template to create and manage wcm.io caConfigs</a></li>
<li><a href="#step-5">Context-Aware Configuration bnd plugin</a></li>
<li><a href="#step-6">Absolute Parent Context Path Strategy</a></li>
<li><a href="#step-7">Root Template Context PathStrategy</a></li>
<li><a href="#step-8">Page Persistence Strategy</a></li>
</ol>
</div>
<hr class="spacer-larger" />
<h3 id="step-1">1. Add dependencies to parent pom.xml</h3>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #339933;">&lt;</span>dependencyManagement<span style="color: #339933;">&gt;</span><br />
&nbsp; <span style="color: #339933;">&lt;</span>dependencies<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; ...<br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>dependency<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>groupId<span style="color: #339933;">&gt;</span>io.<span style="color: #006633;">wcm</span><span style="color: #339933;">&lt;/</span>groupId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>artifactId<span style="color: #339933;">&gt;</span>io.<span style="color: #006633;">wcm</span>.<span style="color: #006633;">caconfig</span>.<span style="color: #006633;">editor</span>.<span style="color: #006633;">package</span><span style="color: #339933;">&lt;/</span>artifactId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>version<span style="color: #339933;">&gt;</span>1.8.0<span style="color: #339933;">&lt;/</span>version<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>type<span style="color: #339933;">&gt;</span>zip<span style="color: #339933;">&lt;/</span>type<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>dependency<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>dependency<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>groupId<span style="color: #339933;">&gt;</span>io.<span style="color: #006633;">wcm</span><span style="color: #339933;">&lt;/</span>groupId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>artifactId<span style="color: #339933;">&gt;</span>io.<span style="color: #006633;">wcm</span>.<span style="color: #006633;">caconfig</span>.<span style="color: #006633;">extensions</span><span style="color: #339933;">&lt;/</span>artifactId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>version<span style="color: #339933;">&gt;</span>1.8.0<span style="color: #339933;">&lt;/</span>version<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>dependency<span style="color: #339933;">&gt;</span><br />
&nbsp; <span style="color: #339933;">&lt;/</span>dependencies<span style="color: #339933;">&gt;</span></div></td></tr></tbody></table></div>
<hr class="spacer-larger" />
<h3 id="step-2">2. Add dependencies to your target maven module</h3>
<p>In this example, we will target all/pom.xml</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #339933;">&lt;</span>dependencies<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; ...<br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>dependency<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>groupId<span style="color: #339933;">&gt;</span>io.<span style="color: #006633;">wcm</span><span style="color: #339933;">&lt;/</span>groupId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>artifactId<span style="color: #339933;">&gt;</span>io.<span style="color: #006633;">wcm</span>.<span style="color: #006633;">caconfig</span>.<span style="color: #006633;">editor</span>.<span style="color: #006633;">package</span><span style="color: #339933;">&lt;/</span>artifactId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>type<span style="color: #339933;">&gt;</span>zip<span style="color: #339933;">&lt;/</span>type<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>dependency<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>dependency<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>groupId<span style="color: #339933;">&gt;</span>io.<span style="color: #006633;">wcm</span><span style="color: #339933;">&lt;/</span>groupId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>artifactId<span style="color: #339933;">&gt;</span>io.<span style="color: #006633;">wcm</span>.<span style="color: #006633;">caconfig</span>.<span style="color: #006633;">extensions</span><span style="color: #339933;">&lt;/</span>artifactId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>dependency<span style="color: #339933;">&gt;</span><br />
<span style="color: #339933;">&lt;/</span>dependencies<span style="color: #339933;">&gt;</span></div></td></tr></tbody></table></div>
<hr class="spacer-larger" />
<h3 id="step-3">3. Configure com.day.jcr.vault&#8217;s &lt;embeded&gt; to target maven module</h3>
<p>In this example, we will target all/pom.xml, and yes, step 2 and 3 are configuration added to the same file.</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #339933;">&lt;</span>plugins<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>plugin<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; ...<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>groupId<span style="color: #339933;">&gt;</span>com.<span style="color: #006633;">day</span>.<span style="color: #006633;">jcr</span>.<span style="color: #006633;">vault</span><span style="color: #339933;">&lt;/</span>groupId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>artifactId<span style="color: #339933;">&gt;</span>content<span style="color: #339933;">-</span>package<span style="color: #339933;">-</span>maven<span style="color: #339933;">-</span>plugin<span style="color: #339933;">&lt;/</span>artifactId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>extensions<span style="color: #339933;">&gt;</span>true<span style="color: #339933;">&lt;/</span>extensions<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>configuration<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>group<span style="color: #339933;">&gt;</span>sourcedcode<span style="color: #339933;">-</span>packages<span style="color: #339933;">&lt;/</span>group<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>filterSource<span style="color: #339933;">&gt;</span>src<span style="color: #339933;">/</span>main<span style="color: #339933;">/</span>content<span style="color: #339933;">/</span>META<span style="color: #339933;">-</span>INF<span style="color: #339933;">/</span>vault<span style="color: #339933;">/</span>filter.<span style="color: #006633;">xml</span><span style="color: #339933;">&lt;/</span>filterSource<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>embeddeds<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>embedded<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>groupId<span style="color: #339933;">&gt;</span>io.<span style="color: #006633;">wcm</span><span style="color: #339933;">&lt;/</span>groupId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>artifactId<span style="color: #339933;">&gt;</span>io.<span style="color: #006633;">wcm</span>.<span style="color: #006633;">caconfig</span>.<span style="color: #006633;">editor</span>.<span style="color: #006633;">package</span><span style="color: #339933;">&lt;/</span>artifactId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>type<span style="color: #339933;">&gt;</span>zip<span style="color: #339933;">&lt;/</span>type<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>target<span style="color: #339933;">&gt;/</span>apps<span style="color: #339933;">/</span>sourcedcode<span style="color: #339933;">/</span>install<span style="color: #339933;">&lt;/</span>target<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>embedded<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>embedded<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>groupId<span style="color: #339933;">&gt;</span>io.<span style="color: #006633;">wcm</span><span style="color: #339933;">&lt;/</span>groupId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>artifactId<span style="color: #339933;">&gt;</span>io.<span style="color: #006633;">wcm</span>.<span style="color: #006633;">caconfig</span>.<span style="color: #006633;">extensions</span><span style="color: #339933;">&lt;/</span>artifactId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>target<span style="color: #339933;">&gt;/</span>apps<span style="color: #339933;">/</span>sourcedcode<span style="color: #339933;">/</span>install<span style="color: #339933;">&lt;/</span>target<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>embedded<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>embeddeds<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>targetURL<span style="color: #339933;">&gt;</span>http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//${crx.host}:${crx.port}/crx/packmgr/service.jsp&lt;/targetURL&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>configuration<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>plugin<span style="color: #339933;">&gt;</span><br />
<span style="color: #339933;">&lt;/</span>plugins<span style="color: #339933;">&gt;</span></div></td></tr></tbody></table></div>
<hr class="spacer-larger" />
<h3 id="step-4">4. Add template to create and manage wcm.io caConfigs</h3>
<p>./ui.apps/src/main/content/jcr_root/apps/sourcedcode/templates/caconfig-template/content.xml</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #339933;">&lt;?</span>xml version<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;1.0&quot;</span> encoding<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;UTF-8&quot;</span><span style="color: #339933;">?&gt;</span><br />
<span style="color: #339933;">&lt;</span>jcr<span style="color: #339933;">:</span>root xmlns<span style="color: #339933;">:</span>sling<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://sling.apache.org/jcr/sling/1.0&quot;</span> xmlns<span style="color: #339933;">:</span>cq<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://www.day.com/jcr/cq/1.0&quot;</span> xmlns<span style="color: #339933;">:</span>jcr<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://www.jcp.org/jcr/1.0&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jcr<span style="color: #339933;">:</span>primaryType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;cq:Template&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jcr<span style="color: #339933;">:</span>title<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Context-Aware Configuration Page&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; allowedPaths<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;[^/content/sourcedcode(/.*)?$]&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ranking<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;{Long}110&quot;</span><span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>jcr<span style="color: #339933;">:</span>content<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jcr<span style="color: #339933;">:</span>primaryType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;cq:PageContent&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sling<span style="color: #339933;">:</span>resourceType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;wcm-io/caconfig/editor/components/page/editor&quot;</span><span style="color: #339933;">/&gt;</span><br />
<span style="color: #339933;">&lt;/</span>jcr<span style="color: #339933;">:</span>root<span style="color: #339933;">&gt;</span></div></td></tr></tbody></table></div>
<hr class="spacer-larger" />
<h3 id="step-5">5. Context-Aware Configuration bnd plugin</h3>
<p>A bnd plugin is provided that scans the classpath of a bundle Maven project at build time and automatically generates a Sling-ContextAware-Configuration-Classes bundle header for all annotation classes annotated with @Configuration. It can be used by both maven-bundle-plugin and bnd-maven-plugin, as both use the bnd library internally.</p>
<p><strong>Standard Configuration</strong><br />
Place the configuration from the root pom.xml as such:</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #339933;">&lt;</span>plugin<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>groupId<span style="color: #339933;">&gt;</span>org.<span style="color: #006633;">apache</span>.<span style="color: #006633;">felix</span><span style="color: #339933;">&lt;/</span>groupId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>artifactId<span style="color: #339933;">&gt;</span>maven<span style="color: #339933;">-</span>bundle<span style="color: #339933;">-</span>plugin<span style="color: #339933;">&lt;/</span>artifactId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>extensions<span style="color: #339933;">&gt;</span>true<span style="color: #339933;">&lt;/</span>extensions<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>configuration<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>instructions<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;!--</span> Generate bundle header containing all configuration annotation classes <span style="color: #339933;">--&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>_plugin<span style="color: #339933;">&gt;</span>org.<span style="color: #006633;">apache</span>.<span style="color: #006633;">sling</span>.<span style="color: #006633;">caconfig</span>.<span style="color: #006633;">bndplugin</span>.<span style="color: #006633;">ConfigurationClassScannerPlugin</span><span style="color: #339933;">&lt;/</span>_plugin<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>instructions<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>configuration<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>dependencies<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>dependency<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>groupId<span style="color: #339933;">&gt;</span>org.<span style="color: #006633;">apache</span>.<span style="color: #006633;">sling</span><span style="color: #339933;">&lt;/</span>groupId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>artifactId<span style="color: #339933;">&gt;</span>org.<span style="color: #006633;">apache</span>.<span style="color: #006633;">sling</span>.<span style="color: #006633;">caconfig</span>.<span style="color: #006633;">bnd</span><span style="color: #339933;">-</span>plugin<span style="color: #339933;">&lt;/</span>artifactId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>version<span style="color: #339933;">&gt;</span>1.0.2<span style="color: #339933;">&lt;/</span>version<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>dependency<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>dependencies<span style="color: #339933;">&gt;</span><br />
<span style="color: #339933;">&lt;/</span>plugin<span style="color: #339933;">&gt;</span></div></td></tr></tbody></table></div>
<hr class="spacer" />
<p><strong>If you use the bnd-maven-plugin and raw bnd statements, you have to configure it with this bnd statement:</strong><br />
Place the configuration from the root pom.xml as such:</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #339933;">&lt;</span>plugin<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>groupId<span style="color: #339933;">&gt;</span>biz.<span style="color: #006633;">aQute</span>.<span style="color: #006633;">bnd</span><span style="color: #339933;">&lt;/</span>groupId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>artifactId<span style="color: #339933;">&gt;</span>bnd<span style="color: #339933;">-</span>maven<span style="color: #339933;">-</span>plugin<span style="color: #339933;">&lt;/</span>artifactId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>configuration<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>bnd<span style="color: #339933;">&gt;&lt;!</span><span style="color: #009900;">&#91;</span>CDATA<span style="color: #009900;">&#91;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ...<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">-</span>plugin org.<span style="color: #006633;">apache</span>.<span style="color: #006633;">sling</span>.<span style="color: #006633;">caconfig</span>.<span style="color: #006633;">bndplugin</span>.<span style="color: #006633;">ConfigurationClassScannerPlugin</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">&gt;&lt;/</span>bnd<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>configuration<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>dependencies<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>dependency<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>groupId<span style="color: #339933;">&gt;</span>org.<span style="color: #006633;">apache</span>.<span style="color: #006633;">sling</span><span style="color: #339933;">&lt;/</span>groupId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>artifactId<span style="color: #339933;">&gt;</span>org.<span style="color: #006633;">apache</span>.<span style="color: #006633;">sling</span>.<span style="color: #006633;">caconfig</span>.<span style="color: #006633;">bnd</span><span style="color: #339933;">-</span>plugin<span style="color: #339933;">&lt;/</span>artifactId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>version<span style="color: #339933;">&gt;</span>1.0.2<span style="color: #339933;">&lt;/</span>version<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>dependency<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>dependencies<span style="color: #339933;">&gt;</span><br />
<span style="color: #339933;">&lt;/</span>plugin<span style="color: #339933;">&gt;</span></div></td></tr></tbody></table></div>
<hr class="spacer" />
<p><strong>Sling Context Aware Configuration context-aware-configuration-bnd-plugin not working as expected</strong><br />
If both installations from the top are not working as expected, please try the configuration as below. Place the configuration from the root pom.xml as such. Take a look at line 21, where you can see we have kept org.apache.sling.caconfig.bndplugin.ConfigurationClassScannerPlugin, org.apache.sling.bnd.models.ModelsScannerPlugin in one line of code, with a comma as the delimiter.</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #339933;">&lt;</span>plugin<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>groupId<span style="color: #339933;">&gt;</span>biz.<span style="color: #006633;">aQute</span>.<span style="color: #006633;">bnd</span><span style="color: #339933;">&lt;/</span>groupId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>artifactId<span style="color: #339933;">&gt;</span>bnd<span style="color: #339933;">-</span>maven<span style="color: #339933;">-</span>plugin<span style="color: #339933;">&lt;/</span>artifactId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>version<span style="color: #339933;">&gt;</span>$<span style="color: #009900;">&#123;</span>bnd.<span style="color: #006633;">version</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">&lt;/</span>version<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>executions<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>execution<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>id<span style="color: #339933;">&gt;</span>bnd<span style="color: #339933;">-</span>process<span style="color: #339933;">&lt;/</span>id<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>goals<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>goal<span style="color: #339933;">&gt;</span>bnd<span style="color: #339933;">-</span>process<span style="color: #339933;">&lt;/</span>goal<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>goals<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>configuration<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>bnd<span style="color: #339933;">&gt;&lt;!</span><span style="color: #009900;">&#91;</span>CDATA<span style="color: #009900;">&#91;</span><br />
Bundle<span style="color: #339933;">-</span>Category<span style="color: #339933;">:</span> $<span style="color: #009900;">&#123;</span>componentGroupName<span style="color: #009900;">&#125;</span><br />
<br />
# export all versioned packages except <span style="color: #000000; font-weight: bold;">for</span> conditional ones <span style="color: #009900;">&#40;</span>https<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//github.com/bndtools/bnd/issues/3721#issuecomment-579026778)</span><br />
<span style="color: #339933;">-</span>exportcontents<span style="color: #339933;">:</span> $<span style="color: #009900;">&#123;</span>removeall<span style="color: #339933;">;</span>$<span style="color: #009900;">&#123;</span>packages<span style="color: #339933;">;</span>VERSIONED<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>$<span style="color: #009900;">&#123;</span>packages<span style="color: #339933;">;</span>CONDITIONAL<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#125;</span><br />
<br />
...<br />
<br />
<span style="color: #006633;">Bundle</span><span style="color: #339933;">-</span>DocURL<span style="color: #339933;">:</span><br />
<span style="color: #339933;">-</span>plugin org.<span style="color: #006633;">apache</span>.<span style="color: #006633;">sling</span>.<span style="color: #006633;">caconfig</span>.<span style="color: #006633;">bndplugin</span>.<span style="color: #006633;">ConfigurationClassScannerPlugin</span>, org.<span style="color: #006633;">apache</span>.<span style="color: #006633;">sling</span>.<span style="color: #006633;">bnd</span>.<span style="color: #006633;">models</span>.<span style="color: #006633;">ModelsScannerPlugin</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>bnd<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>configuration<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>execution<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>executions<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; ...<br />
<span style="color: #339933;">&lt;/</span>plugin<span style="color: #339933;">&gt;</span></div></td></tr></tbody></table></div>
<hr class="spacer-larger" />
<h3 id="step-6">6. Absolute Parent Context Path Strategy</h3>
<p>io.wcm.caconfig.extensions.contextpath.impl.AbsoluteParentContextPathStrategy-sourcedcode.config</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">contextPathBlacklistRegex<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&quot;</span><br />
service.<span style="color: #006633;">ranking</span><span style="color: #339933;">=</span>I<span style="color: #0000ff;">&quot;2000&quot;</span><br />
unlimited<span style="color: #339933;">=</span>B<span style="color: #0000ff;">&quot;false&quot;</span><br />
configPathPatterns<span style="color: #339933;">=</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;/conf$1&quot;</span><span style="color: #009900;">&#93;</span><br />
levels<span style="color: #339933;">=</span>i<span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;1&quot;</span>,<span style="color: #0000ff;">&quot;2&quot;</span>,<span style="color: #0000ff;">&quot;3&quot;</span>,<span style="color: #0000ff;">&quot;4&quot;</span><span style="color: #009900;">&#93;</span><br />
contextPathRegex<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;^/content(/sourcedcode|/experience-fragments/sourcedcode/.*)$&quot;</span><br />
templatePathsBlacklist<span style="color: #339933;">=</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#93;</span></div></td></tr></tbody></table></div>
<p>In this crucial step, we introduce the Absolute Parent Context Path Strategy, found in the io.wcm.caconfig.extensions.contextpath.impl.AbsoluteParentContextPathStrategy-<UNIQUE_IDENTIFIER>.config. This feature allows you to create tailored configurations for specific folders within your content repository. For instance, you can now establish separate configurations for &#8216;/content/sourcedcode/en&#8217; and &#8216;/content/sourcedcode/fr,&#8217; effectively breaking the chain of inheritance. This newfound freedom permits you to cancel inheritance at various levels, from 1 to 4, enabling you to fine-tune configurations to align with your folder structure. This level of precision and customization is pivotal in optimizing your content management experience.</p>
<hr class="spacer-larger" />
<h3 id="step-7">7. Root Template Context PathStrategy</h3>
<p>io.wcm.caconfig.extensions.contextpath.impl.RootTemplateContextPathStrategy-sourcedcode.config</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">maxLevel<span style="color: #339933;">=</span>I<span style="color: #0000ff;">&quot;4&quot;</span><br />
service.<span style="color: #006633;">ranking</span><span style="color: #339933;">=</span>I<span style="color: #0000ff;">&quot;2000&quot;</span><br />
templatePaths<span style="color: #339933;">=</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;/conf/sourcedcode/settings/wcm/templates/content-page&quot;</span>,<span style="color: #0000ff;">&quot;/conf/sourcedcode/settings/wcm/templates/blank-page&quot;</span><span style="color: #009900;">&#93;</span><br />
configPathPatterns<span style="color: #339933;">=</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;/conf$1&quot;</span><span style="color: #009900;">&#93;</span><br />
contextPathRegex<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;^/content/sourcedcode.*)$&quot;</span><br />
templateMatchAllLevels<span style="color: #339933;">=</span>B<span style="color: #0000ff;">&quot;true&quot;</span><br />
minLevel<span style="color: #339933;">=</span>I<span style="color: #0000ff;">&quot;1&quot;</span></div></td></tr></tbody></table></div>
<p>In this step, we focus on configuring the io.wcm.caconfig.extensions.contextpath.impl.RootTemplateContextPathStrategy-<name>.config. This feature allows you to establish a foundational template for your content, ensuring a well-structured content hierarchy in your AEM project. By defining a root template, you simplify content management and maintain consistency throughout your project. Whether you&#8217;re building a website, an application, or a digital experience, configuring a root template is a fundamental step in aligning your content with your project&#8217;s objectives.</p>
<hr class="spacer-larger" />
<h3 id="step-8">8. Absolute Parent Context Path Strategy, Folder Level Ca Configs</h3>
<p>io.wcm.caconfig.extensions.persistence.impl.PagePersistenceStrategy.config</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">service.<span style="color: #006633;">ranking</span><span style="color: #339933;">=</span>I<span style="color: #0000ff;">&quot;1500&quot;</span><br />
enabled<span style="color: #339933;">=</span>B<span style="color: #0000ff;">&quot;true&quot;</span><br />
resourceType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nt:unstructured&quot;</span></div></td></tr></tbody></table></div>
<p>If you intend to maintain the default Sling implementation, there are two options for handling the configurations: you can either package them from the author environment to the publish environment or replicate them from CRXDE Lite. If you opt for the wcm.io editor, it offers a feature that facilitates configuration replication by saving configurations as cq:Page nodes. To activate replication within the editor page, you should utilize the &#8220;PagePersistenceStrategy&#8221; provided by the &#8220;caconfig.extension&#8221; package, which must be deployed in AEM. Additionally, you need to enable the &#8220;io.wcm.caconfig.extensions.persistence.impl.PagePersistenceStrategy&#8221; OSGi configuration within the ui.apps module. Failing to complete this step will result in ca configurations being stored as folders, which necessitates setting the resourceType to nt:unstructured.</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/how-to-embed-wcm-io-context-aware-configuration-editor">How to Embed wcm.io Context-Aware Configuration Editor</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/how-to-embed-wcm-io-context-aware-configuration-editor/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>AEM Sling Servlet: resourceTypes for POST &#038; GET Code Example Code</title>
		<link>https://sourcedcode.com/blog/aem/aem-sling-servlet-resource-type-for-post-get-code-example-code</link>
					<comments>https://sourcedcode.com/blog/aem/aem-sling-servlet-resource-type-for-post-get-code-example-code#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Mon, 28 Aug 2023 06:37:48 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Sling Servlet]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=6020</guid>

					<description><![CDATA[<p>When working with Sling Servlets in AEM, the choice between using a resource type or a sling path as the basis for your servlet&#8217;s operation is crucial. This article delves into the benefits of utilizing resource types and provides practical examples of how resource types can streamline your development process for both POST and GET [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/aem-sling-servlet-resource-type-for-post-get-code-example-code">AEM Sling Servlet: resourceTypes for POST &#038; GET Code Example Code</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>When working with Sling Servlets in AEM, the choice between using a resource type or a sling path as the basis for your servlet&#8217;s operation is crucial. This article delves into the benefits of utilizing resource types and provides practical examples of how resource types can streamline your development process for both POST and GET templates.</p>
<hr class="spacer-larger" />
<h2>Resource Type vs. Sling Path</h2>
<p>The decision between using a resource type and a sling path as the foundation of your servlet&#8217;s functionality can significantly impact your development approach. A resource type is a more flexible and future-proof choice due to its abstraction from specific URLs. Resource types abstract the underlying storage structure, enabling your servlets to work consistently even if the content hierarchy changes. On the other hand, relying on sling paths can lead to brittle implementations, as they are tied to specific URLs that might change over time.</p>
<hr class="spacer-larger" />
<h2>Advantages of Resource Types</h2>
<ol>
<li><strong>Abstraction: </strong>Resource types provide an abstraction layer, separating the servlet&#8217;s logic from the actual URL structure. This ensures that your servlet remains functional even when the content structure evolves.
</li>
<li><strong>Adaptability: </strong>With resource types, your servlet can adapt to different parts of the content hierarchy without requiring modifications. This adaptability becomes crucial in scenarios where content structures are reorganized or repurposed.</li>
<li><strong>Consistency: </strong>By using resource types, you promote consistency in your application. Different components or pages with the same resource type can share the same servlet logic, enhancing maintainability.
</li>
</ol>
<hr class="spacer-large" />
<h2>Caveats when using @SlingServletPaths</h2>
<ol>
<li>Path-bound servlets cannot be access-controlled using the default JCR repository ACLs.</i>
<li>Path-bound servlets can only be registered to a path and not a resource type (i.e. no suffix handling).</i>
<li>If a path-bound servlet is not active, e.g. if the bundle is missing or not started, a POST might result in unexpected results. usually creating a node at /bin/xyz which subsequently overlays the servlets path binding. The mapping is not transparent to a developer looking just at the repository.</i>
</ol>
<hr class="spacer-larger" />
<h3>POST Template using Resource Type</h3>
<p>Consider a scenario where you want to handle form submissions via a POST request for multiple types of components. By utilizing resource types, you can create a centralized servlet that handles these submissions consistently, regardless of the content&#8217;s location.</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">@<span style="color: #003399;">Component</span><span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; service <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span> Servlet.<span style="color: #000000; font-weight: bold;">class</span> <span style="color: #009900;">&#125;</span>,<br />
&nbsp; &nbsp; property <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;sling.servlet.resourceTypes=yourapp/components/form&quot;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;sling.servlet.methods=POST&quot;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#41;</span><br />
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> FormSubmitServlet <span style="color: #000000; font-weight: bold;">extends</span> SlingAllMethodsServlet <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; @Override<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> doPost<span style="color: #009900;">&#40;</span>SlingHttpServletRequest request, SlingHttpServletResponse response<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> ServletException, <span style="color: #003399;">IOException</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Process form submission</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// ...</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Send JSON response</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; JSONObject jsonResponse <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> JSONObject<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; jsonResponse.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;success&quot;</span>, <span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; response.<span style="color: #006633;">setContentType</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;application/json&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; response.<span style="color: #006633;">setCharacterEncoding</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;UTF-8&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; response.<span style="color: #006633;">getWriter</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">write</span><span style="color: #009900;">&#40;</span>jsonResponse.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<hr class="spacer-large" />
<h3>GET Template using Resource Type</h3>
<p>Imagine you need to retrieve data from different types of resources, such as articles and videos, and display them using a single servlet. Utilizing resource types allows you to create a unified servlet to serve diverse content.</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">@<span style="color: #003399;">Component</span><span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; service <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span> Servlet.<span style="color: #000000; font-weight: bold;">class</span> <span style="color: #009900;">&#125;</span>,<br />
&nbsp; &nbsp; property <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;sling.servlet.resourceTypes=yourapp/components/content&quot;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;sling.servlet.methods=GET&quot;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#41;</span><br />
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ContentDisplayServlet <span style="color: #000000; font-weight: bold;">extends</span> SlingSafeMethodsServlet <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; @Override<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> doGet<span style="color: #009900;">&#40;</span>SlingHttpServletRequest request, SlingHttpServletResponse response<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> ServletException, <span style="color: #003399;">IOException</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Fetch and render content</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// ...</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Send JSON response</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; JSONObject jsonResponse <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> JSONObject<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; jsonResponse.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;success&quot;</span>, <span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; response.<span style="color: #006633;">setContentType</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;application/json&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; response.<span style="color: #006633;">setCharacterEncoding</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;UTF-8&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; response.<span style="color: #006633;">getWriter</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">write</span><span style="color: #009900;">&#40;</span>jsonResponse.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<hr class="spacer-larger" />
<h2>Conclusion</h2>
<p>Resource types stand as a powerful tool in AEM&#8217;s arsenal, offering a versatile and robust approach to developing Sling Servlets for both POST and GET templates. By abstracting the underlying URL structure, resource types enable consistent servlet behavior across different content hierarchies. This approach enhances code maintainability, adaptability, and future-proofing. In contrast, sling paths can result in rigid implementations tied to specific URLs. By embracing resource types, developers can create more flexible, reliable, and adaptable solutions in Adobe Experience Manager.</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/aem-sling-servlet-resource-type-for-post-get-code-example-code">AEM Sling Servlet: resourceTypes for POST &#038; GET Code Example Code</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/aem-sling-servlet-resource-type-for-post-get-code-example-code/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>AEM JCR SQL2 Full Text Search Case Insensitive</title>
		<link>https://sourcedcode.com/blog/aem/aem-jcr-sql2-full-text-search-case-insensitive</link>
					<comments>https://sourcedcode.com/blog/aem/aem-jcr-sql2-full-text-search-case-insensitive#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Mon, 28 Aug 2023 06:06:51 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Search]]></category>
		<category><![CDATA[Sling Servlet]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=5999</guid>

					<description><![CDATA[<p>One of the key features of AEM is its support for searching and querying content stored in its Java Content Repository (JCR). In this article, we will explore how to perform a case-insensitive full-text search using the JCR_SQL2 query language in AEM and provide a practical example of achieving this through a servlet. Performing Case-Insensitive [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/aem-jcr-sql2-full-text-search-case-insensitive">AEM JCR SQL2 Full Text Search Case Insensitive</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>One of the key features of AEM is its support for searching and querying content stored in its Java Content Repository (JCR). In this article, we will explore how to perform a case-insensitive full-text search using the JCR_SQL2 query language in AEM and provide a practical example of achieving this through a servlet.</p>
<hr class="spacer-large"/>
<h2>Performing Case-Insensitive Full Text Search</h2>
<p>A case-insensitive full-text search is a common requirement when you want to retrieve content regardless of the letter casing used in the search query. In AEM, the JCR_SQL2 query language is used to interact with the JCR repository. To perform a case-insensitive full-text search, you can utilize the<span class="code-highlight-secondary">LOWER()</span>function to convert both the search query and the content being searched to lowercase. This ensures that the search is not case-sensitive.</p>
<hr class="spacer-larger"/>
<h2>Example Query Code</h2>
<p>Consider a scenario where you want to search for assets that are descendants of a specific path and meet certain criteria, while also performing a case-insensitive search for specific keywords. Below is an example of a JCR_SQL2 query code block that achieves this:</p>
<div class="code-1200">
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br />78<br />79<br />80<br />81<br />82<br />83<br />84<br />85<br />86<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.SlingHttpServletRequest</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.SlingHttpServletResponse</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.servlets.SlingAllMethodsServlet</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.json.JSONArray</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.json.JSONObject</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.servlet.Servlet</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.IOException</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.jcr.query.Query</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.jcr.Session</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.jcr.Node</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.jcr.query.QueryManager</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.jcr.query.QueryResult</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.jcr.query.RowIterator</span><span style="color: #339933;">;</span><br />
<br />
@<span style="color: #003399;">Component</span><span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; service <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span> Servlet.<span style="color: #000000; font-weight: bold;">class</span> <span style="color: #009900;">&#125;</span>,<br />
&nbsp; &nbsp; property <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;sling.servlet.methods=GET&quot;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;sling.servlet.paths=/bin/mysearchservlet&quot;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#41;</span><br />
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MySearchServlet <span style="color: #000000; font-weight: bold;">extends</span> SlingAllMethodsServlet <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; @Override<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> doGet<span style="color: #009900;">&#40;</span>SlingHttpServletRequest request, SlingHttpServletResponse response<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">IOException</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; response.<span style="color: #006633;">setContentType</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;application/json&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; response.<span style="color: #006633;">setCharacterEncoding</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;UTF-8&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Retrieve the search query parameter</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">String</span> queryParameter <span style="color: #339933;">=</span> request.<span style="color: #006633;">getParameter</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;query&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Validate if the query parameter is not null or empty</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>queryParameter <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span> <span style="color: #339933;">||</span> queryParameter.<span style="color: #006633;">isEmpty</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; JSONObject errorResponse <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> JSONObject<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; errorResponse.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;error&quot;</span>, <span style="color: #0000ff;">&quot;Missing query parameter&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; response.<span style="color: #006633;">getWriter</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">write</span><span style="color: #009900;">&#40;</span>errorResponse.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Retrieve the JCR session</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Session session <span style="color: #339933;">=</span> request.<span style="color: #006633;">getResourceResolver</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">adaptTo</span><span style="color: #009900;">&#40;</span>Session.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Define your query</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">String</span> queryString <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SELECT * FROM [cq:Page] AS page &quot;</span> <span style="color: #339933;">+</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;WHERE ISDESCENDANTNODE(page, '/content/myproject')&quot;</span> <span style="color: #339933;">+</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot; &nbsp; &nbsp;AND (&quot;</span> <span style="color: #339933;">+</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot; &nbsp; &nbsp; &nbsp; &nbsp;LOWER(page.[jcr:content/jcr:title]) LIKE '%&quot;</span> <span style="color: #339933;">+</span> queryParameter <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;%'&quot;</span> <span style="color: #339933;">+</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot; &nbsp; &nbsp; &nbsp; &nbsp;OR LOWER(page.[jcr:content/cq:template]) LIKE '%&quot;</span> <span style="color: #339933;">+</span> queryParameter <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;%'&quot;</span> <span style="color: #339933;">+</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot; &nbsp; &nbsp; &nbsp; &nbsp;OR LOWER(page.[jcr:content/jcr:description]) LIKE '%&quot;</span> <span style="color: #339933;">+</span> queryParameter <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;%'&quot;</span> <span style="color: #339933;">+</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot; &nbsp; &nbsp;)&quot;</span> <span style="color: #339933;">+</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;ORDER BY [jcr:score] DESC&quot;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Get the QueryManager and create the query</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; QueryManager queryManager <span style="color: #339933;">=</span> session.<span style="color: #006633;">getWorkspace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getQueryManager</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Query query <span style="color: #339933;">=</span> queryManager.<span style="color: #006633;">createQuery</span><span style="color: #009900;">&#40;</span>queryString, Query.<span style="color: #006633;">JCR_SQL2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Execute the query</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; QueryResult result <span style="color: #339933;">=</span> query.<span style="color: #006633;">execute</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Process the results and build JSON response</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; JSONArray resultsArray <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> JSONArray<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; RowIterator rows <span style="color: #339933;">=</span> result.<span style="color: #006633;">getRows</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span>rows.<span style="color: #006633;">hasNext</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Node pageNode <span style="color: #339933;">=</span> rows.<span style="color: #006633;">nextRow</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getNode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;page&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; JSONObject pageData <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> JSONObject<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pageData.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;title&quot;</span>, pageNode.<span style="color: #006633;">getProperty</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;jcr:content/jcr:title&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pageData.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;template&quot;</span>, pageNode.<span style="color: #006633;">getProperty</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;jcr:content/cq:template&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pageData.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;description&quot;</span>, pageNode.<span style="color: #006633;">getProperty</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;jcr:content/jcr:description&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; resultsArray.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span>pageData<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Respond with JSON search results</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; response.<span style="color: #006633;">getWriter</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">write</span><span style="color: #009900;">&#40;</span>resultsArray.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; JSONObject errorResponse <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> JSONObject<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; errorResponse.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;error&quot;</span>, e.<span style="color: #006633;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; response.<span style="color: #006633;">getWriter</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">write</span><span style="color: #009900;">&#40;</span>errorResponse.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">finally</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Close the JCR session</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; session.<span style="color: #006633;">logout</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
</div>
<hr class="spacer-large" />
<h2>Example Try Catch</h2>
<div class="mention-block">
When utilizing service users in Java, it&#8217;s essential to incorporate try-catch blocks for exception handling. Java introduced enhanced try-catch blocks, which allow you to catch multiple exceptions using a single catch block, in version 7. Before Java 7, try-catch blocks could only handle one exception type per catch block. With the improvements in Java 7, developers gained the ability to efficiently catch and manage various types of exceptions within a structured framework. These enhanced try-catch blocks serve as a powerful means of error management, preventing application crashes, facilitating user-friendly error messages, assisting in the debugging process, and bolstering overall code reliability.</p>
<p>Moreover, when working with service users, it&#8217;s important to remember that the JCR session should always be properly closed. Failing to close the session can lead to lingering threads and resource leaks. Incorporating try-with-resources or explicit session closure ensures that resources are released and system resources are utilized optimally. This practice contributes to maintaining the stability and efficiency of your application.
</p></div>
<div class="code-1200">
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br />78<br />79<br />80<br />81<br />82<br />83<br />84<br />85<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.SlingHttpServletRequest</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.SlingHttpServletResponse</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.servlets.SlingAllMethodsServlet</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.resource.ResourceResolver</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.resource.ResourceResolverFactory</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.json.JSONArray</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.json.JSONObject</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.servlet.Servlet</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.IOException</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Collections</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Map</span><span style="color: #339933;">;</span><br />
<br />
@<span style="color: #003399;">Component</span><span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; service <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span> Servlet.<span style="color: #000000; font-weight: bold;">class</span> <span style="color: #009900;">&#125;</span>,<br />
&nbsp; &nbsp; property <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;sling.servlet.methods=GET&quot;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;sling.servlet.paths=/bin/mysearchservlet&quot;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#41;</span><br />
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MySearchServlet <span style="color: #000000; font-weight: bold;">extends</span> SlingAllMethodsServlet <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; @<span style="color: #003399;">Reference</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> ResourceResolverFactory resolverFactory<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; @Override<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> doGet<span style="color: #009900;">&#40;</span>SlingHttpServletRequest request, SlingHttpServletResponse response<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">IOException</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; response.<span style="color: #006633;">setContentType</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;application/json&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; response.<span style="color: #006633;">setCharacterEncoding</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;UTF-8&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Retrieve the search query parameter</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">String</span> queryParameter <span style="color: #339933;">=</span> request.<span style="color: #006633;">getParameter</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;query&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Validate if the query parameter is not null or empty</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>queryParameter <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span> <span style="color: #339933;">||</span> queryParameter.<span style="color: #006633;">isEmpty</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; JSONObject errorResponse <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> JSONObject<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; errorResponse.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;error&quot;</span>, <span style="color: #0000ff;">&quot;Missing query parameter&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; response.<span style="color: #006633;">getWriter</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">write</span><span style="color: #009900;">&#40;</span>errorResponse.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">final</span> Map<span style="color: #339933;">&lt;</span><span style="color: #003399;">String</span>, Object<span style="color: #339933;">&gt;</span> authInfo <span style="color: #339933;">=</span> <span style="color: #003399;">Collections</span>.<span style="color: #006633;">singletonMap</span><span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ResourceResolverFactory.<span style="color: #006633;">SUBSERVICE</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;sourcedCodeSystemUser&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#40;</span>ResourceResolver resourceResolver <span style="color: #339933;">=</span> resolverFactory.<span style="color: #006633;">getServiceResourceResolver</span><span style="color: #009900;">&#40;</span>authInfo<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Define your query</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">String</span> queryString <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SELECT * FROM [cq:Page] AS page &quot;</span> <span style="color: #339933;">+</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;WHERE ISDESCENDANTNODE(page, '/content/myproject')&quot;</span> <span style="color: #339933;">+</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot; &nbsp; &nbsp;AND (&quot;</span> <span style="color: #339933;">+</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot; &nbsp; &nbsp; &nbsp; &nbsp;LOWER(page.[jcr:content/jcr:title]) LIKE '%&quot;</span> <span style="color: #339933;">+</span> queryParameter <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;%'&quot;</span> <span style="color: #339933;">+</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot; &nbsp; &nbsp; &nbsp; &nbsp;OR LOWER(page.[jcr:content/cq:template]) LIKE '%&quot;</span> <span style="color: #339933;">+</span> queryParameter <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;%'&quot;</span> <span style="color: #339933;">+</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot; &nbsp; &nbsp; &nbsp; &nbsp;OR LOWER(page.[jcr:content/jcr:description]) LIKE '%&quot;</span> <span style="color: #339933;">+</span> queryParameter <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;%'&quot;</span> <span style="color: #339933;">+</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot; &nbsp; &nbsp;)&quot;</span> <span style="color: #339933;">+</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;ORDER BY [jcr:score] DESC&quot;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Get the QueryManager and create the query</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; QueryManager queryManager <span style="color: #339933;">=</span> resourceResolver.<span style="color: #006633;">adaptTo</span><span style="color: #009900;">&#40;</span>QueryManager.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Query query <span style="color: #339933;">=</span> queryManager.<span style="color: #006633;">createQuery</span><span style="color: #009900;">&#40;</span>queryString, Query.<span style="color: #006633;">JCR_SQL2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Execute the query</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; QueryResult result <span style="color: #339933;">=</span> query.<span style="color: #006633;">execute</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Process the results and build JSON response</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; JSONArray resultsArray <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> JSONArray<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; RowIterator rows <span style="color: #339933;">=</span> result.<span style="color: #006633;">getRows</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span>rows.<span style="color: #006633;">hasNext</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Node pageNode <span style="color: #339933;">=</span> rows.<span style="color: #006633;">nextRow</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getNode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;page&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; JSONObject pageData <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> JSONObject<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pageData.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;title&quot;</span>, pageNode.<span style="color: #006633;">getProperty</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;jcr:content/jcr:title&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pageData.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;template&quot;</span>, pageNode.<span style="color: #006633;">getProperty</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;jcr:content/cq:template&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pageData.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;description&quot;</span>, pageNode.<span style="color: #006633;">getProperty</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;jcr:content/jcr:description&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; resultsArray.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span>pageData<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Respond with JSON search results</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; response.<span style="color: #006633;">getWriter</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">write</span><span style="color: #009900;">&#40;</span>resultsArray.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; JSONObject errorResponse <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> JSONObject<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; errorResponse.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;error&quot;</span>, <span style="color: #0000ff;">&quot;An error occurred while processing the request.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; response.<span style="color: #006633;">getWriter</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">write</span><span style="color: #009900;">&#40;</span>errorResponse.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
</div>
<p><strong>Curl Example:</strong></p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">curl <span style="color: #0000ff;">&quot;http://localhost:4502/bin/mysearchservlet?query=my_search_keyword&quot;</span></div></td></tr></tbody></table></div>
<p><strong>Output:</strong></p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #009900;">&#91;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;title&quot;</span><span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;Page Title 1&quot;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;template&quot;</span><span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;/conf/phonak/settings/wcm/templates/mytemplate&quot;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;description&quot;</span><span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;This is the description of Page 1&quot;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span>,<br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;title&quot;</span><span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;Page Title 2&quot;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;template&quot;</span><span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;/conf/phonak/settings/wcm/templates/anothertemplate&quot;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;description&quot;</span><span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;Description for Page 2&quot;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#93;</span></div></td></tr></tbody></table></div>
<hr class="spacer-large"/>
<p>In this example, the<span class="code-highlight-secondary">LOWER()</span>function is applied to both the properties being searched and the search query<span class="code-highlight-secondary">fulltext</span> This ensures that the search is case-insensitive, allowing you to retrieve relevant assets regardless of letter casing.</p>
<p>Practical Example: Implementing the Search in a Servlet</p>
<p>To practically implement the above query within a servlet in AEM, you would typically perform the following steps:</p>
<li>Create a Java servlet that extends<span class="code-highlight-secondary">SlingAllMethodsServlet</span>or implements<span class="code-highlight-secondary">SlingServlet</span></li>
<li>In the servlet&#8217;s<span class="code-highlight-secondary">doGet</span>or<span class="code-highlight-secondary">doPost</span>method, create an instance of the<span class="code-highlight-secondary">QueryManager</span>to execute the JCR_SQL2 query.</li>
<li>Use the query string from the example above, replacing placeholders like<span class="code-highlight-secondary">productCFsRootPath</span>and<span class="code-highlight-secondary">fulltext</span>with actual values.</li>
<li>Process the query result, extract the relevant data, and respond to the client with the search results.</li>
<hr class="spacer-large"/>
<h2>Conclusion</h2>
<p>Performing a case-insensitive full-text search using the JCR_SQL2 query language in Adobe Experience Manager allows you to provide a seamless search experience for users regardless of their choice of letter casing. By utilizing the<span class="code-highlight-secondary">LOWER()</span>function, you can effectively eliminate case sensitivity from your search queries and retrieve the most relevant content. Incorporating this technique into your AEM projects can enhance user experience and ensure that content discovery is efficient and user-friendly.</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/aem-jcr-sql2-full-text-search-case-insensitive">AEM JCR SQL2 Full Text Search Case Insensitive</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/aem-jcr-sql2-full-text-search-case-insensitive/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Granite UI, Touch UI helpPath</title>
		<link>https://sourcedcode.com/blog/aem/granite-ui-touch-ui-helppath</link>
					<comments>https://sourcedcode.com/blog/aem/granite-ui-touch-ui-helppath#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Mon, 28 Aug 2023 05:37:20 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Author]]></category>
		<category><![CDATA[Touch UI]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=5981</guid>

					<description><![CDATA[<p>helpPath typically refers to a configuration property that defines the path to the location where help content or documentation is stored within the AEM repository. The helpPath configuration property is often used in AEM components or templates to specify the location where users can access contextual help documentation related to the specific component or template. [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/granite-ui-touch-ui-helppath">Granite UI, Touch UI helpPath</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><span class="code-highlight-primary">helpPath</span> typically refers to a configuration property that defines the path to the location where help content or documentation is stored within the AEM repository.</p>
<p>The <span class="code-highlight-primary">helpPath</span> configuration property is often used in AEM components or templates to specify the location where users can access contextual help documentation related to the specific component or template. This can be helpful for content authors and administrators who need guidance on how to use certain features or elements within the AEM interface.</p>
<p>By setting the <span class="code-highlight-primary">helpPath</span> property, you provide a reference to the relevant documentation that users can access directly from the AEM interface, making it easier for them to understand and work with different components and features. Clicking on the help path will redirect the author to documentation which may be useful for them to understand how the component works as expected.</p>
<p><a href="https://sourcedcode.com/wp-content/uploads/2023/08/teaser-component-helpPath.png"><img loading="lazy" decoding="async" src="https://sourcedcode.com/wp-content/uploads/2023/08/teaser-component-helpPath.png" alt="helpPath Granite Ui, Touch UI" width="1258" height="448" class="alignnone size-full wp-image-5995" srcset="https://sourcedcode.com/wp-content/uploads/2023/08/teaser-component-helpPath.png 1258w, https://sourcedcode.com/wp-content/uploads/2023/08/teaser-component-helpPath-300x107.png 300w, https://sourcedcode.com/wp-content/uploads/2023/08/teaser-component-helpPath-1024x365.png 1024w, https://sourcedcode.com/wp-content/uploads/2023/08/teaser-component-helpPath-768x274.png 768w, https://sourcedcode.com/wp-content/uploads/2023/08/teaser-component-helpPath-600x214.png 600w" sizes="(max-width: 1258px) 100vw, 1258px" /></a></p>
<p>Keep in mind that the exact implementation and usage of <span class="code-highlight-primary">helpPath</span> can vary based on the specific version of AEM and the customizations made by the organization. Always refer to the official AEM documentation or any relevant resources specific to your version of AEM for the most accurate and up-to-date information.</p>
<hr class="spacer-larger" />
<h3>Example Code</h3>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #339933;">&lt;</span>jcr<span style="color: #339933;">:</span>root xmlns<span style="color: #339933;">:</span>sling<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://sling.apache.org/jcr/sling/1.0&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xmlns<span style="color: #339933;">:</span>jcr<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://www.jcp.org/jcr/1.0&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xmlns<span style="color: #339933;">:</span>nt<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://www.jcp.org/jcr/nt/1.0&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xmlns<span style="color: #339933;">:</span>cq<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://www.day.com/jcr/cq/1.0&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xmlns<span style="color: #339933;">:</span>granite<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://www.adobe.com/jcr/granite/1.0&quot;</span><br />
&nbsp; &nbsp; jcr<span style="color: #339933;">:</span>primaryType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; jcr<span style="color: #339933;">:</span>title<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;My Custom Component&quot;</span><br />
&nbsp; &nbsp; sling<span style="color: #339933;">:</span>resourceType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;cq/gui/components/authoring/dialog&quot;</span><br />
&nbsp; &nbsp; extraClientlibs<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;[myproject.components.mycustomcomponent.editor]&quot;</span><br />
&nbsp; &nbsp; helpPath<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;/content/myproject/help/mycustomcomponent.html&quot;</span><br />
&nbsp; &nbsp; trackingFeature<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;myproject:mycustomcomponent&quot;</span><span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;!--</span> Define your component<span style="color: #0000ff;">'s dialog structure here --&gt;<br />
&lt;/jcr:root&gt;</span></div></td></tr></tbody></table></div>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/granite-ui-touch-ui-helppath">Granite UI, Touch UI helpPath</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/granite-ui-touch-ui-helppath/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Sling Resource Merging Properties</title>
		<link>https://sourcedcode.com/blog/aem/sling-resource-merging-properties</link>
					<comments>https://sourcedcode.com/blog/aem/sling-resource-merging-properties#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Sun, 27 Aug 2023 04:23:10 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Touch UI]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=5970</guid>

					<description><![CDATA[<p>In the realm of AEM developers have a powerful tool at their disposal that allows for seamless customization—Sling Resource Merging. This feature might sound a bit technical, but fear not! In this article, we&#8217;ll break down the key aspects of Sling Resource Merging and delve into its properties, showing you how they can simplify your [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/sling-resource-merging-properties">Sling Resource Merging Properties</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>In the realm of AEM developers have a powerful tool at their disposal that allows for seamless customization—Sling Resource Merging. This feature might sound a bit technical, but fear not! In this article, we&#8217;ll break down the key aspects of Sling Resource Merging and delve into its properties, showing you how they can simplify your development process.</p>
<div class="mention-block">
    <strong>Quick Links:</strong></p>
<ul>
<li><a href="#deeper-look">1. A Deeper Look at Sling Resource Merging</a></li>
<li><a href="#demystifying-slingresource">2. Demystifying Sling Resource Merging Properties</a>
<ul>
<li><a href="#hideProperties">2.1. sling:hideProperties (String or String[])</a></li>
<li><a href="#hideResource">2.2. sling:hideResource (Boolean)</a></li>
<li><a href="#hideChildren">2.3. sling:hideChildren (String or String[])</a></li>
<li><a href="#orderBefore">2.4. sling:orderBefore (String)</a></li>
</ul>
</li>
<li><a href="#real-world-applications">3. Real-world Applications of These Properties</a></li>
<li><a href="#wrapping-up">4. Wrapping Up</a></li>
</ul>
</div>
<hr class="spacer-larger"/>
<h2 id="deeper-look">1. A Deeper Look at Sling Resource Merging</h2>
<p>Sling Resource Merging is like a code-friendly puzzle solver—it lets you combine resources and properties from different locations without getting tangled up. This is especially handy when you&#8217;re looking to make specific changes without messing around in the core functionalities stored in `/libs`. Let&#8217;s dive into the properties that make this process smoother.</p>
<hr class="spacer-larger"/>
<h2 id="demystifying-slingresource">2. Demystifying Sling Resource Merging Properties</h2>
<h3 id="essentials">Here&#8217;s a rundown of the essential properties you&#8217;ll encounter:</h3>
<hr class="spacer" style="background: none;"/>
<h4 id="hideProperties" style="margin-top:60px;">2.1. sling:hideProperties (String or String[])</h4>
<p>This property allows you to hide certain properties that you don&#8217;t want to see. Whether you specify a single property or an array of properties, they&#8217;ll vanish from sight. The wildcard `*` works like magic—it hides everything except what you choose; Specifies the property, or list of properties, to hide.The wildcard * hides all.</p>
<p><strong>Example:</strong></p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #339933;">&lt;</span>linkAriaLabel<br />
&nbsp; &nbsp; jcr<span style="color: #339933;">:</span>primaryType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; sling<span style="color: #339933;">:</span>hideProperties<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;[linkAriaLabel]&quot;</span><br />
&nbsp; &nbsp; sling<span style="color: #339933;">:</span>resourceType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;granite/ui/components/coral/foundation/form/textfield&quot;</span><br />
&nbsp; &nbsp; fieldDescription<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;This aria label will be used for the link.&quot;</span><br />
&nbsp; &nbsp; fieldLabel<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Link Aria Label&quot;</span><br />
&nbsp; &nbsp; emptyText<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Link Aria Label&quot;</span><br />
&nbsp; &nbsp; name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;./linkAriaLabel&quot;</span><span style="color: #339933;">/&gt;</span></div></td></tr></tbody></table></div>
<hr class="spacer" style="background: none;"/>
<h4 id="hideResource" style="margin-top:60px;">2.2. sling:hideResource (Boolean)</h4>
<p>When set to `true`, this property hides a resource entirely, including its children. Think of it as a way to temporarily pull a curtain over a specific resource when you need it out of sight; Indicates whether the resources should be completely hidden, including its children.</p>
<p><strong>Example:</strong> In this example, we are hiding linkAriaLabel from being rendered on the view.</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #339933;">&lt;</span>linkAriaLabel<br />
&nbsp; &nbsp; jcr<span style="color: #339933;">:</span>primaryType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; sling<span style="color: #339933;">:</span>hideResource<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;{Boolean}true&quot;</span><br />
&nbsp; &nbsp; sling<span style="color: #339933;">:</span>resourceType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;granite/ui/components/coral/foundation/form/textfield&quot;</span><br />
&nbsp; &nbsp; fieldDescription<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;This aria label will be used for the link.&quot;</span><br />
&nbsp; &nbsp; fieldLabel<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Link Aria Label&quot;</span><br />
&nbsp; &nbsp; emptyText<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Link Aria Label&quot;</span><br />
&nbsp; &nbsp; name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;./linkAriaLabel&quot;</span><span style="color: #339933;">/&gt;</span></div></td></tr></tbody></table></div>
<hr class="spacer" style="background: none;"/>
<h4 id="hideChildren" style="margin-top:60px;">2.3. sling:hideChildren (String or String[])</h4>
<p>Unlike the previous property, this one selectively hides child nodes while preserving their properties. Whether you&#8217;re hiding one or using `*` to hide them all, the properties stay untouched; Contains the child node, or list of child nodes, to hide. The properties of the node will be maintained. The wildcard * hides all.</p>
<p><strong>Example:</strong> In this example, all children Granite UI fields are hidden from the view.</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #339933;">&lt;</span>fixedcolums<br />
&nbsp; &nbsp; jcr<span style="color: #339933;">:</span>primaryType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; sling<span style="color: #339933;">:</span>resourceType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;granite/ui/components/coral/foundation/fixedcolumns&quot;</span><span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>items jcr<span style="color: #339933;">:</span>primaryType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; sling<span style="color: #339933;">:</span>hideChildren<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;*&quot;</span><span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>properties<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jcr<span style="color: #339933;">:</span>primaryType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sling<span style="color: #339933;">:</span>resourceType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;granite/ui/components/coral/foundation/container&quot;</span><span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>items jcr<span style="color: #339933;">:</span>primaryType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nt:unstructured&quot;</span><span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>pageTitle<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jcr<span style="color: #339933;">:</span>primaryType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sling<span style="color: #339933;">:</span>resourceType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;granite/ui/components/coral/foundation/form/text&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ..<span style="color: #339933;">/&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>description<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jcr<span style="color: #339933;">:</span>primaryType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sling<span style="color: #339933;">:</span>resourceType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;granite/ui/components/coral/foundation/form/text&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ..<span style="color: #339933;">/&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>items<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>properties<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>items<span style="color: #339933;">&gt;</span><br />
<span style="color: #339933;">&lt;/</span>fixedcolums<span style="color: #339933;">&gt;</span></div></td></tr></tbody></table></div>
<hr class="spacer" style="background: none;"/>
<h4 id="orderBefore" style="margin-top:60px;">2.4. sling:orderBefore (String)</h4>
<p>This property will force the Granite UI to render before a specific element. In this example, we are forcing the linkAriaLabel to render before the &#8220;title&#8221; Granite UI; Contains the name of the sibling node that the current node should be positioned in front of.</p>
<p><strong>Example:</strong></p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #339933;">&lt;</span>title<br />
&nbsp; &nbsp; &nbsp;....<span style="color: #339933;">/&gt;</span><br />
<span style="color: #339933;">&lt;</span>linkAriaLabel<br />
&nbsp; &nbsp; jcr<span style="color: #339933;">:</span>primaryType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; sling<span style="color: #339933;">:</span>orderBefore<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;title&quot;</span><br />
&nbsp; &nbsp; sling<span style="color: #339933;">:</span>resourceType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;granite/ui/components/coral/foundation/form/textfield&quot;</span><br />
&nbsp; &nbsp; fieldDescription<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;This aria label will be used for the link.&quot;</span><br />
&nbsp; &nbsp; fieldLabel<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Link Aria Label&quot;</span><br />
&nbsp; &nbsp; emptyText<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Link Aria Label&quot;</span><br />
&nbsp; &nbsp; name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;./linkAriaLabel&quot;</span><span style="color: #339933;">/&gt;</span></div></td></tr></tbody></table></div>
<hr class="spacer-larger"/>
<h2 id="real-world-applications">3. Real-world Applications of These Properties</h2>
<h3>Let&#8217;s translate these properties into practical scenarios:</h3>
<ol>
<li><strong>Tailored Component Styling</strong>: Say you have a core component in `/libs` with default styles. Use `sling:hideProperties` to conceal unnecessary styles and introduce your own in `/apps`. This way, you retain the core functionality while customizing the look.</li>
<li><strong>Conditional Rendering</strong>: For situations where you need to show or hide an entire component, `sling:hideResource` is your ally. It&#8217;s like having a switch to control whether a component and its children should be displayed based on specific conditions.</li>
<li><strong>Optimized Content Arrangement</strong>: Use `sling:orderBefore` to reposition components within a container. This property is particularly helpful for responsive designs, ensuring content displays flawlessly on various devices.</li>
</ol>
<hr class="spacer-larger"/>
<h2 id="wrapping-up">4. Wrapping Up</h2>
<p>Sling Resource Merging isn&#8217;t a mysterious incantation—it&#8217;s a tool that simplifies your AEM development journey. By getting acquainted with properties like `sling:hideProperties`, `sling:hideResource`, `sling:hideChildren`, and `sling:orderBefore`, you&#8217;re equipped to wield customization powers without the fuss. So go ahead, explore, and let Sling Resource Merging elevate your AEM development game!</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/sling-resource-merging-properties">Sling Resource Merging Properties</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/sling-resource-merging-properties/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to access Design Dialogue Properties in Sling Model</title>
		<link>https://sourcedcode.com/blog/aem/how-to-access-design-dialogue-properties-in-sling-model</link>
					<comments>https://sourcedcode.com/blog/aem/how-to-access-design-dialogue-properties-in-sling-model#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Fri, 25 Aug 2023 21:37:11 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Quick Reference]]></category>
		<category><![CDATA[Short Post]]></category>
		<category><![CDATA[Sling Servlet]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=5962</guid>

					<description><![CDATA[<p>Design Dialogs are especially useful for creating components that need to be easily configurable through editable template and policies without directly editing the underlying code. They enable a clear separation between content and presentation, allowing content authors to make changes without needing technical expertise. Design Dialogs are defined using the AEM Touch UI Dialog, which [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/how-to-access-design-dialogue-properties-in-sling-model">How to access Design Dialogue Properties in Sling Model</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Design Dialogs are especially useful for creating components that need to be easily configurable through editable template and policies without directly editing the underlying code. They enable a clear separation between content and presentation, allowing content authors to make changes without needing technical expertise. Design Dialogs are defined using the AEM Touch UI Dialog, which is an integral part of the component development process.</p>
<p>In this article we will talk through how to access the design dialogue settings that is configured in editable template policies within Sling Models. This article will be a quick reference, which means we will provide you code examples for the solution.</p>
<hr class="spacer-larger"/>
<h2>1. Example _cq_design_dialog.xml configuration</h2>
<p>This is a snippet that resides in /apps/core/wcm/components/title/v1/title/_cq_design_dialog.xml</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #339933;">&lt;</span>advancedSettings<br />
&nbsp; &nbsp; jcr<span style="color: #339933;">:</span>primaryType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; jcr<span style="color: #339933;">:</span>title<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Advanced Settings&quot;</span><br />
&nbsp; &nbsp; sling<span style="color: #339933;">:</span>resourceType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;granite/ui/components/coral/foundation/container&quot;</span><br />
&nbsp; &nbsp; margin<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;{Boolean}true&quot;</span><span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>items jcr<span style="color: #339933;">:</span>primaryType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nt:unstructured&quot;</span><span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>renderLayoutAs<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jcr<span style="color: #339933;">:</span>primaryType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sling<span style="color: #339933;">:</span>resourceType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;granite/ui/components/coral/foundation/form/select&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fieldDescription<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Forcing the component to render column layouts as&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fieldLabel<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Render Layout As&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;./renderLayoutAs&quot;</span><span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>items jcr<span style="color: #339933;">:</span>primaryType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nt:unstructured&quot;</span><span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>oneColumn<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jcr<span style="color: #339933;">:</span>primaryType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; text<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Default (One Column)&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; selected<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;{Boolean}true&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;oneColumn&quot;</span><span style="color: #339933;">/&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>twoColumns<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jcr<span style="color: #339933;">:</span>primaryType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; text<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Two Columns&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; selected<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;{Boolean}true&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;twoColumns&quot;</span><span style="color: #339933;">/&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>threeColumns<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jcr<span style="color: #339933;">:</span>primaryType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; text<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Three Columns&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;threeColumns&quot;</span><span style="color: #339933;">/&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>fourColumns<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jcr<span style="color: #339933;">:</span>primaryType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; text<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Four Columns&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;fourColumns&quot;</span><span style="color: #339933;">/&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>items<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>renderLayoutAs<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>items<span style="color: #339933;">&gt;</span><br />
<span style="color: #339933;">&lt;/</span>advancedSettings<span style="color: #339933;">&gt;</span></div></td></tr></tbody></table></div>
<hr class="spacer-larger"/>
<h2>2. Accessing Design Dialog Properties in Sling Models:</h2>
<p>In AEM, Sling Models provide a way to map resource properties to Java objects, making it easier to work with the content of a page. To access Design Dialog properties within a Sling Model, take a look at the example code below.</p>
<p>Take notice, in line:17, we are using <a href="/blog/aem/aem-sling-model-injectors-annotations-cheat-sheet-reference-guide" rel="noopener" target="_blank">Sling Model Specific Annotations, @ScriptVariable</a>, to initiate the currentStyle object. In line:22, we are calling the get method() which is a public method, which here we will attempt to find configuration set via design dialog &#8220;renderLayoutAs&#8221;. If &#8220;renderLayoutAs&#8221; is not configured, then String renderLayoutAs == null. Finally in line:24, we will use a switch statement to execute code based on what is configured.</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.sourcedcode.core.internal.components</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.day.cq.wcm.api.designer.Style</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.SlingHttpServletRequest</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.models.annotations.Model</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.annotation.PostConstruct</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.inject.Inject</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">static</span> org.<span style="color: #006633;">apache</span>.<span style="color: #006633;">commons</span>.<span style="color: #006633;">lang3</span>.<span style="color: #006633;">StringUtils</span>.<span style="color: #006633;">isNotEmpty</span><span style="color: #339933;">;</span><br />
<br />
@Model<span style="color: #009900;">&#40;</span>adaptables <span style="color: #339933;">=</span> SlingHttpServletRequest.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> LayoutColumn <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">String</span> RENDER_LAYOUT_AS_PROP <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;renderLayoutAs&quot;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; @ScriptVariable<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">Style</span> currentStyle<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; @PostConstruct<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> init<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">String</span> renderLayoutAs <span style="color: #339933;">=</span> currentStyle.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>RENDER_LAYOUT_AS_PROP, <span style="color: #003399;">String</span>.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>isNotEmpty<span style="color: #009900;">&#40;</span>renderLayoutAs<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">switch</span> <span style="color: #009900;">&#40;</span>renderLayoutAs<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">case</span> <span style="color: #0000ff;">&quot;oneColumn&quot;</span><span style="color: #339933;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">case</span> <span style="color: #0000ff;">&quot;twoColumns&quot;</span><span style="color: #339933;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">case</span> <span style="color: #0000ff;">&quot;threeColumns&quot;</span><span style="color: #339933;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">case</span> <span style="color: #0000ff;">&quot;fourColumns&quot;</span><span style="color: #339933;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">default</span><span style="color: #339933;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Default case&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/how-to-access-design-dialogue-properties-in-sling-model">How to access Design Dialogue Properties in Sling Model</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/how-to-access-design-dialogue-properties-in-sling-model/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Granite UI, Touch UI trackingFeature</title>
		<link>https://sourcedcode.com/blog/aem/granite-ui-touch-ui-trackingfeature</link>
					<comments>https://sourcedcode.com/blog/aem/granite-ui-touch-ui-trackingfeature#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Tue, 15 Aug 2023 05:42:35 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Touch UI]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=5985</guid>

					<description><![CDATA[<p>In Adobe Experience Manager (AEM), the terms &#8220;tracking code&#8221; and &#8220;tracking feature&#8221; are used to refer to elements that help you gather analytics data about the usage and performance of components or features within your AEM instance. Let&#8217;s break down what each term means: 1. Tracking Code The term &#8220;tracking code&#8221; generally refers to a [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/granite-ui-touch-ui-trackingfeature">Granite UI, Touch UI trackingFeature</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>In Adobe Experience Manager (AEM), the terms &#8220;tracking code&#8221; and &#8220;tracking feature&#8221; are used to refer to elements that help you gather analytics data about the usage and performance of components or features within your AEM instance. Let&#8217;s break down what each term means:</p>
<hr class="spacer-larger" />
<h2>1. Tracking Code</h2>
<p>The term &#8220;tracking code&#8221; generally refers to a piece of code or configuration that is used to collect data about user interactions and behaviors on a website or web application. This data can include information such as page views, clicks, form submissions, and more. In the context of AEM, tracking code can refer to the code or configuration that integrates with analytics tools like Adobe Analytics (formerly known as SiteCatalyst) to capture user data and generate insights about how users are interacting with your AEM-powered websites and digital experiences.</p>
<p>AEM allows you to integrate tracking codes into your templates, components, and pages so that you can measure the effectiveness and performance of your content and features. This data can be used to make informed decisions about content optimization, user experience enhancements, and marketing strategies.</p>
<hr class="spacer-larger" />
<h2>Tracking Feature</h2>
<p>The term &#8220;tracking feature&#8221; in AEM typically refers to a mechanism that enables you to associate analytics tracking with specific components or features within your AEM implementation. This feature helps you monitor and gather data about how users interact with those components or features. The term &#8220;tracking feature&#8221; might be specific to certain versions of AEM or certain projects, as it may not be an official Adobe term.</p>
<p>For example, a &#8220;tracking feature&#8221; could allow you to measure how many times a particular video component is viewed, how often a specific form is submitted, or how users interact with a custom navigation menu. By adding a tracking feature to a component, you can gain insights into user engagement and behavior related to that component.</p>
<p>In the previous example XML you provided, the `trackingFeature` attribute is used to define a tracking feature for a custom component. This attribute value could be used to identify and track interactions specifically related to the &#8220;My Custom Component.&#8221;</p>
<p>Please note that while I can provide information based on my knowledge up until September 2021, specific terms and implementations might have evolved in newer versions of AEM. Always refer to the official AEM documentation and resources specific to your version for the most accurate and up-to-date information.</p>
<hr class="spacer-larger" />
<h2>Implementation</h2>
<p>If you&#8217;re looking to implement tracking for components in AEM, you generally need to integrate with a third-party analytics platform like Adobe Analytics, Google Analytics, or any other analytics tool of your choice. Here&#8217;s a general outline of how you might approach setting up tracking for components:</p>
<ol>
<li><strong>Choose an Analytics Tool:</strong><br />
   Select an analytics tool that fits your needs. Adobe Analytics (formerly SiteCatalyst) is commonly used with AEM, but other tools like Google Analytics are also popular.</li>
<li><strong>Obtain Tracking Code:</strong><br />
   For the selected analytics tool, obtain the tracking code or configuration that needs to be added to your AEM pages.</li>
<li><strong>Implement Tracking Code:</strong><br />
   Integrate the tracking code into your AEM templates or components. You might need to add JavaScript snippets, tags, or configuration data to enable tracking.</li>
<li><strong>Identify Component Interactions:</strong><br />
   Determine what interactions you want to track for your components. This could include clicks on specific buttons, form submissions, video views, etc.</li>
<li><strong>Custom Events or Tracking Calls:</strong><br />
   Implement custom JavaScript events or tracking calls within your components to trigger the analytics tracking when specific interactions occur.</li>
<li><strong>Testing and Validation:</strong><br />
   Test the tracking implementation to ensure that data is being captured accurately. Use the analytics tool&#8217;s reporting interface to verify that the tracking data is being recorded as expected.</li>
</ol>
<p>Please consult your organization&#8217;s guidelines or documentation to understand if the term `trackingFeature` has a specific meaning or if there are custom tracking mechanisms they have set up. Additionally, refer to the documentation of the analytics tool you&#8217;re using to learn how to integrate tracking with AEM components effectively.</p>
<p>As of my last update, there might have been developments or changes in AEM and related tools, so I recommend checking the official documentation for the latest information and best practices.</p>
<hr class="spacer-larger" />
<h2>Example Code</h2>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #339933;">&lt;</span>jcr<span style="color: #339933;">:</span>root xmlns<span style="color: #339933;">:</span>sling<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://sling.apache.org/jcr/sling/1.0&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xmlns<span style="color: #339933;">:</span>jcr<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://www.jcp.org/jcr/1.0&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xmlns<span style="color: #339933;">:</span>nt<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://www.jcp.org/jcr/nt/1.0&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xmlns<span style="color: #339933;">:</span>cq<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://www.day.com/jcr/cq/1.0&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xmlns<span style="color: #339933;">:</span>granite<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://www.adobe.com/jcr/granite/1.0&quot;</span><br />
&nbsp; &nbsp; jcr<span style="color: #339933;">:</span>primaryType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; jcr<span style="color: #339933;">:</span>title<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;My Custom Component&quot;</span><br />
&nbsp; &nbsp; sling<span style="color: #339933;">:</span>resourceType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;cq/gui/components/authoring/dialog&quot;</span><br />
&nbsp; &nbsp; extraClientlibs<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;[myproject.components.mycustomcomponent.editor]&quot;</span><br />
&nbsp; &nbsp; helpPath<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;/content/myproject/help/mycustomcomponent.html&quot;</span><br />
&nbsp; &nbsp; trackingFeature<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;myproject:mycustomcomponent&quot;</span><span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;!--</span> Define your component<span style="color: #0000ff;">'s dialog structure here --&gt;<br />
&lt;/jcr:root&gt;</span></div></td></tr></tbody></table></div>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/granite-ui-touch-ui-trackingfeature">Granite UI, Touch UI trackingFeature</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/granite-ui-touch-ui-trackingfeature/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>JUNIT 5: ArgumentCaptor with Mockito</title>
		<link>https://sourcedcode.com/blog/aem/junit/junit-5-argumentcaptor-with-mockito</link>
					<comments>https://sourcedcode.com/blog/aem/junit/junit-5-argumentcaptor-with-mockito#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Fri, 11 Aug 2023 07:08:32 +0000</pubDate>
				<category><![CDATA[JUNIT]]></category>
		<category><![CDATA[JUNIT5]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=5884</guid>

					<description><![CDATA[<p>Unit testing isn&#8217;t just about confirming your code works; it&#8217;s about ensuring it excels. Mockito, a trusted mock framework, introduces the ArgumentCaptor, a potent tool for honing your unit tests. This feature empowers you to capture and assert method arguments, leading to highly targeted tests. In this article, we&#8217;ll delve into the realm of ArgumentCaptor [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/junit/junit-5-argumentcaptor-with-mockito">JUNIT 5: ArgumentCaptor with Mockito</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Unit testing isn&#8217;t just about confirming your code works; it&#8217;s about ensuring it excels. Mockito, a trusted mock framework, introduces the <span class="code-highlight-secondary">ArgumentCaptor</span>, a potent tool for honing your unit tests. This feature empowers you to capture and assert method arguments, leading to highly targeted tests. </p>
<p><p>In this article, we&#8217;ll delve into the realm of <span class="code-highlight-secondary">ArgumentCaptor</span> within the JUnit 5 framework. And provide some code examples of a Java Class with it&#8217;s Java unit test Class</p>
<hr class="spacer-larger"/>
<h2>Putting ArgumentCaptor to Work: A Real-world Scenario</h2>
<p>Imagine you’re testing a search service that interacts with a search engine API. Your goal is to ensure the service accurately constructs and sends search queries to the API. This is where ArgumentCaptor proves invaluable. It lets you capture the search terms and other parameters, enabling you to assert their correctness with surgical precision.</p>
<p>Let&#8217;s dive into a hands-on example to demonstrate how <span class="code-highlight-secondary">ArgumentCaptor</span> shines in a practical context. For our illustration, we&#8217;ll focus on a <span class="code-highlight-secondary">SearchService</span> that interacts with a search engine to fetch relevant results based on user input.</p>
<div style="height: 50px;"></div>
<h3>SearchService.java</h3>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> SearchService <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> SearchEngine searchEngine<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> SearchService<span style="color: #009900;">&#40;</span>SearchEngine searchEngine<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">searchEngine</span> <span style="color: #339933;">=</span> searchEngine<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> List<span style="color: #339933;">&lt;</span>String<span style="color: #339933;">&gt;</span> search<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> searchTerm<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> searchEngine.<span style="color: #006633;">performSearch</span><span style="color: #009900;">&#40;</span>searchTerm<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>Our mission: to write a JUnit 5 test that verifies whether the <span class="code-highlight-secondary">search</span> method constructs the search query correctly and calls the search engine API with the expected search term. Enter <span class="code-highlight-secondary">ArgumentCaptor</span>.</p>
<div style="height: 50px;"></div>
<h3>SearchServiceTest.java</h3>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.junit.jupiter.api.Test</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.mockito.ArgumentCaptor</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.List</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">static</span> org.<span style="color: #006633;">mockito</span>.<span style="color: #006633;">Mockito</span>.<span style="color: #339933;">*;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> SearchServiceTest <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; @Test<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">void</span> testSearchService<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; SearchEngine searchEngine <span style="color: #339933;">=</span> mock<span style="color: #009900;">&#40;</span>SearchEngine.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; SearchService searchService <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> SearchService<span style="color: #009900;">&#40;</span>searchEngine<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; ArgumentCaptor<span style="color: #339933;">&lt;</span>String<span style="color: #339933;">&gt;</span> searchTermCaptor <span style="color: #339933;">=</span> ArgumentCaptor.<span style="color: #006633;">forClass</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span>.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">String</span> searchTerm <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;AEM JUNIT5 test examples&quot;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; when<span style="color: #009900;">&#40;</span>searchEngine.<span style="color: #006633;">performSearch</span><span style="color: #009900;">&#40;</span>searchTermCaptor.<span style="color: #006633;">capture</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">thenReturn</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">List</span>.<span style="color: #006633;">of</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;result1&quot;</span>, <span style="color: #0000ff;">&quot;result2&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; List<span style="color: #339933;">&lt;</span>String<span style="color: #339933;">&gt;</span> searchResults <span style="color: #339933;">=</span> searchService.<span style="color: #006633;">search</span><span style="color: #009900;">&#40;</span>searchTerm<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; verify<span style="color: #009900;">&#40;</span>searchEngine<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">performSearch</span><span style="color: #009900;">&#40;</span>searchTermCaptor.<span style="color: #006633;">capture</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; assertEquals<span style="color: #009900;">&#40;</span>searchTerm, searchTermCaptor.<span style="color: #006633;">getValue</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; assertEquals<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2</span>, searchResults.<span style="color: #006633;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>In this example, we utilize <span class="code-highlight-secondary">ArgumentCaptor</span> to capture the search term passed to the <span class="code-highlight-secondary">performSearch</span> method of the <span class="code-highlight-secondary">SearchEngine</span>. This allows us to assert that the correct search term is used when interacting with the API.</p>
<hr class="spacer-larger"/>
<h2>Benefits and Best Practices</h2>
<ul>
<li><strong>Focused Testing:</strong> <span class="code-highlight-secondary">ArgumentCaptor</span> lets you zoom in on specific method arguments, enhancing the precision of your tests.</li>
<li><strong>Readable Assertions:</strong> Your test assertions become highly readable and directly tied to real-world scenarios, improving code comprehension.</li>
<li><strong>Use Cases:</strong> While particularly useful for testing interactions with external systems like APIs, remember to employ <span class="code-highlight-secondary">ArgumentCaptor</span> judiciously, focusing on crucial scenarios.</li>
</ul>
<hr class="spacer-larger"/>
<h2>Wrapping Up</h2>
<p>Incorporating the <span class="code-highlight-secondary">ArgumentCaptor</span> into your testing toolbox elevates your unit tests from good to exceptional. By capturing and asserting method arguments, you&#8217;re crafting tests that pinpoint potential issues. As you integrate this feature into your testing routine, you&#8217;ll discover the power of precision-driven tests that ensure your code operates flawlessly, especially in scenarios involving external APIs and intricate parameters. Embrace <span class="code-highlight-secondary">ArgumentCaptor</span>, and watch your unit tests shine with accuracy and insight.</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/junit/junit-5-argumentcaptor-with-mockito">JUNIT 5: ArgumentCaptor with Mockito</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/junit/junit-5-argumentcaptor-with-mockito/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>JUNIT 5: JCR SQL 2 Unit Tests w/ Sling Servlet</title>
		<link>https://sourcedcode.com/blog/aem/junit-5-jcr-sql-2-unit-tests-w-sling-servlet</link>
					<comments>https://sourcedcode.com/blog/aem/junit-5-jcr-sql-2-unit-tests-w-sling-servlet#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Wed, 09 Aug 2023 12:30:05 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[JUNIT]]></category>
		<category><![CDATA[JUNIT5]]></category>
		<category><![CDATA[Premium Content]]></category>
		<category><![CDATA[Search]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=5855</guid>

					<description><![CDATA[<p>I&#8217;ve dedicated quite a chunk of my personal time to crafting this blog post, and yes, I&#8217;ve rigorously tested all useful test cases that you can learn from. Why, you ask? It&#8217;s all for you, my awesome readers! I want to ensure that you not only find value in this post but also gain useful [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/junit-5-jcr-sql-2-unit-tests-w-sling-servlet">JUNIT 5: JCR SQL 2 Unit Tests w/ Sling Servlet</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>I&#8217;ve dedicated quite a chunk of my personal time to crafting this blog post, and yes, I&#8217;ve rigorously tested all useful test cases that you can learn from. Why, you ask? It&#8217;s all for you, my awesome readers! I want to ensure that you not only find value in this post but also gain useful knowledge that you can easily share with your fellow devs.</p>
<p>I&#8217;m here to make it super simple for you. This JCR SQL 2 Unit Tests w/ Sling Servlet blog post will only cover the modern approach to unit testing using JUnit 5 and the io.wcm.testing.aem-mock.junit5 library. I&#8217;m excited to show you a live example of a Servlet utilizing the Java Search, JCR SQL 2 API. By the time we&#8217;re done, you&#8217;ll be equipped with the tools to write tests that not only work but also rock!</p>
<div class="mention-block">
<strong>Quick Links</strong></p>
<ol>
<li><a href="#what-to-test-for-when-testing-a-servlet-or-osgi-service-that-utilizes-the-java-jcr-sql-2-api">What to test for when testing a Servlet or OSGI Service that utilizes the Java, JCR SQL 2 API?</a>
<ol>
<li>a. <a href="#query-string">Query String</a></li>
<li>b. <a href="#results-of-the-query-nodes">Results of the Query, Nodes</a></li>
</ol>
</li>
<li><a href="#code-examples">Code Examples</a>
<ol>
<li>a. <a href="#get-paged-by-path-servlet-java">GetPagedByPathServlet.java</a></li>
<li>b. <a href="#get-paged-by-path-servlet-test-java">GetPagedByPathServletTest.java</a></li>
</ol>
</li>
</ol>
</div>
<div class="mention-block--gold">
<strong>Pre-requirement</strong><br />
&#8211; JUnit 5<br />
&#8211; io.wcm.testing.aem-mock.junit5 library.</p>
<p>Additionally, if you want to learn more about JCR SQL 2, <a href="/blog/aem/aem-jcr-sql2-tutorial-and-examples-and-cheatsheet" target="_blank" rel="noopener">click here</a> to view the blog. Or if you want to explore and learn all other existing AEM Java Search APIs, <a href="/blog/aem/a-simple-guide-to-aem-search-apis-exploring-your-options-for-powerful-search-functionality" rel="noopener" target="_blank">click here</a>.
</div>
<hr class="spacer-larger"/>
<h2 id="what-to-test-for-when-testing-a-servlet-or-osgi-service-that-utilizes-the-java-jcr-sql-2-api">1. What to test for when testing a Servlet or OSGI Service that utilizes the Java, JCR SQL 2 API?</h2>
<div style="height:50px;"></div>
<h4 id="query-string">1a. Query String</h4>
<p>In my opinion, it&#8217;s crucial to focus on two main areas. First, you should thoroughly test the <strong>query string</strong> that gets executed. This query string is like the roadmap guiding your code&#8217;s behavior. Ensuring its accuracy is essential since it forms the backbone of your code&#8217;s functionality.</p>
<h4 id="results-of-the-query-nodes">2b. Results of the Query, Nodes</h4>
<p>The second area of emphasis lies in the <strong>results of the query</strong>, which are obtained through the nodeIterator. This is where the real action happens – think of it as the hub where your code processes data. Testing this part of your code involves ensuring that the data processing via the nodeIterator is in line with your intended modifications.</p>
<p>To sum up, when testing a Servlet or OSGi Service, your primary focus should revolve around two core elements: meticulously verifying the accuracy of the query string and confirming that the data processing through the nodeIterator meets your expectations. By honing in on these aspects, you&#8217;re building a solid foundation of trust in your code.</p>
<hr class="spacer-larger"/>
<h2 id="code-examples">2. Code Examples</h2>
<div style="height:50px;"></div>
<h3 id="get-paged-by-path-servlet-java">2a. GetPagedByPathServlet.java</h3>
<p>Here in this example, you&#8217;d see a AEM Sling Servlet being created, and within doGet you&#8217;d see us utilizing the JCR SQL2 API, which captures and transforms the results into a JSON object.</p>
<div class="code-1200">
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br />78<br />79<br />80<br />81<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.IOException</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.PrintWriter</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.ArrayList</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.List</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.jcr.Node</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.jcr.NodeIterator</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.jcr.RepositoryException</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.jcr.Session</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.jcr.query.Query</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.jcr.query.QueryManager</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.jcr.query.QueryResult</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.SlingHttpServletRequest</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.SlingHttpServletResponse</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.servlets.SlingSafeMethodsServlet</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.osgi.service.component.annotations.Component</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.google.gson.JsonArray</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.google.gson.JsonObject</span><span style="color: #339933;">;</span><br />
<br />
@<span style="color: #003399;">Component</span><span style="color: #009900;">&#40;</span>service <span style="color: #339933;">=</span> javax.<span style="color: #006633;">servlet</span>.<span style="color: #006633;">Servlet</span>.<span style="color: #000000; font-weight: bold;">class</span>, property <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span> <span style="color: #0000ff;">&quot;sling.servlet.paths=/bin/getpagedbypath&quot;</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> GetPagedByPathServlet <span style="color: #000000; font-weight: bold;">extends</span> SlingSafeMethodsServlet <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; @Override<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> doGet<span style="color: #009900;">&#40;</span>SlingHttpServletRequest request, SlingHttpServletResponse response<span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">IOException</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Get the JCR session</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Session session <span style="color: #339933;">=</span> request.<span style="color: #006633;">getResourceResolver</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">adaptTo</span><span style="color: #009900;">&#40;</span>Session.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Query statement</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">String</span> queryString <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SELECT page.* FROM [cq:Page] AS page &quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;INNER JOIN [cq:PageContent] AS jcrContentNode ON ISCHILDNODE(jcrContentNode, page) &quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;WHERE ISDESCENDANTNODE(page, '/content/we-retail') &quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;AND jcrContentNode.[cq:lastModified] &lt;= CAST('2023-01-01T00:00:00.000+00:00' AS DATE)&quot;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Create the query object</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; QueryManager queryManager <span style="color: #339933;">=</span> session.<span style="color: #006633;">getWorkspace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getQueryManager</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Query query <span style="color: #339933;">=</span> queryManager.<span style="color: #006633;">createQuery</span><span style="color: #009900;">&#40;</span>queryString, Query.<span style="color: #006633;">JCR_SQL2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Execute the query</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; QueryResult result <span style="color: #339933;">=</span> query.<span style="color: #006633;">execute</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Get the nodes from the query result</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; NodeIterator nodeIterator <span style="color: #339933;">=</span> result.<span style="color: #006633;">getNodes</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Collect the paths of the first ten pages in a list</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; List<span style="color: #339933;">&lt;</span>String<span style="color: #339933;">&gt;</span> pagePaths <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ArrayList<span style="color: #339933;">&lt;&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span>nodeIterator.<span style="color: #006633;">hasNext</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Node pageNode <span style="color: #339933;">=</span> nodeIterator.<span style="color: #006633;">nextNode</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">String</span> pagePath <span style="color: #339933;">=</span> pageNode.<span style="color: #006633;">getPath</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pagePaths.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>pagePath<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Create a JSON object to hold the results</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; JsonObject jsonResponse <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> JsonObject<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; JsonArray resultsArray <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> JsonArray<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Add the paths to the JSON array</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> path <span style="color: #339933;">:</span> pagePaths<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; resultsArray.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>path<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Add the JSON array to the response object</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jsonResponse.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;results&quot;</span>, resultsArray<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Set the response content type</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; response.<span style="color: #006633;">setContentType</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;application/json&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Write the JSON response to the output</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">PrintWriter</span> writer <span style="color: #339933;">=</span> response.<span style="color: #006633;">getWriter</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.<span style="color: #006633;">print</span><span style="color: #009900;">&#40;</span>jsonResponse.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; writer.<span style="color: #006633;">flush</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span>RepositoryException e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Handle exception</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; response.<span style="color: #006633;">setStatus</span><span style="color: #009900;">&#40;</span>SlingHttpServletResponse.<span style="color: #006633;">SC_INTERNAL_SERVER_ERROR</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; response.<span style="color: #006633;">getWriter</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Error executing query: &quot;</span> <span style="color: #339933;">+</span> e.<span style="color: #006633;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
</div>
<p><strong>JSON response</strong></p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #0000ff;">&quot;results&quot;</span><span style="color: #339933;">:</span><span style="color: #009900;">&#91;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;/content/we-retail/page1&quot;</span>,<br />
&nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;/content/we-retail/page2&quot;</span>,<br />
&nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;/content/we-retail/page3&quot;</span>,<br />
&nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;/content/we-retail/page4&quot;</span>,<br />
&nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;/content/we-retail/page5&quot;</span>,<br />
&nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;/content/we-retail/page6&quot;</span>,<br />
&nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;/content/we-retail/page7&quot;</span>,<br />
&nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;/content/we-retail/page8&quot;</span>,<br />
&nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;/content/we-retail/page9&quot;</span>,<br />
&nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;/content/we-retail/page10&quot;</span><br />
&nbsp; &nbsp;<span style="color: #009900;">&#93;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p><strong>Curl call</strong></p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">curl -X GET http://localhost:4502/bin/getpagedbypath</div></td></tr></tbody></table></div>
<hr class="spacer-larger"/>
<h3 id="get-paged-by-path-servlet-test-java">2b. GetPagedByPathServletTest.java</h3>
<p>Here in this unit test examples. In my opinion, what is mostly effective unit tested for the JCR SQL 2 API, and to test the query string, and next, test the query result. This example does just it. I have tested the code, and it is working as expected.</p>
<div class="code-2000">
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br />78<br />79<br />80<br />81<br />82<br />83<br />84<br />85<br />86<br />87<br />88<br />89<br />90<br />91<br />92<br />93<br />94<br />95<br />96<br />97<br />98<br />99<br />100<br />101<br />102<br />103<br />104<br />105<br />106<br />107<br />108<br />109<br />110<br />111<br />112<br />113<br />114<br />115<br />116<br />117<br />118<br />119<br />120<br />121<br />122<br />123<br />124<br />125<br />126<br />127<br />128<br />129<br />130<br />131<br />132<br />133<br />134<br />135<br />136<br />137<br />138<br />139<br />140<br />141<br />142<br />143<br />144<br />145<br />146<br />147<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">io.wcm.testing.mock.aem.junit5.AemContext</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">io.wcm.testing.mock.aem.junit5.AemContextExtension</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.SlingHttpServletRequest</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.SlingHttpServletResponse</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.resource.ResourceResolver</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.junit.jupiter.api.BeforeEach</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.junit.jupiter.api.Test</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.junit.jupiter.api.extension.ExtendWith</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.mockito.ArgumentCaptor</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.mockito.Captor</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.mockito.Mock</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.mockito.MockitoAnnotations</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.jcr.NodeIterator</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.jcr.RepositoryException</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.jcr.Session</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.jcr.Workspace</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.jcr.query.Query</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.jcr.query.QueryManager</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.jcr.query.QueryResult</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.PrintWriter</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.StringWriter</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">static</span> org.<span style="color: #006633;">junit</span>.<span style="color: #006633;">jupiter</span>.<span style="color: #006633;">api</span>.<span style="color: #006633;">Assertions</span>.<span style="color: #006633;">assertEquals</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">static</span> org.<span style="color: #006633;">mockito</span>.<span style="color: #006633;">Mockito</span>.<span style="color: #339933;">*;</span><br />
<br />
@ExtendWith<span style="color: #009900;">&#40;</span>AemContextExtension.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #000000; font-weight: bold;">class</span> GetPagedByPathServletTest <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">final</span> AemContext context <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> AemContext<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> GetPagedByPathServlet underTest <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> GetPagedByPathServlet<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; @Mock<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> SlingHttpServletRequest request<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; @Mock<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> SlingHttpServletResponse response<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; @Mock<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> QueryManager queryManager<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; @Mock<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> Query query<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; @Mock<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> QueryResult queryResult<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; @Mock<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> Session session<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; @Mock<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> ResourceResolver resourceResolver<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; @Captor<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> ArgumentCaptor<span style="color: #339933;">&lt;</span>String<span style="color: #339933;">&gt;</span> queryCaptor<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; @Mock<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">PrintWriter</span> printWriter<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; @BeforeEach<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">void</span> setUp<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; MockitoAnnotations.<span style="color: #006633;">openMocks</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; context.<span style="color: #006633;">registerService</span><span style="color: #009900;">&#40;</span>QueryManager.<span style="color: #000000; font-weight: bold;">class</span>, queryManager<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; context.<span style="color: #006633;">registerService</span><span style="color: #009900;">&#40;</span>Query.<span style="color: #000000; font-weight: bold;">class</span>, query<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; context.<span style="color: #006633;">registerService</span><span style="color: #009900;">&#40;</span>QueryResult.<span style="color: #000000; font-weight: bold;">class</span>, queryResult<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; when<span style="color: #009900;">&#40;</span>request.<span style="color: #006633;">getResourceResolver</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">thenReturn</span><span style="color: #009900;">&#40;</span>resourceResolver<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; when<span style="color: #009900;">&#40;</span>resourceResolver.<span style="color: #006633;">adaptTo</span><span style="color: #009900;">&#40;</span>Session.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">thenReturn</span><span style="color: #009900;">&#40;</span>session<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Workspace workspace <span style="color: #339933;">=</span> mock<span style="color: #009900;">&#40;</span>Workspace.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; when<span style="color: #009900;">&#40;</span>session.<span style="color: #006633;">getWorkspace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">thenReturn</span><span style="color: #009900;">&#40;</span>workspace<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; when<span style="color: #009900;">&#40;</span>workspace.<span style="color: #006633;">getQueryManager</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">thenReturn</span><span style="color: #009900;">&#40;</span>queryManager<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; when<span style="color: #009900;">&#40;</span>queryManager.<span style="color: #006633;">createQuery</span><span style="color: #009900;">&#40;</span>anyString<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, eq<span style="color: #009900;">&#40;</span>Query.<span style="color: #006633;">JCR_SQL2</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">thenReturn</span><span style="color: #009900;">&#40;</span>query<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; when<span style="color: #009900;">&#40;</span>query.<span style="color: #006633;">execute</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">thenReturn</span><span style="color: #009900;">&#40;</span>queryResult<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; when<span style="color: #009900;">&#40;</span>response.<span style="color: #006633;">getWriter</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">thenReturn</span><span style="color: #009900;">&#40;</span>printWriter<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #008000; font-style: italic; font-weight: bold;">/**<br />
&nbsp; &nbsp; &nbsp;* In this test, we will only focus on the query string that is executed. This is a particularly<br />
&nbsp; &nbsp; &nbsp;* important step, because we would like to ensure that our query string is correct before<br />
&nbsp; &nbsp; &nbsp;* query.execute() is called.<br />
&nbsp; &nbsp; &nbsp;* @throws Exception<br />
&nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; @Test<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">void</span> testDoGet_executedQuery<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; NodeIterator nodeIterator <span style="color: #339933;">=</span> mock<span style="color: #009900;">&#40;</span>NodeIterator.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; when<span style="color: #009900;">&#40;</span>queryResult.<span style="color: #006633;">getNodes</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">thenReturn</span><span style="color: #009900;">&#40;</span>nodeIterator<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; underTest.<span style="color: #006633;">doGet</span><span style="color: #009900;">&#40;</span>request, response<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Verify that the correct query string was executed</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; verify<span style="color: #009900;">&#40;</span>query<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">execute</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Capture the argument passed to queryManager.createQuery</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; verify<span style="color: #009900;">&#40;</span>queryManager<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">createQuery</span><span style="color: #009900;">&#40;</span>queryCaptor.<span style="color: #006633;">capture</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, eq<span style="color: #009900;">&#40;</span>Query.<span style="color: #006633;">JCR_SQL2</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Compare the captured query string with the expected query string</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">String</span> executedQueryString <span style="color: #339933;">=</span> queryCaptor.<span style="color: #006633;">getValue</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">String</span> expectedQueryString <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SELECT page.* FROM [cq:Page] AS page &quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;INNER JOIN [cq:PageContent] AS jcrContentNode ON ISCHILDNODE(jcrContentNode, page) &quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;WHERE ISDESCENDANTNODE(page, '/content/we-retail') &quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;AND jcrContentNode.[cq:lastModified] &lt;= CAST('2023-01-01T00:00:00.000+00:00' AS DATE)&quot;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; assertEquals<span style="color: #009900;">&#40;</span>expectedQueryString, executedQueryString<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #008000; font-style: italic; font-weight: bold;">/**<br />
&nbsp; &nbsp; &nbsp;* In this test, we are actually going to mock the response from query.execute() and verify<br />
&nbsp; &nbsp; &nbsp;* that the results has been processed, and the output of the servlet is correct. Here you<br />
&nbsp; &nbsp; &nbsp;* can see us mocking the NodeIterator, and then mocking the next node calls.<br />
&nbsp; &nbsp; &nbsp;* @throws Exception<br />
&nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; @Test<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">void</span> testDoGet_successfulJsonResponse<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; NodeIterator nodeIterator <span style="color: #339933;">=</span> mock<span style="color: #009900;">&#40;</span>NodeIterator.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; when<span style="color: #009900;">&#40;</span>nodeIterator.<span style="color: #006633;">hasNext</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">thenReturn</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">true</span>, <span style="color: #000066; font-weight: bold;">true</span>, <span style="color: #000066; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; when<span style="color: #009900;">&#40;</span>nodeIterator.<span style="color: #006633;">nextNode</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">thenReturn</span><span style="color: #009900;">&#40;</span>mock<span style="color: #009900;">&#40;</span>javax.<span style="color: #006633;">jcr</span>.<span style="color: #006633;">Node</span>.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; when<span style="color: #009900;">&#40;</span>nodeIterator.<span style="color: #006633;">nextNode</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getPath</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">thenReturn</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/content/we-retail/page1&quot;</span>, <span style="color: #0000ff;">&quot;/content/we-retail/page2&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; when<span style="color: #009900;">&#40;</span>queryResult.<span style="color: #006633;">getNodes</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">thenReturn</span><span style="color: #009900;">&#40;</span>nodeIterator<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; underTest.<span style="color: #006633;">doGet</span><span style="color: #009900;">&#40;</span>request, response<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">String</span> expectedOutput <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;{&quot;</span>results<span style="color: #0000ff;">&quot;:[&quot;</span><span style="color: #339933;">/</span>content<span style="color: #339933;">/</span>we<span style="color: #339933;">-</span>retail<span style="color: #339933;">/</span>page1<span style="color: #0000ff;">&quot;,&quot;</span><span style="color: #339933;">/</span>content<span style="color: #339933;">/</span>we<span style="color: #339933;">-</span>retail<span style="color: #339933;">/</span>page2<span style="color: #0000ff;">&quot;]}&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; printWriter.<span style="color: #006633;">print</span><span style="color: #009900;">&#40;</span>expectedOutput<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #008000; font-style: italic; font-weight: bold;">/**<br />
&nbsp; &nbsp; &nbsp;* In this test, we are going to test a server error, for example a failure for query.execute(),<br />
&nbsp; &nbsp; &nbsp;* and verify that the response status is set to 500, and the error message is printed.<br />
&nbsp; &nbsp; &nbsp;* @throws Exception<br />
&nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; @Test<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">void</span> testDoGet_serverError<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; when<span style="color: #009900;">&#40;</span>queryManager.<span style="color: #006633;">createQuery</span><span style="color: #009900;">&#40;</span>anyString<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, eq<span style="color: #009900;">&#40;</span>Query.<span style="color: #006633;">JCR_SQL2</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">thenReturn</span><span style="color: #009900;">&#40;</span>query<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; when<span style="color: #009900;">&#40;</span>query.<span style="color: #006633;">execute</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">thenThrow</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> RepositoryException<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Test exception&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">StringWriter</span> stringWriter <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">StringWriter</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">PrintWriter</span> printWriter <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">PrintWriter</span><span style="color: #009900;">&#40;</span>stringWriter<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; when<span style="color: #009900;">&#40;</span>response.<span style="color: #006633;">getWriter</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">thenReturn</span><span style="color: #009900;">&#40;</span>printWriter<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; underTest.<span style="color: #006633;">doGet</span><span style="color: #009900;">&#40;</span>request, response<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Verify that the response status is set to 500</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; verify<span style="color: #009900;">&#40;</span>response<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">setStatus</span><span style="color: #009900;">&#40;</span>SlingHttpServletResponse.<span style="color: #006633;">SC_INTERNAL_SERVER_ERROR</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Verify that the error message is printed</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">String</span> expectedErrorMessage <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Error executing query: Test exception<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; assertEquals<span style="color: #009900;">&#40;</span>expectedErrorMessage, stringWriter.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
</div>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/junit-5-jcr-sql-2-unit-tests-w-sling-servlet">JUNIT 5: JCR SQL 2 Unit Tests w/ Sling Servlet</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/junit-5-jcr-sql-2-unit-tests-w-sling-servlet/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Search in AEM</title>
		<link>https://sourcedcode.com/blog/aem/search-in-aem</link>
					<comments>https://sourcedcode.com/blog/aem/search-in-aem#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Fri, 04 Aug 2023 05:32:45 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Search]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=5676</guid>

					<description><![CDATA[<p>This comprehensive guide offers AEM developers like you a roadmap to implement powerful search functionality using AEM Search APIs. Unravel the potential of three core AEM Search APIs: XPath Search API, JCR SQL2 Search API, and Query Builder Search API. Each API brings unique features to the table, and we&#8217;ll guide you through their capabilities [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/search-in-aem">Search in AEM</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>This comprehensive guide offers AEM developers like you a roadmap to implement powerful search functionality using AEM Search APIs.</p>
<p>Unravel the potential of three core AEM Search APIs: XPath Search API, JCR SQL2 Search API, and Query Builder Search API. Each API brings unique features to the table, and we&#8217;ll guide you through their capabilities to help you make the right choice for your projects.</p>
<p>To ensure a seamless learning experience, we present practical Java examples for each API. These real-world scenarios will solidify your understanding and enable you to apply the concepts with confidence.</p>
<p>Ready to supercharge your AEM development skills? Dive into the world of AEM Search APIs and embark on a journey to enhance your content search capabilities. Join us in &#8220;Search in AEM &#8211; A Simple Guide to AEM Search APIs: Exploring Your Options for Powerful Search Functionality.&#8221;</p>
<p>Read the full article here: <a href="https://sourcedcode.com/blog/aem/a-simple-guide-to-aem-search-apis-exploring-your-options-for-powerful-search-functionality">Search in AEM &#8211; A Simple Guide to AEM Search APIs: Exploring Your Options for Powerful Search Functionality</a>.</p>
<p>Unlock the true potential of AEM&#8217;s search capabilities and elevate your projects to new heights!</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/search-in-aem">Search in AEM</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/search-in-aem/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Query Builder API Exclude Pages or Paths</title>
		<link>https://sourcedcode.com/blog/aem/query-builder-api-exclude-pages-or-paths</link>
					<comments>https://sourcedcode.com/blog/aem/query-builder-api-exclude-pages-or-paths#comments</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Fri, 04 Aug 2023 05:01:29 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Search]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=5652</guid>

					<description><![CDATA[<p>This blog article focuses on searching cq:Page under a particular path, but exclude sub pages. In this article we will share you the Query Builder API&#8217;s Query, and share with you the Java code implementation of a servlet. At the end of this article, you should be able to search cq:Page nodes under a particular [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/query-builder-api-exclude-pages-or-paths">Query Builder API Exclude Pages or Paths</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>This blog article focuses on searching cq:Page under a particular path, but exclude sub pages. In this article we will share you the Query Builder API&#8217;s Query, and share with you the Java code implementation of a servlet. At the end of this article, you should be able to search cq:Page nodes under a particular path, but exclude particular resources under some paths, under the sub tree.</p>
<hr class="spacer-larger"/>
<h3>Query Builder API&#8217;s Query:</h3>
<p>Find all cq:Page nodes under /content/my-site/us/en<br />
<strong>NOT</strong> cq:Page nodes under /content/my-site/us/en/services<br />
<strong>NOT</strong> cq:Page nodes under /content/my-site/us/en/products</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">path<span style="color: #339933;">=/</span>content<span style="color: #339933;">/</span>my<span style="color: #339933;">-</span>site<span style="color: #339933;">/</span>us<span style="color: #339933;">/</span>en<br />
type<span style="color: #339933;">=</span>cq<span style="color: #339933;">:</span>Page<br />
<br />
group.1_group.<span style="color: #006633;">p</span>.<span style="color: #006633;">not</span><span style="color: #339933;">=</span><span style="color: #000066; font-weight: bold;">true</span><br />
group.1_group.<span style="color: #006633;">path</span><span style="color: #339933;">=/</span>content<span style="color: #339933;">/</span>my<span style="color: #339933;">-</span>site<span style="color: #339933;">/</span>us<span style="color: #339933;">/</span>en<span style="color: #339933;">/</span>services<br />
group.1_group.<span style="color: #006633;">path</span>.<span style="color: #006633;">self</span><span style="color: #339933;">=</span><span style="color: #000066; font-weight: bold;">true</span><br />
<br />
group.2_group.<span style="color: #006633;">p</span>.<span style="color: #006633;">not</span><span style="color: #339933;">=</span><span style="color: #000066; font-weight: bold;">true</span><br />
group.2_group.<span style="color: #006633;">path</span><span style="color: #339933;">=/</span>content<span style="color: #339933;">/</span>my<span style="color: #339933;">-</span>site<span style="color: #339933;">/</span>us<span style="color: #339933;">/</span>en<span style="color: #339933;">/</span>products<br />
group.2_group.<span style="color: #006633;">path</span>.<span style="color: #006633;">self</span><span style="color: #339933;">=</span><span style="color: #000066; font-weight: bold;">true</span></div></td></tr></tbody></table></div>
<p><strong>XPath Output:</strong><br />
<a href="https://sourcedcode.com/wp-content/uploads/2023/08/x-path-query.png"><img loading="lazy" decoding="async" width="2032" height="422" src="https://sourcedcode.com/wp-content/uploads/2023/08/x-path-query.png" alt="XPath Output" class="alignnone size-full wp-image-5662" srcset="https://sourcedcode.com/wp-content/uploads/2023/08/x-path-query.png 2032w, https://sourcedcode.com/wp-content/uploads/2023/08/x-path-query-300x62.png 300w, https://sourcedcode.com/wp-content/uploads/2023/08/x-path-query-1024x213.png 1024w, https://sourcedcode.com/wp-content/uploads/2023/08/x-path-query-768x159.png 768w, https://sourcedcode.com/wp-content/uploads/2023/08/x-path-query-1536x319.png 1536w, https://sourcedcode.com/wp-content/uploads/2023/08/x-path-query-600x125.png 600w" sizes="(max-width: 2032px) 100vw, 2032px" /></a></p>
<hr class="spacer-larger"/>
<h3>Query Builder API Servlet Example:</h3>
<div class="code-750">
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br />78<br />79<br />80<br />81<br />82<br />83<br />84<br />85<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.SlingHttpServletRequest</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.SlingHttpServletResponse</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.servlets.SlingAllMethodsServlet</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.query.Query</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.query.QueryBuilder</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.osgi.service.component.annotations.Component</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.servlet.Servlet</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.servlet.ServletException</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.IOException</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.ArrayList</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Iterator</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.List</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Map</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.HashMap</span><span style="color: #339933;">;</span><br />
<br />
@<span style="color: #003399;">Component</span><span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; service <span style="color: #339933;">=</span> Servlet.<span style="color: #000000; font-weight: bold;">class</span>,<br />
&nbsp; &nbsp; property <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span> <span style="color: #0000ff;">&quot;sling.servlet.paths=/bin/getPages&quot;</span> <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#41;</span><br />
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> GetPagesServlet <span style="color: #000000; font-weight: bold;">extends</span> SlingAllMethodsServlet <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">int</span> ITEMS_PER_PAGE <span style="color: #339933;">=</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; @Override<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> doGet<span style="color: #009900;">&#40;</span>SlingHttpServletRequest request, SlingHttpServletResponse response<span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">throws</span> ServletException, <span style="color: #003399;">IOException</span> <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">int</span> pageNumber <span style="color: #339933;">=</span> getPageNumber<span style="color: #009900;">&#40;</span>request.<span style="color: #006633;">getParameter</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;pageNumber&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">String</span> contentPath <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;/content/my-site/us/en&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Root path for the pages.</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Create the predicate using a Map</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Map<span style="color: #339933;">&lt;</span><span style="color: #003399;">String</span>, String<span style="color: #339933;">&gt;</span> predicateMap <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HashMap<span style="color: #339933;">&lt;&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; predicateMap.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;path&quot;</span>, contentPath<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; predicateMap.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;type&quot;</span>, <span style="color: #0000ff;">&quot;cq:Page&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Add additional predicate groups if needed</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; predicateMap.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;group.1_group.p.not&quot;</span>, <span style="color: #0000ff;">&quot;true&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; predicateMap.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;group.1_group.path&quot;</span>, contentPath <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;/services&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; predicateMap.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;group.1_group.path.self&quot;</span>, <span style="color: #0000ff;">&quot;true&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; predicateMap.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;group.2_group.p.not&quot;</span>, <span style="color: #0000ff;">&quot;true&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; predicateMap.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;group.2_group.path&quot;</span>, contentPath <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;/products&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; predicateMap.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;group.2_group.path.self&quot;</span>, <span style="color: #0000ff;">&quot;true&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; List<span style="color: #339933;">&lt;</span>String<span style="color: #339933;">&gt;</span> paths <span style="color: #339933;">=</span> getPathsForPage<span style="color: #009900;">&#40;</span>contentPath, pageNumber, predicateMap<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Convert the list of paths to JSON using Gson</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">String</span> jsonResponse <span style="color: #339933;">=</span> convertListToJson<span style="color: #009900;">&#40;</span>paths<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Set the JSON response in the HTTP response</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; response.<span style="color: #006633;">setContentType</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;application/json&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; response.<span style="color: #006633;">getWriter</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">write</span><span style="color: #009900;">&#40;</span>jsonResponse<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> List<span style="color: #339933;">&lt;</span>String<span style="color: #339933;">&gt;</span> getPathsForPage<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> contentPath, <span style="color: #000066; font-weight: bold;">int</span> pageNumber, Map<span style="color: #339933;">&lt;</span><span style="color: #003399;">String</span>, String<span style="color: #339933;">&gt;</span> predicateMap<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Use QueryBuilder to retrieve pages based on the given predicates.</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; List<span style="color: #339933;">&lt;</span>String<span style="color: #339933;">&gt;</span> paths <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ArrayList<span style="color: #339933;">&lt;&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">int</span> startIndex <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>pageNumber <span style="color: #339933;">-</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> ITEMS_PER_PAGE<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; QueryBuilder queryBuilder <span style="color: #339933;">=</span> getResourceResolver<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">adaptTo</span><span style="color: #009900;">&#40;</span>QueryBuilder.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>queryBuilder <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Set the limit and offset for pagination</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; predicateMap.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;p.limit&quot;</span>, <span style="color: #003399;">String</span>.<span style="color: #006633;">valueOf</span><span style="color: #009900;">&#40;</span>ITEMS_PER_PAGE<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; predicateMap.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;p.offset&quot;</span>, <span style="color: #003399;">String</span>.<span style="color: #006633;">valueOf</span><span style="color: #009900;">&#40;</span>startIndex<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Query query <span style="color: #339933;">=</span> queryBuilder.<span style="color: #006633;">createQuery</span><span style="color: #009900;">&#40;</span>predicateMap<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Iterator<span style="color: #339933;">&lt;</span>Map<span style="color: #339933;">&lt;</span><span style="color: #003399;">String</span>, Object<span style="color: #339933;">&gt;&gt;</span> result <span style="color: #339933;">=</span> query.<span style="color: #006633;">getResult</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getHits</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">iterator</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Fetch the paths for the current page</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span>result.<span style="color: #006633;">hasNext</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Map<span style="color: #339933;">&lt;</span><span style="color: #003399;">String</span>, Object<span style="color: #339933;">&gt;</span> hit <span style="color: #339933;">=</span> result.<span style="color: #006633;">next</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">String</span> path <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#41;</span> hit.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;path&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; paths.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>path<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> paths<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Rest of the methods remain the same as in the previous version.</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// getPageNumber, convertListToJson, etc.</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
</div>
<p><strong>Curl Command</strong></p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">curl <span style="color: #339933;">-</span>X GET <span style="color: #0000ff;">&quot;http://localhost:4502/bin/getPages?pageNumber=1&quot;</span></div></td></tr></tbody></table></div>
<p><strong>JSON Output</strong></p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #009900;">&#91;</span><br />
&nbsp; <span style="color: #0000ff;">&quot;/content/my-site/us/en/item-1&quot;</span>,<br />
&nbsp; <span style="color: #0000ff;">&quot;/content/my-site/us/en/item-2&quot;</span>,<br />
&nbsp; <span style="color: #0000ff;">&quot;/content/my-site/us/en/item-3&quot;</span>,<br />
&nbsp; <span style="color: #0000ff;">&quot;/content/my-site/us/en/item-4&quot;</span>,<br />
&nbsp; <span style="color: #0000ff;">&quot;/content/my-site/us/en/item-5&quot;</span>,<br />
&nbsp; <span style="color: #0000ff;">&quot;/content/my-site/us/en/item-6&quot;</span>,<br />
&nbsp; <span style="color: #0000ff;">&quot;/content/my-site/us/en/item-7&quot;</span>,<br />
&nbsp; <span style="color: #0000ff;">&quot;/content/my-site/us/en/item-8&quot;</span>,<br />
&nbsp; <span style="color: #0000ff;">&quot;/content/my-site/us/en/item-9&quot;</span>,<br />
&nbsp; <span style="color: #0000ff;">&quot;/content/my-site/us/en/item-10&quot;</span><br />
<span style="color: #009900;">&#93;</span></div></td></tr></tbody></table></div>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/query-builder-api-exclude-pages-or-paths">Query Builder API Exclude Pages or Paths</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/query-builder-api-exclude-pages-or-paths/feed</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>50 Visual Studio &#124; VS Code Hot Key / Shortcuts for Mac 2023</title>
		<link>https://sourcedcode.com/blog/aem/deployment/50-visual-studio-code-hot-key-shortcuts-for-mac-2023</link>
					<comments>https://sourcedcode.com/blog/aem/deployment/50-visual-studio-code-hot-key-shortcuts-for-mac-2023#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Mon, 31 Jul 2023 06:55:50 +0000</pubDate>
				<category><![CDATA[Deployment]]></category>
		<category><![CDATA[Visual Studio Code]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=5540</guid>

					<description><![CDATA[<p>Welcome to our guide on 50 Visual Studio Code shortcuts for Mac users. Whether you&#8217;re a seasoned developer or just starting, mastering these keyboard shortcuts will significantly enhance your coding productivity. Let&#8217;s dive in and discover the most efficient key combinations for a seamless coding experience! For Window users, visit this article, 50 Visual Studio [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/deployment/50-visual-studio-code-hot-key-shortcuts-for-mac-2023">50 Visual Studio | VS Code Hot Key / Shortcuts for Mac 2023</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Welcome to our guide on 50 Visual Studio Code shortcuts for Mac users. Whether you&#8217;re a seasoned developer or just starting, mastering these keyboard shortcuts will significantly enhance your coding productivity. Let&#8217;s dive in and discover the most efficient key combinations for a seamless coding experience!</p>
<div class="mention-block--gold">
For Window users, visit this article, <a href="https://sourcedcode.com/blog/aem/development/50-visual-studio-code-hot-key-shortcuts-for-windows-2023" rel="noopener" target="_blank">50 Visual Studio Code Hot Key / Shortcuts for Mac 2023</a>.
</div>
<hr class="spacer-larger"/>
<h2>Shortcuts List:</h2>
<ul>
<li><strong>(Command + P)</strong>: Quickly open files by typing their names in the Quick Open dialog.</li>
<li><strong>(Command + N)</strong>: Create a new file in the current workspace.</li>
<li><strong>(Command + Shift + P)</strong>: Open the Command Palette to access various commands and settings.</li>
<li><strong>(Command + B)</strong>: Toggle the visibility of the Side Bar.</li>
<li><strong>(Command + Shift + E)</strong>: Focus and show the File Explorer in the Side Bar.</li>
<li><strong>(Command + Shift + F)</strong>: Search across files in the entire workspace.</li>
<li><strong>(Command + J)</strong>: Toggle the Panel (Output, Terminal, or Debug Console).</li>
<li><strong>(Command + /)</strong>: Toggle line comments for the selected code.</li>
<li><strong>(Option + Shift + Up/Down Arrow)</strong>: Move lines of code up or down.</li>
<li><strong>(Option + Click)</strong>: Add multiple cursors at different positions to edit multiple lines at once.</li>
<li><strong>(Command + Shift + L)</strong>: Select all occurrences of the current selection.</li>
<li><strong>(Command + D)</strong>: Add the next occurrence of the current word to the selection.</li>
<li><strong>(Command + G)</strong>: Jump to a specific line number in the active file.</li>
<li><strong>(Option + Left/Right Arrow)</strong>: Move the cursor to the beginning/end of the current word.</li>
<li><strong>(Option + Up/Down Arrow)</strong>: Move the cursor up or down by paragraph.</li>
<li><strong>(Command + Shift + K)</strong>: Delete the current line.</li>
<li><strong>(Command + Shift + T)</strong>: Reopen the last closed tab.</li>
<li><strong>(Command + Tab / Command + Shift + Tab)</strong>: Cycle through open tabs.</li>
<li><strong>(Command + F2)</strong>: Set multiple cursors to the same word in the file.</li>
<li><strong>(Command + Shift + [ / Command + Shift + ])</strong>: Indent or unindent lines of code.</li>
<li><strong>(Option + Shift + O)</strong>: Sort lines in ascending order.</li>
<li><strong>(Option + Command + Down Arrow)</strong>: Copy lines down.</li>
<li><strong>(Option + Shift + Down Arrow)</strong>: Move lines down.</li>
<li><strong>(Option + Shift + Up Arrow)</strong>: Move lines up.</li>
<li><strong>(Option + Shift + F)</strong>: Format the selected code.</li>
<li><strong>(Option + Command + U)</strong>: Transform to uppercase.</li>
<li><strong>(Option + Command + L)</strong>: Transform to lowercase.</li>
<li><strong>(Command + Enter)</strong>: Insert a new line below the current line.</li>
<li><strong>(Command + Shift + Enter)</strong>: Insert a new line above the current line.</li>
<li><strong>(Command + Shift + \)</strong>: Jump to matching bracket.</li>
<li><strong>(Command + Shift + G)</strong>: Open the Source Control view.</li>
<li><strong>(Command + Shift + E)</strong>: Show Explorer/Files view.</li>
<li><strong>(Command + Shift + X)</strong>: Open the Extensions view.</li>
<li><strong>(Option + Shift + F)</strong>: Format document in the editor.</li>
<li><strong>(Command + F)</strong>: Find and replace text.</li>
<li><strong>(Command + Shift + H)</strong>: Replace in files (Find and replace across multiple files).</li>
<li><strong>(Command + Shift + M)</strong>: Show Problems panel.</li>
<li><strong>(Command + Shift + U)</strong>: Show output panel.</li>
<li><strong>(Command + K + W)</strong>: Close all editor tabs.</li>
<li><strong>(Command + Shift + [ / Command + Shift + ])</strong>: Fold or unfold region.</li>
<li><strong>(Option + F12)</strong>: Show all references of a symbol in the workspace.</li>
<li><strong>(Command + Shift + F10)</strong>: Run a specific test.</li>
<li><strong>(Command + Shift + D)</strong>: Open the Debugger panel.</li>
<li><strong>(Command + Shift + O)</strong>: Go to Symbol in File.</li>
<li><strong>(Command + Shift + U)</strong>: Go to a symbol&#8217;s implementation.</li>
<li><strong>(Command + K + R)</strong>: Show keyboard shortcuts reference.</li>
<li><strong>(Command + Shift + F)</strong>: Show keyboard shortcuts reference.</li>
</ul>
<hr class="spacer-larger"/>
<h2>Conclusion:</h2>
<p>Boost your coding productivity with these 50 essential Visual Studio Code shortcuts, tailored for Mac users. Incorporate these time-saving key combinations into your coding workflow, and watch as you breeze through tasks with remarkable speed and efficiency. Happy coding!</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/deployment/50-visual-studio-code-hot-key-shortcuts-for-mac-2023">50 Visual Studio | VS Code Hot Key / Shortcuts for Mac 2023</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/deployment/50-visual-studio-code-hot-key-shortcuts-for-mac-2023/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>50 Visual Studio &#124; VS Code Hot Key / Shortcuts for Windows 2023</title>
		<link>https://sourcedcode.com/blog/aem/development/50-visual-studio-code-hot-key-shortcuts-for-windows-2023</link>
					<comments>https://sourcedcode.com/blog/aem/development/50-visual-studio-code-hot-key-shortcuts-for-windows-2023#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Mon, 31 Jul 2023 06:47:50 +0000</pubDate>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Visual Studio Code]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=5531</guid>

					<description><![CDATA[<p>Welcome to our guide on 50 Visual Studio Code shortcuts for Windows users. Whether you&#8217;re a seasoned developer or just starting, mastering these keyboard shortcuts will significantly enhance your coding productivity. Let&#8217;s dive in and discover the most efficient key combinations for a seamless coding experience! For Mac users, visit this article, 50 Visual Studio [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/development/50-visual-studio-code-hot-key-shortcuts-for-windows-2023">50 Visual Studio | VS Code Hot Key / Shortcuts for Windows 2023</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Welcome to our guide on 50 Visual Studio Code shortcuts for Windows users. Whether you&#8217;re a seasoned developer or just starting, mastering these keyboard shortcuts will significantly enhance your coding productivity. Let&#8217;s dive in and discover the most efficient key combinations for a seamless coding experience!</p>
<div class="mention-block--gold">
For Mac users, visit this article, <a href="https://sourcedcode.com/blog/aem/deployment/50-visual-studio-code-hot-key-shortcuts-for-mac-2023" rel="noopener" target="_blank">50 Visual Studio Code Hot Key / Shortcuts for Mac 2023</a>.
</div>
<hr class="spacer-larger"/>
<h2>Shortcuts List:</h2>
<ul>
<li><strong>Control + P</strong>: Quickly open files by typing their names in the Quick Open dialog.</li>
<li><strong>Control + N</strong>: Create a new file in the current workspace.</li>
<li><strong>Control + Shift + P</strong>: Open the Command Palette to access various commands and settings.</li>
<li><strong>Control + B</strong>: Toggle the visibility of the Side Bar.</li>
<li><strong>Control + Shift + E</strong>: Focus and show the File Explorer in the Side Bar.</li>
<li><strong>Control + Shift + F</strong>: Search across files in the entire workspace.</li>
<li><strong>Control + J</strong>: Toggle the Panel (Output, Terminal, or Debug Console).</li>
<li><strong>Control + /</strong>: Toggle line comments for the selected code.</li>
<li><strong>Alt + Shift + Up/Down Arrow</strong>: Move lines of code up or down.</li>
<li><strong>Alt + Click</strong>: Add multiple cursors at different positions to edit multiple lines at once.</li>
<li><strong>Control + Shift + L</strong>: Select all occurrences of the current selection.</li>
<li><strong>Control + D</strong>: Add the next occurrence of the current word to the selection.</li>
<li><strong>Control + G</strong>: Jump to a specific line number in the active file.</li>
<li><strong>Alt + Left/Right Arrow</strong>: Move the cursor to the beginning/end of the current word.</li>
<li><strong>Alt + Up/Down Arrow</strong>: Move the cursor up or down by paragraph.</li>
<li><strong>Control + Shift + K</strong>: Delete the current line.</li>
<li><strong>Control + Shift + T</strong>: Reopen the last closed tab.</li>
<li><strong>Control + Tab/Control + Shift + Tab</strong>: Cycle through open tabs.</li>
<li><strong>Control + F2</strong>: Set multiple cursors to the same word in the file.</li>
<li><strong>Control + Shift + [ / Control + Shift + ]</strong>: Indent or unindent lines of code.</li>
<li><strong>Alt + Shift + O</strong>: Sort lines in ascending order.</li>
<li><strong>Alt + Shift + Down Arrow</strong>: Copy lines down.</li>
<li><strong>Alt + Shift + Down Arrow</strong>: Move lines down.</li>
<li><strong>Alt + Shift + Up Arrow</strong>: Move lines up.</li>
<li><strong>Alt + Shift + F</strong>: Format the selected code.</li>
<li><strong>Alt + Shift + U</strong>: Transform to uppercase.</li>
<li><strong>Alt + Shift + L</strong>: Transform to lowercase.</li>
<li><strong>Control + Enter</strong>: Insert a new line below the current line.</li>
<li><strong>Control + Shift + Enter</strong>: Insert a new line above the current line.</li>
<li><strong>Control + Shift + \</strong>: Jump to matching bracket.</li>
<li><strong>Control + Shift + G</strong>: Open the Source Control view.</li>
<li><strong>Control + Shift + E</strong>: Show Explorer/Files view.</li>
<li><strong>Control + Shift + X</strong>: Open the Extensions view.</li>
<li><strong>Alt + Shift + F</strong>: Format document in the editor.</li>
<li><strong>Control + F</strong>: Find and replace text.</li>
<li><strong>Control + Shift + H</strong>: Replace in files (Find and replace across multiple files).</li>
<li><strong>Control + Shift + M</strong>: Show Problems panel.</li>
<li><strong>Control + Shift + U</strong>: Show output panel.</li>
<li><strong>Control + K + W</strong>: Close all editor tabs.</li>
<li><strong>Control + Shift + [ / Control + Shift + ]</strong>: Fold or unfold region.</li>
<li><strong>Alt + F12</strong>: Show all references of a symbol in the workspace.</li>
<li><strong>Control + Shift + F10</strong>: Run a specific test.</li>
<li><strong>Control + Shift + D</strong>: Open the Debugger panel.</li>
<li><strong>Control + Shift + O</strong>: Go to Symbol in File.</li>
<li><strong>Control + Shift + U</strong>: Go to a symbol&#8217;s implementation.</li>
<li><strong>Control + K + R</strong>: Show keyboard shortcuts reference.</li>
<li><strong>Control + Shift + F</strong>: Show keyboard shortcuts reference.</li>
</ul>
<hr class="spacer-larger"/>
<h2>Conclusion:</h2>
<p>Boost your coding productivity with these 50 essential Visual Studio Code shortcuts, tailored for Windows users. Incorporate these time-saving key combinations into your coding workflow, and watch as you breeze through tasks with remarkable speed and efficiency. Happy coding!</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/development/50-visual-studio-code-hot-key-shortcuts-for-windows-2023">50 Visual Studio | VS Code Hot Key / Shortcuts for Windows 2023</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/development/50-visual-studio-code-hot-key-shortcuts-for-windows-2023/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>AEM Sightly Official Documentation: Everything You Need to Know</title>
		<link>https://sourcedcode.com/blog/aem/aem-sightly-official-documentation-everything-you-need-to-know</link>
					<comments>https://sourcedcode.com/blog/aem/aem-sightly-official-documentation-everything-you-need-to-know#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Mon, 31 Jul 2023 06:21:42 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Sightly]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=5513</guid>

					<description><![CDATA[<p>This blog particularly promotes Adobe&#8217;s AEM Sightly documentation, which lives inside of their github repository. In this article, we&#8217;ll explore the significance of AEM Sightly and how its official documentation can be a valuable resource for developers working with Adobe Experience Manager. With understanding Adobe&#8217;s Sightly documentation, you will be equipped with the right tools [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/aem-sightly-official-documentation-everything-you-need-to-know">AEM Sightly Official Documentation: Everything You Need to Know</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>This blog particularly promotes Adobe&#8217;s AEM Sightly documentation, which lives inside of their github repository. In this article, we&#8217;ll explore the significance of AEM Sightly and how its official documentation can be a valuable resource for developers working with Adobe Experience Manager. With understanding Adobe&#8217;s Sightly documentation, you will be equipped with the right tools to effectively and efficiently write AEM Sightly code.
</p>
<p>As per this article is written, Sightly is versioned as 1.4. If you wish to find out what version sightly your AEM environment is using, <a href="https://sourcedcode.com/blog/aem/what-version-sightly-apache-sling-scripting-htl-engineis-my-aem-using#:~:text=Visit%20the%20system%20console%20bundles,see%20the%20versions%20being%20used." rel="noopener" target="_blank">you can refer to this article here, which it will explain you how to find out the Sightly Version</a>.</p>
<p>
   If you want to dive straight into the official documentation, you can access it on GitHub:<br />
   <a href="https://bit.ly/3OAzFIp" target="_blank" rel="noopener">AEM Sightly Documentation</a>
</p>
<div class="mention-block">
   <strong>Quick Links</strong></p>
<ol>
<li><a href="#what-is-sightly">What is AEM Sightly?</a></li>
<li><a href="#understanding-documentation">Understanding the Official Documentation</a></li>
<li><a href="#getting-started">Getting Started with AEM Sightly</a></li>
<li><a href="#sightly-syntax">Sightly Syntax and Expressions</a></li>
<li><a href="#templating-features">Templating Language Features</a></li>
<li><a href="#working-with-components">Working with Sightly in AEM Components</a></li>
<li><a href="#best-practices">Best Practices and Tips</a></li>
<li><a href="#extending-sightly">Extending Sightly</a></li>
<li><a href="#conclusion">Conclusion</a></li>
</ol>
</div>
<hr class="spacer-larger"/>
<div id="what-is-sightly">
<h2>1. What is AEM Sightly?</h2>
<p>
      AEM Sightly is a templating language used for building components in Adobe Experience Manager. It offers a clean and efficient way to separate the presentation layer from the business logic, resulting in more maintainable and reusable code.
   </p>
<p>   Dive straight into the official documentation, you can access it on GitHub:<br />
   <a href="https://bit.ly/3OAzFIp" target="_blank" rel="noopener">AEM Sightly Documentation</a>
</div>
<hr class="spacer-larger"/>
<div id="understanding-documentation">
<h2>2. Understanding the Official Documentation</h2>
<p>
      The official documentation provided by Adobe for AEM Sightly is a comprehensive guide that covers all aspects of working with Sightly. It is organized into different sections, making it easy to find the information you need.
   </p>
<p>   Dive straight into the official documentation, you can access it on GitHub:<br />
   <a href="https://bit.ly/3OAzFIp" target="_blank" rel="noopener">AEM Sightly Documentation</a>
</div>
<hr class="spacer-larger"/>
<div id="getting-started">
<h2>3. Getting Started with AEM Sightly</h2>
<p>
      If you are new to AEM Sightly, the official documentation provides resources to help you get started. You&#8217;ll find step-by-step instructions on setting up your development environment for Sightly projects.
   </p>
<p>   Dive straight into the official documentation, you can access it on GitHub:<br />
   <a href="https://bit.ly/3OAzFIp" target="_blank" rel="noopener">AEM Sightly Documentation</a>
</div>
<hr class="spacer-larger"/>
<div id="sightly-syntax">
<h2>4. Sightly Syntax and Expressions</h2>
<p>
      Sightly introduces its own syntax, different from JSP, for creating templates. The documentation explains the Sightly syntax and how expressions are used within templates to dynamically render content.
   </p>
<p>   Dive straight into the official documentation, you can access it on GitHub:<br />
   <a href="https://bit.ly/3OAzFIp" target="_blank" rel="noopener">AEM Sightly Documentation</a>
</div>
<hr class="spacer-larger"/>
<div id="templating-features">
<h2>5. Templating Language Features</h2>
<p>
      Sightly offers a range of templating language features like conditionals, loops, and variable declarations. The official documentation provides clear examples and explanations of each feature to help you use them effectively in your projects.
   </p>
<p>   Dive straight into the official documentation, you can access it on GitHub:<br />
   <a href="https://bit.ly/3OAzFIp" target="_blank" rel="noopener">AEM Sightly Documentation</a>
</div>
<hr class="spacer-larger"/>
<div id="working-with-components">
<h2>6. Working with Sightly in AEM Components</h2>
<p>
      Learn how to create AEM components using Sightly and integrate them with HTML to build reusable components that enhance the overall user experience.
   </p>
<p>   Dive straight into the official documentation, you can access it on GitHub:<br />
   <a href="https://bit.ly/3OAzFIp" target="_blank" rel="noopener">AEM Sightly Documentation</a>
</div>
<hr class="spacer-larger"/>
<div id="best-practices">
<h2>7. Best Practices and Tips</h2>
<p>
      To make the most out of Sightly, the documentation shares best practices for efficient development and tips to avoid common mistakes.
   </p>
<p>   Dive straight into the official documentation, you can access it on GitHub:<br />
   <a href="https://bit.ly/3OAzFIp" target="_blank" rel="noopener">AEM Sightly Documentation</a>
</div>
<hr class="spacer-larger"/>
<div id="extending-sightly">
<h2>8. Extending Sightly</h2>
<p>
      For advanced users, the official documentation covers how to extend Sightly by writing custom Java Use-API classes to add additional functionality.
   </p>
<p>   Dive straight into the official documentation, you can access it on GitHub:<br />
   <a href="https://bit.ly/3OAzFIp" target="_blank" rel="noopener">AEM Sightly Documentation</a>
</div>
<hr class="spacer-larger"/>
<div id="conclusion">
<h2>Conclusion</h2>
<p>
      AEM Sightly is a powerful templating language that empowers developers in Adobe Experience Manager projects. The official documentation provided by Adobe is an essential resource to understand and leverage the full potential of Sightly in your AEM development journey.
   </p>
<p>
      Throughout this article, we&#8217;ve explored the different aspects of the official documentation and how it can benefit developers. From getting started with Sightly to mastering its templating language features, the documentation acts as a comprehensive guide to help you build robust and efficient AEM components.
   </p>
<p>
      One of the significant advantages of the official documentation is that it is regularly updated by the Adobe team, ensuring that you have access to the latest features and best practices. Additionally, the documentation encourages a collaborative community, where you can contribute and share your insights to improve the experience for all users.
   </p>
<p>
      As you embark on your AEM Sightly development projects, we encourage you to make the most of the official documentation. By referring to it as your go-to resource, you&#8217;ll be equipped with the knowledge and skills needed to create outstanding experiences with Adobe Experience Manager.
   </p>
<p>
      Now that you know where to find the official documentation, dive in, explore, and take advantage of this invaluable resource. Whether you are a beginner or an experienced developer, the AEM Sightly official documentation will undoubtedly be your trusted companion on your journey to building exceptional AEM components.
   </p>
<p>
      Thank you for reading our blog article, and we hope it has inspired you to leverage AEM Sightly&#8217;s capabilities to create amazing digital experiences!
   </p>
<p>   Dive straight into the official documentation, you can access it on GitHub:<br />
   <a href="https://bit.ly/3OAzFIp" target="_blank" rel="noopener">AEM Sightly Documentation</a>
</div>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/aem-sightly-official-documentation-everything-you-need-to-know">AEM Sightly Official Documentation: Everything You Need to Know</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/aem-sightly-official-documentation-everything-you-need-to-know/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>HTML element style tag validation approaches in 2023</title>
		<link>https://sourcedcode.com/blog/css/html-element-style-tag-validation-approaches-in-2023</link>
					<comments>https://sourcedcode.com/blog/css/html-element-style-tag-validation-approaches-in-2023#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Sun, 30 Jul 2023 18:58:35 +0000</pubDate>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[General Web]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=5484</guid>

					<description><![CDATA[<p>In the rapidly changing world of web development, it&#8217;s essential to keep up with the latest standards. Some ways of inserting &#60;style&#62; tag to the HTML document are not valid for HTML5. In this article we will go through different compliant methods to insert &#60;style&#62; tags to your HTML documents. Although there are some invalid [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/css/html-element-style-tag-validation-approaches-in-2023">HTML element style tag validation approaches in 2023</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>In the rapidly changing world of web development, it&#8217;s essential to keep up with the latest standards. Some ways of inserting &lt;style&gt; tag to the HTML document are not valid for HTML5. In this article we will go through different compliant methods to insert &lt;style&gt; tags to your HTML documents. Although there are some invalid ways of inserting the &lt;style&gt; tag, we will explore some alternatives that adhere to the current HTML5 standards.</p>
<div class="mention-block">
<strong>Quick Links</strong></p>
<ol>
<li><a href="#external-stylesheets-valid">External Stylesheets (valid)</a></li>
<li><a href="#inline-style-tag-in-head">Inline &lt;style&gt; tag in the &lt;head&gt; (valid)</a></li>
<li><a href="#inline-style-tag-in-body">Inline &lt;style&gt; tag in the &lt;body&gt; (in-valid), but acceptable.</a></li>
</ol>
</div>
<hr class="spacer-larger"/>
<h2 id="external-stylesheets-valid">1. External Stylesheets (valid)</h2>
<p>One of the most common and recommended ways to style web pages is by using external stylesheets. Instead of adding styles directly into the HTML, you create a separate CSS file and link it to your web page. This keeps your HTML clean and separates the style rules from the content, making it easier to manage and reuse styles across multiple pages.</p>
<p>To link an external stylesheet, use the following code within the &lt;head&gt; section of your HTML document:</p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&lt;<span style="color: #000000; font-weight: bold;">link</span> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;stylesheet&quot;</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;styles.css&quot;</span>&gt;</div></td></tr></tbody></table></div>
<hr class="spacer-larger"/>
<h2 id="inline-style-tag-in-head">2. Inline &lt;style&gt; tag in the &lt;head&gt; (valid)</h2>
<p>Another valid method is to use inline styles in the &lt;head&gt; section. If you have styles that are specific to a single page and won&#8217;t be reused elsewhere, you can write your CSS directly in the &lt;head&gt;. This ensures that your styles are loaded before the page content, preventing any unwanted visual glitches.</p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&lt;!DOCTYPE html&gt;<br />
&lt;<span style="color: #000000; font-weight: bold;">html</span>&gt;<br />
&lt;<span style="color: #000000; font-weight: bold;">head</span>&gt;<br />
&nbsp; &lt;<span style="color: #000000; font-weight: bold;">title</span>&gt;My Page&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">title</span>&gt;<br />
&nbsp; &lt;<span style="color: #000000; font-weight: bold;">style</span>&gt;<br />
&nbsp; &nbsp; <span style="color: #66cc66;">/</span>* Your CSS <span style="color: #000066;">rules</span> here *<span style="color: #66cc66;">/</span><br />
&nbsp; &lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">style</span>&gt;<br />
&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">head</span>&gt;<br />
&lt;<span style="color: #000000; font-weight: bold;">body</span>&gt;<br />
&nbsp; &lt;!-- Your page <span style="color: #000066;">content</span> here --&gt;<br />
&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">body</span>&gt;<br />
&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">html</span>&gt;</div></td></tr></tbody></table></div>
<hr class="spacer-larger"/>
<h2 id="inline-style-tag-in-body">3. Inline &lt;style&gt; tag in the &lt;body&gt; (in-valid), but acceptable.</h2>
<p>A &lt;style&gt; tag within the &lt;body&gt; tag won’t validate because the HTML specs say it can’t be there. The reason behind this restriction is to maintain a clear separation of concerns between the content (HTML) and the presentation (CSS). Placing &lt;style&gt; tags within the &lt;body&gt; goes against the principles of well-structured and maintainable HTML documents. </p>
<p>Try running the code below in <a href="https://validator.w3.org/#validate_by_input" rel="noopener" target="_blank">https://validator.w3.org/#validate_by_input</a>, and you should able to see the error.</p>
<div class="mention-block">
<h5>Can I still use the &lt;style&gt; tag inside of the &lt;body&gt; tag?</h5>
<p>Using the &lt;style&gt; tag directly inside the &lt;body&gt; tag is not a valid approach according to the HTML5 specification. The official HTML5 specification strictly defines the placement of the &lt;style&gt; tag within the &lt;head&gt; element, specifically to separate content (HTML) from presentation (CSS).</p>
<p>However, placing &lt;style&gt; tags in the &lt;body&gt; will work in most modern browsers, but it is considered non-compliant. This approach however is still used by many websites out there. Especially with CMS platforms like WordPress, Drupal, Site-core, and Adobe Experience Managers, full-filling features and UX for simple scenarios, it is acceptable&#8230; The thing is, even thought we have HTML5 specification, even Google <a href="https://www.hobo-web.co.uk/official-google-prefers-valid-html-css/#:~:text=While%20Google%20recommends%20we%20use,it%20is%20to%20the%20query." rel="noopener" target="_blank">(source)</a> themselves are taking shortcuts to cut down performance costs.</p>
<p>Note: While Google recommends we use W3C validation, Google doesn&#8217;t rank valid html and css pages above invalid pages. If Google can crawl and render a page Google will rank the page appropriately based on how relevant it is to the query. <a href="https://www.hobo-web.co.uk/official-google-prefers-valid-html-css/#:~:text=While%20Google%20recommends%20we%20use,it%20is%20to%20the%20query." rel="noopener" target="_blank">source.</a>
</div>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&lt;!DOCTYPE html&gt;<br />
&lt;<span style="color: #000000; font-weight: bold;">html</span>&gt;<br />
&lt;<span style="color: #000000; font-weight: bold;">head</span>&gt;<br />
&nbsp; &lt;<span style="color: #000000; font-weight: bold;">title</span>&gt;My Page&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">title</span>&gt;<br />
&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">head</span>&gt;<br />
&lt;<span style="color: #000000; font-weight: bold;">body</span>&gt;<br />
&nbsp; &lt;!-- Your page <span style="color: #000066;">content</span> here --&gt;<br />
&nbsp; &lt;<span style="color: #000000; font-weight: bold;">style</span>&gt;<br />
&nbsp; &nbsp; * Your CSS <span style="color: #000066;">rules</span> here *<span style="color: #66cc66;">/</span><br />
&nbsp; &lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">style</span>&gt;<br />
&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">body</span>&gt;<br />
&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">html</span>&gt;</div></td></tr></tbody></table></div>
<hr class="spacer-larger"/>
<h2>Summary</h2>
<p>Following W3C standards in web development brings positive outcomes such as improved cross-browser compatibility, accessibility, future-proofing, and maintainability. It also fosters interoperability, boosts SEO performance, enhances security, and contributes to a positive reputation. Embracing W3C standards ensures a faster development process and a healthier web ecosystem.</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/css/html-element-style-tag-validation-approaches-in-2023">HTML element style tag validation approaches in 2023</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/css/html-element-style-tag-validation-approaches-in-2023/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>AEM RichText Remove P Tag on Sightly</title>
		<link>https://sourcedcode.com/blog/aem/aem-richtext-remove-p-tag-on-sightly</link>
					<comments>https://sourcedcode.com/blog/aem/aem-richtext-remove-p-tag-on-sightly#comments</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Sat, 29 Jul 2023 03:29:27 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Sightly]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=5365</guid>

					<description><![CDATA[<p>You may have been trying to search the internet for an out of box solution to remove the single paragraph container for Touch UI, and have found something like removeSingleParagraphContainer. But however, this attribute was for the Classic UI and deprecated. From my knowledge, there isn&#8217;t anything out of the box that can remove the [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/aem-richtext-remove-p-tag-on-sightly">AEM RichText Remove P Tag on Sightly</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>You may have been trying to search the internet for an out of box solution to remove the single paragraph container for Touch UI, and have found something like removeSingleParagraphContainer. But however, this attribute was for the Classic UI and deprecated. From my knowledge, there isn&#8217;t anything out of the box that can remove the p single paragraph container tag. However, I have spent some time and found a very lucrative solution. Lets remove the p tag from the rich text editor!</p>
<p>In this article, we will step through my implementation for us to remove the p tag once and for all, from being rendered. </p>
<p>My solution to this problem will be dealt with in the backend, Sling Model. Some may argue that the solution can be done using Javascript, but that can be very troublesome. Let&#8217;s Keep it Simple Stupid (KISS). There&#8217;s one caveat to this approach; scroll to the bottom of the page to see what it is.</p>
<p>Follow my 3 steps below to remove the P tag wrapper from what is being produced by the cq/gui/components/authoring/dialog/richtext.</p>
<p><iframe loading="lazy" width="560" height="315" src="https://www.youtube.com/embed/WSS1Tfau4dc" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></p>
<hr class="spacer-large"/>
<h3>Step 1. Add Custom Option In the Paraformat Options</h3>
<p>Under the _cq_dialog.xml, <strong>cq/gui/components/authoring/dialog/richtext</strong>, add a new format option under the paraformat list of options. </p>
<p>The selected paraformat option will be a custom HTML element that wraps onto the highlighted or selected text from the author. In this case, when the author have selected text, and then click on the new paraformat option, the Html will look something like this <span class="code-highlight-primary">&lt;notextformat&gt;sometext&lt;/notextformat&gt;</span>.</p>
<div class="codecolorer-container xml default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br />78<br />79<br />80<br />81<br />82<br />83<br />84<br />85<br />86<br />87<br />88<br />89<br />90<br />91<br />92<br />93<br />94<br />95<br />96<br />97<br />98<br />99<br />100<br />101<br />102<br />103<br />104<br />105<br />106<br /></div></td><td><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">// new paraformt to be added into line:77<br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;notextformat</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp;<span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp;<span style="color: #000066;">description</span>=<span style="color: #ff0000;">&quot;No - Text Format&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp;<span style="color: #000066;">tag</span>=<span style="color: #ff0000;">&quot;notextformat&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
// the complete _cq_dialog.xml configuration for the cq/gui/components/authoring/dialog/richtext<br />
// new paraformt to be added into line:77<br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;text</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp;<span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp;<span style="color: #000066;">sling:resourceType</span>=<span style="color: #ff0000;">&quot;cq/gui/components/authoring/dialog/richtext&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp;<span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;./text&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp;<span style="color: #000066;">useFixedInlineToolbar</span>=<span style="color: #ff0000;">&quot;{Boolean}true&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;rtePlugins</span> <span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;format</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">features</span>=<span style="color: #ff0000;">&quot;bold,italic&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;justify</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">features</span>=<span style="color: #ff0000;">&quot;-&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;links</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">features</span>=<span style="color: #ff0000;">&quot;modifylink,unlink&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;lists</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">features</span>=<span style="color: #ff0000;">&quot;*&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;paraformat</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">features</span>=<span style="color: #ff0000;">&quot;*&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;formats</span> <span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;default_p</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">description</span>=<span style="color: #ff0000;">&quot;Paragraph&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">tag</span>=<span style="color: #ff0000;">&quot;p&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;default_h1</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">description</span>=<span style="color: #ff0000;">&quot;Heading 1&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">tag</span>=<span style="color: #ff0000;">&quot;h1&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;default_h2</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">description</span>=<span style="color: #ff0000;">&quot;Heading 2&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">tag</span>=<span style="color: #ff0000;">&quot;h2&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;default_h3</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">description</span>=<span style="color: #ff0000;">&quot;Heading 3&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">tag</span>=<span style="color: #ff0000;">&quot;h3&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;default_h4</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">description</span>=<span style="color: #ff0000;">&quot;Heading 4&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">tag</span>=<span style="color: #ff0000;">&quot;h4&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;default_h5</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">description</span>=<span style="color: #ff0000;">&quot;Heading 5&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">tag</span>=<span style="color: #ff0000;">&quot;h5&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;default_h6</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">description</span>=<span style="color: #ff0000;">&quot;Heading 6&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">tag</span>=<span style="color: #ff0000;">&quot;h6&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;default_blockquote</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">description</span>=<span style="color: #ff0000;">&quot;Quote&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">tag</span>=<span style="color: #ff0000;">&quot;blockquote&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;default_pre</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">description</span>=<span style="color: #ff0000;">&quot;Preformatted&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">tag</span>=<span style="color: #ff0000;">&quot;pre&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;notextformat</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">description</span>=<span style="color: #ff0000;">&quot;No - Text Format&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">tag</span>=<span style="color: #ff0000;">&quot;notextformat&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/formats<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/paraformat<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/rtePlugins<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;uiSettings</span> <span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;cui</span> <span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;inline</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">toolbar</span>=<span style="color: #ff0000;">&quot;[format#bold,format#italic,format#underline,#justify,#lists,links#modifylink,links#unlink,#paraformat]&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;popovers</span> <span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;justify</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">items</span>=<span style="color: #ff0000;">&quot;[justify#justifyleft,justify#justifycenter,justify#justifyright]&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">ref</span>=<span style="color: #ff0000;">&quot;justify&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;lists</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">items</span>=<span style="color: #ff0000;">&quot;[lists#unordered,lists#ordered,lists#outdent,lists#indent]&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">ref</span>=<span style="color: #ff0000;">&quot;lists&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;paraformat</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">items</span>=<span style="color: #ff0000;">&quot;paraformat:getFormats:paraformat-pulldown&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">ref</span>=<span style="color: #ff0000;">&quot;paraformat&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/popovers<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/inline<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/cui<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/uiSettings<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/text<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></div></td></tr></tbody></table></div>
<hr class="spacer-larger"/>
<h3>Step 2. Create the Backend, Sling Model, to Text Transform</h3>
<p>The backend Sling Model will read the ./text property that has been set by the user&#8217;s input. Using the String.ReplaceAll(), we can replace all <span class="code-highlight-secondary">&lt;/?notextformat&gt;</span>, regex pattern, with nothing (meaning that this element will be removed).</p>
<p>For example <span class="code-highlight-primary">&lt;notextformat&gt;sometext&lt;/notextformat&gt;</span>. -> <span class="code-highlight-primary">sometext</span>.</p>
<p>We next save the formatted text into a variable of <span class="code-highlight-secondary"richText</span>, which can be used by sightly to display HTML on the page.</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.sourcedcode.core.models</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.resource.Resource</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.models.annotations.Default</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.models.annotations.Model</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.models.annotations.Optional</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.models.annotations.injectorspecific.ValueMapValue</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.annotation.PostConstruct</span><span style="color: #339933;">;</span><br />
<br />
@Model<span style="color: #009900;">&#40;</span>adaptables<span style="color: #339933;">=</span>Resource.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MyTextComponent <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; @Optional<br />
&nbsp; &nbsp; @ValueMapValue<br />
&nbsp; &nbsp; @<span style="color: #000000; font-weight: bold;">Default</span><span style="color: #009900;">&#40;</span>values <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> text<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> richText<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; @PostConstruct<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> init<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>text.<span style="color: #006633;">isEmpty</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; richText <span style="color: #339933;">=</span> text.<span style="color: #006633;">replaceAll</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;/?notextformat&gt;&quot;</span>, <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> getRichText<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> richText<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<hr class="spacer-larger"/>
<h3>Step 3. Render Text Transform from Sightly</h3>
<p>Now finally we just need to utilise sightly to print the text transformed, <span class="code-highlight-primary">richText</span>, to the screen.</p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #009900;">&lt;sly data-sly-use.myTextComponent<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;com.sourcedcode.core.models.MyTextComponent&quot;</span><span style="color: #66cc66;">/</span>&gt;</span><br />
${myTextComponent.richText @ context='html'}<br />
<span style="color: #009900;">&lt;sly data-sly-use.templates<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;core/wcm/components/commons/v1/templates.html&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; data-sly-call<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;${templates.placeholder @ isEmpty = !myTextComponent.richText}&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span>sly&gt;</span></div></td></tr></tbody></table></div>
<hr class="spacer-large"/>
<div class="mention-block">
<strong>Last Thoughts?</strong><br />
The caveat with this approach is that when you are trying to export JSON format from this component, you will be stuck with this block of text, <span class="code-highlight-primary">&lt;notextformat&gt;sometext&lt;/notextformat&gt;</span>, unless if you text to transform the export as well.</p>
<p>The reason why I did not overwrite the JCR values is that I wanted to retain the natural editing experience for the authors. With my solution when the author decides to make changes to the rich text field, they would not have a werid experience.
</p></div>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/aem-richtext-remove-p-tag-on-sightly">AEM RichText Remove P Tag on Sightly</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/aem-richtext-remove-p-tag-on-sightly/feed</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>Why Indexing in AEM is so important for Search</title>
		<link>https://sourcedcode.com/blog/aem/why-indexing-in-aem-is-so-important-for-search</link>
					<comments>https://sourcedcode.com/blog/aem/why-indexing-in-aem-is-so-important-for-search#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Sat, 29 Jul 2023 03:27:33 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Search]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=5362</guid>

					<description><![CDATA[<p>As we are developers implement search, I would like to share the importance of indexing in AEM. I would like to express that this is a simple post, but enough information to get you to understand the importance of indexing. Continue and read the article below to see the significance &#038; Importance of Indexing in [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/why-indexing-in-aem-is-so-important-for-search">Why Indexing in AEM is so important for Search</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>As we are developers implement search, I would like to share the importance of indexing in AEM. I would like to express that this is a simple post, but enough information to get you to understand the importance of indexing. Continue and read the article below to see the significance &#038; Importance of Indexing in AEM.</p>
<ol>
<li><strong>Improved Search Performance:</strong> Indexing enables rapid content searches, even in large repositories, improving search speed and efficiency.</li>
<li><strong>Enhanced User Experience:</strong> Quick and relevant search results lead to a seamless and satisfying user experience.</li>
<li><strong>Efficient Content Retrieval:</strong> Indexing enables swift access to specific content items, streamlining content management.</li>
<li><strong>Scalability and Performance:</strong> Indexing supports AEM&#8217;s scalability while maintaining high performance levels.</li>
<li><strong>Complex Querying Support:</strong> Indexing efficiently handles complex search queries with multiple filters and conditions.</li>
</ol>
<hr class="spacer-larger" />
<h2>Best Practices for Indexing</h2>
<ul>
<li><strong>Regular Updates:</strong> Schedule frequent index updates to reflect the latest content changes.</li>
<li><strong>Monitor Index Health:</strong> Keep track of index size and performance metrics to identify issues.</li>
<li><strong>Use Index Filters:</strong> Optimize the index&#8217;s size and relevancy by defining specific filters.</li>
<li><strong>Configure Indexing Properties:</strong> Properly configure indexing settings based on content nature and usage patterns.</li>
</ul>
<hr class="spacer-larger" />
<h2>Conclusion</h2>
<p>Indexing is a critical component of AEM, ensuring efficient content retrieval and enhanced user experiences. By following indexing best practices, organizations can fully unlock the potential of AEM for seamless content management and delivery.</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/why-indexing-in-aem-is-so-important-for-search">Why Indexing in AEM is so important for Search</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/why-indexing-in-aem-is-so-important-for-search/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>AEM Effective Pagination with Query Builder API</title>
		<link>https://sourcedcode.com/blog/aem/aem-effective-pagination-with-query-builder-api</link>
					<comments>https://sourcedcode.com/blog/aem/aem-effective-pagination-with-query-builder-api#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Wed, 26 Jul 2023 03:23:47 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Search]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=5359</guid>

					<description><![CDATA[<p>There are many ways to implement pagination for AEM content. Effectively choosing the right solution will indeed Bu decrease development time, and promote a performant experience to your end users. AEM has multiple search API&#8217;s like xPath, JCR SQL2, Node JCR, Query Builder, etc&#8230; But in my opinion, the Query Builder API would be the [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/aem-effective-pagination-with-query-builder-api">AEM Effective Pagination with Query Builder API</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>There are many ways to implement pagination for AEM content. Effectively choosing the right solution will indeed Bu decrease development time, and promote a performant experience to your end users. AEM has multiple search API&#8217;s like xPath, JCR SQL2, Node JCR, Query Builder, etc&#8230; But in my opinion, the Query Builder API would be the most effective decision when building a solution with pagination. In AEM, the Query Builder API has emerged as the preferred solution for creating pagination experiences. In this article, we will explore why the Query Builder API stands out as the go-to choice for pagination in AEM.</p>
<div class="mention-block">
<strong>Quick Links</strong></p>
<ol>
<li><a href="#understanding-pagination-in-aem">1. Understanding Pagination in AEM</a></li>
<li><a href="#the-query-builder-api-an-overview">2. The Query Builder API: An Overview</a></li>
<li>
        <a href="#benefits-of-the-query-builder-api-for-pagination">3. Benefits of the Query Builder API for Pagination</a></p>
<ul>
<li><a href="#performance-optimization">3a. Performance Optimization</a></li>
<li><a href="#flexibility-and-customization">3b. Flexibility and Customization</a></li>
<li><a href="#support-for-dynamic-content">3c. Support for Dynamic Content</a></li>
<li><a href="#facilitating-search-functionality">3d. Facilitating Search Functionality</a></li>
</ul>
</li>
<li>
        <a href="#pagination-and-more-features-with-query-builder-api">4. Pagination and More Features with Query Builder API</a></p>
<ul>
<li><a href="#offset-and-limit">4a.Offset and Limit</a></li>
<li><a href="#sorting">4b.Sorting</a></li>
<li><a href="#search-filters">4c.Search Filters</a></li>
<li><a href="#query-aggregation">4d.Query Aggregation</a></li>
<li><a href="#content-pre-fetching">4e. Content Pre-fetching</a></li>
</ul>
</li>
<li><a href="#a-simple-servlet-for-querying-pages-in-java">A Simple Servlet for Querying Pages in Java</a></li>
<li><a href="#conclusion">Conclusion</a></li>
</ol>
</div>
<hr class="spacer-larger"/>
<h2 id="understanding-pagination-in-aem">1. Understanding Pagination in AEM</h2>
<p>What is pagination? In general, pagination is a process that divides large sets of content into smaller, more manageable sections, commonly referred to as &#8220;pages&#8221;; but however, with AEM, anything can be paginated. By doing so, users can navigate through content easily, without being presented with an exhaustive list all at once. In AEM, pagination is particularly crucial for content-heavy websites or applications, ensuring that visitors can access desired information quickly. You can probably imagine, when the page first loads, you can see the first 10 results, and clicking on &#8220;next&#8221;, you are able to see the next 10 results, and so on&#8230;</p>
<hr class="spacer-larger"/>
<h2 id="the-query-builder-api-an-overview">2. The Query Builder API: An Overview</h2>
<p>The Query Builder API is a powerful tool within AEM that allows developers to construct complex queries to retrieve content from the AEM repository. It is designed to provide a more flexible and efficient way of searching and fetching content than traditional JCR-SQL2 queries. The Query Builder API abstracts the underlying technology and provides an easy-to-use interface to interact with the AEM repository.</p>
<hr class="spacer-larger"/>
<h2 id="benefits-of-the-query-builder-api-for-pagination">3. Benefits of the Query Builder API for Pagination</h2>
<h3 id="performance-optimization">3a. Performance Optimization</h3>
<p>One of the primary reasons the Query Builder API is preferred for pagination in AEM is its ability to optimize performance. When dealing with large repositories, traditional queries can be resource-intensive and slow, impacting the page loading time and user experience. The Query Builder API, on the other hand, leverages optimized query execution, resulting in faster response times and enhanced page performance.</p>
<h3 id="flexibility-and-customization">3b. Flexibility and Customization</h3>
<p>The Query Builder API offers developers a wide range of parameters and options to fine-tune their queries. This level of flexibility enables developers to customize the pagination logic based on specific use cases. Whether it&#8217;s setting the number of items per page, defining sorting criteria, or filtering results, the Query Builder API empowers developers to tailor pagination experiences according to project requirements.</p>
<h3 id="support-for-dynamic-content">3c. Support for Dynamic Content</h3>
<p>In dynamic environments where content changes frequently, pagination needs to adapt to reflect these updates accurately. The Query Builder API can seamlessly handle dynamic content by providing real-time results based on the most recent data in the AEM repository. This ensures that the user always receives the latest content, maintaining an up-to-date and engaging user experience.</p>
<h3 id="facilitating-search-functionality">3d. Facilitating Search Functionality</h3>
<p>Pagination is often used in conjunction with search functionality to improve content discovery. The Query Builder API&#8217;s capability to perform complex searches across various content attributes makes it a natural fit for integrating search with pagination. By combining these features, users can easily find and navigate to the exact content they need.</p>
<hr class="spacer-larger"/>
<h2 id="pagination-and-more-features-with-query-builder-api">4. Pagination and More Features with Query Builder API</h2>
<h3 id="offset-and-limit">4a. Offset and Limit</h3>
<p>The Query Builder API allows developers to define the starting point (offset) and the maximum number of items (limit) to fetch for each page. This enables seamless navigation between pages, allowing users to access content beyond the first page of results.</p>
<h3 id="sorting">4b. Sorting</h3>
<p>To enhance user experience, pagination often goes hand in hand with sorting. The Query Builder API allows developers to specify sorting criteria based on content attributes. For example, you can sort content by date, popularity, or any other relevant property to ensure a logical order for the paginated results.</p>
<h3 id="search-filters">4c. Search Filters</h3>
<p>Incorporating search filters along with pagination empowers users to refine their search queries and find specific content efficiently. The Query Builder API enables developers to apply various filters and constraints to narrow down the results, creating a more personalized experience for users.</p>
<h3 id="query-aggregation">4d. Query Aggregation</h3>
<p>The Query Builder API also supports query aggregation, which enables developers to group results based on specific attributes. This feature is particularly useful when presenting aggregated data, such as categories or tags, in a paginated manner.</p>
<h3 id="content-pre-fetching">4e. Content Pre-fetching</h3>
<p>To further optimize user experience, the Query Builder API allows developers to implement content pre-fetching. By fetching additional content in the background, users experience faster loading times when navigating between pages, reducing any perceived delays.</p>
<hr class="spacer-larger"/>
<h2 id="a-simple-servlet-for-querying-pages-in-java">5. A Simple Servlet for Querying Pages in Java</h2>
<p>Below is an example of a simple Java servlet that uses the Query Builder API to query pages from the AEM repository for pagination purposes:</p>
<div class="code-750">
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.SlingHttpServletRequest</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.SlingHttpServletResponse</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.servlets.SlingAllMethodsServlet</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.osgi.service.component.annotations.Component</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.osgi.service.component.propertytypes.ServiceRanking</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.osgi.service.component.annotations.Reference</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.day.cq.search.PredicateGroup</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.day.cq.search.Query</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.day.cq.search.QueryBuilder</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.day.cq.search.result.SearchResult</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.IOException</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.HashMap</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Map</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.servlet.Servlet</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.servlet.ServletException</span><span style="color: #339933;">;</span><br />
<br />
@<span style="color: #003399;">Component</span><span style="color: #009900;">&#40;</span>service <span style="color: #339933;">=</span> Servlet.<span style="color: #000000; font-weight: bold;">class</span>,<br />
&nbsp; &nbsp; property <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;sling.servlet.methods=GET&quot;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;sling.servlet.paths=/bin/findPagePaths&quot;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;sling.servlet.extensions=json&quot;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><br />
@ServiceRanking<span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1001</span><span style="color: #009900;">&#41;</span> <span style="color: #666666; font-style: italic;">// Adjust the service ranking as per your requirement</span><br />
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> PaginatedPagesServlet <span style="color: #000000; font-weight: bold;">extends</span> SlingAllMethodsServlet <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">long</span> serialVersionUID <span style="color: #339933;">=</span> 1L<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; @<span style="color: #003399;">Reference</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> QueryBuilder queryBuilder<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; @Override<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> doGet<span style="color: #009900;">&#40;</span>SlingHttpServletRequest request, SlingHttpServletResponse response<span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">throws</span> ServletException, <span style="color: #003399;">IOException</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Get request parameters for search and pagination</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">String</span> searchTerm <span style="color: #339933;">=</span> request.<span style="color: #006633;">getParameter</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;q&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">int</span> currentPage <span style="color: #339933;">=</span> <span style="color: #003399;">Integer</span>.<span style="color: #006633;">parseInt</span><span style="color: #009900;">&#40;</span>request.<span style="color: #006633;">getParameter</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;page&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">int</span> pageSize <span style="color: #339933;">=</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Number of items per page</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Calculate the offset to start retrieving items</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">int</span> offset <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>currentPage <span style="color: #339933;">-</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> pageSize<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Build the query map for the QueryBuilder API</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Map<span style="color: #339933;">&lt;</span><span style="color: #003399;">String</span>, String<span style="color: #339933;">&gt;</span> queryMap <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HashMap<span style="color: #339933;">&lt;&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; queryMap.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;path&quot;</span>, <span style="color: #0000ff;">&quot;/content&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Replace with your desired root path</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; queryMap.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;type&quot;</span>, <span style="color: #0000ff;">&quot;cq:Page&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; queryMap.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;fulltext.relPath&quot;</span>, <span style="color: #0000ff;">&quot;jcr:content&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; queryMap.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;fulltext&quot;</span>, searchTerm<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Use the &quot;q&quot; parameter for search terms</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; queryMap.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;p.offset&quot;</span>, <span style="color: #003399;">String</span>.<span style="color: #006633;">valueOf</span><span style="color: #009900;">&#40;</span>offset<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; queryMap.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;p.limit&quot;</span>, <span style="color: #003399;">String</span>.<span style="color: #006633;">valueOf</span><span style="color: #009900;">&#40;</span>pageSize<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Execute the query</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Query query <span style="color: #339933;">=</span> queryBuilder.<span style="color: #006633;">createQuery</span><span style="color: #009900;">&#40;</span>PredicateGroup.<span style="color: #006633;">create</span><span style="color: #009900;">&#40;</span>queryMap<span style="color: #009900;">&#41;</span>, request.<span style="color: #006633;">getResourceResolver</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">adaptTo</span><span style="color: #009900;">&#40;</span>Session.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">SearchResult</span> result <span style="color: #339933;">=</span> query.<span style="color: #006633;">getResult</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Get the paths of the pages from the search result using GJSON</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; JSONArray pathsArray <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> JSONArray<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; result.<span style="color: #006633;">getHits</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #000000; font-weight: bold;">forEach</span><span style="color: #009900;">&#40;</span>hit <span style="color: #339933;">-&gt;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">String</span> path <span style="color: #339933;">=</span> hit.<span style="color: #006633;">getResource</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getPath</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pathsArray.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>path<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Send the paginated content (paths of the pages) to the response</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; response.<span style="color: #006633;">setContentType</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;application/json&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; response.<span style="color: #006633;">getWriter</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">write</span><span style="color: #009900;">&#40;</span>pathsArray.<span style="color: #006633;">toJSONString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
</div>
<p>Curl</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"># Replace <span style="color: #0000ff;">&quot;http://your_server&quot;</span> with the base <span style="color: #003399;">URL</span> of your AEM instance.<br />
# Replace <span style="color: #0000ff;">&quot;/bin/findPagePaths?q=search_term&amp;page=1&quot;</span> with the path to your servlet,<br />
# the desired search term <span style="color: #009900;">&#40;</span>search_term<span style="color: #009900;">&#41;</span>, and the desired page number.<br />
<br />
# Search with <span style="color: #0000ff;">&quot;your_search_term&quot;</span> and get results <span style="color: #000000; font-weight: bold;">for</span> Page <span style="color: #cc66cc;">1</span><br />
curl <span style="color: #339933;">-</span>X GET <span style="color: #0000ff;">&quot;http://your_server/bin/findPagePaths?q=your_search_term&amp;page=1&quot;</span><br />
<br />
# Search with <span style="color: #0000ff;">&quot;another_search_term&quot;</span> and get results <span style="color: #000000; font-weight: bold;">for</span> Page <span style="color: #cc66cc;">2</span><br />
curl <span style="color: #339933;">-</span>X GET <span style="color: #0000ff;">&quot;http://your_server/bin/findPagePaths?q=another_search_term&amp;page=2&quot;</span></div></td></tr></tbody></table></div>
<hr class="spacer-larger"/>
<h2 id="conclusion">5. Conclusion</h2>
<p>In conclusion, the Query Builder API in Adobe Experience Manager is a versatile and powerful tool that provides an ideal solution for implementing pagination experiences. With its performance optimization, flexibility, and support for dynamic content, the Query Builder API ensures that users can navigate through content-rich websites or applications seamlessly.</p>
<p>By incorporating features like offset and limit, sorting, search filters, query aggregation, and content pre-fetching, developers can create highly customizable and efficient pagination experiences for their AEM projects. Additionally, the provided Java servlet example demonstrates how the Query Builder API can be used to retrieve paginated content from the AEM repository. As AEM continues to evolve, leveraging the Query Builder API will remain essential for maintaining an excellent user experience and keeping users engaged with your content.</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/aem-effective-pagination-with-query-builder-api">AEM Effective Pagination with Query Builder API</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/aem-effective-pagination-with-query-builder-api/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>A Simple Guide to AEM Search APIs: Exploring Your Options for Powerful Search Functionality</title>
		<link>https://sourcedcode.com/blog/aem/a-simple-guide-to-aem-search-apis-exploring-your-options-for-powerful-search-functionality</link>
					<comments>https://sourcedcode.com/blog/aem/a-simple-guide-to-aem-search-apis-exploring-your-options-for-powerful-search-functionality#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Sat, 01 Jul 2023 04:44:35 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Search]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=5330</guid>

					<description><![CDATA[<p>As an AEM developer, the ability and skill to identify solutions and implementations to quickly and efficiently search through vast amounts of content is crucial. Understanding the all the AEM platform&#8217;s search API capabilities will ensure you are a effective developer, when implementing solutions for AEM search. In this article, we will explore the various [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/a-simple-guide-to-aem-search-apis-exploring-your-options-for-powerful-search-functionality">A Simple Guide to AEM Search APIs: Exploring Your Options for Powerful Search Functionality</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>As an AEM developer, the ability and skill to identify solutions and implementations to quickly and efficiently search through vast amounts of content is crucial. Understanding the all the AEM platform&#8217;s search API capabilities will ensure you are a effective developer, when implementing solutions for AEM search. In this article, we will explore the various options provided by AEM Search APIs, enabling you to make informed decisions while implementing search capabilities within your AEM projects. Throughout each search API topic, we will provide code examples as well, so you know exactly what to expect.</p>
<div class="mention-block">
<strong>Quick Links</strong></p>
<ol>
<li><a href="#xpath-search-api">XPath Search API</a></li>
<li><a href="#jcr-sql2-search-api">JCR SQL2 Search API</a></li>
<li><a href="#query-builder-search-api">Query Builder Search API</a></li>
</ol>
</div>
<hr class="spacer-larger"/>
<h2 id="xpath-search-api">1. XPath Search API</h2>
<p>XPath is a query language that allows you to navigate through the nodes and elements of an XML document. In the context of AEM, XPath queries can be used to search for content within the JCR (Java Content Repository) repository. While XPath is a powerful and flexible query language, it is essential to use it judiciously, as complex queries can have performance implications.</p>
<p><strong>Some Benefits and Features:</strong></p>
<ol>
<li>XPath Queries: XPath is a versatile query language that enables you to navigate through XML documents and locate specific nodes or elements within the content repository.</li>
<li>Flexibility: XPath queries offer high flexibility and allow you to search content based on various criteria, making it suitable for complex search requirements.</li>
<li>Node Structure: XPath queries rely on the hierarchical structure of nodes, making it well-suited for navigating and filtering content with a fixed structure.</li>
<li>Rich Expressions: With XPath, you can employ a wide range of expressions, such as text matching, attribute filtering, and range-based searches.<br />
Dynamic Content: XPath can handle dynamic content, but developers should be cautious with complex queries as they may impact performance.</li>
</ol>
<p><strong>JAVA Example:</strong></p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.jcr.Node</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.jcr.NodeIterator</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.jcr.query.Query</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.jcr.query.QueryManager</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.jcr.query.QueryResult</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// Assuming you have access to the JCR Session object (session)</span><br />
<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; QueryManager queryManager <span style="color: #339933;">=</span> session.<span style="color: #006633;">getWorkspace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getQueryManager</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #003399;">String</span> xpathQuery <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;/jcr:root/content//*[@jcr:contains(., 'searchKeyword')]&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; Query query <span style="color: #339933;">=</span> queryManager.<span style="color: #006633;">createQuery</span><span style="color: #009900;">&#40;</span>xpathQuery, Query.<span style="color: #006633;">XPATH</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; QueryResult result <span style="color: #339933;">=</span> query.<span style="color: #006633;">execute</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; NodeIterator nodeIterator <span style="color: #339933;">=</span> result.<span style="color: #006633;">getNodes</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span>nodeIterator.<span style="color: #006633;">hasNext</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Node node <span style="color: #339933;">=</span> nodeIterator.<span style="color: #006633;">nextNode</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Process the node that matches the search criteria</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>node.<span style="color: #006633;">getPath</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Handle exceptions</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<hr class="spacer-larger"/>
<h2 id="jcr-sql2-search-api">2. JCR SQL2 Search API</h2>
<p>JCR SQL2 is a structured query language designed specifically for the Java Content Repository. It provides an SQL-like syntax for querying content stored in the repository. JCR SQL2 queries are generally more straightforward to use compared to XPath and are often preferred for basic search requirements due to their familiarity to developers familiar with SQL.</p>
<p><strong>Some Benefits and Features:</strong></p>
<ol>
<li>SQL-Like Syntax: JCR SQL2 provides a structured query language with an SQL-like syntax, making it more familiar to developers experienced in working with relational databases.</li>
<li>Simplicity: JCR SQL2 queries are generally more straightforward to use compared to XPath, especially for developers already familiar with SQL.</li>
<li>Dynamic Queries: JCR SQL2 supports dynamic queries, allowing you to parameterize search criteria and adapt to changing requirements.</li>
<li>Performance Optimization: When used appropriately, JCR SQL2 can offer better performance for complex queries that involve multiple content nodes and properties.</li>
<li>Full-Text Search: JCR SQL2 supports full-text search using the CONTAINS function, enabling text-based searches on content.</li>
</ol>
<p><strong>JAVA Example:</strong></p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.jcr.Node</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.jcr.NodeIterator</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.jcr.query.Query</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.jcr.query.QueryManager</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.jcr.query.QueryResult</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// Assuming you have access to the JCR Session object (session)</span><br />
<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; QueryManager queryManager <span style="color: #339933;">=</span> session.<span style="color: #006633;">getWorkspace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getQueryManager</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #003399;">String</span> sql2Query <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SELECT * FROM [nt:unstructured] AS node WHERE CONTAINS(node.*, 'searchKeyword')&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; Query query <span style="color: #339933;">=</span> queryManager.<span style="color: #006633;">createQuery</span><span style="color: #009900;">&#40;</span>sql2Query, Query.<span style="color: #006633;">JCR_SQL2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; QueryResult result <span style="color: #339933;">=</span> query.<span style="color: #006633;">execute</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; NodeIterator nodeIterator <span style="color: #339933;">=</span> result.<span style="color: #006633;">getNodes</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span>nodeIterator.<span style="color: #006633;">hasNext</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Node node <span style="color: #339933;">=</span> nodeIterator.<span style="color: #006633;">nextNode</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Process the node that matches the search criteria</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>node.<span style="color: #006633;">getPath</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Handle exceptions</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<hr class="spacer-larger"/>
<h2 id="query-builder-search-api">3. Query Builder Search API</h2>
<p>The Query Builder API is a high-level API provided by AEM to build and execute queries against the repository. It acts as a wrapper around the underlying query languages (XPath or JCR SQL2) and provides a more intuitive and developer-friendly interface for constructing complex queries. The Query Builder API abstracts away the complexity of query languages and is recommended for most search scenarios in AEM.</p>
<p><strong>Some Benefits and Features:</strong></p>
<ol>
<li>High-Level API: The Query Builder API is a powerful and high-level abstraction for constructing and executing queries against the repository.</li>
<li>Developer-Friendly: The Query Builder API provides a more intuitive interface compared to raw query languages, making it easier for developers to build complex queries.</li>
<li>Abstraction of Complexity: The API abstracts away the underlying query language, making it more accessible to developers without extensive knowledge of XPath or JCR SQL2.</li>
<li>Faceted Search: The Query Builder API supports faceted search, enabling users to filter search results based on predefined categories or facets.</li>
<li>Spell Checker and Suggestions: The API includes built-in support for spell checking and real-time suggestions, improving the search experience for users.</li>
<li>Great for Pagination: The Query Builder API offers built-in pagination support, allowing you to retrieve search results in manageable chunks. This is particularly useful when dealing with large result sets, as it enhances performance and reduces memory consumption.</li>
</ol>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.day.cq.search.PredicateGroup</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.day.cq.search.Query</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.day.cq.search.QueryBuilder</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.resource.ResourceResolver</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #666666; font-style: italic;">// Assuming you have access to the ResourceResolver object (resourceResolver)</span><br />
<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; QueryBuilder queryBuilder <span style="color: #339933;">=</span> resourceResolver.<span style="color: #006633;">adaptTo</span><span style="color: #009900;">&#40;</span>QueryBuilder.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #003399;">String</span> searchKeyword <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;searchKeyword&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Building the predicate for the query</span><br />
&nbsp; &nbsp; PredicateGroup predicateGroup <span style="color: #339933;">=</span> PredicateGroup.<span style="color: #006633;">create</span><span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;group.1_property&quot;</span>, <span style="color: #0000ff;">&quot;jcr:content/@jcr:title&quot;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;group.1_property.operation&quot;</span>, <span style="color: #0000ff;">&quot;fulltext&quot;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;group.1_property.value&quot;</span>, searchKeyword<br />
&nbsp; &nbsp; <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; Query query <span style="color: #339933;">=</span> queryBuilder.<span style="color: #006633;">createQuery</span><span style="color: #009900;">&#40;</span>predicateGroup, resourceResolver.<span style="color: #006633;">adaptTo</span><span style="color: #009900;">&#40;</span>Session.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; com.<span style="color: #006633;">day</span>.<span style="color: #006633;">cq</span>.<span style="color: #006633;">search</span>.<span style="color: #006633;">result</span>.<span style="color: #003399;">SearchResult</span> result <span style="color: #339933;">=</span> query.<span style="color: #006633;">getResult</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>com.<span style="color: #006633;">day</span>.<span style="color: #006633;">cq</span>.<span style="color: #006633;">search</span>.<span style="color: #006633;">result</span>.<span style="color: #006633;">Hit</span> hit <span style="color: #339933;">:</span> result.<span style="color: #006633;">getHits</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">String</span> path <span style="color: #339933;">=</span> hit.<span style="color: #006633;">getPath</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Process the hit node that matches the search criteria</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>path<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Handle exceptions</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/a-simple-guide-to-aem-search-apis-exploring-your-options-for-powerful-search-functionality">A Simple Guide to AEM Search APIs: Exploring Your Options for Powerful Search Functionality</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/a-simple-guide-to-aem-search-apis-exploring-your-options-for-powerful-search-functionality/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Add inline CSS with AEM Sightly</title>
		<link>https://sourcedcode.com/blog/aem/add-inline-css-with-aem-sightly</link>
					<comments>https://sourcedcode.com/blog/aem/add-inline-css-with-aem-sightly#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Tue, 13 Jun 2023 12:20:51 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[CSS]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=5314</guid>

					<description><![CDATA[<p>AEM Sightly is a templating language that simplifies the integration of HTML and server-side logic. One of the key features of Sightly is the ability to use add inline-css to the component itself, so that your user experience requirements can be full-filed. In this article, we will explore how AEM Sightly enables developers to apply [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/add-inline-css-with-aem-sightly">Add inline CSS with AEM Sightly</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>AEM Sightly is a templating language that simplifies the integration of HTML and server-side logic. One of the key features of Sightly is the ability to use add inline-css to the component itself, so that your user experience requirements can be full-filed. In this article, we will explore how AEM Sightly enables developers to apply inline styles to elements dynamically, enhancing the flexibility and efficiency of web development.</p>
<div class="mention-block">
<strong>Quick Links</strong></p>
<ol>
<li><a href="#inline-css-with-aem-sightly">Inline CSS with AEM Sightly</a></li>
<li><a href="#dynamic-styling-with-css-via-style-tag">Dynamic Styling with CSS via &lt;style&gt; tag</a></li>
</ol>
</div>
<hr class="spacer-large" />
<h2 id="inline-css-with-aem-sightly">1. Inline CSS with AEM Sightly</h2>
<p>AEM Sightly allows developers to apply inline CSS to HTML elements using dynamic content. By leveraging the ${properties.maxHeight @ context=&#8221;styleString&#8221;}, developers can set the max-height property of an element based on the value of the maxHeight property defined in the AEM component dialog.</p>
<p>Consider the following example:</p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;${models.id}&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;cmp-container&quot;</span> <span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;max-height: ${properties.maxHeight @ context=&quot;</span>styleString<span style="color: #ff0000;">&quot;}px&quot;</span>&gt;</span><br />
&nbsp; <span style="color: #808080; font-style: italic;">&lt;!-- Your content here --&gt;</span><br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span><br />
<br />
<br />
//output<br />
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;${models.id}&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;cmp-container&quot;</span> <span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;max-height: 300px&quot;</span>&gt;</span><br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></div></td></tr></tbody></table></div>
<p>In this code snippet, the max-height property is set inline using the ${properties.maxHeight} value defined in the component&#8217;s dialog. The @ context=&#8221;styleString&#8221; ensures that the value is properly processed as a style string.</p>
<p><strong>2. Benefits of Dynamic Inline CSS</strong></p>
<p>Using ${properties.maxHeight @ context=&#8221;styleString&#8221;} for inline CSS with AEM Sightly offers several advantages:</p>
<ol>
<li>Flexibility: Inline CSS allows developers to adapt styles based on user inputs or system properties, making web pages more dynamic and responsive.</li>
<li>Efficiency: By defining styles dynamically within the component code, developers can reduce the need for separate CSS rules and enhance the component&#8217;s reusability.</li>
<li>Component-Level Customization: With dynamic inline CSS, component properties like maxHeight can be set individually for each instance of the component, granting greater customization.</li>
</ol>
<hr class="spacer-larger" />
<h2 id="dynamic-styling-with-css-via-style-tag">2. Dynamic Styling with CSS via &lt;style&gt; tag</h2>
<p>In addition to using inline styles, AEM Sightly also allows dynamic styling through CSS. By incorporating the ${models.id} and ${properties.maxHeight @ context=&#8221;styleString&#8221;} within a &lt;style&gt; block, developers can create more sophisticated and reusable styling rules.</p>
<div class="codecolorer-container css default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br /></div></td><td><div class="css codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&lt;style<span style="color: #00AA00;">&gt;</span><br />
&nbsp; <span style="color: #808080; font-style: italic;">/* Style for the element with the given id (${models.id}) */</span><br />
&nbsp; #$<span style="color: #00AA00;">&#123;</span>models.id<span style="color: #00AA00;">&#125;</span> <span style="color: #00AA00;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">max-height</span><span style="color: #00AA00;">:</span> $<span style="color: #00AA00;">&#123;</span>properties<span style="color: #6666ff;">.maxHeight</span> @ context<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;styleString&quot;</span><span style="color: #00AA00;">&#125;</span>px<span style="color: #00AA00;">;</span><br />
&nbsp; <span style="color: #00AA00;">&#125;</span><br />
&lt;/style<span style="color: #00AA00;">&gt;</span><br />
<br />
<br />
// output<br />
&lt;style<span style="color: #00AA00;">&gt;</span><br />
&nbsp; <span style="color: #cc00cc;">#cmp-container1231432324234</span> <span style="color: #00AA00;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">max-height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">300px</span><span style="color: #00AA00;">;</span><br />
&nbsp; <span style="color: #00AA00;">&#125;</span><br />
&lt;/style<span style="color: #00AA00;">&gt;</span></div></td></tr></tbody></table></div>
<div class="mention-block">
It&#8217;s important to understand the HTML element &lt;style&gt; tag validation approaches in 2023. <a href="https://sourcedcode.com/blog/aem/add-inline-css-with-aem-sightly" rel="noopener" target="_blank">Click here</a> to learn more about &lt;style&gt; tag validation approaches in 2023.</p>
<p>Utilizing the Sightly HTL 1.4 API, @context, will protect against cross-site scripting (XSS) vulnerabilities, HTL automatically recognises the context within which an output string is to be displayed within the final HTML output, and escapes that string appropriately. <a href="https://github.com/adobe/htl-spec/blob/master/SPECIFICATION.md#12-available-expression-options" rel="noopener" target="_blank">reference</a>.</p>
</div>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/add-inline-css-with-aem-sightly">Add inline CSS with AEM Sightly</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/add-inline-css-with-aem-sightly/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>AEM Rich Text Editor rendering aria-labels</title>
		<link>https://sourcedcode.com/blog/aem/aem-rich-text-editor-rendering-aria-labels</link>
					<comments>https://sourcedcode.com/blog/aem/aem-rich-text-editor-rendering-aria-labels#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Sun, 14 May 2023 01:08:24 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Quick Reference]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=4878</guid>

					<description><![CDATA[<p>You have written some custom JavaScript for the AEM Core Text Component, core/wcm/components/text/v2/text, which allows content producers to configure the HTML attribute &#8220;aria-label&#8221; to anchor &#8220;a&#8221; tags. When the page is being rendered on the page, the &#8220;aria-label&#8221; for the links, &#8220;a&#8221; tags, are not visible. You as a developer check crx/de and you do [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/aem-rich-text-editor-rendering-aria-labels">AEM Rich Text Editor rendering aria-labels</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>You have written some custom JavaScript for the AEM Core Text Component, core/wcm/components/text/v2/text, which allows content producers to configure the HTML attribute &#8220;aria-label&#8221; to anchor &#8220;a&#8221; tags. When the page is being rendered on the page, the &#8220;aria-label&#8221; for the links, &#8220;a&#8221; tags, are not visible. You as a developer check crx/de and you do actually see the configured text component contains &#8220;aria-label&#8221; in each of every link.</p>
<p>Why is the aria-label for the AEM Core Text Component not rendering as expected?<br />
For rendering links that contain the &#8220;aria-label&#8221; attribute, AEM refers to AEM&#8217;s XSS (Cross-Site Scripting) protection. This protection mechanism, exclusive to AEM, effectively prevents attackers from injecting malicious code into web pages that are viewed by other users. AEM&#8217;s XSS protection is built upon the trusted AntiSamy Java library, which is provided by OWASP (Open Web Application Security Project).</p>
<p>During the rendering process in AEM, if certain tags are not included in the whitelist, they will be stripped off. This means that any tags not explicitly permitted by the XSS protection configuration will be removed when the web pages are rendered. By enforcing this restriction, AEM ensures that only authorized and safe tags are displayed, significantly reducing the potential risk of XSS vulnerabilities.</p>
<p>In this article, we will configure AEM to allow the &#8220;aria-label&#8221; HTML attribute, so your text component&#8217;s links are rendering as expected. This article does not provide the JavaScript solution for how to add capabilities to the AEM Core Text Component for the &#8220;aria-label&#8221; HTML attribute.</p>
<hr class="spacer-large" />
<h3>Developer steps to enable and allow the AEM Core Text Component  to render &#8220;aria-label&#8221; on the page.</h3>
<ol>
<li>Login to AEM</li>
<li>Visit http://localhost:4502/crx/de/index.jsp#/libs/cq/xssprotection/config.xml</li>
<li>Overlay the XSS protection configuration by copying /libs/cq/xssprotection into /apps/cq/xssprotection (and all it&#8217;s children)</li>
<li>Delete the /apps/cq/xssprotection/rep:policy</li>
<li>From crx/DE you can edit the file /apps/cq/xssprotection/config.xml</li>
<li>On your keyboard, hit &#8220;ctrl + f&#8221; to find &lt;tag name=&#8221;a&#8221; action=&#8221;validate&#8221;&gt;</li>
<li>This is an XML file, so find the end of the closing tag &lt;/tag&gt;</li>
<li>Insert this line of code:
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #339933;">&lt;</span>attribute name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;aria-label&quot;</span><span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>regexp<span style="color: #339933;">-</span>list<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>regexp name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;anything&quot;</span><span style="color: #339933;">/&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>regexp<span style="color: #339933;">-</span>list<span style="color: #339933;">&gt;</span><br />
&nbsp;<span style="color: #339933;">&lt;/</span>attribute<span style="color: #339933;">&gt;</span></div></td></tr></tbody></table></div>
<p><a href="https://sourcedcode.com/wp-content/uploads/2023/06/aria-label-configxml.png"><img loading="lazy" decoding="async" src="https://sourcedcode.com/wp-content/uploads/2023/06/aria-label-configxml.png" alt="Screenshot of config.xml being updated: adding block of code before closing &lt;/tag&gt; element" width="1247" height="728" class="alignnone size-full wp-image-4884" /></a>
</li>
<li>Done</li>
<li>Now test out the Text Component, and expect the aria-labels to render as expected!</li>
<li>Next, you would want to copy the /apps/cq/xssprotection into your code base, so you can deploy the xss configuration into difference environments of AEM automatically.</li>
</ol>
<hr class="spacer-large" />
<div class="mention-block">
<strong>Very Important!</strong><br />
<strong>AEMaaCS</strong>: From time to time, if your AEM website is running on AEMaaCS, when there are updates, you need to ensure that you run through every step from step 1. This ensures that you are inheriting new updated Adobe recommendations for XSS protection.</p>
<p><strong>AEM onPrem</strong>: From time to time, if you have upgraded your AEM environment with a new service pack, you need to ensure that you run through every step from step 1. This ensures that you are inheriting new updated Adobe recommendations for XSS protection.
</div>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/aem-rich-text-editor-rendering-aria-labels">AEM Rich Text Editor rendering aria-labels</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/aem-rich-text-editor-rendering-aria-labels/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>AEM Query Builder Examples with Content Fragments</title>
		<link>https://sourcedcode.com/blog/aem/aem-query-builder-examples-with-content-fragments</link>
					<comments>https://sourcedcode.com/blog/aem/aem-query-builder-examples-with-content-fragments#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Tue, 02 May 2023 03:34:23 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Content Fragment]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Quick Reference]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=4804</guid>

					<description><![CDATA[<p>In this article, I will share some example AEM Query Builder API Search Queries that queries for Content Fragments. 1. Find all Content Fragments with Content Fragment Model 123456type=dam:Asset path=/content/dam/sourcedcode boolproperty=jcr:content/contentFragment boolproperty.value=true property=jcr:content/data/cq:model property.value=/conf/sourcedcode/settings/dam/cfm/models/model1 http://localhost:4502/libs/cq/search/content/querydebug.html?_charset_=UTF-8&#038;query=type%3Ddam%3AAsset%0D%0Apath%3D%2Fcontent%2Fdam%0D%0Aboolproperty%3Djcr%3Acontent%2FcontentFragment%0D%0Aboolproperty.value%3Dtrue%0D%0Aproperty%3Djcr%3Acontent%2Fdata%2Fcq%3Amodel%0D%0Aproperty.value%3D%2Fconf%2Fsourcedcode%2Fsettings%2Fdam%2Fcfm%2Fmodels%2Fmodel1 2. Find all Content Fragments with Content Fragment Model &#038; Property 12345678type=dam:Asset path=/content/dam/sourcedcode boolproperty=jcr:content/contentFragment boolproperty.value=true 1_property=jcr:content/data/cq:model 1_property_1.value=/conf/sourcedcode/settings/dam/cfm/models/model1 2_property=jcr:content/data/master/title 2_property.value=example http://localhost:4502/libs/cq/search/content/querydebug.html?_charset_=UTF-8&#038;query=path%3D%2Fcontent%2Fdam%2Fsourcedcode%0D%0Aboolproperty%3Djcr%3Acontent%2FcontentFragment%0D%0Aboolproperty.value%3Dtrue%0D%0A1_property%3Djcr%3Acontent%2Fdata%2Fcq%3Amodel%0D%0A1_property_1.value%3D%2Fconf%2Fsourcedcode%2Fsettings%2Fdam%2Fcfm%2Fmodels%2Fmodel1%0D%0A2_property%3Djcr%3Acontent%2Fdata%2Fmaster%2Ftitle%0D%0A2_property.value%3Dexample [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/aem-query-builder-examples-with-content-fragments">AEM Query Builder Examples with Content Fragments</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>In this article, I will share some example AEM Query Builder API Search Queries that queries for Content Fragments.</p>
<hr class="spacer-large" />
<h3>1. Find all Content Fragments with Content Fragment Model</h3>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">type<span style="color: #339933;">=</span>dam<span style="color: #339933;">:</span>Asset<br />
path<span style="color: #339933;">=/</span>content<span style="color: #339933;">/</span>dam<span style="color: #339933;">/</span>sourcedcode<br />
boolproperty<span style="color: #339933;">=</span>jcr<span style="color: #339933;">:</span>content<span style="color: #339933;">/</span>contentFragment<br />
boolproperty.<span style="color: #006633;">value</span><span style="color: #339933;">=</span><span style="color: #000066; font-weight: bold;">true</span><br />
property<span style="color: #339933;">=</span>jcr<span style="color: #339933;">:</span>content<span style="color: #339933;">/</span>data<span style="color: #339933;">/</span>cq<span style="color: #339933;">:</span>model<br />
property.<span style="color: #006633;">value</span><span style="color: #339933;">=/</span>conf<span style="color: #339933;">/</span>sourcedcode<span style="color: #339933;">/</span>settings<span style="color: #339933;">/</span>dam<span style="color: #339933;">/</span>cfm<span style="color: #339933;">/</span>models<span style="color: #339933;">/</span>model1</div></td></tr></tbody></table></div>
<p><a href="http://localhost:4502/libs/cq/search/content/querydebug.html?_charset_=UTF-8&#038;query=type%3Ddam%3AAsset%0D%0Apath%3D%2Fcontent%2Fdam%0D%0Aboolproperty%3Djcr%3Acontent%2FcontentFragment%0D%0Aboolproperty.value%3Dtrue%0D%0Aproperty%3Djcr%3Acontent%2Fdata%2Fcq%3Amodel%0D%0Aproperty.value%3D%2Fconf%2Fsourcedcode%2Fsettings%2Fdam%2Fcfm%2Fmodels%2Fmodel1" rel="noopener" target="_blank">http://localhost:4502/libs/cq/search/content/querydebug.html?_charset_=UTF-8&#038;query=type%3Ddam%3AAsset%0D%0Apath%3D%2Fcontent%2Fdam%0D%0Aboolproperty%3Djcr%3Acontent%2FcontentFragment%0D%0Aboolproperty.value%3Dtrue%0D%0Aproperty%3Djcr%3Acontent%2Fdata%2Fcq%3Amodel%0D%0Aproperty.value%3D%2Fconf%2Fsourcedcode%2Fsettings%2Fdam%2Fcfm%2Fmodels%2Fmodel1</a></p>
<hr class="spacer-large" />
<h3>2. Find all Content Fragments with Content Fragment Model &#038; Property</h3>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">type<span style="color: #339933;">=</span>dam<span style="color: #339933;">:</span>Asset<br />
path<span style="color: #339933;">=/</span>content<span style="color: #339933;">/</span>dam<span style="color: #339933;">/</span>sourcedcode<br />
boolproperty<span style="color: #339933;">=</span>jcr<span style="color: #339933;">:</span>content<span style="color: #339933;">/</span>contentFragment<br />
boolproperty.<span style="color: #006633;">value</span><span style="color: #339933;">=</span><span style="color: #000066; font-weight: bold;">true</span><br />
<span style="color: #cc66cc;">1</span>_property<span style="color: #339933;">=</span>jcr<span style="color: #339933;">:</span>content<span style="color: #339933;">/</span>data<span style="color: #339933;">/</span>cq<span style="color: #339933;">:</span>model<br />
<span style="color: #cc66cc;">1</span>_property_1.<span style="color: #006633;">value</span><span style="color: #339933;">=/</span>conf<span style="color: #339933;">/</span>sourcedcode<span style="color: #339933;">/</span>settings<span style="color: #339933;">/</span>dam<span style="color: #339933;">/</span>cfm<span style="color: #339933;">/</span>models<span style="color: #339933;">/</span>model1<br />
<span style="color: #cc66cc;">2</span>_property<span style="color: #339933;">=</span>jcr<span style="color: #339933;">:</span>content<span style="color: #339933;">/</span>data<span style="color: #339933;">/</span>master<span style="color: #339933;">/</span>title<br />
<span style="color: #cc66cc;">2</span>_property.<span style="color: #006633;">value</span><span style="color: #339933;">=</span>example</div></td></tr></tbody></table></div>
<p><a href="http://localhost:4502/libs/cq/search/content/querydebug.html?_charset_=UTF-8&#038;query=path%3D%2Fcontent%2Fdam%2Fsourcedcode%0D%0Aboolproperty%3Djcr%3Acontent%2FcontentFragment%0D%0Aboolproperty.value%3Dtrue%0D%0A1_property%3Djcr%3Acontent%2Fdata%2Fcq%3Amodel%0D%0A1_property_1.value%3D%2Fconf%2Fsourcedcode%2Fsettings%2Fdam%2Fcfm%2Fmodels%2Fmodel1%0D%0A2_property%3Djcr%3Acontent%2Fdata%2Fmaster%2Ftitle%0D%0A2_property.value%3Dexample" rel="noopener" target="_blank">http://localhost:4502/libs/cq/search/content/querydebug.html?_charset_=UTF-8&#038;query=path%3D%2Fcontent%2Fdam%2Fsourcedcode%0D%0Aboolproperty%3Djcr%3Acontent%2FcontentFragment%0D%0Aboolproperty.value%3Dtrue%0D%0A1_property%3Djcr%3Acontent%2Fdata%2Fcq%3Amodel%0D%0A1_property_1.value%3D%2Fconf%2Fsourcedcode%2Fsettings%2Fdam%2Fcfm%2Fmodels%2Fmodel1%0D%0A2_property%3Djcr%3Acontent%2Fdata%2Fmaster%2Ftitle%0D%0A2_property.value%3Dexample</a></p>
<hr class="spacer-large" />
<h3>4. Find all Content Fragments with Content Fragment Model &#038; Full Text Search</h3>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">type<span style="color: #339933;">=</span>dam<span style="color: #339933;">:</span>Asset<br />
path<span style="color: #339933;">=/</span>content<span style="color: #339933;">/</span>dam<br />
boolproperty<span style="color: #339933;">=</span>jcr<span style="color: #339933;">:</span>content<span style="color: #339933;">/</span>contentFragment<br />
boolproperty.<span style="color: #006633;">value</span><span style="color: #339933;">=</span><span style="color: #000066; font-weight: bold;">true</span><br />
property<span style="color: #339933;">=</span>jcr<span style="color: #339933;">:</span>content<span style="color: #339933;">/</span>data<span style="color: #339933;">/</span>cq<span style="color: #339933;">:</span>model<br />
property.<span style="color: #006633;">value</span><span style="color: #339933;">=/</span>conf<span style="color: #339933;">/</span>wknd<span style="color: #339933;">-</span>shared<span style="color: #339933;">/</span>settings<span style="color: #339933;">/</span>dam<span style="color: #339933;">/</span>cfm<span style="color: #339933;">/</span>models<span style="color: #339933;">/</span>adventure<br />
fulltext<span style="color: #339933;">=</span>a<br />
fulltext.<span style="color: #006633;">relPath</span><span style="color: #339933;">=</span>jcr<span style="color: #339933;">:</span>content<span style="color: #339933;">/</span>data<span style="color: #339933;">/</span>master</div></td></tr></tbody></table></div>
<p><a href="http://localhost:4502/libs/cq/search/content/querydebug.html?_charset_=UTF-8&#038;facets=on&#038;query=type%3Ddam%3AAsset%0D%0Apath%3D%2Fcontent%2Fdam%0D%0Aboolproperty%3Djcr%3Acontent%2FcontentFragment%0D%0Aboolproperty.value%3Dtrue%0D%0Aproperty%3Djcr%3Acontent%2Fdata%2Fcq%3Amodel%0D%0Aproperty.value%3D%2Fconf%2Fwknd-shared%2Fsettings%2Fdam%2Fcfm%2Fmodels%2Fadventure%0D%0Afulltext%3Da%0D%0Afulltext.relPath%3Djcr%3Acontent%2Fdata%2Fmaster%0D%0A" rel="noopener" target="_blank">http://localhost:4502/libs/cq/search/content/querydebug.html?_charset_=UTF-8&#038;facets=on&#038;query=type%3Ddam%3AAsset%0D%0Apath%3D%2Fcontent%2Fdam%0D%0Aboolproperty%3Djcr%3Acontent%2FcontentFragment%0D%0Aboolproperty.value%3Dtrue%0D%0Aproperty%3Djcr%3Acontent%2Fdata%2Fcq%3Amodel%0D%0Aproperty.value%3D%2Fconf%2Fwknd-shared%2Fsettings%2Fdam%2Fcfm%2Fmodels%2Fadventure%0D%0Afulltext%3Da%0D%0Afulltext.relPath%3Djcr%3Acontent%2Fdata%2Fmaster%0D%0A</a></p>
<hr class="spacer-large" />
<h3>4. Find all Content Fragments &#038; Full Text Search</h3>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">type<span style="color: #339933;">=</span>dam<span style="color: #339933;">:</span>Asset<br />
path<span style="color: #339933;">=/</span>content<span style="color: #339933;">/</span>dam<span style="color: #339933;">/</span>sourcedcode<br />
boolproperty<span style="color: #339933;">=</span>jcr<span style="color: #339933;">:</span>content<span style="color: #339933;">/</span>contentFragment<br />
boolproperty.<span style="color: #006633;">value</span><span style="color: #339933;">=</span><span style="color: #000066; font-weight: bold;">true</span><br />
property<span style="color: #339933;">=</span>jcr<span style="color: #339933;">:</span>content<span style="color: #339933;">/</span>data<span style="color: #339933;">/</span>cq<span style="color: #339933;">:</span>model<br />
property.<span style="color: #006633;">value</span><span style="color: #339933;">=/</span>conf<span style="color: #339933;">/</span>sourcedcode<span style="color: #339933;">/</span>settings<span style="color: #339933;">/</span>dam<span style="color: #339933;">/</span>cfm<span style="color: #339933;">/</span>models<span style="color: #339933;">/</span>model1<br />
fulltext<span style="color: #339933;">=</span>full text</div></td></tr></tbody></table></div>
<p><a href="http://localhost:4502/libs/cq/search/content/querydebug.html?_charset_=UTF-8&#038;facets=on&#038;query=type%3Ddam%3AAsset%0D%0Apath%3D%2Fcontent%2Fdam%2Fsourcedcode%0D%0Aboolproperty%3Djcr%3Acontent%2FcontentFragment%0D%0Aboolproperty.value%3Dtrue%0D%0Aproperty%3Djcr%3Acontent%2Fdata%2Fcq%3Amodel%0D%0Aproperty.value%3D%2Fconf%2Fsourcedcode%2Fsettings%2Fdam%2Fcfm%2Fmodels%2Fmodel1%0D%0Afulltext%3Dfull+text">http://localhost:4502/libs/cq/search/content/querydebug.html?_charset_=UTF-8&#038;facets=on&#038;query=type%3Ddam%3AAsset%0D%0Apath%3D%2Fcontent%2Fdam%2Fsourcedcode%0D%0Aboolproperty%3Djcr%3Acontent%2FcontentFragment%0D%0Aboolproperty.value%3Dtrue%0D%0Aproperty%3Djcr%3Acontent%2Fdata%2Fcq%3Amodel%0D%0Aproperty.value%3D%2Fconf%2Fsourcedcode%2Fsettings%2Fdam%2Fcfm%2Fmodels%2Fmodel1%0D%0Afulltext%3Dfull+text</a></p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/aem-query-builder-examples-with-content-fragments">AEM Query Builder Examples with Content Fragments</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/aem-query-builder-examples-with-content-fragments/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>@SlingServletPaths Example Code in AEM</title>
		<link>https://sourcedcode.com/blog/aem/slingservletpaths-example-code-in-aem</link>
					<comments>https://sourcedcode.com/blog/aem/slingservletpaths-example-code-in-aem#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Tue, 02 May 2023 03:01:49 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Quick Reference]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=4796</guid>

					<description><![CDATA[<p>This is a quick reference to example code, which will show you how to use the most base instantiation of @SlingServletPaths. The output is a simple JSON response with application/JSON, 200 OK, and response body = { &#8220;property1&#8221;: &#8220;value1&#8221; }. Quick note: it&#8217;s not recommended to use @SlingServletPaths. Check out the caveats when implementing servlets [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/slingservletpaths-example-code-in-aem">@SlingServletPaths Example Code in AEM</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>This is a quick reference to example code, which will show you how to use the most base instantiation of @SlingServletPaths. The output is a simple JSON response with application/JSON, 200 OK, and response body = { &#8220;property1&#8221;: &#8220;value1&#8221; }.</p>
<div class="mention-block">
<strong>Quick note:</strong><br />
it&#8217;s not recommended to use @SlingServletPaths. Check out the caveats when implementing servlets with path, @SlingServletPaths, <a href="https://sourcedcode.com/blog/aem/registering-slingservletpaths-component-property-type">https://sourcedcode.com/blog/aem/registering-slingservletpaths-component-property-type</a>
</div>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.sourcedcode.core.servlets</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.google.gson.JsonObject</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.SlingHttpServletRequest</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.SlingHttpServletResponse</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.servlets.SlingSafeMethodsServlet</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.servlets.annotations.SlingServletPaths</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.osgi.service.component.annotations.Component</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.servlet.Servlet</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.servlet.ServletException</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.IOException</span><span style="color: #339933;">;</span><br />
<br />
@<span style="color: #003399;">Component</span><span style="color: #009900;">&#40;</span>service <span style="color: #339933;">=</span> Servlet.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><br />
@SlingServletPaths<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/bin/example&quot;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> FindContentFragmentServlet <span style="color: #000000; font-weight: bold;">extends</span> SlingSafeMethodsServlet <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; @Override<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> doGet<span style="color: #009900;">&#40;</span>SlingHttpServletRequest request, SlingHttpServletResponse response<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> ServletException, <span style="color: #003399;">IOException</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; response.<span style="color: #006633;">setContentType</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;application/json&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; JsonObject jo <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> JsonObject<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; jo.<span style="color: #006633;">addProperty</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;property1&quot;</span>, <span style="color: #0000ff;">&quot;value1&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; response.<span style="color: #006633;">getWriter</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">write</span><span style="color: #009900;">&#40;</span>jo.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; response.<span style="color: #006633;">setStatus</span><span style="color: #009900;">&#40;</span>SlingHttpServletResponse.<span style="color: #006633;">SC_OK</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<hr class="spacer-larger" />
<h3>Example of Servlet Being Called</h3>
<p><strong>Test:</strong> When I call http://localhost:4502/bin/example, I expect to see a JSON response with application/JSON, 200 OK, and response body = { &#8220;property1&#8221;: &#8220;value1&#8221; }. The example shows that the tests are passing.</p>
<p><a href="https://sourcedcode.com/wp-content/uploads/2023/05/SlingServletPaths-example.png"><img loading="lazy" decoding="async" src="https://sourcedcode.com/wp-content/uploads/2023/05/SlingServletPaths-example.png" alt="" width="1974" height="1534" class="alignnone size-full wp-image-4798" srcset="https://sourcedcode.com/wp-content/uploads/2023/05/SlingServletPaths-example.png 1974w, https://sourcedcode.com/wp-content/uploads/2023/05/SlingServletPaths-example-300x233.png 300w, https://sourcedcode.com/wp-content/uploads/2023/05/SlingServletPaths-example-1024x796.png 1024w, https://sourcedcode.com/wp-content/uploads/2023/05/SlingServletPaths-example-768x597.png 768w, https://sourcedcode.com/wp-content/uploads/2023/05/SlingServletPaths-example-1536x1194.png 1536w, https://sourcedcode.com/wp-content/uploads/2023/05/SlingServletPaths-example-600x466.png 600w" sizes="(max-width: 1974px) 100vw, 1974px" /></a></p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/slingservletpaths-example-code-in-aem">@SlingServletPaths Example Code in AEM</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/slingservletpaths-example-code-in-aem/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to Enable AEM Style System Configuration for Components</title>
		<link>https://sourcedcode.com/blog/aem/how-to-enable-aem-style-system-configuration-for-components</link>
					<comments>https://sourcedcode.com/blog/aem/how-to-enable-aem-style-system-configuration-for-components#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Sun, 30 Apr 2023 22:32:28 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Touch UI]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=4750</guid>

					<description><![CDATA[<p>AEM Style System enables a user-friendly interface, for non-technical users who can easily make style adjustments, fostering creativity and agility. Integrating seamlessly with Adobe Experience Manager, the AEM Style System enables content authors to apply predefined styles effortlessly, maintaining brand consistency across platforms and devices. As developers are trying to create new AEM component&#8217;s this [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/how-to-enable-aem-style-system-configuration-for-components">How to Enable AEM Style System Configuration for Components</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>AEM Style System enables a user-friendly interface, for non-technical users who can easily make style adjustments, fostering creativity and agility. Integrating seamlessly with Adobe Experience Manager, the AEM Style System enables content authors to apply predefined styles effortlessly, maintaining brand consistency across platforms and devices. As developers are trying to create new AEM component&#8217;s this feature must be enabled in order to utilize the AEM Style System feature.</p>
<p>In this blog article, I will be showing you how to enable AEM Style System for your component it&#8217;s frankly just a configuration from the<br />
cq_design_dialog or as developers know it, _cq_design_dialog/.context.html.</p>
<hr class="spacer-large"/>
<h3>1. Disabled Style System</h3>
<p>Without the Style System enabled for a component, the component policies page would look like this:<br />
<a href="https://sourcedcode.com/wp-content/uploads/2023/04/component-poliices-without-enabled-feature.png"><img loading="lazy" decoding="async" src="https://sourcedcode.com/wp-content/uploads/2023/04/component-poliices-without-enabled-feature.png" alt="AEM Style System, not yet configured; default experience" width="2406" height="1460" class="alignnone size-full wp-image-4751" srcset="https://sourcedcode.com/wp-content/uploads/2023/04/component-poliices-without-enabled-feature.png 2406w, https://sourcedcode.com/wp-content/uploads/2023/04/component-poliices-without-enabled-feature-300x182.png 300w, https://sourcedcode.com/wp-content/uploads/2023/04/component-poliices-without-enabled-feature-1024x621.png 1024w, https://sourcedcode.com/wp-content/uploads/2023/04/component-poliices-without-enabled-feature-768x466.png 768w, https://sourcedcode.com/wp-content/uploads/2023/04/component-poliices-without-enabled-feature-1536x932.png 1536w, https://sourcedcode.com/wp-content/uploads/2023/04/component-poliices-without-enabled-feature-2048x1243.png 2048w, https://sourcedcode.com/wp-content/uploads/2023/04/component-poliices-without-enabled-feature-600x364.png 600w" sizes="(max-width: 2406px) 100vw, 2406px" /></a></p>
<hr class="spacer-large"/>
<h3>2. Adding code configurations</h3>
<p>The quickest explanation of why the style system is not visible in the component&#8217;s policies is that you have a missing configuration for the cq_design_dialog. In the instructions below, we will include some code configurations to enable your target component&#8217;s AEM Style System feature. </p>
<ol>
<li>Create a “_cq_design_dialog” folder under /apps/sourcedcode/components/examplecomponent</li>
<li>Create a “.content.xml” file under /apps/sourcedcode/components/examplecomponent/_cq_design_dialog with the file contents below:</li>
<li>Line:15-18 is the code block you should include in the _cq_design_dialog/.content.xml.
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #339933;">&lt;?</span>xml version<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;1.0&quot;</span> encoding<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;UTF-8&quot;</span><span style="color: #339933;">?&gt;</span><br />
<span style="color: #339933;">&lt;</span>jcr<span style="color: #339933;">:</span>root xmlns<span style="color: #339933;">:</span>sling<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://sling.apache.org/jcr/sling/1.0&quot;</span> xmlns<span style="color: #339933;">:</span>cq<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://www.day.com/jcr/cq/1.0&quot;</span> xmlns<span style="color: #339933;">:</span>jcr<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://www.jcp.org/jcr/1.0&quot;</span> xmlns<span style="color: #339933;">:</span>nt<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://www.jcp.org/jcr/nt/1.0&quot;</span><br />
&nbsp; &nbsp; jcr<span style="color: #339933;">:</span>primaryType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; jcr<span style="color: #339933;">:</span>title<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Example Component&quot;</span><br />
&nbsp; &nbsp; sling<span style="color: #339933;">:</span>resourceType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;cq/gui/components/authoring/dialog&quot;</span><span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>content<br />
&nbsp; &nbsp; &nbsp; &nbsp; jcr<span style="color: #339933;">:</span>primaryType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; sling<span style="color: #339933;">:</span>resourceType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;granite/ui/components/coral/foundation/container&quot;</span><span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>items jcr<span style="color: #339933;">:</span>primaryType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nt:unstructured&quot;</span><span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>tabs<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jcr<span style="color: #339933;">:</span>primaryType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sling<span style="color: #339933;">:</span>resourceType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;granite/ui/components/coral/foundation/tabs&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; maximized<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;{Boolean}true&quot;</span><span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>items jcr<span style="color: #339933;">:</span>primaryType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nt:unstructured&quot;</span><span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>styletab<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jcr<span style="color: #339933;">:</span>primaryType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sling<span style="color: #339933;">:</span>resourceType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;granite/ui/components/coral/foundation/include&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; path<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;/mnt/overlay/cq/gui/components/authoring/dialog/style/tab_design/styletab&quot;</span><span style="color: #339933;">/&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>items<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>tabs<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>items<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>content<span style="color: #339933;">&gt;</span><br />
<span style="color: #339933;">&lt;/</span>jcr<span style="color: #339933;">:</span>root<span style="color: #339933;">&gt;</span></div></td></tr></tbody></table></div>
</li>
<li>We are utilizing the out-of-the-box AEM utils &#8220;/mnt/overlay/cq/gui/components/authoring/dialog/style/tab_design/styletab&#8221;, which enables the AEM Style System feature for your target component.</li>
<li>As a result, you should see something like this now. Make sure you configure the input fields indicated in red, and then continue on with the next instructions of this list. <a href="https://sourcedcode.com/wp-content/uploads/2023/04/component-poliices-with-enabled-feature-lined.png"><img loading="lazy" decoding="async" src="https://sourcedcode.com/wp-content/uploads/2023/04/component-poliices-with-enabled-feature-lined.png" alt="AEM Style System, configured" width="2412" height="1462" class="alignnone size-full wp-image-4761" srcset="https://sourcedcode.com/wp-content/uploads/2023/04/component-poliices-with-enabled-feature-lined.png 2412w, https://sourcedcode.com/wp-content/uploads/2023/04/component-poliices-with-enabled-feature-lined-300x182.png 300w, https://sourcedcode.com/wp-content/uploads/2023/04/component-poliices-with-enabled-feature-lined-1024x621.png 1024w, https://sourcedcode.com/wp-content/uploads/2023/04/component-poliices-with-enabled-feature-lined-768x466.png 768w, https://sourcedcode.com/wp-content/uploads/2023/04/component-poliices-with-enabled-feature-lined-1536x931.png 1536w, https://sourcedcode.com/wp-content/uploads/2023/04/component-poliices-with-enabled-feature-lined-2048x1241.png 2048w, https://sourcedcode.com/wp-content/uploads/2023/04/component-poliices-with-enabled-feature-lined-600x364.png 600w" sizes="(max-width: 2412px) 100vw, 2412px" /></a></li>
<li>When editing the component, you should see a &#8220;paintbrush&#8221; indicating that the style system configuration is working as expected. Click on it, and you should see the style configurations that we have configured in step 5.<a href="https://sourcedcode.com/wp-content/uploads/2023/04/component-poliices-with-enabled-feature-inline-lined.png"><img loading="lazy" decoding="async" src="https://sourcedcode.com/wp-content/uploads/2023/04/component-poliices-with-enabled-feature-inline-lined.png" alt="AEM Style System, configured; inline editing experience" width="1170" height="566" class="alignnone size-full wp-image-4762" srcset="https://sourcedcode.com/wp-content/uploads/2023/04/component-poliices-with-enabled-feature-inline-lined.png 1170w, https://sourcedcode.com/wp-content/uploads/2023/04/component-poliices-with-enabled-feature-inline-lined-300x145.png 300w, https://sourcedcode.com/wp-content/uploads/2023/04/component-poliices-with-enabled-feature-inline-lined-1024x495.png 1024w, https://sourcedcode.com/wp-content/uploads/2023/04/component-poliices-with-enabled-feature-inline-lined-768x372.png 768w, https://sourcedcode.com/wp-content/uploads/2023/04/component-poliices-with-enabled-feature-inline-lined-600x290.png 600w" sizes="(max-width: 1170px) 100vw, 1170px" /></a></li>
<li>Done</li>
</ol>
<hr class="spacer-large"/>
<h3>Add AEM Style System in Touch UI (popup)</h3>
<p>Though we have configured and enabled the AEM Style System in the cq_design_dialog, the &#8220;Styles&#8221; option will only be visible in the &#8220;inline&#8221; edit mode for the target component. From the Touch UI (popup), the &#8220;Styles&#8221; tab will not be visible for the popup experience (when authors have clicked on the configure button for a target component). In this next section, we will add a piece of code to make the &#8220;Styles&#8221; tab visible, so content authors can configure the AEM Style System for the Touch UI &#8220;popup&#8221; experience.</p>
<ol>
</li>
<li>Edit your already existing cq_dialog, under _cq_dialog/.content.xml.</li>
<li>Add this line of code:
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #339933;">&lt;</span>styletab<br />
&nbsp; &nbsp; jcr<span style="color: #339933;">:</span>primaryType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; sling<span style="color: #339933;">:</span>resourceType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;granite/ui/components/coral/foundation/include&quot;</span><br />
&nbsp; &nbsp; path<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;/mnt/overlay/cq/gui/components/authoring/dialog/style/tab_edit/styletab&quot;</span><span style="color: #339933;">/&gt;</span></div></td></tr></tbody></table></div>
</li>
<li>We are utilizing the out-of-the-box AEM utils &#8220;/mnt/overlay/cq/gui/components/authoring/dialog/style/tab_edit/styletab&#8221;, which enables the AEM Style System feature for your target component.</li>
<li><strong>Skip this part, it&#8217;s just extra details</strong> &#8211; I wanted to show you an example of the completed configuration file of the _cq_dialog/.content.xml, given in step 2, this line of code only works when your AEM touch UI follows is configured with tabs. line:42-45 is where you can find the exact code that has been mentioned in step 2.
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #339933;">&lt;?</span>xml version<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;1.0&quot;</span> encoding<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;UTF-8&quot;</span><span style="color: #339933;">?&gt;</span><br />
<span style="color: #339933;">&lt;</span>jcr<span style="color: #339933;">:</span>root xmlns<span style="color: #339933;">:</span>sling<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://sling.apache.org/jcr/sling/1.0&quot;</span> xmlns<span style="color: #339933;">:</span>cq<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://www.day.com/jcr/cq/1.0&quot;</span> xmlns<span style="color: #339933;">:</span>jcr<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://www.jcp.org/jcr/1.0&quot;</span> xmlns<span style="color: #339933;">:</span>nt<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://www.jcp.org/jcr/nt/1.0&quot;</span><br />
&nbsp; &nbsp; jcr<span style="color: #339933;">:</span>primaryType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; jcr<span style="color: #339933;">:</span>title<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Example Component&quot;</span><br />
&nbsp; &nbsp; sling<span style="color: #339933;">:</span>resourceType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;cq/gui/components/authoring/dialog&quot;</span><span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>content<br />
&nbsp; &nbsp; &nbsp; &nbsp; jcr<span style="color: #339933;">:</span>primaryType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; sling<span style="color: #339933;">:</span>resourceType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;granite/ui/components/coral/foundation/container&quot;</span><span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>items jcr<span style="color: #339933;">:</span>primaryType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nt:unstructured&quot;</span><span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>tabs<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jcr<span style="color: #339933;">:</span>primaryType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sling<span style="color: #339933;">:</span>resourceType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;granite/ui/components/coral/foundation/tabs&quot;</span><span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>items jcr<span style="color: #339933;">:</span>primaryType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nt:unstructured&quot;</span><span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>tab1<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jcr<span style="color: #339933;">:</span>primaryType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jcr<span style="color: #339933;">:</span>title<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Tab 1&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sling<span style="color: #339933;">:</span>resourceType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;granite/ui/components/coral/foundation/container&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; margin<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;{Boolean}true&quot;</span><span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>items jcr<span style="color: #339933;">:</span>primaryType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nt:unstructured&quot;</span><span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>columns<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jcr<span style="color: #339933;">:</span>primaryType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sling<span style="color: #339933;">:</span>resourceType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;granite/ui/components/coral/foundation/fixedcolumns&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; margin<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;{Boolean}true&quot;</span><span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>items jcr<span style="color: #339933;">:</span>primaryType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nt:unstructured&quot;</span><span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>column<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jcr<span style="color: #339933;">:</span>primaryType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sling<span style="color: #339933;">:</span>resourceType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;granite/ui/components/coral/foundation/container&quot;</span><span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>items jcr<span style="color: #339933;">:</span>primaryType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nt:unstructured&quot;</span><span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>graniteExample1<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jcr<span style="color: #339933;">:</span>primaryType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sling<span style="color: #339933;">:</span>resourceType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;granite/ui/components/coral/foundation/form/textfield&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fieldDescription<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Just an example&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fieldLabel<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;graniteExample1&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;./graniteExample1&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; required<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;{Boolean}false&quot;</span><span style="color: #339933;">/&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>items<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>column<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>items<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>columns<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>items<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>tab1<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>styletab<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jcr<span style="color: #339933;">:</span>primaryType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sling<span style="color: #339933;">:</span>resourceType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;granite/ui/components/coral/foundation/include&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; path<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;/mnt/overlay/cq/gui/components/authoring/dialog/style/tab_edit/styletab&quot;</span><span style="color: #339933;">/&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>items<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>tabs<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>items<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>content<span style="color: #339933;">&gt;</span><br />
<span style="color: #339933;">&lt;/</span>jcr<span style="color: #339933;">:</span>root<span style="color: #339933;">&gt;</span></div></td></tr></tbody></table></div>
</li>
<li><strong>The result:</strong> <a href="https://sourcedcode.com/wp-content/uploads/2023/04/component-poliices-with-enabled-feature-touch-ui-lined-1.png"><img loading="lazy" decoding="async" src="https://sourcedcode.com/wp-content/uploads/2023/04/component-poliices-with-enabled-feature-touch-ui-lined-1.png" alt="AEM Style System with Touch UI (popup) options" width="1370" height="898" class="alignnone size-full wp-image-4763" srcset="https://sourcedcode.com/wp-content/uploads/2023/04/component-poliices-with-enabled-feature-touch-ui-lined-1.png 1370w, https://sourcedcode.com/wp-content/uploads/2023/04/component-poliices-with-enabled-feature-touch-ui-lined-1-300x197.png 300w, https://sourcedcode.com/wp-content/uploads/2023/04/component-poliices-with-enabled-feature-touch-ui-lined-1-1024x671.png 1024w, https://sourcedcode.com/wp-content/uploads/2023/04/component-poliices-with-enabled-feature-touch-ui-lined-1-768x503.png 768w, https://sourcedcode.com/wp-content/uploads/2023/04/component-poliices-with-enabled-feature-touch-ui-lined-1-600x393.png 600w" sizes="(max-width: 1370px) 100vw, 1370px" /></a></li>
</ol>
<hr class="spacer-large"/>
<h3>Last Thoughts</h3>
<p>Enabling the AEM Style System is actually quite simple, but however, sometimes as a developer, you would like to access the configured properties fro the backend code to compute and execute code conditionally on what is configured. To learn how to obtain the style system AEM component configuration In the backend code, take a look at this blog, <a href="https://sourcedcode.com/blog/aem/aem-style-system-component-information-with-code-sling-models">AEM Style System Component Information with Code Sling Models</a>.</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/how-to-enable-aem-style-system-configuration-for-components">How to Enable AEM Style System Configuration for Components</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/how-to-enable-aem-style-system-configuration-for-components/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>AEM Touch UI (Granite UI) Tabs: Example Code</title>
		<link>https://sourcedcode.com/blog/aem/aem-touch-ui-granite-ui-tabs-example-code</link>
					<comments>https://sourcedcode.com/blog/aem/aem-touch-ui-granite-ui-tabs-example-code#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Fri, 28 Apr 2023 23:31:30 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Quick Reference]]></category>
		<category><![CDATA[Touch UI]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=4775</guid>

					<description><![CDATA[<p>Almost all components require developers to put together the Touch UI experience with tabs as the base of their components. It&#8217;s a simple XML code configuration, however, sometimes finding the reference isn&#8217;t that easy to find online. This article is just a simple reference article where I share the configuration as XML, so it can [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/aem-touch-ui-granite-ui-tabs-example-code">AEM Touch UI (Granite UI) Tabs: Example Code</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Almost all components require developers to put together the Touch UI experience with tabs as the base of their components. It&#8217;s a simple XML code configuration, however, sometimes finding the reference isn&#8217;t that easy to find online. This article is just a simple reference article where I share the configuration as XML, so it can be copied and pasted + ready to go at a rapid pace.</p>
<div class="mention-block">
This code was extracted from Adobe&#8217;s code, the WCM Core Components v2.22.6 Latest; so no surprises.
</div>
<p><a href="#code-snippet">Jump to Code Snippet</a></p>
<hr class="spacer-large"/>
<h3>Granite UI (Touch UI) Rendered as</h3>
<p>This is a screenshot of how a very basic Touch UI would look like for author&#8217;s when the author double clicks on the component to make change&#8217;s to it.<br />
<a href="https://sourcedcode.com/wp-content/uploads/2023/04/example-component-tab-1-tab-2.png"><img loading="lazy" decoding="async" src="https://sourcedcode.com/wp-content/uploads/2023/04/example-component-tab-1-tab-2.png" alt="Touch UI Granite UI Code Configuration Example - Tabs" width="2416" height="1448" class="alignnone size-full wp-image-4777" srcset="https://sourcedcode.com/wp-content/uploads/2023/04/example-component-tab-1-tab-2.png 2416w, https://sourcedcode.com/wp-content/uploads/2023/04/example-component-tab-1-tab-2-300x180.png 300w, https://sourcedcode.com/wp-content/uploads/2023/04/example-component-tab-1-tab-2-1024x614.png 1024w, https://sourcedcode.com/wp-content/uploads/2023/04/example-component-tab-1-tab-2-768x460.png 768w, https://sourcedcode.com/wp-content/uploads/2023/04/example-component-tab-1-tab-2-1536x921.png 1536w, https://sourcedcode.com/wp-content/uploads/2023/04/example-component-tab-1-tab-2-2048x1227.png 2048w, https://sourcedcode.com/wp-content/uploads/2023/04/example-component-tab-1-tab-2-600x360.png 600w" sizes="(max-width: 2416px) 100vw, 2416px" /></a></p>
<p><a href="#code-snippet">Jump to Code Snippet</a></p>
<hr class="spacer-large"/>
<h3 id="code-snippet">Code Snippet</h3>
<p>The solution below includes an example with the &#8220;styletab&#8221; which is an out-of-the-box feature for the AEM Style System. You can copy and paste this snippet into your .content.xml, like _cq_dialog/.content.xml:</p>
<div class="code-1250">
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br />78<br />79<br />80<br />81<br />82<br />83<br />84<br />85<br />86<br />87<br />88<br />89<br />90<br />91<br />92<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #339933;">&lt;?</span>xml version<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;1.0&quot;</span> encoding<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;UTF-8&quot;</span><span style="color: #339933;">?&gt;</span><br />
<span style="color: #339933;">&lt;</span>jcr<span style="color: #339933;">:</span>root xmlns<span style="color: #339933;">:</span>sling<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://sling.apache.org/jcr/sling/1.0&quot;</span> xmlns<span style="color: #339933;">:</span>granite<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://www.adobe.com/jcr/granite/1.0&quot;</span> xmlns<span style="color: #339933;">:</span>cq<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://www.day.com/jcr/cq/1.0&quot;</span> xmlns<span style="color: #339933;">:</span>jcr<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://www.jcp.org/jcr/1.0&quot;</span> xmlns<span style="color: #339933;">:</span>nt<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://www.jcp.org/jcr/nt/1.0&quot;</span><br />
&nbsp; &nbsp; jcr<span style="color: #339933;">:</span>primaryType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; jcr<span style="color: #339933;">:</span>title<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Example Component&quot;</span><br />
&nbsp; &nbsp; sling<span style="color: #339933;">:</span>resourceType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;cq/gui/components/authoring/dialog&quot;</span><span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>content<br />
&nbsp; &nbsp; &nbsp; &nbsp; granite<span style="color: #339933;">:</span><span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;cmp-button__editor&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; jcr<span style="color: #339933;">:</span>primaryType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; sling<span style="color: #339933;">:</span>resourceType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;granite/ui/components/coral/foundation/container&quot;</span><span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>items jcr<span style="color: #339933;">:</span>primaryType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nt:unstructured&quot;</span><span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>tabs<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jcr<span style="color: #339933;">:</span>primaryType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sling<span style="color: #339933;">:</span>resourceType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;granite/ui/components/coral/foundation/tabs&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; maximized<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;{Boolean}true&quot;</span><span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>items jcr<span style="color: #339933;">:</span>primaryType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nt:unstructured&quot;</span><span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>tab1<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jcr<span style="color: #339933;">:</span>primaryType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jcr<span style="color: #339933;">:</span>title<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Tab 1&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sling<span style="color: #339933;">:</span>resourceType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;granite/ui/components/coral/foundation/container&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; margin<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;{Boolean}true&quot;</span><span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>items jcr<span style="color: #339933;">:</span>primaryType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nt:unstructured&quot;</span><span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>columns<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jcr<span style="color: #339933;">:</span>primaryType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sling<span style="color: #339933;">:</span>resourceType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;granite/ui/components/coral/foundation/fixedcolumns&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; margin<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;{Boolean}true&quot;</span><span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>items jcr<span style="color: #339933;">:</span>primaryType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nt:unstructured&quot;</span><span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>column<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jcr<span style="color: #339933;">:</span>primaryType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sling<span style="color: #339933;">:</span>resourceType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;granite/ui/components/coral/foundation/container&quot;</span><span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>items jcr<span style="color: #339933;">:</span>primaryType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nt:unstructured&quot;</span><span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>exampleinputfield1<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jcr<span style="color: #339933;">:</span>primaryType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sling<span style="color: #339933;">:</span>resourceType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;granite/ui/components/coral/foundation/form/textfield&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fieldDescription<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Example input 1 field can be placed here&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fieldLabel<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Example Input Field 1&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;./exampleinputfield1&quot;</span><span style="color: #339933;">/&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>examplepathfield1<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jcr<span style="color: #339933;">:</span>primaryType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sling<span style="color: #339933;">:</span>resourceType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;granite/ui/components/coral/foundation/form/pathfield&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fieldDescription<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Example path field 1 field can be placed here&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fieldLabel<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Example Path Field 1&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;./examplepathfield1&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rootPath<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;/content&quot;</span><span style="color: #339933;">/&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>items<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>column<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>items<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>columns<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>items<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>tab1<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>tab2<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jcr<span style="color: #339933;">:</span>primaryType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jcr<span style="color: #339933;">:</span>title<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Tab 2&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sling<span style="color: #339933;">:</span>resourceType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;granite/ui/components/coral/foundation/container&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; margin<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;{Boolean}true&quot;</span><span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>items jcr<span style="color: #339933;">:</span>primaryType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nt:unstructured&quot;</span><span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>columns<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jcr<span style="color: #339933;">:</span>primaryType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sling<span style="color: #339933;">:</span>resourceType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;granite/ui/components/coral/foundation/fixedcolumns&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; margin<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;{Boolean}true&quot;</span><span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>items jcr<span style="color: #339933;">:</span>primaryType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nt:unstructured&quot;</span><span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>column<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jcr<span style="color: #339933;">:</span>primaryType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sling<span style="color: #339933;">:</span>resourceType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;granite/ui/components/coral/foundation/container&quot;</span><span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>items jcr<span style="color: #339933;">:</span>primaryType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nt:unstructured&quot;</span><span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>exampleinputfield2<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jcr<span style="color: #339933;">:</span>primaryType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sling<span style="color: #339933;">:</span>resourceType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;granite/ui/components/coral/foundation/form/textfield&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fieldDescription<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Example input 1 field can be placed here&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fieldLabel<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Example Input Field 2&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;./exampleinputfield2&quot;</span><span style="color: #339933;">/&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>examplepathfield2<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jcr<span style="color: #339933;">:</span>primaryType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sling<span style="color: #339933;">:</span>resourceType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;granite/ui/components/coral/foundation/form/pathfield&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fieldDescription<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Example path field 2 field can be placed here&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fieldLabel<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Example Path Field 2&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;./examplepathfield2&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rootPath<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;/content&quot;</span><span style="color: #339933;">/&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>items<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>column<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>items<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>columns<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>items<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>tab2<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>cq<span style="color: #339933;">:</span>styles<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jcr<span style="color: #339933;">:</span>primaryType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sling<span style="color: #339933;">:</span>resourceType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;granite/ui/components/coral/foundation/include&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; path<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;/mnt/overlay/cq/gui/components/authoring/dialog/style/tab_edit/styletab&quot;</span><span style="color: #339933;">/&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>items<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>tabs<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>items<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>content<span style="color: #339933;">&gt;</span><br />
<span style="color: #339933;">&lt;/</span>jcr<span style="color: #339933;">:</span>root<span style="color: #339933;">&gt;</span></div></td></tr></tbody></table></div>
</div>
<hr class="spacer-large"/>
<h3>Extras</h3>
<p>If you would like to enable your component for the AEM Style System, click here, <a href="https://sourcedcode.com/blog/aem/how-to-enable-aem-style-system-configuration-for-components">How to Enable AEM Style System Configuration for Components</a>.</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/aem-touch-ui-granite-ui-tabs-example-code">AEM Touch UI (Granite UI) Tabs: Example Code</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/aem-touch-ui-granite-ui-tabs-example-code/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>AEM Touch UI Show Hide Tabs by Style System Configuration</title>
		<link>https://sourcedcode.com/blog/aem/aem-touch-ui-show-hide-tabs-by-style-system-configuration</link>
					<comments>https://sourcedcode.com/blog/aem/aem-touch-ui-show-hide-tabs-by-style-system-configuration#comments</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Sun, 16 Apr 2023 01:10:52 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Touch UI]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=4640</guid>

					<description><![CDATA[<p>It&#8217;s no doubt that AEM&#8217;s Style System for Components has become more popular over the past few years, and is used by almost every author in this industry. However, there are some feature flaws in the product for the authoring experience, where sometimes we would like to show or hide Touch UI tabs depending on [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/aem-touch-ui-show-hide-tabs-by-style-system-configuration">AEM Touch UI Show Hide Tabs by Style System Configuration</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>It&#8217;s no doubt that AEM&#8217;s Style System for Components has become more popular over the past few years, and is used by almost every author in this industry. However, there are some feature flaws in the product for the authoring experience, where sometimes we would like to show or hide Touch UI tabs depending on which style system option has been selected for a particular AEM Component.</p>
<p>In this blog article, I have created a solution for this. I have created a custom fix to the issue of hiding or showing Touch UI tabs for a particular component based on which style system has been selected for a given component; so the selected style system controls the hide or show the Touch UI tabs. </p>
<p><strong>How the solution works:</strong><br />
The AEM developer will add code configurations to the cq_dialog.xml which targets one or more tabs with some special properties and nodes like the &#8220;granite:class&#8221; and the &#8220;granite:data&#8221;. After configuring these properties and nodes within the cq_dialog.xml, all tabs will be hidden as the initial rendering phase (during configuration of the component), Upon selection of a Style System, the tabs will be visible based on the matched configuration that is set under the granite:data node properties, based on the StyleSystem CSS class that was set.</p>
<div class="mention-block">
This implementation was tested on Experience Manager 6.5 Service Pack 12 and Experience Manager as a Cloud Service 2022.10.0, but in my opinion, if your AEM environment supports the style system, AEM 6.3 SP1 + Feature Pack 20593, it should be okay.
</div>
<hr class="spacer-larger"/>
<h2 id="the-steps">The Steps</h2>
<p>In this section, I will share with you the steps I have used to make this work as expected. In this section you will be:</p>
<ol>
</li>
<li><a href="#pre-requirements">Pre Requirements.</a></li>
<li><a href="#create-a-new-component-as-example-component">Creating a new component named Example Component.</a></li>
<li><a href="#create-sling-model-for-the-example-component">Creating Sling Model for the  Example Component.</a></li>
<li><a href="#create-the-touch-ui-custom-java-script-implementation">Creating the Touch UI custom JavaScript implementation.</a></li>
<li><a href="#finally-test-it-out">Testing it out.</a></li>
<li><a href="#configuration-explanation-of-the-touch-ui-granite-tab-fields">Configuration Explanation of the Touch UI Granite Tab Fields.</a></li>
</ol>
<hr class="spacer-larger"/>
<h3 id="pre-requirements">0. Pre Requirements</h3>
<p>The creation of this solution to hide or show Touch UI tabs for a particular component based on which style system is selected is based on the best practices of creating AEM components, following the guidelines of the AEM Core Components. This means that when a component is created, it requires a sling model to extends the com.adobe.cq.wcm.core.components.util.AbstractComponentImpl class. In turn the extension of the com.adobe.cq.wcm.core.components.util.AbstractComponentImpl will provide helpers that will expose the appliedCssClassNames property when the component is called with model.json. </p>
<p>Next, the sling model must declare the org.apache.sling.models.annotations.Exporter annotation, so model.json can be called upon for the particular component.</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">path<span style="color: #339933;">:</span> http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//localhost:4502/content/sourcedcode/test/_jcr_content/root/container/container/examplecomponent_536346544.model.json</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #0000ff;">&quot;id&quot;</span><span style="color: #339933;">:</span><span style="color: #0000ff;">&quot;examplecomponent-d4c74a60c1&quot;</span>,<br />
&nbsp; &nbsp;<span style="color: #0000ff;">&quot;dataLayer&quot;</span><span style="color: #339933;">:</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;examplecomponent-d4c74a60c1&quot;</span><span style="color: #339933;">:</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0000ff;">&quot;@type&quot;</span><span style="color: #339933;">:</span><span style="color: #0000ff;">&quot;sourcedcode/components/examplecomponent&quot;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0000ff;">&quot;repo:modifyDate&quot;</span><span style="color: #339933;">:</span><span style="color: #0000ff;">&quot;2023-04-15T23:49:42Z&quot;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp;<span style="color: #009900;">&#125;</span>,<br />
&nbsp; &nbsp;<span style="color: #0000ff;">&quot;:type&quot;</span><span style="color: #339933;">:</span><span style="color: #0000ff;">&quot;sourcedcode/components/examplecomponent&quot;</span>,<br />
&nbsp; &nbsp;<span style="color: #0000ff;">&quot;appliedCssClassNames&quot;</span><span style="color: #339933;">:</span><span style="color: #0000ff;">&quot;show-tab-two-now&quot;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p><a href="#create-sling-model-for-the-example-component">Module B</a> within the article will show you how to setup the sling model to export JSON as mentioned above.</p>
<hr class="spacer-larger"/>
<h2 id="create-a-new-component-as-example-component">A. Create a new component as Example Component</h2>
<p>You will be creating a new component as Example Component where I will install a simple example of the sightly component content&#8217;s a simple Touch UI configuration, and also a simple _cq_design_dialog, so you can actually configure the style system for your given component.</p>
<p>Please note that all files created should be placed under: /ui.apps/src/main/content/jcr_root/apps/sourcedcode/components/examplecomponent</p>
<ol>
<li>Create a new folder /apps/sourcedcode/components/examplecomponent</li>
<li>Create an &#8220;examplecomponent.html&#8221; file under /apps/sourcedcode/components/examplecomponent with the file contents of:
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">Example Component</div></td></tr></tbody></table></div>
</li>
<li>Create a &#8220;.content.xml&#8221; file under /apps/sourcedcode/components/examplecomponent with the file contents of
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&lt;?xml <span style="color: #000066;">version</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;1.0&quot;</span> encoding<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;UTF-8&quot;</span>?&gt;<br />
&lt;jcr:root xmlns:cq<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://www.day.com/jcr/cq/1.0&quot;</span> xmlns:jcr<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://www.jcp.org/jcr/1.0&quot;</span><br />
&nbsp; &nbsp; jcr:primaryType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;cq:Component&quot;</span><br />
&nbsp; &nbsp; jcr:<span style="color: #000066;">title</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Example Component&quot;</span><br />
&nbsp; &nbsp; componentGroup<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;SourcedCode - Content&quot;</span><span style="color: #66cc66;">/</span>&gt;</div></td></tr></tbody></table></div>
</li>
<li>Create a &#8220;_cq_editConfig.xml&#8221; file under /apps/sourcedcode/components/examplecomponent with the file contents of
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&lt;?xml <span style="color: #000066;">version</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;1.0&quot;</span> encoding<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;UTF-8&quot;</span>?&gt;<br />
&lt;jcr:root xmlns:cq<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://www.day.com/jcr/cq/1.0&quot;</span> xmlns:jcr<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://www.jcp.org/jcr/1.0&quot;</span><br />
&nbsp; &nbsp; jcr:primaryType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;cq:EditConfig&quot;</span><span style="color: #66cc66;">/</span>&gt;</div></td></tr></tbody></table></div>
</li>
<li>Create a &#8220;_cq_dialog&#8221; folder under /apps/sourcedcode/components/examplecomponent</li>
<li id="touch-ui-code-configuration">Create a &#8220;.content.xml&#8221; file under /apps/sourcedcode/components/examplecomponent/_cq_dialog with the file contents below.
<p style="padding-top:10px;">We have included custom granite properties to this file in order for this feature to work. If you would like to understand exactly what as added, <a href="#configuration-of-the-touch-ui-granite-tab-fields">please click here to read it in the last section</a>.</p>
<div class="code-1500">
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br />78<br />79<br />80<br />81<br />82<br />83<br />84<br />85<br />86<br />87<br />88<br />89<br />90<br />91<br />92<br />93<br />94<br />95<br />96<br />97<br />98<br />99<br />100<br />101<br />102<br />103<br />104<br />105<br />106<br />107<br />108<br />109<br />110<br />111<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&lt;?xml <span style="color: #000066;">version</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;1.0&quot;</span> encoding<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;UTF-8&quot;</span>?&gt;<br />
&lt;jcr:root xmlns:sling<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://sling.apache.org/jcr/sling/1.0&quot;</span> xmlns:granite<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://www.adobe.com/jcr/granite/1.0&quot;</span> xmlns:cq<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://www.day.com/jcr/cq/1.0&quot;</span> xmlns:jcr<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://www.jcp.org/jcr/1.0&quot;</span> xmlns:nt<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://www.jcp.org/jcr/nt/1.0&quot;</span><br />
&nbsp; &nbsp; jcr:primaryType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; jcr:<span style="color: #000066;">title</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Example Component&quot;</span><br />
&nbsp; &nbsp; sling:resourceType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;cq/gui/components/authoring/dialog&quot;</span>&gt;<br />
&nbsp; &nbsp; &lt;<span style="color: #000066;">content</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; jcr:primaryType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; sling:resourceType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;granite/ui/components/coral/foundation/container&quot;</span>&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;items jcr:primaryType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;nt:unstructured&quot;</span>&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;tabs<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jcr:primaryType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sling:resourceType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;granite/ui/components/coral/foundation/tabs&quot;</span>&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;items jcr:primaryType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;nt:unstructured&quot;</span>&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;tab1<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jcr:primaryType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jcr:<span style="color: #000066;">title</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Tab 1&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sling:resourceType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;granite/ui/components/coral/foundation/container&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; margin<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;{Boolean}true&quot;</span>&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;items jcr:primaryType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;nt:unstructured&quot;</span>&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;columns<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jcr:primaryType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sling:resourceType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;granite/ui/components/coral/foundation/fixedcolumns&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; margin<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;{Boolean}true&quot;</span>&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;items jcr:primaryType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;nt:unstructured&quot;</span>&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;column<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jcr:primaryType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sling:resourceType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;granite/ui/components/coral/foundation/container&quot;</span>&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;items jcr:primaryType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;nt:unstructured&quot;</span>&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;graniteExample1<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jcr:primaryType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sling:resourceType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;granite/ui/components/coral/foundation/form/textfield&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fieldDescription<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Just an example&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fieldLabel<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;graniteExample1&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;./graniteExample1&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; required<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;{Boolean}false&quot;</span><span style="color: #66cc66;">/</span>&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;<span style="color: #66cc66;">/</span>items&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;<span style="color: #66cc66;">/</span>column&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;<span style="color: #66cc66;">/</span>items&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;<span style="color: #66cc66;">/</span>columns&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;<span style="color: #66cc66;">/</span>items&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;<span style="color: #66cc66;">/</span>tab1&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;tab2<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; granite:<span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;cq-dialog-stylesystem-tab-showhide&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jcr:primaryType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jcr:<span style="color: #000066;">title</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Tab 2&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sling:resourceType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;granite/ui/components/coral/foundation/container&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; margin<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;{Boolean}true&quot;</span>&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;items jcr:primaryType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;nt:unstructured&quot;</span>&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;columns<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jcr:primaryType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sling:resourceType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;granite/ui/components/coral/foundation/fixedcolumns&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; margin<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;{Boolean}true&quot;</span>&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;items jcr:primaryType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;nt:unstructured&quot;</span>&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;column<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jcr:primaryType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sling:resourceType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;granite/ui/components/coral/foundation/container&quot;</span>&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;items jcr:primaryType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;nt:unstructured&quot;</span>&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;graniteExample2<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jcr:primaryType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sling:resourceType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;granite/ui/components/coral/foundation/form/textfield&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fieldDescription<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Just an example&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fieldLabel<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;graniteExample2&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;./graniteExample2&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; required<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;{Boolean}false&quot;</span><span style="color: #66cc66;">/</span>&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;<span style="color: #66cc66;">/</span>items&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;<span style="color: #66cc66;">/</span>column&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;<span style="color: #66cc66;">/</span>items&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;<span style="color: #66cc66;">/</span>columns&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;<span style="color: #66cc66;">/</span>items&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;granite:<span style="color: #000066;">data</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jcr:primaryType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; showTabOnAppliedCssClass<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;show-tab-two-now&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tabTitleName<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Tab 2&quot;</span><span style="color: #66cc66;">/</span>&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;<span style="color: #66cc66;">/</span>tab2&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;tab3<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jcr:primaryType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jcr:<span style="color: #000066;">title</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Tab 3&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sling:resourceType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;granite/ui/components/coral/foundation/container&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; margin<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;{Boolean}true&quot;</span>&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;items jcr:primaryType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;nt:unstructured&quot;</span>&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;columns<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jcr:primaryType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sling:resourceType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;granite/ui/components/coral/foundation/fixedcolumns&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; margin<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;{Boolean}true&quot;</span>&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;items jcr:primaryType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;nt:unstructured&quot;</span>&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;column<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jcr:primaryType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sling:resourceType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;granite/ui/components/coral/foundation/container&quot;</span>&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;items jcr:primaryType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;nt:unstructured&quot;</span>&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;graniteExample3<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jcr:primaryType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sling:resourceType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;granite/ui/components/coral/foundation/form/textfield&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fieldDescription<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Just an example&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fieldLabel<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;graniteExample3&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;./graniteExample3&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; required<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;{Boolean}false&quot;</span><span style="color: #66cc66;">/</span>&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;<span style="color: #66cc66;">/</span>items&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;<span style="color: #66cc66;">/</span>column&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;<span style="color: #66cc66;">/</span>items&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;<span style="color: #66cc66;">/</span>columns&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;<span style="color: #66cc66;">/</span>items&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;<span style="color: #66cc66;">/</span>tab3&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;styletab<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jcr:primaryType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sling:resourceType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;granite/ui/components/coral/foundation/include&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; path<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;/mnt/overlay/cq/gui/components/authoring/dialog/style/tab_edit/styletab&quot;</span><span style="color: #66cc66;">/</span>&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;<span style="color: #66cc66;">/</span>items&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;<span style="color: #66cc66;">/</span>tabs&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;<span style="color: #66cc66;">/</span>items&gt;<br />
&nbsp; &nbsp; &lt;<span style="color: #66cc66;">/</span>content&gt;<br />
&lt;<span style="color: #66cc66;">/</span>jcr:root&gt;</div></td></tr></tbody></table></div>
</div>
</li>
<li>Create a &#8220;_cq_design_dialog&#8221; folder under /apps/sourcedcode/components/examplecomponent</li>
<li>Create a &#8220;.content.xml&#8221; file under /apps/sourcedcode/components/examplecomponent/_cq_design_dialog with the file contents below:
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&lt;?xml <span style="color: #000066;">version</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;1.0&quot;</span> encoding<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;UTF-8&quot;</span>?&gt;<br />
&lt;jcr:root xmlns:sling<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://sling.apache.org/jcr/sling/1.0&quot;</span> xmlns:granite<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://www.adobe.com/jcr/granite/1.0&quot;</span> xmlns:cq<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://www.day.com/jcr/cq/1.0&quot;</span> xmlns:jcr<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://www.jcp.org/jcr/1.0&quot;</span> xmlns:nt<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://www.jcp.org/jcr/nt/1.0&quot;</span><br />
&nbsp; &nbsp; jcr:primaryType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; jcr:<span style="color: #000066;">title</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Example Component&quot;</span><br />
&nbsp; &nbsp; sling:resourceType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;cq/gui/components/authoring/dialog&quot;</span>&gt;<br />
&nbsp; &nbsp; &lt;<span style="color: #000066;">content</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; jcr:primaryType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; sling:resourceType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;granite/ui/components/coral/foundation/container&quot;</span>&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;items jcr:primaryType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;nt:unstructured&quot;</span>&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;tabs<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jcr:primaryType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sling:resourceType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;granite/ui/components/coral/foundation/tabs&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; maximized<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;{Boolean}true&quot;</span>&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;items jcr:primaryType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;nt:unstructured&quot;</span>&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;styletab<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jcr:primaryType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sling:resourceType<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;granite/ui/components/coral/foundation/include&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; path<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;/mnt/overlay/cq/gui/components/authoring/dialog/style/tab_design/styletab&quot;</span><span style="color: #66cc66;">/</span>&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;<span style="color: #66cc66;">/</span>items&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;<span style="color: #66cc66;">/</span>tabs&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;<span style="color: #66cc66;">/</span>items&gt;<br />
&nbsp; &nbsp; &lt;<span style="color: #66cc66;">/</span>content&gt;<br />
&lt;<span style="color: #66cc66;">/</span>jcr:root&gt;</div></td></tr></tbody></table></div>
</li>
<li>You are now done with the creation of the example component.</li>
</ol>
<hr class="spacer-larger"/>
<h2 id="create-sling-model-for-the-example-component">B. Create Sling Model for the  Example Component</h2>
<p>This is a very simple implementation for a sling model for the Example Component. The reason why we need to setup the Sling Model backend for our component because we need to obtain the &#8220;appliedCssClassNames&#8221; property from the configured component, which is configured by the content authors. If you have not already, please take a look at the <a href="#pre-requirements">pre-requirements</a> section of this website, where calling the model.json of this particular component should expose the &#8220;appliedCssClassNames&#8221; which is vital for this solution to work. Implementing com.adobe.cq.wcm.core.components.util.AbstractComponentImpl is a best practice of the WCM Core Components where it promotes new features like the data-layer, and should be apart of your development tool kit when developing more modern AEM components. </p>
<p>Next, the sling model must declare the org.apache.sling.models.annotations.Exporter annotation, so model.json can be called upon for the particular component; like http://localhost:4502/content/sourcedcode/test/_jcr_content/root/container/container/examplecomponent_536346544.model.json.</p>
<p>Being able to resolve .model.json is vital for the hide or show Touch UI tabs for a particular component based on which style system is selected to work.</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.sourcedcode.core.internal.models</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.adobe.cq.export.json.ExporterConstants</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.adobe.cq.wcm.core.components.util.AbstractComponentImpl</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.SlingHttpServletRequest</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.models.annotations.DefaultInjectionStrategy</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.models.annotations.Exporter</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.models.annotations.Model</span><span style="color: #339933;">;</span><br />
<br />
@Model<span style="color: #009900;">&#40;</span>adaptables <span style="color: #339933;">=</span> SlingHttpServletRequest.<span style="color: #000000; font-weight: bold;">class</span>, resourceType <span style="color: #339933;">=</span> ExampleComponentImpl.<span style="color: #006633;">RESOURCE_TYPE</span>, defaultInjectionStrategy <span style="color: #339933;">=</span> DefaultInjectionStrategy.<span style="color: #006633;">OPTIONAL</span><span style="color: #009900;">&#41;</span><br />
@Exporter<span style="color: #009900;">&#40;</span>name <span style="color: #339933;">=</span> ExporterConstants.<span style="color: #006633;">SLING_MODEL_EXPORTER_NAME</span>, extensions <span style="color: #339933;">=</span> ExporterConstants.<span style="color: #006633;">SLING_MODEL_EXTENSION</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ExampleComponentImpl <span style="color: #000000; font-weight: bold;">extends</span> AbstractComponentImpl <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">String</span> RESOURCE_TYPE <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;sourcedcode/components/examplecomponent&quot;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<hr class="spacer-larger"/>
<h3 id="create-the-touch-ui-custom-java-script-implementation">C. Create the Touch UI custom JavaScript implementation</h3>
<p>You will be creating a clientlib-author Client Library which will be executed inthe editor.html authoring page. The Javascript should be executed upon opening up a Touch UI dialog.</p>
<p>Please note that all files created should be placed under: /ui.apps/src/main/content/jcr_root/apps/sourcedcode/clientlibs/clientlib-author</p>
<ol>
<li>Create the &#8220;clientlib-author&#8221; folder under /ui.apps/src/main/content/jcr_root/apps/sourcedcode/clientlibs</li>
<li>Create a &#8220;.content.xml&#8221; file under /ui.apps/src/main/content/jcr_root/apps/sourcedcode/clientlibs with the file contents of:
<div class="mention-block">
To understand how to add a Custom Client Library for AEM Author Editor Touch UI, <a href="https://sourcedcode.com/blog/aem/adding-custom-client-library-for-aem-author-editor-touch-ui" rel="noopener" target="_blank">click here</a>.
</div>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #339933;">&lt;?</span>xml version<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;1.0&quot;</span> encoding<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;UTF-8&quot;</span><span style="color: #339933;">?&gt;</span><br />
<span style="color: #339933;">&lt;</span>jcr<span style="color: #339933;">:</span>root xmlns<span style="color: #339933;">:</span>cq<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://www.day.com/jcr/cq/1.0&quot;</span> xmlns<span style="color: #339933;">:</span>jcr<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://www.jcp.org/jcr/1.0&quot;</span><br />
&nbsp; &nbsp; jcr<span style="color: #339933;">:</span>primaryType<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;cq:ClientLibraryFolder&quot;</span><br />
&nbsp; &nbsp; categories<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;[cq.authoring.editor.sites.page.hook]&quot;</span><br />
&nbsp; &nbsp; dependencies<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;[cq.authoring.editor.sites.page]&quot;</span><span style="color: #339933;">/&gt;</span></div></td></tr></tbody></table></div>
</li>
<li>Create the &#8220;js&#8221; folder under /ui.apps/src/main/content/jcr_root/apps/sourcedcode/clientlibs/clientlib-author</li>
<li>Create a file named &#8220;stylesystem-tab-showhide.js&#8221; with the contents inside:
<div class="code-750">
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #008000; font-style: italic; font-weight: bold;">/** &nbsp; &nbsp;<br />
* Author: Brian Kasing Li @ https://www.linkedin.com/in/briankasingli &nbsp; &nbsp;<br />
* Documentation: https://sourcedcode.com/blog/aem/aem-touch-ui-show-hide-tabs-by-style-system-configurgation&nbsp; &nbsp; &nbsp;<br />
**/</span><br />
<br />
<span style="color: #009900;">&#40;</span>function <span style="color: #009900;">&#40;</span>document, $<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">&quot;use strict&quot;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; var <span style="color: #000000; font-weight: bold;">CONST</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; TARGET_GRANITE_CLASS<span style="color: #339933;">:</span> <span style="color: #0000ff;">'.cq-dialog-stylesystem-tab-showhide'</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; GRANITE_DATA_PROP_TAB_TITLE_NAME<span style="color: #339933;">:</span> <span style="color: #0000ff;">'tabtitlename'</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; GRANITE_DATA_PROP_SHOW_TAB_ON_APPLIED_CSS_CLASS<span style="color: #339933;">:</span> <span style="color: #0000ff;">'showtabonappliedcssclass'</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; APPLIED_CSS_CLASS_NAMES<span style="color: #339933;">:</span> <span style="color: #0000ff;">'appliedCssClassNames'</span>,<br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #008000; font-style: italic; font-weight: bold;">/**<br />
&nbsp; &nbsp; &nbsp;* foundation-contentloaded<br />
&nbsp; &nbsp; &nbsp;* adding event listener to the Touch UI popup, so when the Touch UI is envoked, the code in will be executed.<br />
&nbsp; &nbsp; &nbsp;* - initially, any TouchUI tabs which includes granite:class=&quot;cq-dialog-stylesystem-tab-showhide&quot; will be hidden.<br />
&nbsp; &nbsp; &nbsp;* - upon response from the .model.json ajax request, we will showTabs based on what's configured for &quot;tabtitlename&quot; and &quot;showTabOnAppliedCssClass&quot;.<br />
&nbsp; &nbsp; &nbsp;* <br />
&nbsp; &nbsp; &nbsp;* @returns void<br />
&nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; $<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">on</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;foundation-contentloaded&quot;</span>, function <span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span>e.<span style="color: #006633;">target</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">prop</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'tagName'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">===</span> <span style="color: #0000ff;">'CORAL-DIALOG'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; hideTabs<span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span>e.<span style="color: #006633;">target</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var url <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span>e.<span style="color: #006633;">target</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">find</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'.cq-dialog'</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'action'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;.model.json&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $.<span style="color: #006633;">getJSON</span><span style="color: #009900;">&#40;</span>url, function<span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#91;</span><span style="color: #000000; font-weight: bold;">CONST</span>.<span style="color: #006633;">APPLIED_CSS_CLASS_NAMES</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; showTabs<span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span>e.<span style="color: #006633;">target</span><span style="color: #009900;">&#41;</span>, data<span style="color: #009900;">&#91;</span><span style="color: #000000; font-weight: bold;">CONST</span>.<span style="color: #006633;">APPLIED_CSS_CLASS_NAMES</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #008000; font-style: italic; font-weight: bold;">/**<br />
&nbsp; &nbsp; &nbsp;* this finds all Touch UI fields with the cssClass .cq-dialog-stylesystem-tab-showhide, which should be found as an attribute<br />
&nbsp; &nbsp; &nbsp;* under sling:resourceType=&quot;granite/ui/components/coral/foundation/container&quot;, which &quot;hides&quot; all tab options from the authors.<br />
&nbsp; &nbsp; &nbsp;* @returns void<br />
&nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; function hideTabs<span style="color: #009900;">&#40;</span>$parentEle<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; $parentEle.<span style="color: #006633;">find</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">CONST</span>.<span style="color: #006633;">TARGET_GRANITE_CLASS</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">each</span><span style="color: #009900;">&#40;</span>function<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var $this <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var tabtitlename <span style="color: #339933;">=</span> $this.<span style="color: #006633;">data</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">CONST</span>.<span style="color: #006633;">GRANITE_DATA_PROP_TAB_TITLE_NAME</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'._coral-Tabs-itemLabel'</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">each</span><span style="color: #009900;">&#40;</span>function<span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">html</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">===</span> tabtitlename<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">closest</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'coral-tab'</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #008000; font-style: italic; font-weight: bold;">/**<br />
&nbsp; &nbsp; &nbsp;* after a successful response of the .model.json ajax request, <br />
&nbsp; &nbsp; &nbsp;* this finds all Touch UI fields with the cssClass .cq-dialog-stylesystem-tab-showhide, which should be found as an attribute<br />
&nbsp; &nbsp; &nbsp;* under sling:resourceType=&quot;granite/ui/components/coral/foundation/container&quot;. Based on the set properties of<br />
&nbsp; &nbsp; &nbsp;* granite:data values set for &quot;tabtitlename&quot; and &quot;showTabOnAppliedCssClass&quot;, the matched tabs will be &quot;visible&quot; from the authors.<br />
&nbsp; &nbsp; &nbsp;* <br />
&nbsp; &nbsp; &nbsp;* @returns void<br />
&nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; function showTabs<span style="color: #009900;">&#40;</span>$parentEle, appliedCssClassNames<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; $parentEle.<span style="color: #006633;">find</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">CONST</span>.<span style="color: #006633;">TARGET_GRANITE_CLASS</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">each</span><span style="color: #009900;">&#40;</span>function<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var $this <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var tabtitlename <span style="color: #339933;">=</span> $this.<span style="color: #006633;">data</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">CONST</span>.<span style="color: #006633;">GRANITE_DATA_PROP_TAB_TITLE_NAME</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var targetappliedcssclass <span style="color: #339933;">=</span> $this.<span style="color: #006633;">data</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">CONST</span>.<span style="color: #006633;">GRANITE_DATA_PROP_SHOW_TAB_ON_APPLIED_CSS_CLASS</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #0000ff;">'INVALID_APPLIED_CSS_CLASS'</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>appliedCssClassNames.<span style="color: #006633;">split</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">' '</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">includes</span><span style="color: #009900;">&#40;</span>targetappliedcssclass<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'._coral-Tabs-itemLabel'</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">each</span><span style="color: #009900;">&#40;</span>function<span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">html</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">===</span> tabtitlename<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">closest</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'coral-tab'</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">show</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>document, Granite.$<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
</div>
</li>
<li>Create a &#8220;js.txt&#8221; file under /ui.apps/src/main/content/jcr_root/apps/sourcedcode/clientlibs with the file contents of:
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">#base<span style="color: #339933;">=</span>js<br />
stylesystem<span style="color: #339933;">-</span>tab<span style="color: #339933;">-</span>showhide.<span style="color: #006633;">js</span></div></td></tr></tbody></table></div>
</li>
<li>You are now finished creating the clientlib-author client library.</li>
</ol>
<hr class="spacer-larger"/>
<h3 id="finally-test-it-out">D. Finally, test it out.</h3>
<ol>
<li>Edit the component policies within the editable template, to include a style system class of &#8220;show-tab-two-now&#8221;</li>
<li>Edit a page of your choice, and drag the Example Component into the page</li>
<li>Configure the component to add style system &#8220;show-tab-two-now&#8221; for the given component</li>
<li>Note: if &#8220;show-tab-two-now&#8221; is not an option as a Style System for your current component, then you must add some policies for your component.</li>
<li>Now you should see Tab 2 visible.</li>
<li>Done</li>
</ol>
<hr class="spacer-larger"/>
<h3 id="configuration-explanation-of-the-touch-ui-granite-tab-fields">E. Configuration Explanation of the Touch UI Granite Tab Fields</h3>
<p>After the installation of the client library custom code, you should be able to start adding properties to your Touch UI code, for this feature, like the screenshot below:<br />
<a href="https://sourcedcode.com/wp-content/uploads/2023/04/touch-ui-tabs-configuration-in-code-lines-detail.png"><img decoding="async" src="https://sourcedcode.com/wp-content/uploads/2023/04/touch-ui-tabs-configuration-in-code-lines-detail.png" alt="Touch UI Granite UI Code Configuration Example" width="100%" class="size-full wp-image-4659" /></a> </p>
<p>Indicating in the screenshot above, you have realized that we are introducing <span class="code-highlight-primary">granite:class=&#8221;cq-dialog-stylesystem-tab-showhide&#8221;</span>line:43 which will be placed at the root level of the tab XML structure; when this property is placed, when author initially call the TouchUI popup, all tabs with this granite:class will be hidden. Inside of the tab XML structure, we introduced a new node configuration, line:70,as <span class="code-highlight-primary">granite:data</span>, which introduced two new properties.</p>
<p>The <span class="code-highlight-primary">granite:data</span> has two properties that will determine which tab to show, and also which option of style system has been configured, so we can show the tab as expected.</p>
<p><strong>Note:</strong>, since we are using the granite <span class="code-highlight-secondary">namespace</span>, you need to ensure your XML declaration for the Touch UI includes: <span class="code-highlight-secondary">xmlns:granite=&#8221;http://www.adobe.com/jcr/granite/1.0&#8243;</span>. You can see this example from the <a href="#touch-ui-code-configuration">Touch UI code configuration that we have installed</a> line:2 in our code examples.</p>
<p><strong>properties:</strong></p>
<ul>
<li><strong>tabTitleName</strong>: the exact name of the tab (jcr:title). Taking a look at the screenshot above line:73 this property matches exactly what is under line:43, the jcr:title.</li>
<li><strong>showTabOnAppliedCssClass</strong>: this is the CSS class name that has been configured by the content authors via AEM&#8217;s style system; this field must match exactly to the style system CSS class that has been configured by the component policies. The CSS class set here is the target&#8217;s the Style System CSS class name that should make the table visible when matched.</li>
</ul>
<hr class="spacer-larger"/>
<h3>Summary</h3>
<p>Please understand that even if the tabs are hidden from the Touch UI, the existing properties that are already content authored without this feature will not be removed as expected, and Sightly may continue to render content on the page; this means that&#8230; if for example, I have the style system enable or disable the Touch UI checkbox to &#8220;open new tab&#8221;. if this field was already content authored&#8230; and this custom code hide&#8217;s the field&#8230; since the already configured component&#8217;s property is still persisted, your Sightly may be still opening the button in a new tab.</p>
<p>To ensure that if a style system is enabled, and you do not want Sightly to render some items on the page, you will need to make some changes to the code itself.  </p>
<div class="mention-block">
To learn how to obtain the style system AEM component configuration In the backend code, take a look at this blog, <a href="https://sourcedcode.com/blog/aem/aem-style-system-component-information-with-code-sling-models" rel="noopener" target="_blank">AEM Style System Component Information with Code Sling Models</a>.
</div>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/aem-touch-ui-show-hide-tabs-by-style-system-configuration">AEM Touch UI Show Hide Tabs by Style System Configuration</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/aem-touch-ui-show-hide-tabs-by-style-system-configuration/feed</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>AEM Style System Component Information with Code Sling Models</title>
		<link>https://sourcedcode.com/blog/aem/aem-style-system-component-information-with-code-sling-models</link>
					<comments>https://sourcedcode.com/blog/aem/aem-style-system-component-information-with-code-sling-models#comments</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Thu, 13 Apr 2023 00:41:21 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Sling Models]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=4606</guid>

					<description><![CDATA[<p>As an AEM full-stack web developer who frequently works with AEM components, it&#8217;s not uncommon to require access to the AEM Style System configuration of a specific component. This information can prove invaluable when writing conditional algorithms to manipulate data output. However, the question remains: how can one retrieve the necessary AEM Style System information [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/aem-style-system-component-information-with-code-sling-models">AEM Style System Component Information with Code Sling Models</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>As an AEM full-stack web developer who frequently works with AEM components, it&#8217;s not uncommon to require access to the AEM Style System configuration of a specific component. This information can prove invaluable when writing conditional algorithms to manipulate data output. However, the question remains: how can one retrieve the necessary AEM Style System information from within the components themselves via the backend?</p>
<p>Thankfully, Adobe offers a useful tool in the form of the com.adobe.cq.wcm.style.ComponentStyleInfo Sling model utility class. This class provides a straightforward means of accessing vital information about the styles applied to a component via Style System. By utilizing the methods provided by ComponentStyleInfo, developers can quickly and easily obtain the style information necessary to enhance the functionality of their AEM components.</p>
<p>In this blog article you will find examples on how to get the AEM Component&#8217;s Style System configuration from the backend using sling models or just with the resource object itself.</p>
<hr class="spacer-large"/>
<h4>A. Code Example of resource.adaptTo(ComponentStyleInfo.class)</h4>
<p>In the examples below we will observe a targeted component as a &#8220;Resource&#8221; which we will adapt the ComponentStyleInfo.class.</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">ComponentStyleInfo componentStyleInfo <span style="color: #339933;">=</span> resource.<span style="color: #006633;">adaptTo</span><span style="color: #009900;">&#40;</span>ComponentStyleInfo.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>Once the resource have been adapted, you can see all these available properties. Here you can access the entire component&#8217;s policies, like the ability to view:</p>
<ul>
<li><strong>appliedCssClasses</strong>: list of applied CSS classes (this is a String type).</li>
<li><strong>styles</strong>: Which is a list of the AEM Style System items that has been selected, with all the meta data involved (this is a LinkedList type)</li>
<li><strong>contentPolicyStyleInfo</strong>: this an object that exposes the entire AEM Style System, Style Groups, that is configured for this given component.</li>
</ul>
<p><a href="https://sourcedcode.com/wp-content/uploads/2023/04/ComponentStyleInfo-debug-example.png"><img decoding="async" src="https://sourcedcode.com/wp-content/uploads/2023/04/ComponentStyleInfo-debug-example.png" alt="Screenshot of the ComponentStyleInfo-debug" width="500" class="alignnone size-full wp-image-4610" srcset="https://sourcedcode.com/wp-content/uploads/2023/04/ComponentStyleInfo-debug-example.png 732w, https://sourcedcode.com/wp-content/uploads/2023/04/ComponentStyleInfo-debug-example-287x300.png 287w, https://sourcedcode.com/wp-content/uploads/2023/04/ComponentStyleInfo-debug-example-600x627.png 600w" sizes="(max-width: 732px) 100vw, 732px" /></a></p>
<hr class="spacer-large"/>
<div class="mention-block">
It&#8217;s common that developers would only want to retrieve the list of appliedCssClasses, and so, here&#8217;s an example below where only the appliedCssClasses will be returned to the backend developer. The appliedCssClasses is then used to validate if my class exists, and if so, execute some code&#8230; if not, do nothing.
</div>
<hr class="spacer-large"/>
<h4>B. Code Example of testing appliedCssClasses</h4>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #003399;">String</span> appliedCssClasses <span style="color: #339933;">=</span> Optional.<span style="color: #006633;">ofNullable</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">resource</span>.<span style="color: #006633;">adaptTo</span><span style="color: #009900;">&#40;</span>ComponentStyleInfo.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp;.<span style="color: #006633;">map</span><span style="color: #009900;">&#40;</span>ComponentStyleInfo<span style="color: #339933;">::</span>getAppliedCssClasses<span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp;.<span style="color: #006633;">filter</span><span style="color: #009900;">&#40;</span>StringUtils<span style="color: #339933;">::</span>isNotBlank<span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp;.<span style="color: #006633;">orElse</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>appliedCssClasses.<span style="color: #006633;">contains</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;my-class&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp;<span style="color: #666666; font-style: italic;">// execute</span><br />
<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span><br />
&nbsp;<span style="color: #666666; font-style: italic;">// do nothing</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/aem-style-system-component-information-with-code-sling-models">AEM Style System Component Information with Code Sling Models</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/aem-style-system-component-information-with-code-sling-models/feed</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
		<item>
		<title>Checking run mode from Sightly HTL in AEM in 2023</title>
		<link>https://sourcedcode.com/blog/aem/checking-run-mode-from-sightly-htl-in-aem-in-2023</link>
					<comments>https://sourcedcode.com/blog/aem/checking-run-mode-from-sightly-htl-in-aem-in-2023#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Fri, 07 Apr 2023 00:45:32 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Development]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=4625</guid>

					<description><![CDATA[<p>While we are developing in the modern world of AEM, sometimes we may want to understand if our backend implementation is being executed under &#8220;development&#8221;, &#8220;staging&#8221;, and &#8220;production&#8221;. In the past, we use the SlingSettingsService, but unfortunately, the SlingSettingsService is flagged as a deprecated service in AEM. According to one of the most prominent AEM [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/checking-run-mode-from-sightly-htl-in-aem-in-2023">Checking run mode from Sightly HTL in AEM in 2023</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>While we are developing in the modern world of AEM, sometimes we may want to understand if our backend implementation is being executed under &#8220;development&#8221;, &#8220;staging&#8221;, and &#8220;production&#8221;. In the past, we use the SlingSettingsService, but unfortunately, the SlingSettingsService is flagged as a deprecated service in AEM. According to one of the most prominent AEM enthusiasts in the AEM world, he says &#8220;I would go so far as to say, that the use of slingSettings.getRunModes() should be considered bad practice in AEM project code.&#8221;&#8230; for whatever reason.</p>
<p>However, sometimes in our implementation, we are actually likely to get the current run mode from the AEM backend so that we can execute some unique operations. In this article, I will share with you my very simple solution for retrieving the current run mode, so you can do what you need to do.</p>
<div class="mention-block">
<strong>slingSettingsService is a deprecated service</strong><br />
In our last <a href="https://sourcedcode.com/blog/aem/checking-run-mode-from-sightly-htl-in-aem" rel="noopener" target="_blank">blog</a> post, We understand that the slingSettingsService is a deprecated service, and you would still like to find a way to retrieve the run mode where it equals to “development”, “staging”, or “production”, This is our response to it.
</div>
<hr class="spacer-large" />
<h3>Solution:</h2>
<p>Create an AEM run mode OSGI service which will have the ability to return us to either &#8220;development&#8221;, &#8220;staging&#8221;, &#8220;production&#8221;. This OSGI service will be a very simple service where it behaves like a configuration service in AEM; we will name this the RunModeIdentifierService. </p>
<p>Where with the help of the @ObjectClassDefinition and @Designate we will declare the &#8220;runMode&#8221; property in the OSGI Service. Next using the standard AEM configuration for defining configuration properties for a run mode, we will place the service configuration inside of the run mode configuration folders. The run mode is indicated by a suffix on the folder name. This allows you to store all configurations in one repository as. For example:</p>
<p>/apps/sourcedcode/config.development<br />
/apps/sourcedcode/config.staging<br />
/apps/sourcedcode/config.production</p>
<hr class="spacer-large" />
<h3>A. Create an interface for your RunModeIdentifierService</h3>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.glob.sourcedcode.core.services</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">interface</span> RunModeIdentifierService <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #008000; font-style: italic; font-weight: bold;">/**<br />
&nbsp; &nbsp; &nbsp;* @return runMode that is configured in the com.glob.sourcedcode.core.services.impl.RunModeIdentifierServiceImpl.cfg.json within it's run mode configuration folder.<br />
&nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; <span style="color: #003399;">String</span> getRunMode<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<hr class="spacer-large" />
<h3>B. Create an implementation for your RunModeIdentifierService</h3>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.glob.sourcedcode.core.services.impl</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.glob.sourcedcode.core.services.RunModeIdentifierService</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.osgi.service.component.annotations.Activate</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.osgi.service.component.annotations.Component</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.osgi.service.metatype.annotations.AttributeDefinition</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.osgi.service.metatype.annotations.AttributeType</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.osgi.service.metatype.annotations.Designate</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.osgi.service.metatype.annotations.ObjectClassDefinition</span><span style="color: #339933;">;</span><br />
<br />
@<span style="color: #003399;">Component</span><span style="color: #009900;">&#40;</span>service <span style="color: #339933;">=</span> RunModeIdentifierService.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><br />
@Designate<span style="color: #009900;">&#40;</span>ocd <span style="color: #339933;">=</span> RunModeIdentifierServiceImpl.<span style="color: #006633;">Config</span>.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> RunModeIdentifierServiceImpl <span style="color: #000000; font-weight: bold;">implements</span> RunModeIdentifierService <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; @ObjectClassDefinition<span style="color: #009900;">&#40;</span>name <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Run Mode Identifier Service&quot;</span>, description <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;This service is used to identify the run mode which this context is currently running on.&quot;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> @<span style="color: #000000; font-weight: bold;">interface</span> Config <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; @AttributeDefinition<span style="color: #009900;">&#40;</span>name <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Run Mode&quot;</span>, description <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;The current run mode identifier for this current context e.g. &quot;</span>development<span style="color: #0000ff;">&quot;,&quot;</span>staging<span style="color: #0000ff;">&quot;,&quot;</span>production<span style="color: #0000ff;">&quot;&quot;</span>, type <span style="color: #339933;">=</span> AttributeType.<span style="color: #006633;">STRING</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">String</span> runMode<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">default</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> runMode<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; @Activate<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> active<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">final</span> Config config<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; runMode <span style="color: #339933;">=</span> config.<span style="color: #006633;">runMode</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; @Override<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> getRunMode<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> runMode<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<hr class="spacer-large" />
<h3>C. Create 3 configuration files, and place them under the run mode configuration folders</h3>
<p>/apps/sourcedcode/config.development/com.sonova.advancedbionics.core.services.impl.RunModeIdentifierServiceImpl.cfg.json</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #009900;">&#123;</span><br />
&nbsp; <span style="color: #0000ff;">&quot;runMode&quot;</span><span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;development&quot;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>/apps/sourcedcode/config.staging/com.sonova.advancedbionics.core.services.impl.RunModeIdentifierServiceImpl.cfg.json</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #009900;">&#123;</span><br />
&nbsp; <span style="color: #0000ff;">&quot;runMode&quot;</span><span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;staging&quot;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>/apps/sourcedcode/config.production/com.sonova.advancedbionics.core.services.impl.RunModeIdentifierServiceImpl.cfg.json</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #009900;">&#123;</span><br />
&nbsp; <span style="color: #0000ff;">&quot;runMode&quot;</span><span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;production&quot;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<hr class="spacer-large" />
<h3>D. Example Sling Model using the RunModeIdentifierService</h3>
<p>And finally, in this example, we are using the @OSGiService RunModeIdentifierService that calls runModeIdentifierService.getRunMode(), which returns the correct value set in com.sonova.advancedbionics.core.services.impl.RunModeIdentifierServiceImpl.cfg.json for the given run mode folder, /apps/sourcedcode/config.${runmode-folder}</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.glob.sourcedcode.core.internal.models</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.adobe.cq.export.json.ExporterConstants</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.fasterxml.jackson.annotation.JsonGetter</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.glob.sourcedcode.core.services.RunModeIdentifierService</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.glob.base.core.components.util.AbstractComponentImpl</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.SlingHttpServletRequest</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.models.annotations.DefaultInjectionStrategy</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.models.annotations.Exporter</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.models.annotations.Model</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.models.annotations.injectorspecific.OSGiService</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.annotation.PostConstruct</span><span style="color: #339933;">;</span><br />
<br />
@Model<span style="color: #009900;">&#40;</span>adaptables <span style="color: #339933;">=</span> SlingHttpServletRequest.<span style="color: #000000; font-weight: bold;">class</span>, resourceType <span style="color: #339933;">=</span> ExampleComponentImpl.<span style="color: #006633;">RESOURCE_TYPE</span>, defaultInjectionStrategy <span style="color: #339933;">=</span> DefaultInjectionStrategy.<span style="color: #006633;">OPTIONAL</span><span style="color: #009900;">&#41;</span><br />
@Exporter<span style="color: #009900;">&#40;</span>name <span style="color: #339933;">=</span> ExporterConstants.<span style="color: #006633;">SLING_MODEL_EXPORTER_NAME</span>, extensions <span style="color: #339933;">=</span> ExporterConstants.<span style="color: #006633;">SLING_MODEL_EXTENSION</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ExampleComponentImpl <span style="color: #000000; font-weight: bold;">extends</span> AbstractComponentImpl <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">String</span> RESOURCE_TYPE <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;sourcedcode/components/examplecomponent&quot;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> runMode<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; @OSGiService<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> RunModeIdentifierService runModeIdentifierService<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; @PostConstruct<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> init<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; runMode <span style="color: #339933;">=</span> runModeIdentifierService.<span style="color: #006633;">getRunMode</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; @JsonGetter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;runMode&quot;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #003399;">String</span> getRunMode<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> runMode<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/checking-run-mode-from-sightly-htl-in-aem-in-2023">Checking run mode from Sightly HTL in AEM in 2023</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/checking-run-mode-from-sightly-htl-in-aem-in-2023/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Set AEM Local Environment and Secret Variables AEMaaCS</title>
		<link>https://sourcedcode.com/blog/aem/set-aem-local-environment-and-secret-variables-aemaacs</link>
					<comments>https://sourcedcode.com/blog/aem/set-aem-local-environment-and-secret-variables-aemaacs#comments</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Thu, 30 Mar 2023 00:39:10 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[AEMaaCS]]></category>
		<category><![CDATA[Development]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=4545</guid>

					<description><![CDATA[<p>As an AEM developer developing for the AEMaaCS SDK, it&#8217;s essential to have a local environment properly set up for development purposes. You may encounter environment-specific and secret variables in your OSGI configuration files. As an AEM developer trying to familiarize new features of the AEMaaCS SDK development environment, setting up environment-specific and secret variables [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/set-aem-local-environment-and-secret-variables-aemaacs">Set AEM Local Environment and Secret Variables AEMaaCS</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>As an AEM developer developing for the AEMaaCS SDK, it&#8217;s essential to have a local environment properly set up for development purposes. You may encounter environment-specific and secret variables in your OSGI configuration files. As an AEM developer trying to familiarize new features of the AEMaaCS SDK development environment, setting up environment-specific and secret variables is non-trivial at first. Once you have done it once, it will be much easier to move forward. </p>
<p>In this article, I will show you how to set up environment-specific and secret variables. If you would like to understand when to use environment-specific and secret variables effectively, check out the official AEM Adobe git documentation. At the end of this article, you are equipped to run your AEM local development environment with environment-specific and secret variables!</p>
<p>One last thing, it looks like only AEMaaCS SDK has environment-specific and secret variables feature enabled for OSGI configurations.</p>
<hr class="spacer-large"/>
<h5>Examples of what OSGI configurations would look like with environment and secret variables set in your code base:</h5>
<p><strong>Environment-specific variable</strong><br />
high-level use-case: Values that are specific to a particular environment and may vary between different development environments cannot be targeted accurately by run mode, as AEMaaCS only has a single development run mode. For instance:</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #3366CC;">&quot;url&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;$[env:SERVER_API_URL]&quot;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p><strong>Secret variable</strong><br />
high-level use-case: Sensitive information, such as confidential data or authentication credentials, should not be stored in Git repositories due to security concerns. For instance:</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #3366CC;">&quot;api-key&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;$[secret:SERVER_API_KEY]&quot;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>Example of an OSGI configuration with the combination of the environment-specific and secret variables being used:</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #3366CC;">&quot;connection.timeout&quot;</span><span style="color: #339933;">:</span> <span style="color: #CC0000;">1000</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp;<span style="color: #3366CC;">&quot;api-key&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;$[secret:SERVER_API_KEY]&quot;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp;<span style="color: #3366CC;">&quot;url&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;$[env:SERVER_API_URL]&quot;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<div class="mention-block">
Please note that environment-specific and secret variables allow defaults, so if your environment is not set up properly with the right configuration, it will use the default settings.</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #3366CC;">&quot;connection.timeout&quot;</span><span style="color: #339933;">:</span> <span style="color: #CC0000;">1000</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp;<span style="color: #3366CC;">&quot;api-key&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;$[secret:SERVER_API_KEY;default=https://api.sourcedcode.com&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #3366CC;">&quot;,<br />
&nbsp; &nbsp;&quot;</span>url<span style="color: #3366CC;">&quot;: &quot;</span>$<span style="color: #009900;">&#91;</span>env<span style="color: #339933;">:</span>SERVER_API_URL<span style="color: #339933;">;</span><span style="color: #000066; font-weight: bold;">default</span><span style="color: #339933;">=</span>23u1kn1jbkjs789fds8f_ewrqasd<span style="color: #009900;">&#93;</span><span style="color: #3366CC;">&quot;<br />
}<br />
From the &lt;a href=&quot;</span>https<span style="color: #339933;">:</span><span style="color: #006600; font-style: italic;">//github.com/AdobeDocs/experience-manager-cloud-service.en/blob/main/help/implementing/deploying/configuring-osgi.md&quot; rel=&quot;noopener&quot; target=&quot;_blank&quot;&gt;documentation&lt;/a&gt;, it looks like only AEMaaCS has environment-specific and secret variables feature enabled for OSGI configurations.</span></div></td></tr></tbody></table></div>
</div>
<hr class="spacer-large"/>
<p>So how we can actually set these environments and secret variables into AEM? Well, it&#8217;s simple. We will be using a Linux environment to set this up. In the examples below, we will be setting up one environment-specific variable and one secret variable.</p>
<ul>
<li>$[env:SERVER_API_URL]</li>
<li>$[secret:SERVER_API_KEY]</li>
</ul>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #3366CC;">&quot;connection.timeout&quot;</span><span style="color: #339933;">:</span> <span style="color: #CC0000;">1000</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp;<span style="color: #3366CC;">&quot;url&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;$[env:SERVER_API_URL]&quot;</span><br />
&nbsp; &nbsp;<span style="color: #3366CC;">&quot;api-key&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;$[secret:SERVER_API_KEY]&quot;</span><span style="color: #339933;">,</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<hr class="spacer-large"/>
<h2>1. set AEM Environment variables on local AEM instance</h2>
<ol>
<li>Close down your local AEM environment.</li>
<li>open git bash or terminal.</li>
<li>cd to the AEM folder, where the executable jar file exists.</li>
<li>run <span class="code-highlight-primary">export SERVER_API_URL=https://api.sourcedcode.com</span></li>
<li>run <span class="code-highlight-primary">echo ${SERVER_API_URL}</span>// you should see the environment variable being set as this call will echo out what the environment variable is for SERVER_API_URL.</li>
<li>now restart your local AEM environment.</li>
<li>done.</li>
</ol>
<hr class="spacer-large"/>
<h2>2. set AEM Secret variables on local AEM instance</h2>
<ol>
<li>Close down your local AEM environment.</li>
<li>open git bash or terminal.</li>
<li>cd to the AEM folder, where the executable jar file exists.</li>
<li>run <span class="code-highlight-primary">vim ./crx-quickstart/conf/quickstart.properties</span></li>
<li>add this to the last line <span class="code-highlight-primary">org.apache.felix.configadmin.plugin.interpolation.secretsdir=${sling.home}/secretsdir</span></li>
<li>save in vim.</li>
<li>run <span class="code-highlight-primary">mkdir ./crx-quickstart/secretsdir</span></li>
<li>run <span class="code-highlight-primary">cd ./crx-quickstart/secretsdir</span></li>
<li>run <span class="code-highlight-primary">echo &#8220;23u1kn1jbkjs789fds8f_ewrqasd&#8221; > SERVER_API_KEY</span></li>
<li>repeat the step-9 to add more secret variables into your AEM local environment. run <span class="code-highlight-primary">echo &#8220;secret_value&#8221; > secret_key</span></li>
<li>You may have more than 1 secret variable stored in the secretsdir folder: <a href="https://sourcedcode.com/wp-content/uploads/2023/03/secretsdir.png"><img decoding="async" src="https://sourcedcode.com/wp-content/uploads/2023/03/secretsdir.png" alt="Example of showing many instances of secret variables declared" width="50%" height="auto" class="alignnone size-full wp-image-4569" srcset="https://sourcedcode.com/wp-content/uploads/2023/03/secretsdir.png 890w, https://sourcedcode.com/wp-content/uploads/2023/03/secretsdir-300x75.png 300w, https://sourcedcode.com/wp-content/uploads/2023/03/secretsdir-768x192.png 768w, https://sourcedcode.com/wp-content/uploads/2023/03/secretsdir-600x150.png 600w" sizes="(max-width: 890px) 100vw, 890px" /></a></li>
<li>now restart your local AEM environment.</li>
<li>done.</li>
</ol>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/set-aem-local-environment-and-secret-variables-aemaacs">Set AEM Local Environment and Secret Variables AEMaaCS</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/set-aem-local-environment-and-secret-variables-aemaacs/feed</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
		<item>
		<title>AEM Sightly Component(s) Empty CQ PlaceHolder</title>
		<link>https://sourcedcode.com/blog/aem/aem-sightly-components-empty-cq-placeholder</link>
					<comments>https://sourcedcode.com/blog/aem/aem-sightly-components-empty-cq-placeholder#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Sat, 25 Feb 2023 21:55:28 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Sightly]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=4453</guid>

					<description><![CDATA[<p>In almost all cases, component&#8217;s that are not configured, dragged onto the page should have some sort of indicator telling content authors that they should configure the component; a few of us calls this the empty component placeholder or &#8220;cq-placeholder&#8221;. A novice AEM full-stack may not be geared with the right tools, and so they [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/aem-sightly-components-empty-cq-placeholder">AEM Sightly Component(s) Empty CQ PlaceHolder</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>In almost all cases, component&#8217;s that are not configured, dragged onto the page should have some sort of indicator telling content authors that they should configure the component; a few of us calls this the empty component placeholder or &#8220;cq-placeholder&#8221;. A novice AEM full-stack may not be geared with the right tools, and so they add unnecessary Sightly HTL code into the .html file, and try to create this indicator experience. Let&#8217;s not re-create the wheel. There&#8217;s actually an Adobe way to create the &#8220;placeholder&#8221; AEM component experience. This is using the Adobe WCM Core Component&#8217;s &#8220;core/wcm/components/commons/v1/templates.html” script; what exactly is the &#8220;core/wcm/components/commons/v1/templates.html”?</p>
<p>In the <a href="https://github.com/adobe/aem-core-wcm-components" rel="noopener" target="_blank">Adobe Core Component&#8217;s Library</a>, you will be able to find this particular file &#8220;<a href="https://github.com/adobe/aem-core-wcm-components/blob/main/content/src/content/jcr_root/apps/core/wcm/components/commons/v1/templates.html" rel="noopener" target="_blank">core/wcm/components/commons/v1/templates.html</a>&#8220;. This file is a template that renders an HTML element on the page with the &#8220;cq-placeholder&#8221; cssClass that makes the rendered element on the page look something like this.</p>
<p><a href="https://sourcedcode.com/wp-content/uploads/2023/02/screenshot-placeholder-teaser-normal.png"><img loading="lazy" decoding="async" src="https://sourcedcode.com/wp-content/uploads/2023/02/screenshot-placeholder-teaser-normal.png" alt="Screenshot of the place holder using core/wcm/components/commons/v1/templates.html" width="1106" height="274" class="alignnone size-full wp-image-4478" srcset="https://sourcedcode.com/wp-content/uploads/2023/02/screenshot-placeholder-teaser-normal.png 1106w, https://sourcedcode.com/wp-content/uploads/2023/02/screenshot-placeholder-teaser-normal-300x74.png 300w, https://sourcedcode.com/wp-content/uploads/2023/02/screenshot-placeholder-teaser-normal-1024x254.png 1024w, https://sourcedcode.com/wp-content/uploads/2023/02/screenshot-placeholder-teaser-normal-768x190.png 768w, https://sourcedcode.com/wp-content/uploads/2023/02/screenshot-placeholder-teaser-normal-600x149.png 600w" sizes="(max-width: 1106px) 100vw, 1106px" /></a></p>
<p>When we inspect the <a href="https://github.com/adobe/aem-core-wcm-components/blob/main/content/src/content/jcr_root/apps/core/wcm/components/commons/v1/templates.html" rel="noopener" target="_blank">Adobe code</a>, you will see the sightly HTL code as like this:</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #339933;">&lt;</span>sly data<span style="color: #339933;">-</span>sly<span style="color: #339933;">-</span>template.<span style="color: #006633;">placeholder</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;${@ isEmpty, classAppend, emptyTextAppend}&quot;</span><span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>div data<span style="color: #339933;">-</span>sly<span style="color: #339933;">-</span>test<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;${(wcmmode.edit || wcmmode.preview) &amp;&amp; isEmpty}&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;cq-placeholder ${classAppend}&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;data<span style="color: #339933;">-</span>emptytext<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;${component.properties.jcr:title}${emptyTextAppend &amp;&amp; ' - '}${emptyTextAppend}&quot;</span><span style="color: #339933;">&gt;&lt;/</span>div<span style="color: #339933;">&gt;</span><br />
<span style="color: #339933;">&lt;/</span>sly<span style="color: #339933;">&gt;</span></div></td></tr></tbody></table></div>
<p>We understand that we are using Sightly HTL Version: 1.4; where this version enables the feature &#8220;template &#038; calls&#8221;, and templates. From the code above, you can see that &#8220;core/wcm/components/commons/v1/templates.html&#8221; is a Sightly template, and its main purpose is to be called via &#8220;data-sly-use&#8221;. Line-1: This template accepts 3 parameters: isEmpty, classAppend, emptyTextAppend. Line-2: This template is declaring a new div, and <span style="color: red;">only rendered when (edit or preview mode) and isEmpty = true</span>. Line-3: This appends the cq-placeholder cssClass for this &lt;div&gt;, and include custom ${classAppend} if exists. Finally Line-4: renders the resource&#8217;s component.properties.jcr:title (component who calls this script) on the screen, and also appends ${emptyTextAppend} to the cq-placeholder&#8217;s text if present.</p>
<div class="mention-block">
<strong>core/wcm/components/commons/v1/templates.html accepts 3 parameters:</strong></p>
<ul>
<li>isEmpty: This value must be a boolean, which true will force the cq-template to appear.</li>
<li>classAppend: This value must be a string, where it will be appended to the rendered HTML cq-placeholder.</li>
<li>emptyTextAppend: This value must be a string, where text will be appended into the cq-placeholder.</li>
</ul>
</div>
<hr class="spacer-larger" />
<h2>Examples:</h2>
<p>&nbsp;</p>
<h3>1. Basic call example to &#8220;core/wcm/components/commons/v1/templates.html&#8221;</h3>
<p>In this example, you can see us calling the Sling Model backend &#8220;com.sourcedcode.core.components.models.Teaser&#8221;, and capturing the Sling Model in a &#8220;model&#8221; variable. Line-3, we understand that the templates.html is accepting the &#8220;isEmpty&#8221; parameter. The &#8220;isEmpty&#8221; parameter is evaluated with &#8220;!model.titleText&#8221; (this means if the model.titleText is empty or null it will return true). When &#8220;isEmpty&#8221; is true, then the cq-placeholder will be rendered, and if false. It will never be rendered.</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #339933;">&lt;</span>sly data<span style="color: #339933;">-</span>sly<span style="color: #339933;">-</span>use.<span style="color: #006633;">model</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;com.sourcedcode.core.components.models.Teaser&quot;</span><span style="color: #339933;">/&gt;</span><br />
<span style="color: #339933;">&lt;</span>sly data<span style="color: #339933;">-</span>sly<span style="color: #339933;">-</span>use.<span style="color: #006633;">template</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;core/wcm/components/commons/v1/templates.html&quot;</span> <br />
&nbsp; &nbsp; &nbsp;data<span style="color: #339933;">-</span>sly<span style="color: #339933;">-</span>call<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;${template.placeholder @ isEmpty=!model.titleText}&quot;</span><span style="color: #339933;">&gt;&lt;/</span>sly<span style="color: #339933;">&gt;</span></div></td></tr></tbody></table></div>
<p><a href="https://sourcedcode.com/wp-content/uploads/2023/02/screenshot-placeholder-teaser-normal.png"><img loading="lazy" decoding="async" src="https://sourcedcode.com/wp-content/uploads/2023/02/screenshot-placeholder-teaser-normal.png" alt="Screenshot of the place holder using core/wcm/components/commons/v1/templates.html" width="1106" height="274" class="alignnone size-full wp-image-4478" srcset="https://sourcedcode.com/wp-content/uploads/2023/02/screenshot-placeholder-teaser-normal.png 1106w, https://sourcedcode.com/wp-content/uploads/2023/02/screenshot-placeholder-teaser-normal-300x74.png 300w, https://sourcedcode.com/wp-content/uploads/2023/02/screenshot-placeholder-teaser-normal-1024x254.png 1024w, https://sourcedcode.com/wp-content/uploads/2023/02/screenshot-placeholder-teaser-normal-768x190.png 768w, https://sourcedcode.com/wp-content/uploads/2023/02/screenshot-placeholder-teaser-normal-600x149.png 600w" sizes="(max-width: 1106px) 100vw, 1106px" /></a></p>
<hr class="spacer-larger" />
<h3>2. Second example to &#8220;core/wcm/components/commons/v1/templates.html&#8221;</h3>
<p>In this example, Line-3, you will notice that model.titleText &#038;&#038; model.descriptionText are being evaluated, and must not be null or empty. If the evaluation of isEmpty is true, cq-placeholder will be visible.</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #339933;">&lt;</span>sly data<span style="color: #339933;">-</span>sly<span style="color: #339933;">-</span>use.<span style="color: #006633;">model</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;com.sourcedcode.core.components.models.Teaser&quot;</span><span style="color: #339933;">/&gt;</span><br />
<span style="color: #339933;">&lt;</span>sly data<span style="color: #339933;">-</span>sly<span style="color: #339933;">-</span>use.<span style="color: #006633;">template</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;core/wcm/components/commons/v1/templates.html&quot;</span> <br />
&nbsp; &nbsp; &nbsp;data<span style="color: #339933;">-</span>sly<span style="color: #339933;">-</span>call<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;${template.placeholder @ isEmpty=!(model.titleText &amp;&amp; model.descriptionText)}&quot;</span><span style="color: #339933;">&gt;&lt;/</span>sly<span style="color: #339933;">&gt;</span></div></td></tr></tbody></table></div>
<p><a href="https://sourcedcode.com/wp-content/uploads/2023/02/screenshot-placeholder-teaser-normal.png"><img loading="lazy" decoding="async" src="https://sourcedcode.com/wp-content/uploads/2023/02/screenshot-placeholder-teaser-normal.png" alt="Screenshot of the place holder using core/wcm/components/commons/v1/templates.html" width="1106" height="274" class="alignnone size-full wp-image-4478" srcset="https://sourcedcode.com/wp-content/uploads/2023/02/screenshot-placeholder-teaser-normal.png 1106w, https://sourcedcode.com/wp-content/uploads/2023/02/screenshot-placeholder-teaser-normal-300x74.png 300w, https://sourcedcode.com/wp-content/uploads/2023/02/screenshot-placeholder-teaser-normal-1024x254.png 1024w, https://sourcedcode.com/wp-content/uploads/2023/02/screenshot-placeholder-teaser-normal-768x190.png 768w, https://sourcedcode.com/wp-content/uploads/2023/02/screenshot-placeholder-teaser-normal-600x149.png 600w" sizes="(max-width: 1106px) 100vw, 1106px" /></a></p>
<hr class="spacer-larger" />
<h3>3. Third example to &#8220;core/wcm/components/commons/v1/templates.html&#8221;</h3>
<p>In this example, Line-3, notice that we are using other parameters to construct the cq-placeholder; classAppend, where we are passing in cmp-teaser as a customCSSClass. Line-4, we are utilizing the parameter, emptyTextAppend, where we can add custom description to the cq-placeholder. The expected behavior here is, when the evaluation of isEmpty is true, we expect to see the rendered cq-placeholder with some description test. See the screenshot below for an example.</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #339933;">&lt;</span>sly data<span style="color: #339933;">-</span>sly<span style="color: #339933;">-</span>use.<span style="color: #006633;">model</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;com.sourcedcode.core.components.models.Teaser&quot;</span><span style="color: #339933;">&gt;&lt;/</span>sly<span style="color: #339933;">&gt;</span><br />
<span style="color: #339933;">&lt;</span>sly data<span style="color: #339933;">-</span>sly<span style="color: #339933;">-</span>use.<span style="color: #006633;">template</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;core/wcm/components/commons/v1/templates.html&quot;</span> <br />
&nbsp; &nbsp; &nbsp;data<span style="color: #339933;">-</span>sly<span style="color: #339933;">-</span>call<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;${template.placeholder @ isEmpty=!(model.titleText &amp;&amp; model.descriptionText), classAppend='cmp-teaser', <br />
&nbsp; &nbsp; &nbsp;emptyTextAppend='This component must be configured'}&quot;</span><span style="color: #339933;">&gt;&lt;/</span>sly<span style="color: #339933;">&gt;</span></div></td></tr></tbody></table></div>
<p><a href="https://sourcedcode.com/wp-content/uploads/2023/02/screenshot-placeholder-teaser-custom-description.png"><img loading="lazy" decoding="async" src="https://sourcedcode.com/wp-content/uploads/2023/02/screenshot-placeholder-teaser-custom-description.png" alt="Screenshot of the place holder using core/wcm/components/commons/v1/templates.html with custom description" width="1070" height="328" class="alignnone size-full wp-image-4468" srcset="https://sourcedcode.com/wp-content/uploads/2023/02/screenshot-placeholder-teaser-custom-description.png 1070w, https://sourcedcode.com/wp-content/uploads/2023/02/screenshot-placeholder-teaser-custom-description-300x92.png 300w, https://sourcedcode.com/wp-content/uploads/2023/02/screenshot-placeholder-teaser-custom-description-1024x314.png 1024w, https://sourcedcode.com/wp-content/uploads/2023/02/screenshot-placeholder-teaser-custom-description-768x235.png 768w, https://sourcedcode.com/wp-content/uploads/2023/02/screenshot-placeholder-teaser-custom-description-600x184.png 600w" sizes="(max-width: 1070px) 100vw, 1070px" /></a></p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/aem-sightly-components-empty-cq-placeholder">AEM Sightly Component(s) Empty CQ PlaceHolder</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/aem-sightly-components-empty-cq-placeholder/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>AEM Developers Courses 2023 That Really Helped Me</title>
		<link>https://sourcedcode.com/blog/aem/aem-developers-courses-2023-that-really-helped-me</link>
					<comments>https://sourcedcode.com/blog/aem/aem-developers-courses-2023-that-really-helped-me#comments</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Wed, 22 Feb 2023 00:00:55 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Development]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=3913</guid>

					<description><![CDATA[<p>There are a couple of courses that I would like to share that have really helped me, not just in interviews, but also in my daily AEM development regime. In my opinion, I think these are the best courses for anyone who is either getting started as an AEM developer or who is already working [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/aem-developers-courses-2023-that-really-helped-me">AEM Developers Courses 2023 That Really Helped Me</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>There are a couple of courses that I would like to share that have really helped me, not just in interviews, but also in my daily AEM development regime. In my opinion, I think these are the best courses for anyone who is either getting started as an AEM developer or who is already working as an AEM developer for more than 2+ years. Even right now, today, since I started my AEM career in 2015, this course by far has really helped me by re-aligning AEM concepts and AEM development practices that are not in my every AEM development cycle. At the bottom of this article, take a look at the reasons <a href="#how-this-course-helped-me">how this course helped me</a>.</p>
<p>I believe any AEM developers at any level will benefit from these courses.</p>
<p>I put together a <span class="code-highlight-secondary"><strong>course roadmap, step by step</strong></span>, that you should follow, to really help you learn. <span class="code-highlight-secondary">You should step through each and every course from 1&#8230;the-end-of-the-table-of-contents</span>; I recommend this order. All these courses are offered by Plural Sight. Plural Sightly is a paid company that offers online video training courses for software developers, IT administrators, and creative professionals. If you subscribe to their training services, you will obtain more than just the courses I am listing below. </p>
<p>I did have a look at the udemy.com AEM courses. From my analysis, the udemy.com courses do not provide the same level of detail as the Plural Sight&#8217;s online training videos; udemy.com provides extremely high-level concepts with training material that does not include too many follow-me-code tutorials. So, I really appreciate the content that Plural Sight is offering, and it will really help any level of AEM developers refresh or upgrade their skills. If you use Plural Sight, you will not only get access to every AEM course listed below, but other technical courses that suits your needs.<!-- At the end of this article, you will find, "other helpful resources", which will link to other resources that you should checkout after you step through 1...the-end-of-the-table-of-contents. !--></p>
<ul>
<li><a href="#fundamentals-of-building-from-projects-in-aem">1. Fundamentals of Building from Projects in AEM</a></li>
<li><a href="#extending-adobe-experience-manager-foundations-backend">2. Fundamentals of Extending Adobe Experience Manager &#8211; Backend</a></li>
<li><a href="#develop-websites-and-components-in-adobe-experience-manager">3. Develop Websites and Components in Adobe Experience Manager</a></li>
<li><a href="#develop-websites-and-components-in-adobe-experience-manager-advanced">4. Develop Websites and Components in Adobe Experience Manager Advanced</a></li>
<li><a href="#extending-adobe-experience-manager-advanced">5. Extending Adobe Experience Manager Advanced</a></li>
<li><a href="#introduction-advanced-dialogs-with-granite-ui">6. Introduction &#038; Advanced Dialogs with Granite UI</a></li>
<li><a href="#aem-building-full-stack-components">7. AEM Building Full Stack Components</a></li>
<li><a href="#additional=resources">Additional Resources</a></li>
<li><a href="#how-this-course-helped-me">How this course helped me</a></li>
</ul>
<div class="mention-block" style="text-align:center">
The courses below are all <strong>PAID</strong> only, but you can get a 10-day free trial today from my affiliate link here, <a href="https://bit.ly/3DYcJw6" rel="noopener" target="_blank">Get PluralSight 10 Days for Free</a>.
</div>
<hr class="spacer-large" />
<h3 id="fundamentals-of-building-from-projects-in-aem">1. Fundamentals of Building from Projects in AEM</h3>
<p><strong>Course Length: (3.5hrs)</strong><br />
This course will teach you how to build and debug Adobe Experience Manager (AEM) packages and how you can use them to import and export content to and from AEM&#8217;s Java Content Repository (JCR.) Software required: Adobe Experience Manager, Maven.</p>
<p>This course includes learning of:</p>
<ul>
<li>Fundamentals of building projects in AEM</li>
<li>Pushing code and content into AEM with import and export</li>
<li>Building AEM projects with Maven</li>
<li>Understanding Maven pom.xml</li>
<li>Setting up IDE environments like IntelliJ and Eclipse</li>
<li>Enable AEM for debug mode with IntelliJ or Eclipse</li>
<li>Understanding what is happening with code and content is built in AEM</li>
<li>Working with the content package manager and content packages via filters</li>
<li>Fundamentals of OSGI cofigurations</li>
</ul>
<p><a href="https://pluralsight.pxf.io/5bVb2o" rel="noopener" target="_blank">https://www.pluralsight.com/courses/aem-fundamentals-building-projects</a></p>
<hr class="spacer-large" />
<h3 id="extending-adobe-experience-manager-foundations-backend">2. Fundamentals Extending Adobe Experience Manager &#8211; Backend</h3>
<p><strong>Course Length: (2hrs)</strong><br />
This course is extending #1 Fundamentals of Building from Projects in AEM. This course is ideal for backend developers and focuses on developing services, servlets, and jobs in AEM. This course is retired, but it does have some concepts that I think AEM developers should understand.</p>
<p>This course includes learning of:</p>
<ul>
<li>What exactly is AEM</li>
<li>Introduction of the OSGI Framework</li>
<li>Introduction to the Java Content Repository (JCR)</li>
<li>Introduction to Apache Sling</li>
<li>Introduction to Granite UI (Touch UI)</li>
<li>Installing AEM Locally</li>
<li>Introduction to AEM Run modes</li>
<li>Introduction to AEM Package Manager</li>
<li>Introduction to OSGI Services (backend)</li>
<li>Introduction to AEM Configuration</li>
</ul>
<p><a href="https://pluralsight.pxf.io/6bJyob" rel="noopener" target="_blank">https://www.pluralsight.com/courses/extending-aem-foundations</a></p>
<hr class="spacer-large" />
<h3 id="develop-websites-and-components-in-adobe-experience-manager">3. Develop Websites and Components in Adobe Experience Manager</h3>
<p><strong>Course Length: (3.5hrs)</strong><br />
This course will teach you the basics for developing websites using AEM, including structure component development, understanding Apache Sling and the JCR, and using HTL.</p>
<p>This course includes learning of:</p>
<ul>
<li>The architecture and overview of AEM and it&#8217;s technical stack</li>
<li>Concepts of JCR and Apache Sling</li>
<li>Development tools in AEM; like CRX/DE</li>
<li>Introduction to AEM JCR</li>
<li>Introduction to AEM content rendering</li>
<li>Basic AEM templates</li>
<li>Basic AEM content &#038; structure components with Sightly</li>
<li>Basic AEM component inheritance</li>
<li>Basic AEM touch UI</li>
<li>Basic AEM design dialog</li>
<li>Basic AEM logging</li>
</ul>
<p><a href="https://pluralsight.pxf.io/RykGmR" rel="noopener" target="_blank">https://www.pluralsight.com/courses/develop-websites-components-aem</a></p>
<hr class="spacer-large" />
<p><!-- 

<div class="mention-block">
The courses below are all <strong>PAID</strong> only, but you can get a 10-day free trial today from my affiliate link here, <a href="https://bit.ly/3DYcJw6" rel="noopener" target="_blank">Get PluralSight 10 Days for Free</a>. 10 days completely free!</div>

 !--></p>
<div class="mention-block" style="text-align:center">
The courses below are all <strong>PAID</strong> only, but you can get a 10-day free trial today from my affiliate link here, <a href="https://bit.ly/3DYcJw6" rel="noopener" target="_blank">Get PluralSight 10 Days for Free</a>.
</div>
<hr class="spacer-large" />
<h3 id="develop-websites-and-components-in-adobe-experience-manager-advanced">4. Develop Websites and Components in Adobe Experience Manager Advanced</h3>
<p><strong>Course Length: (3.5hrs)</strong><br />
This course teaches you the advanced methods for developing websites, including using AEM&#8217;s responsive grid, advanced content component development, debugging, and testing.</p>
<p>In this course, I recommend to skip the &#8220;Using Brackets for Developmment&#8221;, because this IDE is not as efficient than Visual Studio Code and IntelliJ, in my opinion.</p>
<p>This course includes learning of:</p>
<ul>
<li>Introduction of response design in AEM</li>
<li>Introduction of the responsive grid layout</li>
<li>Introduction of response design in AEM</li>
<li>AEM sling selectors with components</li>
<li>Handling AEM 404 error pages</li>
<li>AEM sling redirects</li>
<li>AEM translations via internalization (i18n)</li>
<li>Touch UI dialogs</li>
<li>Creating AEM Component with intermediate concepts</li>
<li>Creating AEM Component with advanced concepts</li>
<li>Concepts for AEM client libraries</li>
<li>Client Libraries</li>
<li>Backend Core: JCR Search API</li>
<li>Frontend asynchronous development with AEM components</li>
<li>Testing and debugging AEM components</li>
</ul>
<p><a href="https://pluralsight.pxf.io/4e1Gor" rel="noopener" target="_blank">https://www.pluralsight.com/courses/develop-websites-components-aem-advanced</a></p>
<hr class="spacer-large" />
<h3 id="extending-adobe-experience-manager-advanced">5. Extending Adobe Experience Manager Advanced</h3>
<p><strong>Course Length: (6hrs)</strong><br />
This course is an extension of #4, developing AEM websites and components (advanced). This course includes advanced methods for developing websites, including using AEM&#8217;s backend offerings like: content migration, AEM Workflows, OSG backend services and servlets, and unit testing.<br />
This course includes learning of:</p>
<ul>
<li>Configuration of your development environemnt</li>
<li>OSGI Overview and Deep Dive</li>
<li>OSGI advanced concepts like annotations, bundle activator, create and use custom services, code OSGI configurations</li>
<li>Deep dive into the Apache Sling Framework</li>
<li>Concepts of Sling Architecture, system users, sling servlets, sling resolution process</li>
<li>Backend event handling</li>
<li>Advanced concepts for the JCR</li>
<li>JCR Model, event handling, observation listener</li>
<li>Search: configuration of indexes, using AEM indexing tools, and query synax</li>
<li>Search: creation of an AEM search servlet</li>
<li>Polling importers</li>
<li>AEM Workflows: workflow models, workflow steps, workflow launchers</li>
<li>Programically create pages and assets in AEM</li>
<li>Programically creating a website in AEM</li>
<li>Unit testing with JUNIT for AEM backend</li>
<li>Understanding AEM content ingestion and migration</li>
<li>User permissions and groups</li>
</ul>
<p><a href="https://pluralsight.pxf.io/NKr94b" rel="noopener" target="_blank">https://www.pluralsight.com/courses/extending-aem-advanced</a></p>
<hr class="spacer-large" />
<div class="mention-block" style="text-align:center">
The courses below are all <strong>PAID</strong> only, but you can get a 10-day free trial today from my affiliate link here, <a href="https://bit.ly/3DYcJw6" rel="noopener" target="_blank">Get PluralSight 10 Days for Free</a>.
</div>
<hr class="spacer-large" />
<h3 id="introduction-advanced-dialogs-with-granite-ui">6. Introduction &#038; Advanced Dialogs with Granite UI</h3>
<p><strong>Course Length: (2hrs)</strong><br />
This course will teach you to build AEM dialogs &#038; custom AEM dialogs, including Granite UI, understand dialog node structure, apply input validation, and tracing input back to AEM&#8217;s JCR.<br />
This course includes learning of:</p>
<ul>
<li>Introduction of Granite UI</li>
<li>Understanding the Granite UI documentation</li>
<li>Understanding the Granite UI on the server</li>
<li>Granite UI containers, layout, and multifield items</li>
<li>Migration from Coral2 to Coral3</li>
<li>Follow-me, building tab Granite UI components</li>
<li>Granite UI form fields such as checkbox, dropdown, etc&#8230;</li>
<li>Advanced Granite UI with custom Javascript validations</li>
<li>Introduction to Datasources</li>
<li>Follow-me, Datasource lists with ACS Commons</li>
</ul>
<p><a href="https://pluralsight.pxf.io/yR7q9b" rel="noopener" target="_blank">https://www.pluralsight.com/courses/adobe-experience-manager-advanced-dialogs-granite-ui</a></p>
<hr class="spacer-large" />
<h3 id="aem-building-full-stack-components">7. AEM Building Full Stack Components</h3>
<p><strong>Course Length: (2hrs)</strong><br />
Learn to leverage AEM&#8217;s rendering lifecycle to architect solutions based on designs. You&#8217;ll work with components, editable templates, and page properties to build content structures that are returned as JSON from an API endpoint.<br />
This course includes learning of:</p>
<ul>
<li>AEM Full Stack development introduction</li>
<li>Translating designs into AEM components</li>
<li>Building AEM Components from HTML Mockups</li>
<li>Static and Editable templates</li>
<li>Building an API Endpoint to Handle AJAX requests</li>
<li>Sling Servlets, Query Builder, and JSON</li>
<li>AEM components tying to backend servlets</li>
</ul>
<p><a href="https://www.pluralsight.com/courses/aem-building-full-stack-components?clickid=Sry1Gq1aYxyNWHQzKgxhwRaIUkDXadS2NTFuTo0&#038;irgwc=1&#038;mpid=3205385&#038;aid=7010a000001xAKZAA2&#038;utm_medium=digital_affiliate&#038;utm_campaign=3205385&#038;utm_source=impactradius" rel="noopener" target="_blank">https://www.pluralsight.com/courses/aem-building-full-stack-components</a></p>
<hr class="spacer-large" />
<h3 id="additional=resources">Additional Resources</h3>
<p>After completing all the steps above, enhance your learning with other training and resources on the web, specifically for AEM.</p>
<p><strong><a href="https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager-blogs/bg-p/adobe-experience-manager-blogs" rel="noopener" target="_blank">Adobe Experience Manager Forums</a></strong> &#8211; This is a platform created by Adobe to provide AEM knowledge to the public. This includes a community forum where AEM developers can share ideas, discuss problems, find new AEM technical blog articles, and much more. You can learn a lot here by reading about problems and how they are solved. This is a community that I stand by, and commit my own ideas, help answer AEM technical questions, and participate. <a href="https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager-blogs/bg-p/adobe-experience-manager-blogs" rel="noopener" target="_blank">https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager-blogs/bg-p/adobe-experience-manager-blogs</a></p>
<h5>More Video Training Series</h5>
<p>These are free online video training materials that the AEM community and I find very useful for learning &#038; reviewing AEM development practices. If you run through the entire playlist for each and every Youtube video playlist below, you should be reinforced, moving your way up to a best-in-class, AEM developer.</p>
<ul>
<li><a href="https://www.youtube.com/playlist?list=PLEaEQSM_Y4tmJjQICTFDm2lU5mNmd_Oar" rel="noopener" target="_blank"><strong>AEM Geeks</strong></a> &#8211; Strengthening your learning by reviewing <a href="https://www.youtube.com/playlist?list=PLEaEQSM_Y4tmJjQICTFDm2lU5mNmd_Oar" rel="no opener noopener" target="_blank">AEMGEEKS&#8217;s youtube AEM series</a>, <a href="https://www.youtube.com/playlist?list=PLEaEQSM_Y4tmJjQICTFDm2lU5mNmd_Oar" rel="noopener" target="_blank">https://www.youtube.com/playlist?list=PLEaEQSM_Y4tmJjQICTFDm2lU5mNmd_Oar</a>. AEMGeeks really did a great job by sharing full-stack AEM topics and should provide more knowledge. </li>
<li><a href="https://www.youtube.com/c/SGAEM/playlists" rel="noopener" target="_blank"><strong>SG AEM</strong></a> &#8211; This youtube channel offers easy-to-understand AEM full-stack web development tutorials that can help you fine-tune your AEM skills. <a href="https://www.youtube.com/c/SGAEM/playlists" rel="noopener" target="_blank">https://www.youtube.com/c/SGAEM/playlists</a></li>
</ul>
<hr class="spacer-large" />
<h3 id="how-this-course-helped-me">How this course helped me</h3>
<ul>
<li>Prepare for interviews. Before jumping into technical interviews, I would go all of the courses at 2x the speed. These courses help me review all the major technicalities of AEM. I would just watch all the videos starting from the fundamentals of building AEM web components &#038; services to advanced concepts and practices.</li>
<li>During my daily work regime, this course helped me re-align my AEM concepts and coding practices. After watching the videos, I understood exactly what AEM-specific technologies I was trying to re-align and was able to immediately start putting my knowledge the practice.</li>
<li>The easy-to-follow and understanding courses include the entire AEM technical stack, which refreshes my learning for AEM sites; regarding AEM sightly components, OSGI configurations, editable templates, touch UI, and more.</li>
</ul>
<style>
#custom_html-9 {display:none;}
</style>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/aem-developers-courses-2023-that-really-helped-me">AEM Developers Courses 2023 That Really Helped Me</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/aem-developers-courses-2023-that-really-helped-me/feed</wfw:commentRss>
			<slash:comments>38</slash:comments>
		
		
			</item>
		<item>
		<title>jackrabbit-filter: Filter root&#8217;s ancestor &#8216;/etc/mobile/groups&#8217;</title>
		<link>https://sourcedcode.com/blog/aem/jackrabbit-filter-filter-roots-ancestor-etc-mobile-groups</link>
					<comments>https://sourcedcode.com/blog/aem/jackrabbit-filter-filter-roots-ancestor-etc-mobile-groups#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Sat, 18 Feb 2023 02:34:20 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[AEMaaCS]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=4381</guid>

					<description><![CDATA[<p>A mobile emulator is a tool used to test how a website or application will appear and function on a mobile device. It allows developers to preview and test their mobile websites or applications without the need for an actual mobile device. There are several mobile emulators available for AEM, such as the iOS Simulator [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/jackrabbit-filter-filter-roots-ancestor-etc-mobile-groups">jackrabbit-filter: Filter root&#8217;s ancestor &#8216;/etc/mobile/groups&#8217;</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>A mobile emulator is a tool used to test how a website or application will appear and function on a mobile device. It allows developers to preview and test their mobile websites or applications without the need for an actual mobile device.</p>
<p>There are several mobile emulators available for AEM, such as the iOS Simulator and Android Emulator. These emulators simulate the functionality and appearance of mobile devices, allowing developers to test their websites or applications as if they were running on an actual device.</p>
<p>In AEM, the &#8220;/etc/mobile/groups&#8221; is a location where mobile groups are created and managed. Mobile groups are used to segment content for different mobile devices, such as smartphones and tablets. They allow you to configure and tailor your website or application for specific devices, optimizing the user experience for each device type.</p>
<p>Using the /etc/mobile/groups feature, you can create and manage different groups of mobile devices, set up rules for device detection, and define content for each group. This allows you to provide a tailored experience for users based on the device they are using.</p>
<p>When I tried to introduce a new mobile emulator under the path of ui.content/../etc/mobile/groups/sourcedcode, I was getting a big error:</p>
<hr />
<p><strong style="color:red">[ERROR]</strong> ValidationViolation: &#8220;jackrabbit-filter: Filter root&#8217;s ancestor &#8216;/etc/mobile/groups&#8217; is not covered by any of the specified dependencies nor a valid root.&#8221;, filePath=META-INF/vault/filter.xml<br />
<strong style="color:orange">[INFO]</strong> ValidationViolation: &#8220;jackrabbit-filter: Found orphaned filter entries: entry with root &#8216;/etc/mobile/groups/sourcedcode'&#8221;</p>
<hr class="spacer-large" />
<h3>Solution</h3>
<p>Under the ui.content/pom.xml it looks like we can add configuration to allow validRoots as a part of the maven build. You can simply add this configuration as a part of the &lt;plugin&gt;, and it should be working as expected.</p>
<p>Keep an eye on the code below, line:16-22.</p>
<div class="codecolorer-container xml default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br /></div></td><td><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&lt;!-- ====================================================================== --<span style="color: #000000; font-weight: bold;">&gt;</span><br />
&lt;!-- V A U L T &nbsp; P A C K A G E &nbsp; P L U G I N S &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;--<span style="color: #000000; font-weight: bold;">&gt;</span><br />
&lt;!-- ====================================================================== --<span style="color: #000000; font-weight: bold;">&gt;</span><br />
<span style="color: #000000; font-weight: bold;">&lt;plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span>org.apache.jackrabbit<span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span>filevault-package-maven-plugin<span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span>1.1.6<span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;properties<span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;cloudManagerTarget<span style="color: #000000; font-weight: bold;">&gt;</span></span>none<span style="color: #000000; font-weight: bold;">&lt;/cloudManagerTarget<span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;/properties<span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;group<span style="color: #000000; font-weight: bold;">&gt;</span></span>com.sourcedcode<span style="color: #000000; font-weight: bold;">&lt;/group<span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;name<span style="color: #000000; font-weight: bold;">&gt;</span></span>sourcedcode.ui.content<span style="color: #000000; font-weight: bold;">&lt;/name<span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;packageType<span style="color: #000000; font-weight: bold;">&gt;</span></span>content<span style="color: #000000; font-weight: bold;">&lt;/packageType<span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;accessControlHandling<span style="color: #000000; font-weight: bold;">&gt;</span></span>merge<span style="color: #000000; font-weight: bold;">&lt;/accessControlHandling<span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;validatorsSettings<span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;jackrabbit-filter<span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;options<span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;validRoots<span style="color: #000000; font-weight: bold;">&gt;</span></span>/conf,/content,/content/experience-fragments,/content/dam,/etc/mobile/groups<span style="color: #000000; font-weight: bold;">&lt;/validRoots<span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;/options<span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;/jackrabbit-filter<span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;/validatorsSettings<span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;dependencies<span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span>com.sourcedcode<span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span>sourcedcode.ui.apps<span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span>$<span style="color: #66cc66;">&#123;</span>project.version<span style="color: #66cc66;">&#125;</span><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;/dependencies<span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;/configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
<span style="color: #000000; font-weight: bold;">&lt;/plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></div></td></tr></tbody></table></div>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/jackrabbit-filter-filter-roots-ancestor-etc-mobile-groups">jackrabbit-filter: Filter root&#8217;s ancestor &#8216;/etc/mobile/groups&#8217;</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/jackrabbit-filter-filter-roots-ancestor-etc-mobile-groups/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to login to AEMaaCS Local Publish crx/de system/console</title>
		<link>https://sourcedcode.com/blog/aem/how-to-login-to-aemaacs-local-publish-crx-de-system-console</link>
					<comments>https://sourcedcode.com/blog/aem/how-to-login-to-aemaacs-local-publish-crx-de-system-console#comments</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Wed, 15 Feb 2023 23:49:14 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[AEMaaCS]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=4370</guid>

					<description><![CDATA[<p>As an AEM developer working in the AEMaaCS environment, it&#8217;s common to need to run AEMaaCS local author and publish while developing in your local environment. Typically, authenticating into the AEMaaCS local author environment is straightforward, but accessing the AEMaaCS local publish environment requires some additional steps. The AEMaaCS local publish environment runs on port [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/how-to-login-to-aemaacs-local-publish-crx-de-system-console">How to login to AEMaaCS Local Publish crx/de system/console</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>As an AEM developer working in the AEMaaCS environment, it&#8217;s common to need to run AEMaaCS local author and publish while developing in your local environment. Typically, authenticating into the AEMaaCS local author environment is straightforward, but accessing the AEMaaCS local publish environment requires some additional steps. </p>
<p>The AEMaaCS local publish environment runs on port 4503, and the security settings are configured by default to align with AEMaaCS setup. If you need to debug the AEMaaCS local publish environment, it&#8217;s important to authenticate into the environment, especially for accessing crx/de and system/console.</p>
<p>In this article, we will guide you through the process of authenticating into the AEMaaCS local publish environment.</p>
<hr class="spacer-large" />
<h3>To access the crx/de and system/console for your AEM publish environment, follow these simple steps:</h3>
<ol>
<li>Open your web browser and go to <a href="http://localhost:4503/libs/granite/core/content/login.html" rel="noopener" target="_blank">http://localhost:4503/libs/granite/core/content/login.html</a>.</li>
<li>Enter the username <b>&#8220;admin&#8221;</b> and the password <b>&#8220;admin&#8221;</b>.</li>
<li>Once you have successfully logged in, you can navigate to the <b>crx/de</b> and <b>system/console</b> environment.</li>
<li>Visit crx/de: <a href="http://localhost:4503/crx/de/index.jsp" rel="noopener" target="_blank">http://localhost:4503/crx/de/index.jsp</a></li>
<li>Visit system/console: <a href="http://localhost:4503/system/console/bundles" rel="noopener" target="_blank">http://localhost:4503/system/console/bundles</a>
</ol>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/how-to-login-to-aemaacs-local-publish-crx-de-system-console">How to login to AEMaaCS Local Publish crx/de system/console</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/how-to-login-to-aemaacs-local-publish-crx-de-system-console/feed</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>What are AEM Content Fragments &#038; it&#8217;s Use Cases</title>
		<link>https://sourcedcode.com/blog/aem/what-are-aem-content-fragments-its-use-cases</link>
					<comments>https://sourcedcode.com/blog/aem/what-are-aem-content-fragments-its-use-cases#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Tue, 31 Jan 2023 06:51:13 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Content Fragment]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=4355</guid>

					<description><![CDATA[<p>AEM Content Fragments, CF, are units of reusable and modular content in AEM that can be managed and shared across multiple pages and digital channels. They allow content to be created and managed independently of the pages and templates that use them, making it easier to maintain consistent and up-to-date content across multiple channels. CF&#8217;s [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/what-are-aem-content-fragments-its-use-cases">What are AEM Content Fragments &#038; it&#8217;s Use Cases</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>AEM Content Fragments, CF, are units of reusable and modular content in AEM that can be managed and shared across multiple pages and digital channels. They allow content to be created and managed independently of the pages and templates that use them, making it easier to maintain consistent and up-to-date content across multiple channels. CF&#8217;s can be text, images, videos, interactive elements, or any other type of digital content. They provide a flexible and scalable way to manage content in AEM, improving the speed and efficiency of content creation and management.</p>
<p>CF also support headless architecture, where the content can be consumed and displayed through APIs without the need for a user interface. This allows organizations to create and manage content in AEM, and then surface it in a variety of different channels and applications, such as websites, mobile apps, and voice assistants. AEM&#8217;s content services utilize this functionality to make it easy for developers to retrieve and display CF&#8217;s in their applications. This provides organizations with a flexible and scalable way to manage content across multiple channels and touchpoints, improving the overall user experience and the efficiency of content management.</p>
<p>In addition to its technical capabilities, AEM CF&#8217;s are also designed to be author-friendly. The CF Model Editor is easy to use and allows authors to create and manage CF&#8217;s without needing technical expertise. This helps to reduce the dependency on developers and improve the speed and efficiency of content creation and management. The editor provides a simple and intuitive interface for authors to create and manage CF&#8217;s, including text, images, videos, and other digital assets. This makes it easier for organizations to keep their content up-to-date and consistent across multiple channels and touchpoints.</p>
<hr class="spacer-large" />
<h3>AEM Content Fragments Use Cases</h3>
<ol>
<li><strong>Migrated content from 3rd party API</strong>: AEM CF&#8217;s can be used to cache and manage content that is migrated from a third-party API into the AEM JCR. This helps to improve the performance and stability of the system by reducing the reliance on the API and improving the speed of data retrieval.
<p><p/><strong class="code-highlight-primary">Example</strong>: A company has a large catalog of product information that is stored in an external API. To improve the performance of the company&#8217;s website, the product information is migrated into the AEM JCR using CF&#8217;s. The CF&#8217;s are cached in the AEM JCR to improve the speed of data retrieval and reduce the reliance on the API. This helps to improve the overall user experience and the stability of the system.</p>
</li>
<li><strong>Reusable content component</strong>: Reusable content components allow organizations to create a library of content that can be used across multiple pages and digital experiences. This includes things like headers, footers, images, and product descriptions.</li>
<li><strong>Multi-channel deliver</strong>: With AEM CF&#8217;s, organizations can deliver consistent content across multiple channels, such as websites, mobile apps, and social media. This helps to ensure that the same message and content is being presented across all channels, regardless of the device or platform being used.</li>
<li><strong>Personalizatio</strong>: AEM CF&#8217;s can be used to create personalizable content components that can be customized for individual users based on their preferences and behavior. This includes things like product recommendations and personalized call-to-action (CTA) buttons.</li>
<li><strong>Translation and localizatio</strong>: AEM CF&#8217;s can be used to create content that can be easily translated and localized for global audiences. This includes things like product descriptions, news articles, and support pages.</li>
<li><strong>Product information managemen</strong>: With AEM CF&#8217;s, organizations can manage product information, such as descriptions, specifications, and images, in a centralized location. This makes it easier to keep product information up-to-date and consistent across all channels.</li>
<li><strong>Marketing campaign</strong>: AEM CF&#8217;s can be used to create and manage content components for marketing campaigns, such as landing pages and email templates. This helps to ensure that marketing campaigns are consistent and effective, regardless of the channel being used.</li>
<li><strong>News and blog article</strong>: AEM CF&#8217;s can be used to create and manage news and blog articles that can be reused across multiple pages and digital experiences. This makes it easier to keep information up-to-date and consistent, regardless of the channel being used.</li>
<li><strong>Event page</strong>: AEM CF&#8217;s can be used to create and manage content for event pages, such as conference schedules, speaker bios, and session descriptions. This helps to ensure that event information is consistent and up-to-date, regardless of the channel being used.</li>
<li><strong>Testimonials and review</strong>: AEM CF&#8217;s can be used to create and manage testimonials and reviews that can be displayed on product pages or marketing materials. This helps to provide customers with valuable insights and information about products and services.</li>
<li><strong>Employee profile</strong>: AEM CF&#8217;s can be used to create and manage employee profiles that can be displayed on the company website or intranet. This helps to provide customers and employees with information about the people behind the company.</li>
<li><strong>FAQ</strong>: AEM CF&#8217;s can be used to create and manage frequently asked questions (FAQs) that can be displayed on support pages or help centers. This helps to provide customers with the information they need to resolve issues and answer questions.</li>
<li><strong>How-to guide</strong>: AEM CF&#8217;s can be used to create and manage how-to guides that can be used to educate customers or support employees. This helps to provide customers and employees with the information they need to complete tasks and achieve their goals.</li>
<li><strong>Landing page</strong>: AEM CF&#8217;s can be used to create and manage landing pages for marketing campaigns, such as product launches or special promotions. This helps to ensure that landing pages are consistent and effective, regardless of the channel being used.</li>
<li><strong>Social media post</strong>: AEM CF&#8217;s can be used to create and manage social media posts that can be used across multiple social media platforms. This helps to ensure that social media posts are consistent and effective, regardless of the channel being used</li>
<li><strong>Video conten</strong>: AEM CF&#8217;s can be used to create and manage video content that can be used across multiple pages and digital experiences. This helps to ensure that video content is consistent and up-to-date, regardless of the channel being used.</li>
<li><strong>Interactive conten</strong>: AEM CF&#8217;s can be used to create and manage interactive content, such as quizzes, surveys, and calculators. This helps to engage customers and provide them with valuable information and insights.</li>
<li><strong>User-generated conten</strong>: AEM CF&#8217;s can be used to manage user-generated content, such as reviews, testimonials, and comments. This helps to provide customers with valuable insights and information about products and services.</li>
<li><strong>Support page</strong>: AEM CF&#8217;s can be used to create and manage support pages, such as FAQs and help centers. This helps to provide customers with the information they need to resolve issues and answer questions.</li>
<li><strong>Help center</strong>: AEM CF&#8217;s can be used to create and manage help centers that can be used to educate customers and support employees. This helps to provide customers and employees with the information they need to complete tasks and achieve their goals.</li>
<li><strong>Marketing material</strong>: AEM CF&#8217;s can be used to create and manage marketing materials, such as brochures, flyers, and email templates. This helps to ensure that marketing materials are consistent and effective, regardless of the channel being used.</li>
</ol>
<hr class="spacer-large" />
<h3>Summary</h3>
<p>In Summary, AEM content fragment&#8217;s are reusable, modular units of content that can be managed and shared across multiple pages and digital experiences. They provide a flexible and scalable way to manage content in AEM and support headless architecture, allowing the content to be consumed and displayed through APIs. AEM CF&#8217;s are easy for authors to use and provide a simple interface for creating and managing text, images, videos, and other digital assets. AEM CF&#8217;s can be used for a variety of purposes including managing migrated content, reusable content components, multi-channel delivery, personalization, translation and localization, product information management, marketing campaigns, news and blog articles, event pages, testimonials and reviews, and employee profiles.</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/what-are-aem-content-fragments-its-use-cases">What are AEM Content Fragments &#038; it&#8217;s Use Cases</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/what-are-aem-content-fragments-its-use-cases/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>JUNIT5: What Exactly is org.mockito.junit.jupiter.MockitoExtension and Sling Model Example</title>
		<link>https://sourcedcode.com/blog/aem/junit/junit5-what-exactly-is-org-mockito-junit-jupiter-mockitoextension-and-sling-model-examplejunit5-what-exactly-is-org-mockito-junit-jupiter-mockitoextension-and-examples</link>
					<comments>https://sourcedcode.com/blog/aem/junit/junit5-what-exactly-is-org-mockito-junit-jupiter-mockitoextension-and-sling-model-examplejunit5-what-exactly-is-org-mockito-junit-jupiter-mockitoextension-and-examples#comments</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Sat, 28 Jan 2023 06:56:04 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[JUNIT]]></category>
		<category><![CDATA[JUNIT5]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=4266</guid>

					<description><![CDATA[<p>org.mockito.junit.jupiter.MockitoExtension is a JUnit 5 extension provided by the Mockito library. It allows you to use the Mockito framework to create and inject mocked objects into your JUnit 5 test classes. This extension provides several features such as annotation-based mock creation, automatic detection of unused stubs, and support for the Mockito API. It enables you [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/junit/junit5-what-exactly-is-org-mockito-junit-jupiter-mockitoextension-and-sling-model-examplejunit5-what-exactly-is-org-mockito-junit-jupiter-mockitoextension-and-examples">JUNIT5: What Exactly is org.mockito.junit.jupiter.MockitoExtension and Sling Model Example</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>org.mockito.junit.jupiter.MockitoExtension is a JUnit 5 extension provided by the Mockito library. It allows you to use the Mockito framework to create and inject mocked objects into your JUnit 5 test classes. This extension provides several features such as annotation-based mock creation, automatic detection of unused stubs, and support for the Mockito API. It enables you to write clean and readable tests by allowing you to use the familiar Mockito API directly in your JUnit 5 tests, without the need to manually instantiate mock objects or use a separate mocking framework. This can make it easier to write and maintain unit tests that use mocked dependencies.</p>
<p>In additional, this post will be relating more to a Sling Model. In this example, we will create a sling model utilizing dependencies of 2 services.</p>
<hr class="spacer-large"/>
<p><strong>Example Implementation for a Sling Model</strong></p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">Here is an example implementation of the UnderTestSlingModel <span style="color: #000000; font-weight: bold;">class</span> that can be used in the provided JUnit5 test<span style="color: #339933;">:</span><br />
<br />
java<br />
Copy code<br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.SlingHttpServletRequest</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.models.annotations.Model</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.models.annotations.injectorspecific.SlingObject</span><span style="color: #339933;">;</span><br />
<br />
@Model<span style="color: #009900;">&#40;</span>adaptables <span style="color: #339933;">=</span> SlingHttpServletRequest.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> UnderTestSlingModel <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; @SlingObject<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> Service1 service1<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; @SlingObject<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> Service2 service2<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> getData<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> service1.<span style="color: #006633;">getData</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> service2.<span style="color: #006633;">getData</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<hr class="spacer-large" />
<p><strong>Example JUNIT5:</strong></p>
<div class="code-750">
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.junit.jupiter.api.Test</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.junit.jupiter.api.extension.ExtendWith</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.mockito.Mock</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.mockito.InjectMocks</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.mockito.junit.jupiter.MockitoExtension</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">io.wcm.testing.mock.aem.junit5.AemContext</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">io.wcm.testing.mock.aem.junit5.AemContextExtension</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">static</span> org.<span style="color: #006633;">junit</span>.<span style="color: #006633;">jupiter</span>.<span style="color: #006633;">api</span>.<span style="color: #006633;">Assertions</span>.<span style="color: #006633;">assertEquals</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">static</span> org.<span style="color: #006633;">mockito</span>.<span style="color: #006633;">ArgumentMatchers</span>.<span style="color: #006633;">any</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">static</span> org.<span style="color: #006633;">mockito</span>.<span style="color: #006633;">Mockito</span>.<span style="color: #006633;">when</span><span style="color: #339933;">;</span><br />
<br />
@ExtendWith<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>AemContextExtension.<span style="color: #000000; font-weight: bold;">class</span>, MockitoExtension.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #000000; font-weight: bold;">class</span> UnderTestSlingModelTest <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; @Mock<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> Service1 service1<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; @Mock<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> Service2 service2<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; @InjectMocks<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> UnderTestSlingModel underTest<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> AemContext context <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> AemContext<span style="color: #009900;">&#40;</span>ResourceResolverType.<span style="color: #006633;">JCR_MOCK</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; @Test<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">void</span> test1<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Setting up the mocked services</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; context.<span style="color: #006633;">registerService</span><span style="color: #009900;">&#40;</span>service1<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; context.<span style="color: #006633;">registerService</span><span style="color: #009900;">&#40;</span>service2<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Creating the underTest sling model</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; underTest <span style="color: #339933;">=</span> context.<span style="color: #006633;">request</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">adaptTo</span><span style="color: #009900;">&#40;</span>UnderTestSlingModel.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//Testing the mocked services</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; when<span style="color: #009900;">&#40;</span>service1.<span style="color: #006633;">getData</span><span style="color: #009900;">&#40;</span>any<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">thenReturn</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;test1&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; when<span style="color: #009900;">&#40;</span>service2.<span style="color: #006633;">getData</span><span style="color: #009900;">&#40;</span>any<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">thenReturn</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;test2&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; assertEquals<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;test1test2&quot;</span>, underTest.<span style="color: #006633;">getData</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; @Test<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">void</span> test2<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Setting up the mocked services</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; context.<span style="color: #006633;">registerService</span><span style="color: #009900;">&#40;</span>service1<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; context.<span style="color: #006633;">registerService</span><span style="color: #009900;">&#40;</span>service2<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Creating the underTest sling model</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; underTest <span style="color: #339933;">=</span> context.<span style="color: #006633;">request</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">adaptTo</span><span style="color: #009900;">&#40;</span>UnderTestSlingModel.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//Testing the mocked services</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; when<span style="color: #009900;">&#40;</span>service1.<span style="color: #006633;">getData</span><span style="color: #009900;">&#40;</span>any<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">thenReturn</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;test3&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; when<span style="color: #009900;">&#40;</span>service2.<span style="color: #006633;">getData</span><span style="color: #009900;">&#40;</span>any<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">thenReturn</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;test4&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; assertEquals<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;test3test4&quot;</span>, underTest.<span style="color: #006633;">getData</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
</div>
<hr class="spacer-large" />
<p><strong>pom.xml</strong></p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #339933;">&lt;</span>dependency<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>groupId<span style="color: #339933;">&gt;</span>org.<span style="color: #006633;">junit</span>.<span style="color: #006633;">jupiter</span><span style="color: #339933;">&lt;/</span>groupId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>artifactId<span style="color: #339933;">&gt;</span>junit<span style="color: #339933;">-</span>jupiter<span style="color: #339933;">-</span>api<span style="color: #339933;">&lt;/</span>artifactId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>version<span style="color: #339933;">&gt;</span>5.7.0<span style="color: #339933;">&lt;/</span>version<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>scope<span style="color: #339933;">&gt;</span>test<span style="color: #339933;">&lt;/</span>scope<span style="color: #339933;">&gt;</span><br />
<span style="color: #339933;">&lt;/</span>dependency<span style="color: #339933;">&gt;</span><br />
<span style="color: #339933;">&lt;</span>dependency<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>groupId<span style="color: #339933;">&gt;</span>org.<span style="color: #006633;">junit</span>.<span style="color: #006633;">jupiter</span><span style="color: #339933;">&lt;/</span>groupId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>artifactId<span style="color: #339933;">&gt;</span>junit<span style="color: #339933;">-</span>jupiter<span style="color: #339933;">-</span>engine<span style="color: #339933;">&lt;/</span>artifactId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>version<span style="color: #339933;">&gt;</span>5.7.0<span style="color: #339933;">&lt;/</span>version<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>scope<span style="color: #339933;">&gt;</span>test<span style="color: #339933;">&lt;/</span>scope<span style="color: #339933;">&gt;</span><br />
<span style="color: #339933;">&lt;/</span>dependency<span style="color: #339933;">&gt;</span><br />
<span style="color: #339933;">&lt;</span>dependency<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>groupId<span style="color: #339933;">&gt;</span>io.<span style="color: #006633;">wcm</span><span style="color: #339933;">&lt;/</span>groupId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>artifactId<span style="color: #339933;">&gt;</span>io.<span style="color: #006633;">wcm</span>.<span style="color: #006633;">testing</span>.<span style="color: #006633;">mock</span>.<span style="color: #006633;">aem</span><span style="color: #339933;">&lt;/</span>artifactId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>version<span style="color: #339933;">&gt;</span>7.4.0<span style="color: #339933;">&lt;/</span>version<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>scope<span style="color: #339933;">&gt;</span>test<span style="color: #339933;">&lt;/</span>scope<span style="color: #339933;">&gt;</span><br />
<span style="color: #339933;">&lt;/</span>dependency<span style="color: #339933;">&gt;</span><br />
<span style="color: #339933;">&lt;</span>dependency<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>groupId<span style="color: #339933;">&gt;</span>org.<span style="color: #006633;">mockito</span><span style="color: #339933;">&lt;/</span>groupId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>artifactId<span style="color: #339933;">&gt;</span>mockito<span style="color: #339933;">-</span>junit<span style="color: #339933;">-</span>jupiter<span style="color: #339933;">&lt;/</span>artifactId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>version<span style="color: #339933;">&gt;</span>3.6.28<span style="color: #339933;">&lt;/</span>version<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>scope<span style="color: #339933;">&gt;</span>test<span style="color: #339933;">&lt;/</span>scope<span style="color: #339933;">&gt;</span><br />
<span style="color: #339933;">&lt;/</span>dependency<span style="color: #339933;">&gt;</span></div></td></tr></tbody></table></div>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/junit/junit5-what-exactly-is-org-mockito-junit-jupiter-mockitoextension-and-sling-model-examplejunit5-what-exactly-is-org-mockito-junit-jupiter-mockitoextension-and-examples">JUNIT5: What Exactly is org.mockito.junit.jupiter.MockitoExtension and Sling Model Example</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/junit/junit5-what-exactly-is-org-mockito-junit-jupiter-mockitoextension-and-sling-model-examplejunit5-what-exactly-is-org-mockito-junit-jupiter-mockitoextension-and-examples/feed</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>AEM JUNIT5 with io.wcm.testing.mock.aem.junit5.AemContextExtension</title>
		<link>https://sourcedcode.com/blog/aem/junit/aem-junit5-with-io-wcm-testing-mock-aem-junit5-aemcontextextension</link>
					<comments>https://sourcedcode.com/blog/aem/junit/aem-junit5-with-io-wcm-testing-mock-aem-junit5-aemcontextextension#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Sat, 28 Jan 2023 05:35:44 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[JUNIT]]></category>
		<category><![CDATA[JUNIT5]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=4240</guid>

					<description><![CDATA[<p>io.wcm.testing.mock.aem.junit5.AemContextExtension is an extension for JUnit 5 that provides a way to run AEM (Adobe Experience Manager) unit tests with mocked AEM objects. This extension allows you to set up an AemContext object in your JUnit 5 test class, which provides access to mocked AEM objects such as the ResourceResolver, SlingSettings, and more. This makes [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/junit/aem-junit5-with-io-wcm-testing-mock-aem-junit5-aemcontextextension">AEM JUNIT5 with io.wcm.testing.mock.aem.junit5.AemContextExtension</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>io.wcm.testing.mock.aem.junit5.AemContextExtension is an extension for JUnit 5 that provides a way to run AEM (Adobe Experience Manager) unit tests with mocked AEM objects. This extension allows you to set up an AemContext object in your JUnit 5 test class, which provides access to mocked AEM objects such as the ResourceResolver, SlingSettings, and more. This makes it easier to test your code that interacts with AEM without actually requiring a running AEM instance. You can imagine, when using io.wcm.testing.mock.aem.junit5.AemContextExtension imported class, the JCR is virtually created in memory, you can think that this is a mock AEM JCR.</p>
<div class="mention-block">
<strong>Quick Links</strong></p>
<ol>
<li><a href="#exactly-what-is-io-wcm-testing-mock-aem-junit5-aemcontextextension">Exactly what is io.wcm.testing.mock.aem.junit5.AemContextExtension?</a></li>
<li><a href="#what-are-the-use-cases-for-io-wcm-testing-mock-aem-junit5-aemcontextextension">What are the use cases for io.wcm.testing.mock.aem.junit5.AemContextExtension</a>
<ul>
<li><a href="#pom-xml">a. pom.xml</a></li>
</ul>
</li>
<li><a href="#choosing-the-right-aemcontext-to-speed-up-tests">Choosing the Right AemContext to Speed Up Tests</a></li>
</ol>
</div>
<hr class="spacer-larger" />
<h3 id="exactly-what-is-io-wcm-testing-mock-aem-junit5-aemcontextextension">1. Exactly what is io.wcm.testing.mock.aem.junit5.AemContextExtension?</h3>
<li>io.wcm.testing.mock.aem.junit5.AemContextExtension enables you to mock a in-memory AEM JCR, exactly like the AEM instance.</li>
<li>When mocking the JCR instance, you can imagine that this is an empty JCR, with no nodes inside of it, so you will need to use Java to add resources in the mock JCR repository.</li>
<li>Services like the pageManger, tagManger, resourceResolver, etc&#8230; will be available in the mock JCR instance.</li>
<li>io.wcm.testing.mock.aem.junit5.AemContextExtension is an extension for JUnit 5 that allows for running AEM (Adobe Experience Manager) unit tests with mocked AEM objects.</li>
<li>It provides a way to set up an AemContext object in a JUnit 5 test class, which gives access to mocked AEM objects such as the ResourceResolver, SlingSettings, and more.</li>
<li>This makes it easier to test code that interacts with AEM without requiring a running AEM instance.</li>
<li>It allows developers to write unit tests that can test their AEM-based code in isolation, without relying on a running AEM instance or a test environment set up with a specific version of AEM.</li>
<li>This extension can be used for testing AEM components, AEM service, AEM workflows and more.</li>
<li>It reduces the time and cost of testing by eliminating the need for a running AEM instance, and allows for faster test execution and more efficient development.</li>
<hr class="spacer-larger"/>
<h3 id="what-are-the-use-cases-for-io-wcm-testing-mock-aem-junit5-aemcontextextension">2. What are the use cases for io.wcm.testing.mock.aem.junit5.AemContextExtension</h3>
<ul>
<li>Unit testing AEM-based projects without the need for a running AEM instance</li>
<li>Isolating your tests from the dependencies on a specific AEM version or environment</li>
<li>Mocking specific AEM objects, such as the ResourceResolver or SlingSettings, for more fine-grained control over the test environment</li>
<li>Simplifying the setup and tear-down of AEM-related test objects</li>
<li>Improving the reliability and repeatability of your tests by reducing external dependencies.</li>
</ul>
<hr class="spacer"/>
<p>Here&#8217;s an example of how to use AemContextExtension in a JUnit 5 test class:</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">static</span> org.<span style="color: #006633;">junit</span>.<span style="color: #006633;">jupiter</span>.<span style="color: #006633;">api</span>.<span style="color: #006633;">Assertions</span>.<span style="color: #006633;">assertEquals</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">static</span> org.<span style="color: #006633;">junit</span>.<span style="color: #006633;">jupiter</span>.<span style="color: #006633;">api</span>.<span style="color: #006633;">Assertions</span>.<span style="color: #006633;">assertNotNull</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.junit.jupiter.api.Test</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.junit.jupiter.api.extension.ExtendWith</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">io.wcm.testing.mock.aem.junit5.AemContext</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">io.wcm.testing.mock.aem.junit5.AemContextExtension</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.resource.Resource</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.resource.ResourceResolver</span><span style="color: #339933;">;</span><br />
<br />
@ExtendWith<span style="color: #009900;">&#40;</span>AemContextExtension.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #000000; font-weight: bold;">class</span> MyTest <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">final</span> AemContext context <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> AemContext<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; @Test<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">void</span> testMockResourceObjects<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// create mock resource objects</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; context.<span style="color: #006633;">create</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">resource</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/content/object1&quot;</span>, <span style="color: #0000ff;">&quot;prop1&quot;</span>, <span style="color: #0000ff;">&quot;value1&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; context.<span style="color: #006633;">create</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">resource</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/content/object2&quot;</span>, <span style="color: #0000ff;">&quot;prop1&quot;</span>, <span style="color: #0000ff;">&quot;value2&quot;</span>, <span style="color: #0000ff;">&quot;prop2&quot;</span>, <span style="color: #0000ff;">&quot;value3&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; context.<span style="color: #006633;">create</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">resource</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/content/object3&quot;</span>, <span style="color: #0000ff;">&quot;prop1&quot;</span>, <span style="color: #0000ff;">&quot;value4&quot;</span>, <span style="color: #0000ff;">&quot;prop2&quot;</span>, <span style="color: #0000ff;">&quot;value5&quot;</span>, <span style="color: #0000ff;">&quot;prop3&quot;</span>, <span style="color: #0000ff;">&quot;value6&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// get resource resolver</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; ResourceResolver resourceResolver <span style="color: #339933;">=</span> context.<span style="color: #006633;">resourceResolver</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// test object 1</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Resource resource1 <span style="color: #339933;">=</span> resourceResolver.<span style="color: #006633;">getResource</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/content/object1&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; assertNotNull<span style="color: #009900;">&#40;</span>resource1<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; assertEquals<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;value1&quot;</span>, resource1.<span style="color: #006633;">getValueMap</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;prop1&quot;</span>, <span style="color: #003399;">String</span>.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// test object 2</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Resource resource2 <span style="color: #339933;">=</span> resourceResolver.<span style="color: #006633;">getResource</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/content/object2&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; assertNotNull<span style="color: #009900;">&#40;</span>resource2<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; assertEquals<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;value2&quot;</span>, resource2.<span style="color: #006633;">getValueMap</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;prop1&quot;</span>, <span style="color: #003399;">String</span>.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; assertEquals<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;value3&quot;</span>, resource2.<span style="color: #006633;">getValueMap</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;prop2&quot;</span>, <span style="color: #003399;">String</span>.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// test object 3</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Resource resource3 <span style="color: #339933;">=</span> resourceResolver.<span style="color: #006633;">getResource</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/content/object3&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; assertNotNull<span style="color: #009900;">&#40;</span>resource3<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; assertEquals<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;value4&quot;</span>, resource3.<span style="color: #006633;">getValueMap</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;prop1&quot;</span>, <span style="color: #003399;">String</span>.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; assertEquals<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;value5&quot;</span>, resource3.<span style="color: #006633;">getValueMap</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;prop2&quot;</span>, <span style="color: #003399;">String</span>.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; assertEquals<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;value6&quot;</span>, resource3.<span style="color: #006633;">getValueMap</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;prop3&quot;</span>, <span style="color: #003399;">String</span>.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<hr class="spacer-large"/>
<h3 id="pom-xml">2a. pom.xml</h3>
<p>These dependencies are what is being used in my pom.xml file for the example above. </p>
<p><strong>3 include dependencies:</strong></p>
<ol>
<li>The first dependency is the &#8220;wcm-io-test-context-aem&#8221; library which provides the AemContext extension and utility classes for unit testing AEM-based Java code.</li>
<li>The second dependency is &#8220;junit-jupiter-api&#8221; which provides the JUnit 5 API for writing tests.</li>
<li>The third dependency is &#8220;junit-jupiter-engine&#8221; which provides the JUnit 5 TestEngine implementation for running tests.</li>
</ol>
<p>Keep in mind that these versions could be different based on the latest version of the dependencies, you should check the documentation for the latest versions before use&#8230; these are my settings.</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #339933;">&lt;</span>dependency<span style="color: #339933;">&gt;</span><br />
&nbsp; <span style="color: #339933;">&lt;</span>groupId<span style="color: #339933;">&gt;</span>io.<span style="color: #006633;">wcm</span>.<span style="color: #006633;">testing</span><span style="color: #339933;">&lt;/</span>groupId<span style="color: #339933;">&gt;</span><br />
&nbsp; <span style="color: #339933;">&lt;</span>artifactId<span style="color: #339933;">&gt;</span>wcm<span style="color: #339933;">-</span>io<span style="color: #339933;">-</span>test<span style="color: #339933;">-</span>context<span style="color: #339933;">-</span>aem<span style="color: #339933;">&lt;/</span>artifactId<span style="color: #339933;">&gt;</span><br />
&nbsp; <span style="color: #339933;">&lt;</span>version<span style="color: #339933;">&gt;</span>3.3.0<span style="color: #339933;">&lt;/</span>version<span style="color: #339933;">&gt;</span><br />
&nbsp; <span style="color: #339933;">&lt;</span>scope<span style="color: #339933;">&gt;</span>test<span style="color: #339933;">&lt;/</span>scope<span style="color: #339933;">&gt;</span><br />
<span style="color: #339933;">&lt;/</span>dependency<span style="color: #339933;">&gt;</span><br />
<span style="color: #339933;">&lt;</span>dependency<span style="color: #339933;">&gt;</span><br />
&nbsp; <span style="color: #339933;">&lt;</span>groupId<span style="color: #339933;">&gt;</span>org.<span style="color: #006633;">junit</span>.<span style="color: #006633;">jupiter</span><span style="color: #339933;">&lt;/</span>groupId<span style="color: #339933;">&gt;</span><br />
&nbsp; <span style="color: #339933;">&lt;</span>artifactId<span style="color: #339933;">&gt;</span>junit<span style="color: #339933;">-</span>jupiter<span style="color: #339933;">-</span>api<span style="color: #339933;">&lt;/</span>artifactId<span style="color: #339933;">&gt;</span><br />
&nbsp; <span style="color: #339933;">&lt;</span>version<span style="color: #339933;">&gt;</span>5.7.0<span style="color: #339933;">&lt;/</span>version<span style="color: #339933;">&gt;</span><br />
&nbsp; <span style="color: #339933;">&lt;</span>scope<span style="color: #339933;">&gt;</span>test<span style="color: #339933;">&lt;/</span>scope<span style="color: #339933;">&gt;</span><br />
<span style="color: #339933;">&lt;/</span>dependency<span style="color: #339933;">&gt;</span><br />
<span style="color: #339933;">&lt;</span>dependency<span style="color: #339933;">&gt;</span><br />
&nbsp; <span style="color: #339933;">&lt;</span>groupId<span style="color: #339933;">&gt;</span>org.<span style="color: #006633;">junit</span>.<span style="color: #006633;">jupiter</span><span style="color: #339933;">&lt;/</span>groupId<span style="color: #339933;">&gt;</span><br />
&nbsp; <span style="color: #339933;">&lt;</span>artifactId<span style="color: #339933;">&gt;</span>junit<span style="color: #339933;">-</span>jupiter<span style="color: #339933;">-</span>engine<span style="color: #339933;">&lt;/</span>artifactId<span style="color: #339933;">&gt;</span><br />
&nbsp; <span style="color: #339933;">&lt;</span>version<span style="color: #339933;">&gt;</span>5.7.0<span style="color: #339933;">&lt;/</span>version<span style="color: #339933;">&gt;</span><br />
&nbsp; <span style="color: #339933;">&lt;</span>scope<span style="color: #339933;">&gt;</span>test<span style="color: #339933;">&lt;/</span>scope<span style="color: #339933;">&gt;</span><br />
<span style="color: #339933;">&lt;/</span>dependency<span style="color: #339933;">&gt;</span></div></td></tr></tbody></table></div>
<hr class="spacer-larger"/>
<h3 id="choosing-the-right-aemcontext-to-speed-up-tests">3. Choosing the Right AemContext to Speed Up Tests</h3>
<p>The AemContextExtension allows for <strong>direct injection of the context</strong> into test methods, this can speed up test suite execution in cases where certain tests require the use of real JCR due to the use of indexes or other JCR features, while others do not. The more &#8220;mocked&#8221; the underlying resource resolver is, the faster the context will be. Therefore, it is recommended to use the following contexts in this order if possible:</p>
<ol>
<li>
<h4>org.apache.sling.testing.mock.sling.junit5.NoResourceResolverTypeAemContext (fastest)</h4>
<ul>
<li>
            NoResourceResolverTypeAemContext is a type of AemContext that is used for tests that do not require a resource resolver.</p>
<li>When this type of AemContext is injected into a test method, it means that the test will not have access to any resource resolving functionality, such as resolving resources by path or querying the JCR.</li>
<li>This can be useful for tests that do not rely on any resources and only test pure Java logic.</li>
<li>This AemContext is the fastest of all the AemContexts because it does not have to instantiate a resource resolver and therefore it is lightweight, and can be useful when running test suites that requires a lot of test cases.</li>
</ul>
</li>
<li>
<h4>org.apache.sling.testing.mock.sling.junit5.ResourceResolverMockAemContext (default when just AemContext is used)</h4>
<ul>
<li>ResourceResolverMockAemContext is an extension of AemContext which mocks the AEM resource resolver.</li>
<li>When you inject an AemContext of this type, it means that the resource resolver used within your test will be a mocked version, rather than the real resource resolver. </li>
<li>This can be useful for faster test execution and for isolating your tests from external dependencies. </li>
<li>It is the default context when using AemContext alone.</li>
</ul>
</li>
<li>
<h4>org.apache.sling.testing.mock.sling.junit5.JcrMockAemContext (slower)</h4>
<ul>
<li>JcrMockAemContext is an extension of AemContext which mocks the AEM resource resolver.</li>
<li>Injecting AEMContext of JcrMockAemContext means that the test class is using a mocked version of the JCR for its AEM context; this means that the JCR functionality is being simulated in order to test the functionality of the code being tested, rather than utilizing a real JCR instance.
<li>This can be useful for testing as it allows for faster execution and a more controlled environment.</li>
<li>The JcrMockAemContext also allows you to use JCR specific features, such as indexes, in your tests. This is useful when you need to test the functionality of your code that uses JCR indexes.</li>
<li>
            This is slower to compared to other AemContext because it simulates a full JCR repository, including the persistence layer. This means that it has to perform more operations and calculations in order to simulate the JCR repository, which can lead to slower test execution times. Additionally, if your tests are using features that require a real JCR repository, such as indexing or searching, this context may be slower as it is still a mocked version of the repository.
         </li>
</ul>
</li>
<li>
<h4>org.apache.sling.testing.mock.sling.junit5.JcrOakAemContext (slowest)</h4>
<ul>
<li>Injecting AEMContext of JcrOakAemContext simulates a real JCR (Java Content Repository) with OakJCR.</li>
<li>This context is the slowest of all the AemContext options because it uses a real JCR and therefore takes more resources and time to run the test.</li>
</li>
</ul>
</li>
</ol>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">final</span> AemContext noResourceResolverTypeAemContext <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> AemContext<span style="color: #009900;">&#40;</span>ResourceResolverType.<span style="color: #006633;">NONE</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// fastest</span><br />
<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">final</span> AemContext resourceResolverMockAemContext <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> AemContext<span style="color: #009900;">&#40;</span>ResourceResolverType.<span style="color: #006633;">RESOURCERESOLVER_MOCK</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// default</span><br />
<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">final</span> AemContext jcrMockAemContext <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> AemContext<span style="color: #009900;">&#40;</span>ResourceResolverType.<span style="color: #006633;">JCR_MOCK</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// slower</span><br />
<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">final</span> AemContext jcrOakAemContext <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> AemContext<span style="color: #009900;">&#40;</span>ResourceResolverType.<span style="color: #006633;">JCR_OAK</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// slowest</span></div></td></tr></tbody></table></div>
<p>It is common to see tests where AemContext is stored in a field in a test class. However, if a single test requires JCR, this can slow down all other tests. With the ability to inject context as a test method parameter, previous tests will be as fast as before.</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/junit/aem-junit5-with-io-wcm-testing-mock-aem-junit5-aemcontextextension">AEM JUNIT5 with io.wcm.testing.mock.aem.junit5.AemContextExtension</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/junit/aem-junit5-with-io-wcm-testing-mock-aem-junit5-aemcontextextension/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Mocking Static Methods in JUNIT5</title>
		<link>https://sourcedcode.com/blog/aem/junit/junit5/mocking-static-methods-in-junit5</link>
					<comments>https://sourcedcode.com/blog/aem/junit/junit5/mocking-static-methods-in-junit5#comments</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Sat, 28 Jan 2023 05:12:08 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[JUNIT]]></category>
		<category><![CDATA[JUNIT5]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=4223</guid>

					<description><![CDATA[<p>PowerMock is a Java framework that allows you to unit test code that uses static methods, constructors, and private methods. PowerMock uses a combination of bytecode manipulation and reflection to enable the mocking of these types of methods. PowerMock is not officially supported by JUnit 5. PowerMock is built on top of EasyMock and provides [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/junit/junit5/mocking-static-methods-in-junit5">Mocking Static Methods in JUNIT5</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>PowerMock is a Java framework that allows you to unit test code that uses static methods, constructors, and private methods. PowerMock uses a combination of bytecode manipulation and reflection to enable the mocking of these types of methods.</p>
<p>PowerMock is not officially supported by JUnit 5. PowerMock is built on top of EasyMock and provides additional functionality such as the ability to mock static methods, constructors, and private methods. PowerMock uses a different test runner than the one provided by JUnit 5, so it is not directly compatible with JUnit 5.</p>
<p>Alternatively, you can use mockito-inline for inline mocking, it allows you to mock static methods, final classes, and methods, and more.</p>
<p>JUnit 5 provides its own extension model that allows for the creation of custom test runners and the registration of extensions. You could write your own test runner for PowerMock that works with JUnit 5 or use a different mocking framework that is compatible with JUnit 5.</p>
<div class="mention-block">
<strong>PowerMock is not officially supported by JUnit 5</strong><br />
If you are using JUnit5 and you really need to use Powermock, you could use the powermock-module-junit5 and powermock-api-mockito2 which have support for JUnit5, but it&#8217;s not recommended as it&#8217;s not officially supported by JUnit5, and to use mockito-inline as suggested.
</div>
<hr class="spacer-larger"/>
<h2>JUNIT5 Mock Static Method Code Examples</h2>
<p>Here&#8217;s an example of how to use mockito-inline to mock a static method in JUnit 5. Starting with a Utils class, we displaying an example of us initializing a Utils class with a static method of getString().</p>
<p><strong>Utils.java class</strong><br />
This is a simple utils class used by JAVA, where it has a static method of getString().</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Utils <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #003399;">String</span> getString<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #0000ff;">&quot;Original string&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p><strong>MyTest.java class</strong><br />
This is an example of a class utilizing the utils class. As you can see in the code, line:10 &#038;&#038; line:11 is performing the mocking mechanism. It is important to note that we are using mockito-inine which introduced Mockito.mockStatic, where we can mock the static method for the Utils class.</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.junit.jupiter.api.Test</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">static</span> org.<span style="color: #006633;">junit</span>.<span style="color: #006633;">jupiter</span>.<span style="color: #006633;">api</span>.<span style="color: #006633;">Assertions</span>.<span style="color: #006633;">assertEquals</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.mockito.Mockito</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MyTest <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; @Test<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> testStaticMethod<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// mock the static method of the Utils class</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Mockito.<span style="color: #006633;">mockStatic</span><span style="color: #009900;">&#40;</span>Utils.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Mockito.<span style="color: #006633;">when</span><span style="color: #009900;">&#40;</span>Utils.<span style="color: #006633;">getString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">thenReturn</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Mocked string&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// create an instance of the class that calls the static method</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; MyClass myClass <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> MyClass<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; assertEquals<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Mocked string&quot;</span>, myClass.<span style="color: #006633;">getStringFromUtils</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p><strong>pom.xml</strong><br />
These are the maven dependencies being used to get the code working as expected for the JUNIT5 examples above.</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #339933;">&lt;</span>dependency<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>groupId<span style="color: #339933;">&gt;</span>org.<span style="color: #006633;">junit</span>.<span style="color: #006633;">jupiter</span><span style="color: #339933;">&lt;/</span>groupId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>artifactId<span style="color: #339933;">&gt;</span>junit<span style="color: #339933;">-</span>jupiter<span style="color: #339933;">-</span>api<span style="color: #339933;">&lt;/</span>artifactId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>version<span style="color: #339933;">&gt;</span>5.11.0<span style="color: #339933;">&lt;/</span>version<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>scope<span style="color: #339933;">&gt;</span>test<span style="color: #339933;">&lt;/</span>scope<span style="color: #339933;">&gt;</span><br />
<span style="color: #339933;">&lt;/</span>dependency<span style="color: #339933;">&gt;</span><br />
<span style="color: #339933;">&lt;</span>dependency<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>groupId<span style="color: #339933;">&gt;</span>org.<span style="color: #006633;">junit</span>.<span style="color: #006633;">jupiter</span><span style="color: #339933;">&lt;/</span>groupId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>artifactId<span style="color: #339933;">&gt;</span>junit<span style="color: #339933;">-</span>jupiter<span style="color: #339933;">-</span>engine<span style="color: #339933;">&lt;/</span>artifactId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>version<span style="color: #339933;">&gt;</span>5.11.0<span style="color: #339933;">&lt;/</span>version<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>scope<span style="color: #339933;">&gt;</span>test<span style="color: #339933;">&lt;/</span>scope<span style="color: #339933;">&gt;</span><br />
<span style="color: #339933;">&lt;/</span>dependency<span style="color: #339933;">&gt;</span><br />
<span style="color: #339933;">&lt;</span>dependency<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>groupId<span style="color: #339933;">&gt;</span>org.<span style="color: #006633;">mockito</span><span style="color: #339933;">&lt;/</span>groupId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>artifactId<span style="color: #339933;">&gt;</span>mockito<span style="color: #339933;">-</span>core<span style="color: #339933;">&lt;/</span>artifactId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>version<span style="color: #339933;">&gt;</span>3.6.0<span style="color: #339933;">&lt;/</span>version<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>scope<span style="color: #339933;">&gt;</span>test<span style="color: #339933;">&lt;/</span>scope<span style="color: #339933;">&gt;</span><br />
<span style="color: #339933;">&lt;/</span>dependency<span style="color: #339933;">&gt;</span><br />
<span style="color: #339933;">&lt;</span>dependency<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>groupId<span style="color: #339933;">&gt;</span>org.<span style="color: #006633;">mockito</span><span style="color: #339933;">&lt;/</span>groupId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>artifactId<span style="color: #339933;">&gt;</span>mockito<span style="color: #339933;">-</span>inline<span style="color: #339933;">&lt;/</span>artifactId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>version<span style="color: #339933;">&gt;</span>3.6.0<span style="color: #339933;">&lt;/</span>version<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>scope<span style="color: #339933;">&gt;</span>test<span style="color: #339933;">&lt;/</span>scope<span style="color: #339933;">&gt;</span><br />
<span style="color: #339933;">&lt;/</span>dependency<span style="color: #339933;">&gt;</span></div></td></tr></tbody></table></div>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/junit/junit5/mocking-static-methods-in-junit5">Mocking Static Methods in JUNIT5</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/junit/junit5/mocking-static-methods-in-junit5/feed</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>Advancing Your AEM Skills: Tips for Junior Developers</title>
		<link>https://sourcedcode.com/blog/aem/advancing-your-aem-skills-tips-for-junior-developers</link>
					<comments>https://sourcedcode.com/blog/aem/advancing-your-aem-skills-tips-for-junior-developers#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Fri, 27 Jan 2023 01:06:25 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=4217</guid>

					<description><![CDATA[<p>AEM has grown in popularity over the past few years, and AEM developers are in high demand as a result, as they can assist businesses in utilizing the platform to produce compelling digital experiences. This article is for an AEM junior developer who wants to stand out from the competition. I will provide some detail [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/advancing-your-aem-skills-tips-for-junior-developers">Advancing Your AEM Skills: Tips for Junior Developers</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>AEM has grown in popularity over the past few years, and AEM developers are in high demand as a result, as they can assist businesses in utilizing the platform to produce compelling digital experiences. This article is for an AEM junior developer who wants to stand out from the competition. I will provide some detail on what I think you should be working on to become a best-in-class AEM developer.</p>
<hr class="spacer-large"/>
<div class="mention-block--gold">
<strong>Quick Note!</strong><br />
I&#8217;d like to share some courses that have greatly benefited me, both in interviews and my daily AEM development work. In my opinion, these courses are the best for AEM developers, whether you&#8217;re starting out or have over 2 years of experience. Even today, since I began my AEM career in 2015, this course continues to help me by reinforcing AEM concepts and practices that are not part of my daily routine. You can find more details on how this course has helped me here -> <a href="https://sourcedcode.com/blog/aem/aem-developers-courses-2022-that-really-helped-me" rel="noopener" target="_blank">https://sourcedcode.com/blog/aem/aem-developers-courses-2022-that-really-helped-me</a>
</div>
<hr class="spacer-large"/>
<p>In my opinion, writing clear, effective, and maintainable code is one of the most crucial characteristics that distinguish novice AEM developers. Junior developers must have a firm grasp of the fundamentals of the Java language, including data structures, algorithms, and design patterns, as AEM is built on top of Java. Additionally, they must to be familiar with other widely used web development technologies including HTML, CSS, and JavaScript.</p>
<p>Having a strong learning attitude, combined with the drive to become a full-stack AEM developer, sets a junior AEM developer apart. The ability to work with backend services, such as schedulers, servlets, sling models, and integrate with third-party services, Oauth2 services, search engines, data importer services, etc&#8230; can make a big impact on the complexity and sophistication of digital experiences organizations can build. In addition to these technical skills, it is also important for junior AEM developers to have proficiency in Adobe HTL, Javascript, CSS, and HTML. Junior developers with a diverse set of technical skills and a strong learning attitude will be highly valued and in high demand. This combination can lead to a successful and rewarding career in AEM development.</p>
<p>It&#8217;s also essential to have a strong understanding of AEM&#8217;s architecture and the different components that make up the platform. Junior developers should have a good understanding of the AEM building blocks such as templates, components, and workflows. They should also be familiar with AEM&#8217;s front-end development tools such as Sightly and Granite UI.</p>
<p>To have a solid technical foundation in the general of web development, junior AEM developers should also have strong problem-solving skills. AEM is a complex platform, and developers will often be faced with challenging problems that require creative solutions. Junior developers who can think critically and come up with innovative solutions will be in high demand.</p>
<p>A junior AEM developer who has a solid understanding of Java, web development technologies (including front-end web development), AEM&#8217;s architecture, and AEM&#8217;s proprietary platform, has strong problem-solving skills, will be in high demand in the job market. With the right skills and mindset, you can become a valuable asset to any organization that uses AEM. I would like to highlight again that In my opinion, you&#8217;d be a more valuable AEM developer if you focus on full-stack AEM development, rather than just focusing on frontend or backend.</p>
<hr class="spacer-large"/>
<h4>In Conclusion</h4>
<p>Having a strong learning attitude is critical for junior AEM developers to excel in their careers. A curious and self-motivated mindset drives continuous improvement, leading to a better understanding of the platform and the development process. This, in turn, helps in becoming a best-in-class AEM developer. Staying updated with the latest technologies and trends, experimenting with new features, and seeking feedback from mentors can enhance the skills and knowledge needed to deliver high-quality solutions. Hence, having a striving learning attitude is a vital aspect of success in the AEM development field.</p>
<p>A junior AEM developer should spend some time offline, in their personal time, to learn how to write backend code with backend services as well as AEM front code like Sightly javascript html and css. It&#8217;s not just about being good at what you do, it&#8217;s about being passionate about it. By taking the time to learn and grow, you will be able to stand out from the rest.</p>
<div class="mention-block--gold">
Recently, there are many people AEM developers (0-5 years’ experience) contacting me via LinkedIn and asking me for tips on how they can improve as an #AEM full stack engineer. They asked me if I can recommend a road map or any well-known AEM courses that will help me in the past to become where I am today. They asked me to share some links to training materials to either start or strengthen their AEM development career. “I appreciate you all contacting me for help!”… I’ve been replying with the same message to these folks with the same course roadmap and outline, and I hope everyone found my links helpful. Instead of repeating myself, I have created a new article for #AEM <a href="https://bit.ly/3fGZSq8">Developers Courses 2022</a>, <a href="https://bit.ly/3fGZSq8">https://sourcedcode.com/blog/aem/aem-developers-courses-2022-that-really-helped-me</a>.
</div>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/advancing-your-aem-skills-tips-for-junior-developers">Advancing Your AEM Skills: Tips for Junior Developers</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/advancing-your-aem-skills-tips-for-junior-developers/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>error: immutable file &#8216;conf.d/dispatcher_vhost.conf&#8217; has been changed!</title>
		<link>https://sourcedcode.com/blog/aem/error-immutable-file-conf-d-dispatcher_vhost-conf-has-been-changed</link>
					<comments>https://sourcedcode.com/blog/aem/error-immutable-file-conf-d-dispatcher_vhost-conf-has-been-changed#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Fri, 27 Jan 2023 00:56:25 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Dispatcher]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=4212</guid>

					<description><![CDATA[<p>While setting up Adobe Experience Manager (AEM) as a Cloud Service&#8217;s dispatcher SDK on my local Mac machine, following this Adobe documentation, I encountered an error while running the command &#8220;./bin/validate.sh src&#8221;. The error message read &#8220;error: immutable file &#8216;conf.d/dispatcher_vhost.conf&#8217; has been changed!&#8221;. After some research, I found that the issue was related to the [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/error-immutable-file-conf-d-dispatcher_vhost-conf-has-been-changed">error: immutable file &#8216;conf.d/dispatcher_vhost.conf&#8217; has been changed!</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>While setting up Adobe Experience Manager (AEM) as a Cloud Service&#8217;s dispatcher SDK on my local Mac machine, <a href="https://experienceleague.adobe.com/docs/experience-manager-learn/cloud-service/local-development-environment-set-up/dispatcher-tools.html" rel="noopener" target="_blank">following this Adobe documentation</a>, I encountered an error while running the command &#8220;./bin/validate.sh src&#8221;. The error message read &#8220;error: immutable file &#8216;conf.d/dispatcher_vhost.conf&#8217; has been changed!&#8221;.</p>
<p>After some research, I found that the issue was related to the access permissions of the file in question. To resolve the problem, I ran the command &#8220;chmod 777 conf.d/dispatcher_vhost.conf&#8221; on my Mac machine. This successfully allowed me to proceed with my local AEM setup.</p>
<hr class="spacer-large"/>
<h3>But what exactly is &#8220;chmod 777&#8221;?</h3>
<p>In Linux and Unix-based operating systems, &#8220;chmod&#8221; stands for &#8220;change mode&#8221; and is used to adjust the read, write, and execute permissions of a file or directory. The number &#8220;777&#8221; is a three-digit code called the &#8220;file mode&#8221; or &#8220;permission mode&#8221;. It represents the permissions for the owner of the file, the group the file belongs to, and all other users.</p>
<p>Here are the details about the 777 permission:</p>
<p>7 is the permission for owner<br />
7 is the permission for group<br />
7 is the permission for others (users)<br />
Each digit in the file mode is a sum of the values for the read (4), write (2), and execute (1) permissions. So, 777 means that the owner, the group, and other users all have full read, write, and execute permissions for the file or directory.</p>
<p>It&#8217;s important to note that chmod 777 is considered a very open permission, and is not recommended from a security standpoint. It&#8217;s generally better to use more restrictive permissions such as 644 for files and 755 for directories, which will still allow the owner to read and write to the file, but prevent others from making any changes. However, for local testing purposes, chmod 777 can be used.</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/error-immutable-file-conf-d-dispatcher_vhost-conf-has-been-changed">error: immutable file &#8216;conf.d/dispatcher_vhost.conf&#8217; has been changed!</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/error-immutable-file-conf-d-dispatcher_vhost-conf-has-been-changed/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>AEM Programmatically Write/Update/Modify AEM JCR node property/properties</title>
		<link>https://sourcedcode.com/blog/aem/aem-programmatically-write-update-modify-aem-jcr-node-property-properties</link>
					<comments>https://sourcedcode.com/blog/aem/aem-programmatically-write-update-modify-aem-jcr-node-property-properties#comments</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Sun, 15 Jan 2023 08:54:59 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Development]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=4145</guid>

					<description><![CDATA[<p>In this article, I will be presenting code snippets for how we can programmatically update AEM JCR nodes in AEM using Java; using the org.apache.sling.api.resource.ModifiableValueMap and javax.jcr.Node API. In this article, we are showcasing the way that you would programmatically update AEM JCR nodes in your local machine, logged in as a System Users in [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/aem-programmatically-write-update-modify-aem-jcr-node-property-properties">AEM Programmatically Write/Update/Modify AEM JCR node property/properties</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>In this article, I will be presenting code snippets for how we can programmatically update AEM JCR nodes in AEM using Java; using the org.apache.sling.api.resource.ModifiableValueMap and javax.jcr.Node API.</p>
<p>In this article, we are showcasing the way that you would programmatically update AEM JCR nodes in your local machine, logged in as a System Users in AEM. If you would like <a href="https://sourcedcode.com/blog/aem/create-system-service-users-in-aem-6-5-with-code-configurations" rel="noopener" target="_blank">how to setup your system user programmatically with code configurations, read this article here</a>.</p>
<div class="mention-block">
<b>Quick Links</b></p>
<ol>
<li><a href="#org.apache.sling.api.resource.ModifiableValueMap">Method 1, Programmatically Update AEM JCR nodes in JAVA with org.apache.sling.api.resource.ModifiableValueMap</a></li>
<li><a href="#javax.jcr.Node">Method 2, Programmatically Update AEM JCR nodes in JAVA with, javax.jcr.Node</a></li>
</ol>
</div>
<div class="mention-block--gold">
<strong>Exploring AEM Service Users: A Simple Setup Guide</strong><br />
Dive into the world of Adobe Experience Manager with our blog post, &#8220;Exploring AEM Service Users.&#8221; Whether you&#8217;re on AEMaaCS or AEM 6.5.4+, we&#8217;ve got you covered with an easy-to-follow guide on setting up a system user. No jargon, just straightforward steps to demystify the AEM service user. Enhance your AEM experience effortlessly – check out our blog and learn today -> <a href="https://sourcedcode.com/blog/aem/create-system-service-users-in-aem-6-5-with-code-configurations">https://sourcedcode.com/blog/aem/create-system-service-users-in-aem-6-5-with-code-configurations</a></p>
</div>
<hr class="spacer-large"/>
<h2 id="org.apache.sling.api.resource.ModifiableValueMap">Method 1, Programmatically Update AEM JCR nodes in JAVA with org.apache.sling.api.resource.ModifiableValueMap</h2>
<p>Take a look at line 7,8 where we adapt the resource object to ModifiableValueMap.class, make the change in the existingProperty using the ModifiableValueMap API, put&#8230; In line 9, we are updating an existing property, and in line 10, we are removing an existingProperty. Finally, in line 11, using the resolver to commit the changes. The commit method will Persist all pending changes into the JCR, documentation <a href="https://sling.apache.org/apidocs/sling11/org/apache/sling/api/resource/ResourceResolver.html" rel="noopener" target="_blank">here</a>.</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #000000; font-weight: bold;">final</span> Map<span style="color: #339933;">&lt;</span><span style="color: #003399;">String</span>, Object<span style="color: #339933;">&gt;</span> authInfo <span style="color: #339933;">=</span> <span style="color: #003399;">Collections</span>.<span style="color: #006633;">singletonMap</span><span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; ResourceResolverFactory.<span style="color: #006633;">SUBSERVICE</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;sourcedCodeSystemUser&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#40;</span>ResourceResolver resolver <span style="color: #339933;">=</span> factory.<span style="color: #006633;">getServiceResourceResolver</span><span style="color: #009900;">&#40;</span>authInfo<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; Resource resource <span style="color: #339933;">=</span> resolver.<span style="color: #006633;">getResource</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/content/sourcedcode/jcr:content&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>Objects.<span style="color: #006633;">nonNull</span><span style="color: #009900;">&#40;</span>resource<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; ModifiableValueMap map <span style="color: #339933;">=</span> resource.<span style="color: #006633;">adaptTo</span><span style="color: #009900;">&#40;</span>ModifiableValueMap.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; map.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;newProperty&quot;</span>, <span style="color: #0000ff;">&quot;value&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; map.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;existingProperty&quot;</span>, <span style="color: #0000ff;">&quot;value&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; map.<span style="color: #006633;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;existingProperty&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//remove</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; resolver.<span style="color: #006633;">commit</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; e.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<div class="mention-block">
<b>try-with-resources statement line:4</b><br />
The <b>try-with-resources</b> statement is a try statement that declares one or more resources. A resource is as an object that must be closed after the program is finished with it. The try-with-resources statement ensures that each resource is closed at the end of the statement. Any object that implements java.lang.AutoCloseable, which includes all objects which implement java.io.Closeable, can be used as a resource. <a href="https://docs.oracle.com/javase/8/docs/technotes/guides/language/try-with-resources.html" rel="noopener" target="_blank">reference documentation</a>.
</div>
<hr class="spacer-large"/>
<h2 id="javax.jcr.Node">Method 2, Programmatically Update AEM JCR nodes in JAVA with, javax.jcr.Node</h2>
<p>Take a look at line 6, where we will get the JCR node as a javax.jcr.Node object, in line 7 we will check if that Node exists, and line 8, we create a new property. On line 9, we will update an existing property, and in line 10, we will remove an existing property, in line 11, we will save all changes into the repository.</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #000000; font-weight: bold;">final</span> Map<span style="color: #339933;">&lt;</span><span style="color: #003399;">String</span>, Object<span style="color: #339933;">&gt;</span> authInfo <span style="color: #339933;">=</span> <span style="color: #003399;">Collections</span>.<span style="color: #006633;">singletonMap</span><span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; ResourceResolverFactory.<span style="color: #006633;">SUBSERVICE</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;sourcedCodeSystemUser&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#40;</span>ResourceResolver resolver <span style="color: #339933;">=</span> factory.<span style="color: #006633;">getServiceResourceResolver</span><span style="color: #009900;">&#40;</span>authInfo<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; Session session <span style="color: #339933;">=</span> resolver.<span style="color: #006633;">adaptTo</span><span style="color: #009900;">&#40;</span>Session.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; Node contentNode <span style="color: #339933;">=</span> session.<span style="color: #006633;">getNode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/content/sourcedcode/jcr:content&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>Objects.<span style="color: #006633;">nonNull</span><span style="color: #009900;">&#40;</span>contentNode<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; contentNode.<span style="color: #006633;">setProperty</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;newProperty&quot;</span>, <span style="color: #0000ff;">&quot;value&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; contentNode.<span style="color: #006633;">setProperty</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;existingProperty&quot;</span>, <span style="color: #0000ff;">&quot;value&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; contentNode.<span style="color: #006633;">setProperty</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;existingProperty&quot;</span>, <span style="color: #009900;">&#40;</span>Value<span style="color: #009900;">&#41;</span><span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//remove</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; session.<span style="color: #006633;">save</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; e.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<hr class="spacer-large"/>
<h3>This article covers questions like</h3>
<ul>
<li>How to modify AEM JCR node property/properties programmatically?</li>
<li>Modify AEM JCR node property/properties programmatically with code</li>
<li>Use AEM Sling API to modify AEM JCR node property/properties</li>
<li>Use AEM Node JCR to modify AEM JCR node property/properties</li>
</ul>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/aem-programmatically-write-update-modify-aem-jcr-node-property-properties">AEM Programmatically Write/Update/Modify AEM JCR node property/properties</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/aem-programmatically-write-update-modify-aem-jcr-node-property-properties/feed</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>JUnit 5: Mocking the HttpClient in Java</title>
		<link>https://sourcedcode.com/blog/aem/junit-5-mocking-the-httpclient-in-java</link>
					<comments>https://sourcedcode.com/blog/aem/junit-5-mocking-the-httpclient-in-java#comments</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Sat, 31 Dec 2022 07:01:38 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[JUNIT]]></category>
		<category><![CDATA[JUNIT5]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=4115</guid>

					<description><![CDATA[<p>Unfortunately when building AEM backend logic, the org.apache.http.client.HttpClient is non-trivial to write unit tests. In my case, I scavenged across the net to find a solution where you can make an GET and POST request via HttpClient in particular for AEM, and unit test is performing as expected. In order for me write successful to [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/junit-5-mocking-the-httpclient-in-java">JUnit 5: Mocking the HttpClient in Java</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Unfortunately when building AEM backend logic, the org.apache.http.client.HttpClient is non-trivial to write unit tests. In my case, I scavenged across the net to find a solution where you can make an GET and POST request via HttpClient in particular for AEM, and unit test is performing as expected. In order for me write successful to my servlet, I had to refactor the code. Forcefully, I had to change the org.apache.http.client.HttpClient to <strong>org.apache.http.osgi.services.HttpClientBuilderFactory</strong> OSGI service; the HttpClientBuilderFactor giving me the HttpClient that I need.</p>
<p>This article will showcase a successful unit test with the doGet and doPost example code. The result of the methods will return a JSON string, which we will mock.</p>
<hr class="spacer-larger" />
<h3>1. Dependencies</h3>
<p>Before we begin, I would like to mention the dependencies that I am using to get this code to work <strong>(please make sure you are using JUNIT5)</strong>:</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #339933;">&lt;</span>dependency<span style="color: #339933;">&gt;</span><br />
&nbsp; <span style="color: #339933;">&lt;</span>groupId<span style="color: #339933;">&gt;</span>io.<span style="color: #006633;">wcm</span><span style="color: #339933;">&lt;/</span>groupId<span style="color: #339933;">&gt;</span><br />
&nbsp; <span style="color: #339933;">&lt;</span>artifactId<span style="color: #339933;">&gt;</span>io.<span style="color: #006633;">wcm</span>.<span style="color: #006633;">testing</span>.<span style="color: #006633;">aem</span><span style="color: #339933;">-</span>mock.<span style="color: #006633;">junit5</span><span style="color: #339933;">&lt;/</span>artifactId<span style="color: #339933;">&gt;</span><br />
&nbsp; <span style="color: #339933;">&lt;</span>exclusions<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>exclusion<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>groupId<span style="color: #339933;">&gt;</span>org.<span style="color: #006633;">apache</span>.<span style="color: #006633;">sling</span><span style="color: #339933;">&lt;/</span>groupId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>artifactId<span style="color: #339933;">&gt;</span>org.<span style="color: #006633;">apache</span>.<span style="color: #006633;">sling</span>.<span style="color: #006633;">models</span>.<span style="color: #006633;">impl</span><span style="color: #339933;">&lt;/</span>artifactId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>exclusion<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;</span>exclusion<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>groupId<span style="color: #339933;">&gt;</span>org.<span style="color: #006633;">slf4j</span><span style="color: #339933;">&lt;/</span>groupId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #339933;">&lt;</span>artifactId<span style="color: #339933;">&gt;</span>slf4j<span style="color: #339933;">-</span>simple<span style="color: #339933;">&lt;/</span>artifactId<span style="color: #339933;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">&lt;/</span>exclusion<span style="color: #339933;">&gt;</span><br />
&nbsp; <span style="color: #339933;">&lt;/</span>exclusions<span style="color: #339933;">&gt;</span><br />
&nbsp; <span style="color: #339933;">&lt;</span>scope<span style="color: #339933;">&gt;</span>test<span style="color: #339933;">&lt;/</span>scope<span style="color: #339933;">&gt;</span><br />
<span style="color: #339933;">&lt;/</span>dependency<span style="color: #339933;">&gt;</span><br />
<span style="color: #339933;">&lt;</span>dependency<span style="color: #339933;">&gt;</span><br />
&nbsp; <span style="color: #339933;">&lt;</span>groupId<span style="color: #339933;">&gt;</span>org.<span style="color: #006633;">mockito</span><span style="color: #339933;">&lt;/</span>groupId<span style="color: #339933;">&gt;</span><br />
&nbsp; <span style="color: #339933;">&lt;</span>artifactId<span style="color: #339933;">&gt;</span>mockito<span style="color: #339933;">-</span>core<span style="color: #339933;">&lt;/</span>artifactId<span style="color: #339933;">&gt;</span><br />
&nbsp; <span style="color: #339933;">&lt;</span>version<span style="color: #339933;">&gt;</span>4.1.0<span style="color: #339933;">&lt;/</span>version<span style="color: #339933;">&gt;</span><br />
&nbsp; <span style="color: #339933;">&lt;</span>scope<span style="color: #339933;">&gt;</span>test<span style="color: #339933;">&lt;/</span>scope<span style="color: #339933;">&gt;</span><br />
<span style="color: #339933;">&lt;/</span>dependency<span style="color: #339933;">&gt;</span><br />
<span style="color: #339933;">&lt;</span>dependency<span style="color: #339933;">&gt;</span><br />
&nbsp; <span style="color: #339933;">&lt;</span>groupId<span style="color: #339933;">&gt;</span>org.<span style="color: #006633;">mockito</span><span style="color: #339933;">&lt;/</span>groupId<span style="color: #339933;">&gt;</span><br />
&nbsp; <span style="color: #339933;">&lt;</span>artifactId<span style="color: #339933;">&gt;</span>mockito<span style="color: #339933;">-</span>junit<span style="color: #339933;">-</span>jupiter<span style="color: #339933;">&lt;/</span>artifactId<span style="color: #339933;">&gt;</span><br />
&nbsp; <span style="color: #339933;">&lt;</span>version<span style="color: #339933;">&gt;</span>4.1.0<span style="color: #339933;">&lt;/</span>version<span style="color: #339933;">&gt;</span><br />
&nbsp; <span style="color: #339933;">&lt;</span>scope<span style="color: #339933;">&gt;</span>test<span style="color: #339933;">&lt;/</span>scope<span style="color: #339933;">&gt;</span><br />
<span style="color: #339933;">&lt;/</span>dependency<span style="color: #339933;">&gt;</span></div></td></tr></tbody></table></div>
<div class="spacer-large"></div>
<h3>2. HttpClientServlet.java</h3>
<div class="code-1000">
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.sourcedcode.core.servlets</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.adobe.granite.rest.Constants</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.drew.lang.annotations.NotNull</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.fasterxml.jackson.databind.ObjectMapper</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.google.gson.Gson</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.google.gson.JsonObject</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.http.client.methods.CloseableHttpResponse</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.http.client.methods.HttpGet</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.http.client.methods.HttpPost</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.http.entity.ContentType</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.http.entity.StringEntity</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.http.impl.client.CloseableHttpClient</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.http.osgi.services.HttpClientBuilderFactory</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.http.util.EntityUtils</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.SlingHttpServletRequest</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.SlingHttpServletResponse</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.servlets.HttpConstants</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.servlets.SlingAllMethodsServlet</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.servlets.annotations.SlingServletResourceTypes</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.osgi.service.component.annotations.Component</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.osgi.service.component.annotations.Reference</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.servlet.Servlet</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.servlet.ServletException</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.servlet.http.HttpServletResponse</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.IOException</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.nio.charset.StandardCharsets</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.HashMap</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Map</span><span style="color: #339933;">;</span><br />
<br />
@<span style="color: #003399;">Component</span><span style="color: #009900;">&#40;</span>service <span style="color: #339933;">=</span> Servlet.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><br />
@SlingServletResourceTypes<span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; methods <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>HttpConstants.<span style="color: #006633;">METHOD_GET</span>, HttpConstants.<span style="color: #006633;">METHOD_POST</span><span style="color: #009900;">&#125;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; resourceTypes <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;sourcedcode/component&quot;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; selectors <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #0000ff;">&quot;example&quot;</span><span style="color: #009900;">&#125;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; extensions <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #0000ff;">&quot;json&quot;</span><span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#41;</span><br />
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> HttpClientServlet <span style="color: #000000; font-weight: bold;">extends</span> SlingAllMethodsServlet <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; @<span style="color: #003399;">Reference</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> HttpClientBuilderFactory clientBuilderFactory<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; @Override<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> doGet<span style="color: #009900;">&#40;</span>@NotNull SlingHttpServletRequest request, @NotNull SlingHttpServletResponse response<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> ServletException, <span style="color: #003399;">IOException</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; CloseableHttpClient client <span style="color: #339933;">=</span> clientBuilderFactory.<span style="color: #006633;">newBuilder</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">build</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; HttpGet getMethod <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HttpGet<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;https://dummy.restapiexample.com/api/v1/employee/1&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; CloseableHttpResponse httpClientResponse <span style="color: #339933;">=</span> client.<span style="color: #006633;">execute</span><span style="color: #009900;">&#40;</span>getMethod<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">String</span> responseBody <span style="color: #339933;">=</span> EntityUtils.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span>httpClientResponse.<span style="color: #006633;">getEntity</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; JsonObject jsonObject <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Gson<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">fromJson</span><span style="color: #009900;">&#40;</span>responseBody, JsonObject.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; response.<span style="color: #006633;">setStatus</span><span style="color: #009900;">&#40;</span>HttpServletResponse.<span style="color: #006633;">SC_OK</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; response.<span style="color: #006633;">setContentType</span><span style="color: #009900;">&#40;</span>Constants.<span style="color: #006633;">CT_JSON</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; response.<span style="color: #006633;">setCharacterEncoding</span><span style="color: #009900;">&#40;</span>StandardCharsets.<span style="color: #006633;">UTF_8</span>.<span style="color: #006633;">name</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; response.<span style="color: #006633;">getWriter</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">write</span><span style="color: #009900;">&#40;</span>jsonObject.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; @Override<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> doPost<span style="color: #009900;">&#40;</span>@NotNull SlingHttpServletRequest request, @NotNull SlingHttpServletResponse response<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> ServletException, <span style="color: #003399;">IOException</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; CloseableHttpClient client <span style="color: #339933;">=</span> clientBuilderFactory.<span style="color: #006633;">newBuilder</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">build</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; ObjectMapper mapper <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ObjectMapper<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Map<span style="color: #339933;">&lt;</span><span style="color: #003399;">String</span>, String<span style="color: #339933;">&gt;</span> object <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HashMap<span style="color: #339933;">&lt;&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; object.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;test&quot;</span>, <span style="color: #0000ff;">&quot;value&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; StringEntity requestData <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> StringEntity<span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mapper.<span style="color: #006633;">writeValueAsString</span><span style="color: #009900;">&#40;</span>object<span style="color: #009900;">&#41;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ContentType.<span style="color: #006633;">APPLICATION_JSON</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; HttpPost postMethod <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HttpPost<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;https://freemeposting.free.beeceptor.com/my/api/path&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; postMethod.<span style="color: #006633;">setEntity</span><span style="color: #009900;">&#40;</span>requestData<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; postMethod.<span style="color: #006633;">setHeader</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Test&quot;</span>, <span style="color: #0000ff;">&quot;Test&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; CloseableHttpResponse preRenderedResponse <span style="color: #339933;">=</span> client.<span style="color: #006633;">execute</span><span style="color: #009900;">&#40;</span>postMethod<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">String</span> responseBody <span style="color: #339933;">=</span> EntityUtils.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span>preRenderedResponse.<span style="color: #006633;">getEntity</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; JsonObject jsonObject <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Gson<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">fromJson</span><span style="color: #009900;">&#40;</span>responseBody, JsonObject.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; response.<span style="color: #006633;">setStatus</span><span style="color: #009900;">&#40;</span>HttpServletResponse.<span style="color: #006633;">SC_OK</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; response.<span style="color: #006633;">setContentType</span><span style="color: #009900;">&#40;</span>Constants.<span style="color: #006633;">CT_JSON</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; response.<span style="color: #006633;">setCharacterEncoding</span><span style="color: #009900;">&#40;</span>StandardCharsets.<span style="color: #006633;">UTF_8</span>.<span style="color: #006633;">name</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; response.<span style="color: #006633;">getWriter</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">write</span><span style="color: #009900;">&#40;</span>jsonObject.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
</div>
<hr class="spacer-larger" />
<div class="code-1250">
<h3>3. HttpClientServletTest.java</h3>
<p>In all, the most important line here that you should take a look at is line:60. On this line you can see that I am injecting mocks into the HttpClientBuilderFactory osgi service, which when clientBuilderFactory.newBuilder().build() is being called, the HttpClientBuilderFactory is bring returned in lin:47, which will be the HttpClient itself.</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br />78<br />79<br />80<br />81<br />82<br />83<br />84<br />85<br />86<br />87<br />88<br />89<br />90<br />91<br />92<br />93<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.sourcedcode.core.servlets</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">io.wcm.testing.mock.aem.junit5.AemContext</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">io.wcm.testing.mock.aem.junit5.AemContextExtension</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.http.HttpEntity</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.http.client.methods.CloseableHttpResponse</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.http.impl.client.CloseableHttpClient</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.http.impl.client.HttpClientBuilder</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.http.osgi.services.HttpClientBuilderFactory</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.SlingHttpServletResponse</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.servlets.SlingAllMethodsServlet</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.testing.mock.sling.ResourceResolverType</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.testing.mock.sling.servlet.MockSlingHttpServletRequest</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.junit.jupiter.api.Test</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.junit.jupiter.api.extension.ExtendWith</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.mockito.InjectMocks</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.mockito.Mock</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.mockito.junit.jupiter.MockitoExtension</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.servlet.ServletException</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.ByteArrayInputStream</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.IOException</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.InputStream</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.PrintWriter</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">static</span> org.<span style="color: #006633;">mockito</span>.<span style="color: #006633;">ArgumentMatchers</span>.<span style="color: #006633;">any</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">static</span> org.<span style="color: #006633;">mockito</span>.<span style="color: #006633;">Mockito</span>.<span style="color: #339933;">*;</span><br />
<br />
@ExtendWith<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>AemContextExtension.<span style="color: #000000; font-weight: bold;">class</span>, MockitoExtension.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> HttpClientServletTest <span style="color: #000000; font-weight: bold;">extends</span> SlingAllMethodsServlet <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">final</span> AemContext aemContext <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> AemContext<span style="color: #009900;">&#40;</span>ResourceResolverType.<span style="color: #006633;">JCR_MOCK</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; @Mock<br />
&nbsp; &nbsp; HttpClientBuilderFactory clientBuilderFactory<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; @Mock<br />
&nbsp; &nbsp; CloseableHttpClient closeableHttpClientMock<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; @Mock<br />
&nbsp; &nbsp; CloseableHttpResponse closeableHttpResponseMock<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; @InjectMocks<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> HttpClientServlet unitTest <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HttpClientServlet<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; @Test<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> testServletDoGet<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> ServletException, <span style="color: #003399;">IOException</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">String</span> responseData <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;{status: &quot;</span>success<span style="color: #0000ff;">&quot;}&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">InputStream</span> anyInputStream <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">ByteArrayInputStream</span><span style="color: #009900;">&#40;</span>responseData.<span style="color: #006633;">getBytes</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; MockSlingHttpServletRequest request <span style="color: #339933;">=</span> aemContext.<span style="color: #006633;">request</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; SlingHttpServletResponse response <span style="color: #339933;">=</span> mock<span style="color: #009900;">&#40;</span>SlingHttpServletResponse.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; HttpEntity httpEntityMock <span style="color: #339933;">=</span> &nbsp;mock<span style="color: #009900;">&#40;</span>HttpEntity.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; when<span style="color: #009900;">&#40;</span>clientBuilderFactory.<span style="color: #006633;">newBuilder</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">thenReturn</span><span style="color: #009900;">&#40;</span>mock<span style="color: #009900;">&#40;</span>HttpClientBuilder.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; when<span style="color: #009900;">&#40;</span>clientBuilderFactory.<span style="color: #006633;">newBuilder</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">build</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">thenReturn</span><span style="color: #009900;">&#40;</span>closeableHttpClientMock<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; when<span style="color: #009900;">&#40;</span>closeableHttpClientMock.<span style="color: #006633;">execute</span><span style="color: #009900;">&#40;</span>any<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">thenReturn</span><span style="color: #009900;">&#40;</span>closeableHttpResponseMock<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; when<span style="color: #009900;">&#40;</span>closeableHttpResponseMock.<span style="color: #006633;">getEntity</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">thenReturn</span><span style="color: #009900;">&#40;</span>httpEntityMock<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; when<span style="color: #009900;">&#40;</span>httpEntityMock.<span style="color: #006633;">getContent</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">thenReturn</span><span style="color: #009900;">&#40;</span>anyInputStream<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">PrintWriter</span> printWriterMock <span style="color: #339933;">=</span> mock<span style="color: #009900;">&#40;</span><span style="color: #003399;">PrintWriter</span>.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; when<span style="color: #009900;">&#40;</span>response.<span style="color: #006633;">getWriter</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">thenReturn</span><span style="color: #009900;">&#40;</span>printWriterMock<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; aemContext.<span style="color: #006633;">registerService</span><span style="color: #009900;">&#40;</span>HttpClientBuilderFactory.<span style="color: #000000; font-weight: bold;">class</span>, clientBuilderFactory<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; unitTest.<span style="color: #006633;">doGet</span><span style="color: #009900;">&#40;</span>request, response<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; verify<span style="color: #009900;">&#40;</span>printWriterMock<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">write</span><span style="color: #009900;">&#40;</span>eq<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;{&quot;</span>status<span style="color: #0000ff;">&quot;:&quot;</span>success<span style="color: #0000ff;">&quot;}&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; @Test<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> testServletDoPost<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> ServletException, <span style="color: #003399;">IOException</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">String</span> responseData <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;{status: &quot;</span>success<span style="color: #0000ff;">&quot;}&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">InputStream</span> anyInputStream <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">ByteArrayInputStream</span><span style="color: #009900;">&#40;</span>responseData.<span style="color: #006633;">getBytes</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; MockSlingHttpServletRequest request <span style="color: #339933;">=</span> aemContext.<span style="color: #006633;">request</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; SlingHttpServletResponse response <span style="color: #339933;">=</span> mock<span style="color: #009900;">&#40;</span>SlingHttpServletResponse.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; HttpEntity httpEntityMock <span style="color: #339933;">=</span> &nbsp;mock<span style="color: #009900;">&#40;</span>HttpEntity.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; when<span style="color: #009900;">&#40;</span>clientBuilderFactory.<span style="color: #006633;">newBuilder</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">thenReturn</span><span style="color: #009900;">&#40;</span>mock<span style="color: #009900;">&#40;</span>HttpClientBuilder.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; when<span style="color: #009900;">&#40;</span>clientBuilderFactory.<span style="color: #006633;">newBuilder</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">build</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">thenReturn</span><span style="color: #009900;">&#40;</span>closeableHttpClientMock<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; when<span style="color: #009900;">&#40;</span>closeableHttpClientMock.<span style="color: #006633;">execute</span><span style="color: #009900;">&#40;</span>any<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">thenReturn</span><span style="color: #009900;">&#40;</span>closeableHttpResponseMock<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; when<span style="color: #009900;">&#40;</span>closeableHttpResponseMock.<span style="color: #006633;">getEntity</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">thenReturn</span><span style="color: #009900;">&#40;</span>httpEntityMock<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; when<span style="color: #009900;">&#40;</span>httpEntityMock.<span style="color: #006633;">getContent</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">thenReturn</span><span style="color: #009900;">&#40;</span>anyInputStream<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">PrintWriter</span> printWriterMock <span style="color: #339933;">=</span> mock<span style="color: #009900;">&#40;</span><span style="color: #003399;">PrintWriter</span>.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; when<span style="color: #009900;">&#40;</span>response.<span style="color: #006633;">getWriter</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">thenReturn</span><span style="color: #009900;">&#40;</span>printWriterMock<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; aemContext.<span style="color: #006633;">registerService</span><span style="color: #009900;">&#40;</span>HttpClientBuilderFactory.<span style="color: #000000; font-weight: bold;">class</span>, clientBuilderFactory<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; unitTest.<span style="color: #006633;">doPost</span><span style="color: #009900;">&#40;</span>request, response<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; verify<span style="color: #009900;">&#40;</span>printWriterMock<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">write</span><span style="color: #009900;">&#40;</span>eq<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;{&quot;</span>status<span style="color: #0000ff;">&quot;:&quot;</span>success<span style="color: #0000ff;">&quot;}&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
</div>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/junit-5-mocking-the-httpclient-in-java">JUnit 5: Mocking the HttpClient in Java</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/junit-5-mocking-the-httpclient-in-java/feed</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
			</item>
		<item>
		<title>Deploying Core Module of the AEM Project</title>
		<link>https://sourcedcode.com/blog/aem/deploying-core-module-of-the-aem-project</link>
					<comments>https://sourcedcode.com/blog/aem/deploying-core-module-of-the-aem-project#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Thu, 22 Dec 2022 04:33:04 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Deployment]]></category>
		<category><![CDATA[Development]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=4102</guid>

					<description><![CDATA[<p>For rapid AEM backend developer, we would like to build the AEM core module bundle to our running local AEM instance. In this article, we will configure the core bundle with an automated script. Simple build the project with mvn clean install -PautoInstallBundle. This is actually a standard that is shipped from the aem-project-archetype-39, but [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/deploying-core-module-of-the-aem-project">Deploying Core Module of the AEM Project</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>For rapid AEM backend developer, we would like to build the AEM core module bundle to our running local AEM instance. In this article, we will configure the core bundle with an automated script. Simple build the project with mvn clean install -PautoInstallBundle. This is actually a standard that is shipped from the aem-project-archetype-39, but not configured to the AEM core module.</p>
<p>At the creation of this article, I have used <a href="https://github.com/adobe/aem-project-archetype/tree/aem-project-archetype-39" rel="noopener" target="_blank">https://github.com/adobe/aem-project-archetype/tree/aem-project-archetype-39</a>. </p>
<h3>1. Add a new profile in your core/pom.xml</h3>
<div class="codecolorer-container xml default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br /></div></td><td><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;profiles<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;profile<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>autoInstallBundle<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;activation<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;activeByDefault<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>false<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/activeByDefault<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/activation<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;build<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;pluginManagement<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;plugins<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.apache.sling<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>sling-maven-plugin<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>2.4.0<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;executions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;execution<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>install-bundle<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;goals<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;goal<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>install<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/goal<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/goals<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;slingUrl<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${aem.host}:${aem.port}/system/console<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/slingUrl<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/execution<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/executions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/plugins<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/pluginManagement<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/build<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/profile<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/profiles<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></div></td></tr></tbody></table></div>
<hr class="spacer-large"/>
<h3>2. Change directory to the core bundle folder, and then run the command below:</h3>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">cd ~<span style="color: #339933;">/</span>git<span style="color: #339933;">/</span><span style="color: #cc66cc;">2023</span><span style="color: #339933;">/</span>sourcedcode<span style="color: #339933;">/</span>core<br />
<br />
mvn clean install <span style="color: #339933;">-</span>PautoInstallBundle</div></td></tr></tbody></table></div>
<hr class="spacer-large"/>
<h3>3. What&#8217;s the difference between Maven plugins vs dependencies?</h3>
<p><strong>Plugins</strong> are used during the code build phase, when code is being built by Maven; plugins are where much of the real action is performed, plugins are used to: create jar files, create war files, compile code, unit test code, create project documentation, and on and on. Almost any action that you can think of performing on a project is implemented as a Maven plugin.</p>
<p><strong>Dependencies</strong> are declared and used by Maven. During the build, Maven will download the dependencies to your local repository and then use this to compile your JAR. We use the &lt;scope&#038;;gt;test/&lt;scope&#038;;gt;t to indicate that dependency is not required at the runtime of the application but is used only for test purposes; this dependency will not be bundled with the .jar producted.</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/deploying-core-module-of-the-aem-project">Deploying Core Module of the AEM Project</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/deploying-core-module-of-the-aem-project/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Create System &#124; Service Users in AEM 6.5 with Code Configurations</title>
		<link>https://sourcedcode.com/blog/aem/create-system-service-users-in-aem-6-5-with-code-configurations</link>
					<comments>https://sourcedcode.com/blog/aem/create-system-service-users-in-aem-6-5-with-code-configurations#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Sun, 27 Nov 2022 00:35:46 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Sightly]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=4026</guid>

					<description><![CDATA[<p>In this article we will walk through how to configure your AEM project to have the AEM environment self configure System Users in AEM with code, so that you would not need to do it the manual way. With the leverage of the org.apache.sling.jcr.api v2.4.0 bundle provided by AEM 6.5.4+ or AEM as a Cloud [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/create-system-service-users-in-aem-6-5-with-code-configurations">Create System | Service Users in AEM 6.5 with Code Configurations</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>In this article we will walk through how to configure your AEM project to have the AEM environment self configure System Users in AEM with code, so that you would not need to do it the <a href="https://experienceleague.adobe.com/docs/experience-manager-65/administering/security/security-service-users.html?lang=en" rel="noopener" target="_blank">manual way</a>. </p>
<p>With the leverage of the org.apache.sling.jcr.api v2.4.0 bundle provided by <strong>AEM 6.5.4+</strong> or <strong>AEM as a Cloud Service</strong>, we are able to utilize the Repository Initialization (repoinit) feature. At the start of this article, we will quickly provide a review of what a system user is, next we will explain what actually is the Repository Initialization (repoinit) feature and it&#8217;s dependencies, and finally, we will be providing some code examples on how to setup this feature on your own AEM instance with a code follow through.</p>
<p>AEM System Users are also referred as Service Users.</p>
<div class="mention-block">
<strong>Quick Links</strong></p>
<ol>
<li><a href="#aem-system-user-quick-review" rel="noopener">AEM System User Quick Review</a></li>
<li><a href="#what-is-repository-initialization-repoinit" rel="noopener">What Is Repository Initialization (repoinit)?</a></li>
<li><a href="#aem-dependencies-for-the-repository-initialization-feature-sling-repo-init">AEM Dependencies for the Repository Initialization Feature(Sling RepoInit)</a></li>
<li><a href="#code-follow-through">Code Follow Through</a>
<ul>
<li><a href="#configure-org-apache-sling-jcr-repoinit-repository-initializer-pid">A. Configure org.apache.sling.jcr.repoinit.RepositoryInitializer PID</a></li>
<li><a href="#configure-org-apache-sling-serviceusermapping-impl-service-user-mapper-impl-amended-pid">B. Configure org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended PID</a></li>
<li><a href="#register-basic-servlet-get-request">C. Register Basic Servlet (GET Request)</a></li>
<li><a href="#test-and-validate-the-servlet-response">D. Test and Validate the Servlet Response</a></li>
<li><a href="#service-user-in-user-admin">E. ServiceUser in UserAdmin</a></li>
</ul>
</li>
</ol>
</div>
<hr class="spacer-large"/>
<h3 id="aem-system-user-quick-review">1. AEM System User Quick Review</h3>
<p>Before we begin, let&#8217;s reiterate what a System User in AEM is. A system user is a JCR user with no password set and a minimal set of privileges that are necessary to perform a specific task. Having no password set means that it will not be possible to login with a system user. A system user is typically utilized by the AEM backend code which have privileges to create, read, update, and delete nodes in the JCR; the backend code will authenticate as a system user as a session when needed, and is required to session logout right when the task or tasks have been completed. Not logging out of a system user from the AEM backend will cause issues. If you do not logout of a session that you have opened, your AEM will be flooded by opened sessions, your AEM will start complaining with *INFO* [Apache Sling Resource Resolver Finalizer Thread] org.apache.sling.resourceresolver.impl.CommonResourceResolverFactoryImpl Unclosed ResourceResolver, and eventually your AEM environment will run out of memory and crash; to learn more about this topic, take a look at this blog article, <a href="https://cqdump.joerghoh.de/2018/11/12/resourceresolvers-and-sessions-you-open-it-you-close-it/" rel="noopener" target="_blank">ResourceResolvers and Sessions — “you open it</a>, you close it”, by Jörg Hoh. The rule of thumb for creating System Users is to keep the privileges very specific; ensure you have a plan for this system user.</p>
<hr class="spacer-large"/>
<h2 id="what-is-repository-initialization-repoinit">2. What Is Repository Initialization (repoinit)?</h2>
<p>Sling RepoInit is a mechanism that allows configuration code to run before the SlingRepository service is registered. Configuration code is registered under the org.apache.sling.jcr.repoinit.RepositoryInitializer factory PID, and written in a mini-language.</p>
<p>The org.apache.sling.repoinit.parser implements a mini-language meant to create paths, system users and manage access control in a content repository, as well as registering JCR namespaces, node types and privileges. Defining access control content consists of setting and deleting policies of type access control lists (ACL) for which individual access control entries (ACE) can be added and removed.</p>
<p>Full documentation found <a href="https://sling.apache.org/documentation/bundles/repository-initialization.html" rel="noopener" target="_blank">here</a>.</p>
<hr class="spacer-large"/>
<h2 id="aem-dependencies-for-the-repository-initialization-feature-sling-repo-init">3. AEM Dependencies for the Repository Initialization Feature(Sling RepoInit)</h2>
<p>To be able to use this feature, you must have <strong>AEM 6.5.4+</strong> or <strong>AEM as a Cloud Service</strong>.</p>
<p>From out of the box AEM 6.5, it already includes a version of Sling RepoInit, but this is likely an older version without the service pack. If you are not able to replicate the <a href="#code-follow-through">code follow through</a> mentioned on this article, consider upgrading your AEM service pack to the supported version <strong>AEM 6.5.4+</strong>. Take a look at my bundle versions found in /system/console/bundles (as these installed versions are working as expected on my machine):</p>
<ul>
<li>org.apache.sling.jcr.api @ 2.4.0</li>
<li>org.apache.sling.jcr.repoinit @ 1.1.28</li>
<li>org.apache.sling.repoinit.parser @ 1.6.2</li>
</ul>
<hr class="spacer-larger"/>
<h2 id="code-follow-through">4. Code Follow Through</h2>
<p>In the code follow through, you will create a system user with code configurations. Next, with the system user, you will write code for a simple AEM Servlet which will be a GET request, which will write a new property into an existing node in AEM.</p>
<hr class="spacer-large"/>
<h3 id="configure-org-apache-sling-jcr-repoinit-repository-initializer-pid">A. Configure org.apache.sling.jcr.repoinit.RepositoryInitializer PID</h3>
<p>With the org.apache.sling.jcr.repoinit.RepositoryInitializer factory PID, we will be creating a new configuration file.</p>
<p>With this configuration, we are creating a system user named sourcedCodeSystemUser, and will be placed into the folder structure of /home/users/system/sourcedCode. The system user, sourcedCodeSystemUser, will have ACL (Access Control List) privileges configured to:</p>
<ul>
<li>allow read,write,replicate for all JCR resources which exists under /content/sourcedcode</li>
<li>allow read,write,replicate for all JCR resources which exists under /conf/sourcedcode</li>
<li>allow ALL-CRUD-ACTIONS for all JCR resources which exists under /content/we-retail</li>
</ul>
<p><strong>filename: </strong>/apps/sourcedcode/config/org.apache.sling.jcr.repoinit.RepositoryInitializer~sourcedcodeSystemUser.config</p>
<div class="codecolorer-container xml default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">scripts=[&quot;<br />
&nbsp; &nbsp; create service user sourcedCodeSystemUser with path /home/users/system/sourcedCode<br />
&nbsp; &nbsp; set ACL for sourcedCodeSystemUser<br />
&nbsp; &nbsp; &nbsp; &nbsp; allow jcr:read,rep:write,crx:replicate on /content/sourcedcode<br />
&nbsp; &nbsp; &nbsp; &nbsp; allow jcr:read,rep:write,crx:replicate on /conf/sourcedcode<br />
&nbsp; &nbsp; &nbsp; &nbsp; allow jcr:all on /content/we-retail<br />
&nbsp; &nbsp; end<br />
&quot;]</div></td></tr></tbody></table></div>
<p><strong>filename: </strong>/apps/sourcedcode/config/org.apache.sling.jcr.repoinit.RepositoryInitializer~sourcedcodeSystemUser.cfg.json</p>
<div class="codecolorer-container xml default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #000066;">scripts</span>=<span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;<br />
&nbsp; &nbsp; create service user sourcedCodeSystemUser with path /home/users/system/sourcedCode<br />
&nbsp; &nbsp; set ACL for sourcedCodeSystemUser<br />
&nbsp; &nbsp; &nbsp; &nbsp; allow jcr:read,rep:write,crx:replicate on /content/sourcedcode<br />
&nbsp; &nbsp; &nbsp; &nbsp; allow jcr:read,rep:write,crx:replicate on /conf/sourcedcode<br />
&nbsp; &nbsp; &nbsp; &nbsp; allow jcr:all on /content/we-retail<br />
&nbsp; &nbsp; end<br />
&quot;</span><span style="color: #66cc66;">&#93;</span></div></td></tr></tbody></table></div>
<p>Such configurations have two optional fields:<br />
A multi-value <strong>references</strong> field with each value providing the URL (as a String) of raw repoinit statements.<br />
A multi-value <strong>scripts</strong> field with each value providing repoinit statements as plain text in a String.</p>
<hr class="spacer-large"/>
<h3 id="configure-org-apache-sling-serviceusermapping-impl-service-user-mapper-impl-amended-pid">B. Configure org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended PID</h3>
<p>To add a mapping from your service to the corresponding System Users you need to create a factory configuration for the [ServiceUserMapper](https://sling.apache.org/apidocs/sling7/org/apache/sling/serviceusermapping/ServiceUserMapper.html) service. To keep this modular such configurations can be provided using the Sling amend mechanism. </p>
<p>Below, you will see us mapping the sourcedcode.core backend to the sourcedCodeSystemUser.</p>
<p>filename: org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended-sourcedcodeSystemUser.config</p>
<div class="codecolorer-container xml default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br /></div></td><td><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #000066;">user.mapping</span>=<span style="color: #66cc66;">&#91;</span> \<br />
&nbsp; <span style="color: #ff0000;">&quot;sourcedcode.core:sourcedCodeSystemUser\=[sourcedCodeSystemUser]&quot;</span><br />
<span style="color: #66cc66;">&#93;</span></div></td></tr></tbody></table></div>
<hr class="spacer-large"/>
<h3 id="register-basic-servlet-get-request">C. Register Basic Servlet (GET Request)</h3>
<p>line:38, we are creating the Map<String, Object> authInfo class with ResourceResolverFactory.SUBSERVICE set to the system user that we have just created, &#8220;sourcedCodeSystemUser&#8221;.</p>
<p>line:41, we will utilize the Java 7 API, “try-wth-resource”, best practice, to ensure that when we open a new session, we are never forgetting to close the session after the use of it; Since Sling9 (roughly 2016) the ResourceResolver interface implements the AutoCloseable marker interface, so the try-with-resource idiom can be used. Here we are obtaining the resolver via ResourceResolverFactory.getServiceResourceResolver() method.</p>
<p>line:42, we are adapting the resolver into a javax.jcr.Session.class.</p>
<p>line:44-50, we are getting the AEM JCR node, writing new properties to /content/sourcedcode/jcr:content, and replicating the node. And on succeess, we will return the message of &#8220;Test is saved and replicated&#8221;.</p>
<p><strong>filename</strong>: sourcedcode/core/src/main/java/com/sourcedcode/core/servlets/SimpleGetServlet.java</p>
<div class="code-750">
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.sourcedcode.core.servlets</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.day.cq.replication.ReplicationActionType</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.day.cq.replication.Replicator</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.SlingHttpServletRequest</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.SlingHttpServletResponse</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.resource.ResourceResolver</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.resource.ResourceResolverFactory</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.servlets.HttpConstants</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.servlets.SlingAllMethodsServlet</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.osgi.service.component.annotations.Component</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.osgi.service.component.annotations.Reference</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.jcr.Node</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.jcr.Session</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.servlet.Servlet</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.IOException</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Collections</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Map</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Objects</span><span style="color: #339933;">;</span><br />
<br />
@<span style="color: #003399;">Component</span><span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; service <span style="color: #339933;">=</span> Servlet.<span style="color: #000000; font-weight: bold;">class</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; property <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;sling.servlet.paths=/bin/simple-get&quot;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;sling.servlet.methods=&quot;</span> <span style="color: #339933;">+</span> HttpConstants.<span style="color: #006633;">METHOD_GET</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> SimpleGetServlet <span style="color: #000000; font-weight: bold;">extends</span> SlingAllMethodsServlet <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; @<span style="color: #003399;">Reference</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> ResourceResolverFactory factory<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; @<span style="color: #003399;">Reference</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> Replicator replicator<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; @Override<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> doGet<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">final</span> SlingHttpServletRequest req, <span style="color: #000000; font-weight: bold;">final</span> SlingHttpServletResponse resp<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">IOException</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">final</span> Map<span style="color: #339933;">&lt;</span><span style="color: #003399;">String</span>, Object<span style="color: #339933;">&gt;</span> authInfo <span style="color: #339933;">=</span> <span style="color: #003399;">Collections</span>.<span style="color: #006633;">singletonMap</span><span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ResourceResolverFactory.<span style="color: #006633;">SUBSERVICE</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;sourcedCodeSystemUser&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#40;</span>ResourceResolver resolver <span style="color: #339933;">=</span> factory.<span style="color: #006633;">getServiceResourceResolver</span><span style="color: #009900;">&#40;</span>authInfo<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Session session <span style="color: #339933;">=</span> resolver.<span style="color: #006633;">adaptTo</span><span style="color: #009900;">&#40;</span>Session.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Node contentNode <span style="color: #339933;">=</span> session.<span style="color: #006633;">getNode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/content/sourcedcode/jcr:content&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>Objects.<span style="color: #006633;">nonNull</span><span style="color: #009900;">&#40;</span>contentNode<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; contentNode.<span style="color: #006633;">setProperty</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;test&quot;</span>, <span style="color: #0000ff;">&quot;works&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; session.<span style="color: #006633;">save</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; replicator.<span style="color: #006633;">replicate</span><span style="color: #009900;">&#40;</span>session, ReplicationActionType.<span style="color: #006633;">ACTIVATE</span>, contentNode.<span style="color: #006633;">getPath</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; resp.<span style="color: #006633;">setStatus</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">200</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; resp.<span style="color: #006633;">getWriter</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">write</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Test is saved and replicated.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; e.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; resp.<span style="color: #006633;">setStatus</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">500</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; resp.<span style="color: #006633;">getWriter</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">write</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Failed to save.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
</div>
<hr class="spacer-large"/>
<h4>D. Test and Validate the Servlet Response</h3>
<p>Now use your maven skills to build the project!</p>
<p>Next, after a successful build, you would want to make a call to your AEM servlet, via <a href="http://localhost:4502/bin/simple-get" rel="noopener" target="_blank">http://localhost:4502/bin/simple-get</a>. With the service system successfully configured in your environment, you should be able to see a successful message.</p>
<p><strong>Test is saved and replicated.</strong></p>
<p>Revealing the changes in the JCR content, <a href="http://localhost:4502/crx/de/index.jsp#/content/sourcedcode/jcr%3Acontent" rel="noopener" target="_blank">http://localhost:4502/crx/de/index.jsp#/content/sourcedcode/jcr%3Acontent</a>, you should be able to see the changes.<br />
<a href="https://sourcedcode.com/wp-content/uploads/2022/11/sourcedCodeSystemUser-successful-servlet.png"><img loading="lazy" decoding="async" src="https://sourcedcode.com/wp-content/uploads/2022/11/sourcedCodeSystemUser-successful-servlet.png" alt="Screenshot of the crx/de properties for the JCR node, /content/sourcedcode/jcr%3Acontent" width="3840" height="2070" class="alignnone size-full wp-image-4065" srcset="https://sourcedcode.com/wp-content/uploads/2022/11/sourcedCodeSystemUser-successful-servlet.png 3840w, https://sourcedcode.com/wp-content/uploads/2022/11/sourcedCodeSystemUser-successful-servlet-300x162.png 300w, https://sourcedcode.com/wp-content/uploads/2022/11/sourcedCodeSystemUser-successful-servlet-1024x552.png 1024w, https://sourcedcode.com/wp-content/uploads/2022/11/sourcedCodeSystemUser-successful-servlet-768x414.png 768w, https://sourcedcode.com/wp-content/uploads/2022/11/sourcedCodeSystemUser-successful-servlet-1536x828.png 1536w, https://sourcedcode.com/wp-content/uploads/2022/11/sourcedCodeSystemUser-successful-servlet-2048x1104.png 2048w, https://sourcedcode.com/wp-content/uploads/2022/11/sourcedCodeSystemUser-successful-servlet-600x323.png 600w" sizes="(max-width: 3840px) 100vw, 3840px" /></a></p>
<hr class="spacer-large"/>
<h4 id="service-user-in-user-admin">E. ServiceUser in UserAdmin</h3>
<p>If you like, take a look at <a href="http://localhost:4502/useradmi" rel="noopener" target="_blank">http://localhost:4502/useradmin</a>. Search for the sourcedcodeSystemUser and review the permissions for this system user. You should be able to see permissions reflected for this system user:</p>
<ul>
<li>allow read,write,replicate for all JCR resources which exists under /content/sourcedcode</li>
<li>allow read,write,replicate for all JCR resources which exists under /conf/sourcedcode</li>
<li>allow ALL-CRUD-ACTIONS for all JCR resources which exists under /content/we-retail</li>
</ul>
<p><a href="https://sourcedcode.com/wp-content/uploads/2022/11/sourcedCodeSystemUser.png"><img decoding="async" src="https://sourcedcode.com/wp-content/uploads/2022/11/sourcedCodeSystemUser.png" alt="In the AEM useradmin console, showcasing the sourcedcodeSystemUser with correct permissions." width="100%" height="2067" class="alignnone size-full wp-image-4061" srcset="https://sourcedcode.com/wp-content/uploads/2022/11/sourcedCodeSystemUser.png 3835w, https://sourcedcode.com/wp-content/uploads/2022/11/sourcedCodeSystemUser-300x162.png 300w, https://sourcedcode.com/wp-content/uploads/2022/11/sourcedCodeSystemUser-1024x552.png 1024w, https://sourcedcode.com/wp-content/uploads/2022/11/sourcedCodeSystemUser-768x414.png 768w, https://sourcedcode.com/wp-content/uploads/2022/11/sourcedCodeSystemUser-1536x828.png 1536w, https://sourcedcode.com/wp-content/uploads/2022/11/sourcedCodeSystemUser-2048x1104.png 2048w, https://sourcedcode.com/wp-content/uploads/2022/11/sourcedCodeSystemUser-600x323.png 600w" sizes="(max-width: 3835px) 100vw, 3835px" /></a></p>
<hr class="spacer-large"/>
<h3>This article covers questions like</h3>
<ul>
<li>How to create AEM System User Programmatically</li>
<li>How to create AEM System User Automatically</li>
<li>How to create AEM System User on AEMaaCS</li>
<li>How to create AEM System User with Code</li>
<li>How to create AEM System User that is not manual</li>
<li>How to create AEM System User the preferred way</li>
<li>How to create AEM Service User Programmatically</li>
<li>How to create AEM Service User Automatically</li>
<li>How to create AEM Service User on AEMaaCS</li>
<li>How to create AEM Service User with Code</li>
<li>How to create AEM Service User that is not manual</li>
<li>How to create AEM Service User the preferred way</li>
</ul>
<hr class="spacer-large"/>
<h3>Path not found by AEMaaCS</h3>
<p>Sometimes you may find errors in the AEMaaCS pipelines due to the reason that when reference to path that you are allowing system user permissions to, path does not exist. And so, the node must declare creation of these path&#8217;s in the repo-init script. Although the path&#8217;s are already installed inside of AEM, it wouldn&#8217;t do anything anyways&#8230; this is to fix the repo-init system user pipeline errors.</p>
<p>Here&#8217;s an example of us creating a repo-init system user which allows permissions for the system user, and includes the creation of paths:</p>
<ul>
<li>allow jcr:all on /content/sourcedcode</li>
<li>allow jcr:all on /conf/sourcedcode</li>
<li>allow jcr:all on /content/dam/sourcedcode</li>
<li>allow jcr:all on /content/cq:tags/sourcedcode</li>
</ul>
<h3>repoinit cfg json example for creating system user</h3>
<p><strong>filename: </strong>/apps/sourcedcode/config/org.apache.sling.jcr.repoinit.RepositoryInitializer~sourcedcodeSystemUser.cfg.json</strong></p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #009900;">&#123;</span><br />
&nbsp; <span style="color: #0000ff;">&quot;scripts&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><br />
&nbsp; &nbsp; <span style="color: #0000ff;">&quot;create path (sling:OrderedFolder) /content/dam/sourcedcode&quot;</span>,<br />
&nbsp; &nbsp; <span style="color: #0000ff;">&quot;create path (nt:unstructured) /content/dam/sourcedcode/jcr:content&quot;</span>,<br />
&nbsp; &nbsp; <span style="color: #0000ff;">&quot;create path (cq:Page) /content/sourcedcode&quot;</span>,<br />
&nbsp; &nbsp; <span style="color: #0000ff;">&quot;create path (cq:PageContent) /content/sourcedcode/jcr:content&quot;</span>,<br />
&nbsp; &nbsp; <span style="color: #0000ff;">&quot;create path (sling:Folder) /conf/sourcedcode&quot;</span>,<br />
&nbsp; &nbsp; <span style="color: #0000ff;">&quot;create path (cq:Tag) /content/cq:tags/sourcedcode&quot;</span>,<br />
&nbsp; &nbsp; <span style="color: #0000ff;">&quot;set properties on /conf/sourcedcode<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span> &nbsp;set jcr:title{String} to &quot;</span>Sourced Code<span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>end&quot;</span>,<br />
&nbsp; &nbsp; <span style="color: #0000ff;">&quot;set properties on /content/dam/sourcedcode/jcr:content<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span> &nbsp;set cq:conf{String} to /conf/sourcedcode<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span> &nbsp;set jcr:title{String} to &quot;</span>Sourced Code<span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>end&quot;</span>,<br />
&nbsp; &nbsp; <span style="color: #0000ff;">&quot;create service user sourcedcodeSystemUser with path /home/users/system/sourcedcode&quot;</span>,<br />
&nbsp; &nbsp; <span style="color: #0000ff;">&quot;set ACL for sourcedcodeSystemUser <span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span> &nbsp;allow jcr:all on /content/sourcedcode<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span> &nbsp;allow jcr:all on /conf/sourcedcode<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span> &nbsp;allow jcr:all on /content/dam/sourcedcode<span style="color: #000099; font-weight: bold;">\n</span> &nbsp;allow jcr:all on /content/cq:tags/sourcedcode<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>end&quot;</span><br />
&nbsp; <span style="color: #009900;">&#93;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/create-system-service-users-in-aem-6-5-with-code-configurations">Create System | Service Users in AEM 6.5 with Code Configurations</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/create-system-service-users-in-aem-6-5-with-code-configurations/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>resourceResolverFactory.getAdministrativeResourceResolver(null) WhiteList Bundle for Administrative Login</title>
		<link>https://sourcedcode.com/blog/aem/whitelist-bundle-for-administrative-login</link>
					<comments>https://sourcedcode.com/blog/aem/whitelist-bundle-for-administrative-login#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Thu, 17 Nov 2022 02:18:06 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Security]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=4076</guid>

					<description><![CDATA[<p>When working for organizations with the goal of migrating from AEM 6X to 6.5 or to AEM Cloud as a Service. It&#8217;s very common that the AEM backend code still utilizes the deprecated resourceResolverFactory.getAdministrativeResourceResolver(null) @depricated API. This method has been deprecated as of 2.4 (bundle version 2.5.0) because of inherent security issues. Services requiring specific [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/whitelist-bundle-for-administrative-login">resourceResolverFactory.getAdministrativeResourceResolver(null) WhiteList Bundle for Administrative Login</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>When working for organizations with the goal of migrating from AEM 6X to 6.5 or to AEM Cloud as a Service. It&#8217;s very common that the AEM backend code still utilizes the deprecated resourceResolverFactory.getAdministrativeResourceResolver(null) <a href="https://sling.apache.org/apidocs/sling12/org/apache/sling/api/resource/ResourceResolverFactory.html#getAdministrativeResourceResolver-java.util.Map-" rel="noopener" target="_blank">@depricated API</a>. This method has been deprecated as of 2.4 (bundle version 2.5.0) because of inherent security issues. Services requiring specific permissions should use the getServiceResourceResolver(), AEM service users <a href="https://experienceleague.adobe.com/docs/experience-manager-64/administering/security/security-service-users.html?lang=en" rel="noopener" target="_blank">instead</a>.</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#40;</span>ResourceResolver resolver <span style="color: #339933;">=</span> resourceResolverFactory.<span style="color: #006633;">getAdministrativeResourceResolver</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// do something</span><br />
<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span>LoginException e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; e.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>In the later versions of AEM, from the default AEM environment configurations, it has disabled the use of resourceResolverFactory.getAdministrativeResourceResolver(null) because of inherent security issues and has disabled the API. Without any configurations made on AEM, the AEM environment will causes the API call to not work as expected, and the resourceResolverFactory.getAdministrativeResourceResolver(null) returns as a null object. </p>
<hr class="spacer-large"/>
<h2>Solving the Issue</h2>
<p>During times of rapid development, developers are not positions to refactor the deprecated API. That&#8217;s okay. AEM provides configuration to re-enable this disabled feature as a temporary solution for the environment to allow the deprecated API. You have two options.</p>
<div class="mention-block">
<strong>Quick Links</strong></p>
<ol>
<li><a href="#apache-sling-login-admin-whitelist">Apache Sling Login Admin Whitelist</a></li>
<li><a href="#apache-sling-login-admin-whitelist-configuration-fragment">Apache Sling Login Admin Whitelist Configuration Fragment</a></li>
</ol>
</div>
<hr class="spacer-large"/>
<h3 id="apache-sling-login-admin-whitelist">1. Apache Sling Login Admin Whitelist</h3>
<p><a href="http://localhost:4502/system/console/configMgr/org.apache.sling.jcr.base.internal.LoginAdminWhitelist" rel="noopener" target="_blank">Visit http://localhost:4502/system/console/configMgr/org.apache.sling.jcr.base.internal.LoginAdminWhitelist</a><br />
<a href="https://sourcedcode.com/wp-content/uploads/2022/11/apache-sling-login-admin-whitelist.png"><img decoding="async" src="https://sourcedcode.com/wp-content/uploads/2022/11/apache-sling-login-admin-whitelist.png" alt="" width="300px" class="alignnone size-full wp-image-4078" srcset="https://sourcedcode.com/wp-content/uploads/2022/11/apache-sling-login-admin-whitelist.png 1925w, https://sourcedcode.com/wp-content/uploads/2022/11/apache-sling-login-admin-whitelist-300x218.png 300w, https://sourcedcode.com/wp-content/uploads/2022/11/apache-sling-login-admin-whitelist-1024x746.png 1024w, https://sourcedcode.com/wp-content/uploads/2022/11/apache-sling-login-admin-whitelist-768x559.png 768w, https://sourcedcode.com/wp-content/uploads/2022/11/apache-sling-login-admin-whitelist-1536x1119.png 1536w, https://sourcedcode.com/wp-content/uploads/2022/11/apache-sling-login-admin-whitelist-600x437.png 600w" sizes="(max-width: 1925px) 100vw, 1925px" /></a><br />
<strong>whitelist.bypass</strong>: {Boolean} if true, by default all the bundles will be allowed to use getAdministrativeResourceResolver() deprecated API.<br />
<strong>whitelist.bundles.regexp</strong>: Regular expression for bundle symbolic names for which loginAdministrative() is allowed. NOT recommended for production use, but useful for testing with generated bundles.</p>
<hr class="spacer-large"/>
<h3 id="apache-sling-login-admin-whitelist-configuration-fragment">2. Apache Sling Login Admin Whitelist Configuration Fragment</h3>
<p><a href="http://localhost:4502/system/console/configMgr/org.apache.sling.jcr.base.internal.LoginAdminWhitelist.fragment" rel="noopener" target="_blank">http://localhost:4502/system/console/configMgr/org.apache.sling.jcr.base.internal.LoginAdminWhitelist.fragment</a><br />
<a href="https://sourcedcode.com/wp-content/uploads/2022/11/apache-sling-login-admin-whitelist-configuration-fragment.png"><img decoding="async" src="https://sourcedcode.com/wp-content/uploads/2022/11/apache-sling-login-admin-whitelist-configuration-fragment.png" alt="" width="300px" class="alignnone size-full wp-image-4077" srcset="https://sourcedcode.com/wp-content/uploads/2022/11/apache-sling-login-admin-whitelist-configuration-fragment.png 1901w, https://sourcedcode.com/wp-content/uploads/2022/11/apache-sling-login-admin-whitelist-configuration-fragment-300x221.png 300w, https://sourcedcode.com/wp-content/uploads/2022/11/apache-sling-login-admin-whitelist-configuration-fragment-1024x755.png 1024w, https://sourcedcode.com/wp-content/uploads/2022/11/apache-sling-login-admin-whitelist-configuration-fragment-768x566.png 768w, https://sourcedcode.com/wp-content/uploads/2022/11/apache-sling-login-admin-whitelist-configuration-fragment-1536x1133.png 1536w, https://sourcedcode.com/wp-content/uploads/2022/11/apache-sling-login-admin-whitelist-configuration-fragment-600x443.png 600w" sizes="(max-width: 1901px) 100vw, 1901px" /></a><br />
<strong>whitelist.name</strong>: Optional name to disambiguate configurations.<br />
<strong>whitelist.bundles</strong>: A list of bundle symbolic names allowed to use loginAdministrative().</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/whitelist-bundle-for-administrative-login">resourceResolverFactory.getAdministrativeResourceResolver(null) WhiteList Bundle for Administrative Login</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/whitelist-bundle-for-administrative-login/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>WCM Core Components Sling Models Interfaces Design</title>
		<link>https://sourcedcode.com/blog/aem/wcm-core-components-sling-models-interfaces-design</link>
					<comments>https://sourcedcode.com/blog/aem/wcm-core-components-sling-models-interfaces-design#comments</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Sat, 05 Nov 2022 20:18:16 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Sling Models]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=3884</guid>

					<description><![CDATA[<p>While reviewing Adobe&#8217;s WCM Core components you may realize that the Sling model all have JAVA interfaces. Why do they follow this design pattern, and what benefits does it help to the overall design of their Sling models? In this article, I will share my understanding of why Adobe designed its Sling models like this. [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/wcm-core-components-sling-models-interfaces-design">WCM Core Components Sling Models Interfaces Design</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>While reviewing <a href="https://github.com/adobe/aem-core-wcm-components" rel="noopener" target="_blank">Adobe&#8217;s WCM Core components</a> you may realize that the Sling model all have <strong>JAVA interfaces</strong>. Why do they follow this design pattern, and what benefits does it help to the overall design of their Sling models? In this article, I will share my understanding of why Adobe designed its Sling models like this.</p>
<p><strong>The simple answer</strong> is <strong>backward compatibility</strong> and <strong>versioning</strong> for implementing v1,v2,v3&#8230; of the AEM Core Components.</p>
<p>In this article, we will target the <a href="https://github.com/adobe/aem-core-wcm-components/blob/main/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/models/Title.java" rel="noopener" target="_blank">https://github.com/adobe/aem-core-wcm-components/blob/main/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/models/Title.java</a> Sling Model interface, to see what Adobe&#8217;s design pattern is with the Sling Models.</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">@ConsumerType<br />
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">interface</span> Title <span style="color: #000000; font-weight: bold;">extends</span> <span style="color: #003399;">Component</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #003399;">String</span> PN_DESIGN_DEFAULT_TYPE <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;type&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #003399;">String</span> PN_TITLE_LINK_DISABLED <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;linkDisabled&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">default</span> <span style="color: #003399;">String</span> getText<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">default</span> <span style="color: #003399;">String</span> getType<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; @Nullable<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">default</span> Link getLink<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; @Deprecated<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">default</span> <span style="color: #003399;">String</span> getLinkURL<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">default</span> <span style="color: #000066; font-weight: bold;">boolean</span> isLinkDisabled<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<hr class="spacer-large" />
<h2>Why Interfaces</h2>
<p>One of the fundamental concepts of Java is <strong>Java Interface</strong>. Java Interface is a fundamental component of all programming languages and are extensively used in software engineering design patterns. The majority of frameworks strongly rely on the interface. </p>
<p>Java&#8217;s interfaces offer a means of achieving abstraction. Additionally, the contract for the subclasses to implement is defined by the Java interface. Let&#8217;s imagine, for instance, that we wish to make a creation using a variety of animals. Here, we can design the interface for the Animal object type and specify all the methods that it will support. For the sake of simplicity, we can limit ourselves to just two methods: walk(), which will make our animal walk, and talk(), which will make the animal talk.</p>
<hr class="spacer-large" />
<h2>Benefits of Java Interfaces</h2>
<ul>
<li>It is wise to code in terms of interfaces since implementation classes cannot remove the methods we are using. Interfaces offer a contract for all implementation classes.</li>
<li>Interfaces are a great place to start when defining Types and building top-level hierarchies in our programs.</li>
<li>Since a Java class can implement many interfaces, it&#8217;s usually preferable to utilize an interface as a superclass.</li>
</ul>
<hr class="spacer-large" />
<h2>Adobe&#8217;s Approach</h2>
<p>From what I can see, Adobe&#8217;s approach to their Sling Model designs is highly prioritized on backward compatibility. When version 1 of the WCM Core Title component was released, the <a href="https://github.com/adobe/aem-core-wcm-components/blob/main/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/models/Title.java" rel="noopener" target="_blank">Title interface</a> was created for it. The sling model backend is implemented via <a href="https://github.com/adobe/aem-core-wcm-components/blob/main/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/internal/models/v1/TitleImpl.java" rel="noopener" target="_blank">com.adobe.cq.wcm.core.components.internal.models.v1.TitleImpl</a>. The Sightly code is tightly coupled with the getters() for the backend Sling Models. </p>
<p>As we move on in time, Adobe identifies bad performance their <a href="https://github.com/adobe/aem-core-wcm-components/blob/main/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/internal/models/v1/TitleImpl.java" rel="noopener" target="_blank">com.adobe.cq.wcm.core.components.internal.models.v1.TitleImpl</a> Sling Model backend logic, so they introduced the v3 Title (skipped a version). For v3 implementation of the Title interface, they introduced <a href="https://github.com/adobe/aem-core-wcm-components/blob/main/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/internal/models/v3/TitleImpl.java" rel="noopener" target="_blank">com.adobe.cq.wcm.core.components.internal.models.v3.TitleImpl</a>, and it extends from v1 Title and implements the <a href="https://github.com/adobe/aem-core-wcm-components/blob/main/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/models/Title.java" rel="noopener" target="_blank">Title interface</a>. </p>
<p>Expected, customers are supposed to benefit from the performance improvements from the version upgrades, so AEM developers would update their organization&#8217;s proxied components to reference to the WCM Core Component&#8217;s latest version For the sake of the example, <span style="color: red;">WCM Core Title Component, the latest Adobe backend Sling Model version updates are required to implement the <a href="https://github.com/adobe/aem-core-wcm-components/blob/main/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/models/Title.java" rel="no opener noopener" target="_blank">Title interface</a>, getters are still available, so this guarantees that our proxied components are still working as expected</span>. </p>
<p>After updating our proxied components to reference the latest WCM Core Components, our components will benefit from the latest performance fixes. Simply to utilize the latest v3 of the title component&#8217;s performance enhanced BE execution, change your proxy component&#8217;s sling:resourceSuperType to &#8220;core/wcm/components/title/v3/title&#8221;, and it would take effect. Now v3 of the title component, &#8220;core/wcm/components/title/v3/title&#8221;, will be referenced to the correct backend Sling Model implementation, and invokes the correct version. The Sling Model is mapped via resourceType = TitleImpl.RESOURCE_TYPE, and that&#8217;s how the proxied component will select the correct v3 implementation of the title component, and execute the backend to produce the data model back to the front end (via Sightly);</p>
<p>Example of Adobe&#8217;s WCM Core Component&#8217;s v3 Title Component&#8217;s implementation. Take a look at line 15, where the implementation of the title v3 is registered with the resourceType. This component&#8217;s implementation also extends from com.adobe.cq.wcm.core.components.internal.models.v1.TitleImpl and implements Title interface.</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.adobe.cq.wcm.core.components.internal.models.v3</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.SlingHttpServletRequest</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.models.annotations.Exporter</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.models.annotations.Model</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.adobe.cq.export.json.ComponentExporter</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.adobe.cq.export.json.ExporterConstants</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.adobe.cq.wcm.core.components.commons.link.Link</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.adobe.cq.wcm.core.components.models.Title</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.fasterxml.jackson.annotation.JsonIgnore</span><span style="color: #339933;">;</span><br />
<br />
@Model<span style="color: #009900;">&#40;</span>adaptables <span style="color: #339933;">=</span> SlingHttpServletRequest.<span style="color: #000000; font-weight: bold;">class</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; adapters <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>Title.<span style="color: #000000; font-weight: bold;">class</span>, ComponentExporter.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#125;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; resourceType <span style="color: #339933;">=</span> TitleImpl.<span style="color: #006633;">RESOURCE_TYPE</span><span style="color: #009900;">&#41;</span><br />
@Exporter<span style="color: #009900;">&#40;</span>name <span style="color: #339933;">=</span> ExporterConstants.<span style="color: #006633;">SLING_MODEL_EXPORTER_NAME</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; extensions <span style="color: #339933;">=</span> ExporterConstants.<span style="color: #006633;">SLING_MODEL_EXTENSION</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> TitleImpl <span style="color: #000000; font-weight: bold;">extends</span> com.<span style="color: #006633;">adobe</span>.<span style="color: #006633;">cq</span>.<span style="color: #006633;">wcm</span>.<span style="color: #006633;">core</span>.<span style="color: #006633;">components</span>.<span style="color: #006633;">internal</span>.<span style="color: #006633;">models</span>.<span style="color: #006633;">v1</span>.<span style="color: #006633;">TitleImpl</span> <span style="color: #000000; font-weight: bold;">implements</span> Title <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">String</span> RESOURCE_TYPE <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;core/wcm/components/title/v3/title&quot;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; @Override<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> Link getLink<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> link.<span style="color: #006633;">isValid</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">?</span> link <span style="color: #339933;">:</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; @Override<br />
&nbsp; &nbsp; @JsonIgnore<br />
&nbsp; &nbsp; @Deprecated<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> getLinkURL<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">getLinkURL</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>Adobe&#8217;s Github: <a href="https://github.com/adobe/aem-core-wcm-components/blob/main/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/internal/models/v3/TitleImpl.java" rel="noopener" target="_blank">https://github.com/adobe/aem-core-wcm-components/blob/main/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/internal/models/v3/TitleImpl.java</a></p>
<hr class="spacer-large" />
<h2>Lesson here</h2>
<p>The lesson here is, if you are planning to create your own versioned components for your organization, creating interfaces for Sling Models is actually a great design pattern. It allows your organization to be future proof, to fix performance issues, and extend new concepts. Most of all, the latest versions will still be backwards compatible. </p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/wcm-core-components-sling-models-interfaces-design">WCM Core Components Sling Models Interfaces Design</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/wcm-core-components-sling-models-interfaces-design/feed</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
			</item>
		<item>
		<title>Webpack Dev Server ^3.9.0 unable to POST (send data to server)</title>
		<link>https://sourcedcode.com/blog/javascript/webpack-dev-server-3-9-0-unable-to-post-send-data-to-server</link>
					<comments>https://sourcedcode.com/blog/javascript/webpack-dev-server-3-9-0-unable-to-post-send-data-to-server#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Fri, 28 Oct 2022 21:36:50 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[JavaScript]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=3855</guid>

					<description><![CDATA[<p>While working on the web pack dev server (version ^3.9.0), you may have changed some configurations with the proxy configuration, so you can proxy specific paths like /api or /bin to refer to a server of your choice; in this example, we are referencing to our AEM local environment in localhost:4502. While making server calls, [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/javascript/webpack-dev-server-3-9-0-unable-to-post-send-data-to-server">Webpack Dev Server ^3.9.0 unable to POST (send data to server)</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>While working on the web pack dev server (version ^3.9.0), you may have changed some configurations with the proxy configuration, so you can proxy specific paths like /api or /bin to refer to a server of your choice; in this example, we are referencing to our AEM local environment in localhost:4502. While making server calls, the <strong>GET</strong> HTTP Methods are working as expected and proxying local AEM.</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">devServer<span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; port<span style="color: #339933;">:</span> <span style="color: #CC0000;">9999</span><span style="color: #339933;">,</span><br />
&nbsp; inline<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span><br />
&nbsp; proxy<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; context<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'/bin'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; target<span style="color: #339933;">:</span> <span style="color: #3366CC;">'http://localhost:4502'</span><span style="color: #339933;">,</span><br />
&nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><br />
&nbsp; writeToDisk<span style="color: #339933;">,</span><br />
&nbsp; liveReload<span style="color: #339933;">:</span> <span style="color: #339933;">!</span>writeToDisk<br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>However, the <strong>POST</strong> HTTP method does not work. You are likely to see a <span style="color: red;">403 Forbidden error</span>; unable to send data to local AEM (proxy server). A simple solution to fix this is to add append another configuration property to your dev server key named <strong>setup()</strong>. This will take the original POST URL and redirect with the same URL, making it a GET request; it&#8217;s a bit hacky, but it works well.</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">devServer<span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; port<span style="color: #339933;">:</span> <span style="color: #CC0000;">9999</span><span style="color: #339933;">,</span><br />
&nbsp; inline<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span><br />
&nbsp; proxy<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; context<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'/bin'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; target<span style="color: #339933;">:</span> <span style="color: #3366CC;">'http://localhost:4502'</span><span style="color: #339933;">,</span><br />
&nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><br />
&nbsp; setup<span style="color: #009900;">&#40;</span>app<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; app.<span style="color: #660066;">post</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'*'</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span>req<span style="color: #339933;">,</span> res<span style="color: #009900;">&#41;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; res.<span style="color: #660066;">redirect</span><span style="color: #009900;">&#40;</span>req.<span style="color: #660066;">originalUrl</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><br />
&nbsp; writeToDisk<span style="color: #339933;">,</span><br />
&nbsp; liveReload<span style="color: #339933;">:</span> <span style="color: #339933;">!</span>writeToDisk<br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<hr class="spacer-large"/>
<p>This article should answer your questions for:</p>
<ul>
<li>Webpack Dev Server, unable to make a POST to the proxied server?</li>
<li>Webpack Dev Server, proxy configurations does not allow me to POST?</li>
<li>Webpack Dev Server, I am getting a 403 Forbidden error whenever I try to make a POST via proxy configurations?</li>
<li>Webpack Dev Server, Why can&#8217;t I make a POST request to my proxy backend server?</li>
<li>Webpack Dev Server, Why can&#8217;t I send data to to my proxied server?</li>
<li>Webpack Dev Server, 301 forbidden POST request, not able to send data to my server?</li>
<li>How do I get Webpack Dev Server to accept POST requests</li>
</ul>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/javascript/webpack-dev-server-3-9-0-unable-to-post-send-data-to-server">Webpack Dev Server ^3.9.0 unable to POST (send data to server)</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/javascript/webpack-dev-server-3-9-0-unable-to-post-send-data-to-server/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>AEM Sightly Comments with Examples</title>
		<link>https://sourcedcode.com/blog/aem/aem-sightly-comments-with-examples</link>
					<comments>https://sourcedcode.com/blog/aem/aem-sightly-comments-with-examples#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Thu, 20 Oct 2022 01:58:54 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Sightly]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=3868</guid>

					<description><![CDATA[<p>When writing comments in your Sightly HTL file, it&#8217;s best practice not to use HTML comments, but to use the sightly, HTML Template Language. 1. HTL comments are not evaluated and returned back as an empty string in the server-side rendered results. This is best practice when developers are including some comments for other developers [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/aem-sightly-comments-with-examples">AEM Sightly Comments with Examples</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>When writing comments in your Sightly HTL file, it&#8217;s best practice not to use HTML comments, but to use the sightly, HTML Template Language.</p>
<p><strong>1. HTL comments are not evaluated and returned back as an empty string in the server-side rendered results.</strong></p>
<p>This is best practice when developers are including some comments for other developers in their organization.</p>
<p>Sightly HTL comments combine HTML and JavaScript multi-line comments: &lt;!&#8211;/* */&#8211;&gt;</p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&lt;!--<span style="color: #66cc66;">/</span>* The <span style="color: #000066;">content</span> of this comment will be removed from the output. *<span style="color: #66cc66;">/</span>--&gt;<br />
<span style="color: #66cc66;">//</span> output: <span style="color: #ff0000;">&quot;&quot;</span><br />
<br />
&lt;!--<span style="color: #66cc66;">/</span>* <br />
&nbsp; &nbsp; &nbsp; The <span style="color: #000066;">content</span> of this comment will be removed from the output.<br />
&nbsp; &nbsp; &nbsp; The <span style="color: #000066;">content</span> of this comment will be removed from the output.<br />
&nbsp; &nbsp; &nbsp; The <span style="color: #000066;">content</span> of this comment will be removed from the output.<br />
&nbsp; &nbsp; &nbsp; The <span style="color: #000066;">content</span> of this comment will be removed from the output. <br />
&nbsp; &nbsp; &nbsp; Page <span style="color: #000066;">title</span>: $<span style="color: #66cc66;">&#123;</span>currentPage.jcr:<span style="color: #000066;">title</span><span style="color: #66cc66;">&#125;</span><br />
*<span style="color: #66cc66;">/</span>--&gt;<br />
<span style="color: #66cc66;">//</span> output: <span style="color: #ff0000;">&quot;&quot;</span></div></td></tr></tbody></table></div>
<p><strong>2. Standard HTML comments, the comments are evaluated and are server-side rendered with the expected results.</strong></p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">&lt;!-- Page <span style="color: #000066;">title</span>: $<span style="color: #66cc66;">&#123;</span>currentPage.jcr:<span style="color: #000066;">title</span><span style="color: #66cc66;">&#125;</span> --&gt;<br />
<br />
<span style="color: #66cc66;">//</span>output &lt;!-- Page <span style="color: #000066;">title</span>: Home Page --&gt;</div></td></tr></tbody></table></div>
<p>Available for HTML Template Language Specification 1.4<br />
Release Date: 18 June 2018<br />
Reference: <a href="https://github.com/adobe/htl-spec/blob/master/SPECIFICATION.md" rel="noopener" target="_blank">https://github.com/adobe/htl-spec/blob/master/SPECIFICATION.md</a> </p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/aem-sightly-comments-with-examples">AEM Sightly Comments with Examples</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/aem-sightly-comments-with-examples/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Race Conditions with window.Granite?.I18n</title>
		<link>https://sourcedcode.com/blog/aem/race-conditions-with-window-granite-i18n</link>
					<comments>https://sourcedcode.com/blog/aem/race-conditions-with-window-granite-i18n#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Wed, 21 Sep 2022 01:17:24 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Client Libraries]]></category>
		<category><![CDATA[JavaScript]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=3815</guid>

					<description><![CDATA[<p>We have created a JavaScript micro-frontend in VueJS to handle a new feature for our website. The JavaScript micro-frontend is set up nicely inside of a maven module. Along with it&#8217;s own Node Package Manager configuration, we used the aem-clientlib-generator to generate a client library under /apps/sourcedcode/clientlibs/micro-frontend. Within our VueJS application, we have a utility [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/race-conditions-with-window-granite-i18n">Race Conditions with window.Granite?.I18n</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>We have created a JavaScript micro-frontend in VueJS to handle a new feature for our website. The JavaScript micro-frontend is set up nicely inside of a maven module. Along with it&#8217;s own Node Package Manager configuration, we used the <a href="https://www.npmjs.com/package/aem-clientlib-generator" rel="noopener" target="_blank">aem-clientlib-generator</a> to generate a client library under /apps/sourcedcode/clientlibs/micro-frontend. </p>
<p>Within our VueJS application, we have a utility named i18n.js, the file looks like this (code below). Throughout application, we will call this util i18n(function) to get values from our i18n AEM dictionary.</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #FF0000;">export</span> <span style="color: #000066; font-weight: bold;">default</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; i18n<span style="color: #009900;">&#40;</span>id<span style="color: #339933;">,</span> params<span style="color: #339933;">,</span> notes<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>window.<span style="color: #660066;">Granite</span><span style="color: #339933;">?</span>.<span style="color: #660066;">I18n</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span> window.<span style="color: #660066;">Granite</span>.<span style="color: #660066;">I18n</span>.<span style="color: #000066; font-weight: bold;">get</span><span style="color: #009900;">&#40;</span>id<span style="color: #339933;">,</span> params<span style="color: #339933;">,</span> notes<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span> id<span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p><strong>When we test out the micro-frontend, we noticed that sometimes the window.Granite, AEM global object, is intermittently working; sometimes the window object is valid/not, so dictionary values are loaded, and sometimes they are not. Why window.Granite is sometimes undefined? Well, this looks like a race condition issue.</strong></p>
<div class="mention-block">
<strong>What is a race condition?</strong><br />
In short, a race condition occurs when a device or system attempts to do two or more actions at the same time, but the actions must be performed in the proper sequence to be performed correctly.<br />
</strong>
</div>
<p>How can we ensure window.Granite is loaded first before our application is loaded next? In the next section let&#8217;s look at the different ways to see how we can do this.</p>
<hr/>
<p><strong>Solutions</strong></p>
<ol>
<li><a href="#manually">Manually Invoking the i18n.js from /libs/clientlibs/granite/utils/source/I18n.js</a></li>
<li><a href="http://via-clientlibrary">Include the granite.utils as a dependency</a></li>
</ol>
<hr class="spacer-large" />
<div style="text-align:center; margin-bottom: 100px;">
<h2>Solutions</h2>
<p>In this section of the blog, you will find two solutions to this problem.
</p></div>
<h3 id="manually">1. Manually Invoking the i18n.js from /libs/clientlibs/granite/utils/source/I18n.js</h3>
<p>From the page template that your micro-frontend is embedded, you can just call the Adobe core Granite utils > i18n.js before your custom code, like the code provided below. Viewing the source code of your HTML page should look something like this; where the i18n.js is loaded first, and then your application is loaded secondly. Using the proxy method for accessing client libraries, you can serve /libs/clientlibs/granite/utils/source/I18n.js with /etc.clientlibs/clientlibs/granite/utils.js.</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span> src<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;/etc.clientlibs/clientlibs/granite/utils.js&quot;</span><span style="color: #339933;">&gt;&lt;/</span>script<span style="color: #339933;">&gt;</span><br />
<span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span> src<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;/etc.clientlibs/sourcedcode/clientlibs/micro-frontend.min.js&quot;</span><span style="color: #339933;">&gt;&lt;/</span>script<span style="color: #339933;">&gt;</span></div></td></tr></tbody></table></div>
<hr class="spacer-larger" />
<h3 id="via-clientlibrary">2. Include the <strong>granite.utils</strong> as a dependency</h3>
<p>.</p>
<p>Simply ensure that your client library has a dependency for the <strong>granite.utils</strong>.</p>
<div class="mention-block">Please be aware that if you are planning to this client library approach, you are actually going to load unwanted JavaScripts apart of your page load. This includes: Sling.js, Util.js, HTTP.js, I18n.js, TouchIndicator.js, OptOutUtil.js, and the init.js (according to the <a href="http://localhost:4502/crx/de/index.jsp#/libs/clientlibs/granite/utils/js.txt" rel="noopener" target="_blank">js.txt</a> in the Adobe AEM core library). If all you want is the i18n.js, then you should try out solution #1.</div>
<p><em>In line:6, notice how the a dependency have been added.</em></p>
<div class="codecolorer-container xml default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br /></div></td><td><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;jcr:root</span> <span style="color: #000066;">xmlns:cq</span>=<span style="color: #ff0000;">&quot;http://www.day.com/jcr/cq/1.0&quot;</span> <span style="color: #000066;">xmlns:jcr</span>=<span style="color: #ff0000;">&quot;http://www.jcp.org/jcr/1.0&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp;<span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;cq:ClientLibraryFolder&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp;<span style="color: #000066;">allowProxy</span>=<span style="color: #ff0000;">&quot;{Boolean}true&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp;<span style="color: #000066;">categories</span>=<span style="color: #ff0000;">&quot;[sourcedcode.micro-frontend]&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp;<span style="color: #000066;">dependencies</span>=<span style="color: #ff0000;">&quot;[granite.utils]&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span></div></td></tr></tbody></table></div>
<p>While in this article, we have mentioned that we are using the <a href="https://www.npmjs.com/package/aem-clientlib-generator" rel="noopener" target="_blank">aem-clientlib-generator</a> for our micro-frontend, so to install it, it would be as simple as adding a new property in the clientlib.config.js, and would be something that looks like this: <strong>line:33</strong></p>
<div class="code-500">
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #000066; font-weight: bold;">const</span> path <span style="color: #339933;">=</span> require<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'path'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000066; font-weight: bold;">const</span> BUILD_DIR <span style="color: #339933;">=</span> path.<span style="color: #660066;">join</span><span style="color: #009900;">&#40;</span>__dirname<span style="color: #339933;">,</span> <span style="color: #3366CC;">'dist'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #000066; font-weight: bold;">const</span> CLIENTLIB_DIR <span style="color: #339933;">=</span> path.<span style="color: #660066;">join</span><span style="color: #009900;">&#40;</span><br />
&nbsp; __dirname<span style="color: #339933;">,</span><br />
&nbsp; <span style="color: #3366CC;">'..'</span><span style="color: #339933;">,</span><br />
&nbsp; <span style="color: #3366CC;">'ui.apps'</span><span style="color: #339933;">,</span><br />
&nbsp; <span style="color: #3366CC;">'src'</span><span style="color: #339933;">,</span><br />
&nbsp; <span style="color: #3366CC;">'main'</span><span style="color: #339933;">,</span><br />
&nbsp; <span style="color: #3366CC;">'content'</span><span style="color: #339933;">,</span><br />
&nbsp; <span style="color: #3366CC;">'jcr_root'</span><span style="color: #339933;">,</span><br />
&nbsp; <span style="color: #3366CC;">'apps'</span><span style="color: #339933;">,</span><br />
&nbsp; <span style="color: #3366CC;">'sourcedcode'</span><span style="color: #339933;">,</span><br />
&nbsp; <span style="color: #3366CC;">'clientlibs'</span><br />
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000066; font-weight: bold;">const</span> libsBaseConfig <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; allowProxy<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span><br />
&nbsp; serializationFormat<span style="color: #339933;">:</span> <span style="color: #3366CC;">'xml'</span><span style="color: #339933;">,</span><br />
&nbsp; cssProcessor<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'default:none'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'min:none'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><br />
&nbsp; jsProcessor<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'default:none'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'min:none'</span><span style="color: #009900;">&#93;</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #006600; font-style: italic;">// Config for `aem-clientlib-generator`</span><br />
module.<span style="color: #660066;">exports</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; context<span style="color: #339933;">:</span> BUILD_DIR<span style="color: #339933;">,</span><br />
&nbsp; clientLibRoot<span style="color: #339933;">:</span> CLIENTLIB_DIR<span style="color: #339933;">,</span><br />
&nbsp; libs<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; ...<span style="color: #660066;">libsBaseConfig</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; name<span style="color: #339933;">:</span> <span style="color: #3366CC;">'micro-frontend'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; categories<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'sourcedcode.micro-frontend'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; dependencies<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'granite.utils'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; assets<span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; js<span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cwd<span style="color: #339933;">:</span> <span style="color: #3366CC;">'clientlib-site'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; files<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'**/*.js'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; flatten<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">false</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; css<span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cwd<span style="color: #339933;">:</span> <span style="color: #3366CC;">'clientlib-site'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; files<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'**/*.css'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; flatten<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">false</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// Copy all other files into the `resources` ClientLib directory</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; resources<span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cwd<span style="color: #339933;">:</span> <span style="color: #3366CC;">'clientlib-site'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; files<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'**/*.*'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; flatten<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ignore<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'**/*.js'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'**/*.css'</span><span style="color: #009900;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; <span style="color: #009900;">&#93;</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
</div>
<div class="mention-block">
<strong>Still! My AEM i18n Not Showing Translations!</strong><br />
Sometimes after deploying new dictionary keys and values in your AEM platform, you will realize, in rare occasions, you&#8217;re dictionary values are not loading as expected. Have no fear, I have created an article here for how to solve this problem. Click here to learn how to refresh the <a href="/blog/aem/aem-i18n-not-showing-translations">Apache Sling I18N translation engine</a>.
</div>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/race-conditions-with-window-granite-i18n">Race Conditions with window.Granite?.I18n</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/race-conditions-with-window-granite-i18n/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>What are AEM ExtraClientlibs?</title>
		<link>https://sourcedcode.com/blog/aem/what-are-aem-extraclientlibs</link>
					<comments>https://sourcedcode.com/blog/aem/what-are-aem-extraclientlibs#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Tue, 20 Sep 2022 04:51:05 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Client Libraries]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Touch UI]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=3796</guid>

					<description><![CDATA[<p>When dealing with cq:ClientLibraryFolder (node type), you may have come across a property called extraClientlibs. What are extraClientlibs and how does it work? As you may recall, when you want to add custom functionality or styling to the Touch Dialogues (in edit author mode, editor.html), we must include cq.authoring.editor.sites.page as a dependency and cq.authoring.editor.sites.page.hook as [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/what-are-aem-extraclientlibs">What are AEM ExtraClientlibs?</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>When dealing with cq:ClientLibraryFolder (node type), you may have come across a property called extraClientlibs. What are extraClientlibs and how does it work?</p>
<p>As you may recall, when you want to add custom functionality or styling to the Touch Dialogues (in edit author mode, editor.html), we must include cq.authoring.editor.sites.page as a dependency and cq.authoring.editor.sites.page.hook as a category to our client library&#8217;s configuration. The configuration would look something like this:</p>
<div class="codecolorer-container xml default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span><br />
<span style="color: #000000; font-weight: bold;">&lt;jcr:root</span> <span style="color: #000066;">xmlns:cq</span>=<span style="color: #ff0000;">&quot;http://www.day.com/jcr/cq/1.0&quot;</span> <span style="color: #000066;">xmlns:jcr</span>=<span style="color: #ff0000;">&quot;http://www.jcp.org/jcr/1.0&quot;</span><br />
&nbsp; &nbsp; <span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;cq:ClientLibraryFolder&quot;</span><br />
&nbsp; &nbsp; <span style="color: #000066;">dependencies</span>=<span style="color: #ff0000;">&quot;[cq.authoring.editor.sites.page]&quot;</span><br />
&nbsp; &nbsp; <span style="color: #000066;">categories</span>=<span style="color: #ff0000;">&quot;[cq.authoring.editor.sites.page.hook]&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></div></td></tr></tbody></table></div>
<p><a href="https://sourcedcode.com/wp-content/uploads/2022/09/cq.authoring.editor.sites_.page_.click_.png"><img decoding="async" src="https://sourcedcode.com/wp-content/uploads/2022/09/cq.authoring.editor.sites_.page_.click_.png" alt="Diagram of how the ccq.authoring.editor.sites will be triggered." width="100%" class="alignnone size-full wp-image-3801" srcset="https://sourcedcode.com/wp-content/uploads/2022/09/cq.authoring.editor.sites_.page_.click_.png 1638w, https://sourcedcode.com/wp-content/uploads/2022/09/cq.authoring.editor.sites_.page_.click_-300x116.png 300w, https://sourcedcode.com/wp-content/uploads/2022/09/cq.authoring.editor.sites_.page_.click_-1024x395.png 1024w, https://sourcedcode.com/wp-content/uploads/2022/09/cq.authoring.editor.sites_.page_.click_-768x296.png 768w, https://sourcedcode.com/wp-content/uploads/2022/09/cq.authoring.editor.sites_.page_.click_-1536x593.png 1536w, https://sourcedcode.com/wp-content/uploads/2022/09/cq.authoring.editor.sites_.page_.click_-600x232.png 600w" sizes="(max-width: 1638px) 100vw, 1638px" /></a></p>
<p>This configuration above will evoke the client library every time the Touch UI dialogue is triggered, for all components. Illustrated above, from the author (editor.html), clicking on any component throughout the entire AEM platform, will invoke the client library.</p>
<p><strong>Benefits of using cq.authoring.editor.sites.page:</strong></p>
<ol>
<li>Client libraries created like this will be invoked for all components (when the Touch UI is open)</li>
</ol>
<hr class="spacer-large" />
<p><strong>But however, what happens if you only want your custom functionality or styling to be only called by ONE component? Well, we use the extraClientlibs property from the component&#8217;s Touch UI dialogue.</strong></p>
<p><a href="https://sourcedcode.com/wp-content/uploads/2022/09/my.example.clientlib.calls_.png"><img decoding="async" src="https://sourcedcode.com/wp-content/uploads/2022/09/my.example.clientlib.calls_.png" alt="Diagram of how the extraClientlibs will be triggered." width="100%" height="451" class="alignnone size-full wp-image-3803" srcset="https://sourcedcode.com/wp-content/uploads/2022/09/my.example.clientlib.calls_.png 1452w, https://sourcedcode.com/wp-content/uploads/2022/09/my.example.clientlib.calls_-300x93.png 300w, https://sourcedcode.com/wp-content/uploads/2022/09/my.example.clientlib.calls_-1024x318.png 1024w, https://sourcedcode.com/wp-content/uploads/2022/09/my.example.clientlib.calls_-768x239.png 768w, https://sourcedcode.com/wp-content/uploads/2022/09/my.example.clientlib.calls_-600x186.png 600w" sizes="(max-width: 1452px) 100vw, 1452px" /></a></p>
<p>Illustrated above, you will notice that adding String[] extraClientlibs to the cq:dialog (root node) of the component, the client library will only be invoked, only targeting the Touch UI dialogue that is associated to a specific component.</p>
<p><strong>Benefits of using extraClientlibs:</strong></p>
<ol>
<li>Touch UI will only invoke the targeted client library that is configured.</li>
<li>Client libraries can be created to be specifically used for a particular component.</li>
</ol>
<p><strong>Example of usage of extraClientlibs in line:6</strong></p>
<div class="codecolorer-container xml default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br /></div></td><td><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span><br />
<span style="color: #000000; font-weight: bold;">&lt;jcr:root</span> <span style="color: #000066;">xmlns:sling</span>=<span style="color: #ff0000;">&quot;http://sling.apache.org/jcr/sling/1.0&quot;</span> <span style="color: #000066;">xmlns:granite</span>=<span style="color: #ff0000;">&quot;http://www.adobe.com/jcr/granite/1.0&quot;</span> <span style="color: #000066;">xmlns:cq</span>=<span style="color: #ff0000;">&quot;http://www.day.com/jcr/cq/1.0&quot;</span> <span style="color: #000066;">xmlns:jcr</span>=<span style="color: #ff0000;">&quot;http://www.jcp.org/jcr/1.0&quot;</span> <span style="color: #000066;">xmlns:nt</span>=<span style="color: #ff0000;">&quot;http://www.jcp.org/jcr/nt/1.0&quot;</span><br />
&nbsp; <span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span><br />
&nbsp; <span style="color: #000066;">jcr:title</span>=<span style="color: #ff0000;">&quot;Component's Granite UI&quot;</span><br />
&nbsp; <span style="color: #000066;">sling:resourceType</span>=<span style="color: #ff0000;">&quot;cq/gui/components/authoring/dialog&quot;</span><br />
&nbsp; <span style="color: #000066;">extraClientlibs</span>=<span style="color: #ff0000;">&quot;[my.custom.clientlib]&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">&lt;content</span><br />
&nbsp; &nbsp; <span style="color: #000066;">granite:class</span>=<span style="color: #ff0000;">&quot;cmp-teaser__editor cmp-image__editor&quot;</span><br />
&nbsp; &nbsp; <span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; <span style="color: #000066;">sling:resourceType</span>=<span style="color: #ff0000;">&quot;granite/ui/components/coral/foundation/container&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;items</span> <span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;tabs</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">sling:resourceType</span>=<span style="color: #ff0000;">&quot;granite/ui/components/coral/foundation/tabs&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;items</span> <span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;layout</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">jcr:title</span>=<span style="color: #ff0000;">&quot;Layout&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">sling:resourceType</span>=<span style="color: #ff0000;">&quot;granite/ui/components/coral/foundation/container&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">margin</span>=<span style="color: #ff0000;">&quot;{Boolean}true&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">sling:orderBefore</span>=<span style="color: #ff0000;">&quot;actions&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;items</span> <span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;columns</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">sling:resourceType</span>=<span style="color: #ff0000;">&quot;granite/ui/components/coral/foundation/fixedcolumns&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">margin</span>=<span style="color: #ff0000;">&quot;{Boolean}true&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;items</span> <span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;column</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">sling:resourceType</span>=<span style="color: #ff0000;">&quot;granite/ui/components/coral/foundation/container&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;items</span> <span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;layout</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">sling:resourceType</span>=<span style="color: #ff0000;">&quot;granite/ui/components/coral/foundation/form/select&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">fieldLabel</span>=<span style="color: #ff0000;">&quot;Layout&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;./layout&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><br />
...</div></td></tr></tbody></table></div>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/what-are-aem-extraclientlibs">What are AEM ExtraClientlibs?</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/what-are-aem-extraclientlibs/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>What Version Sightly, Apache Sling Scripting HTL Engine, is my AEM Using?</title>
		<link>https://sourcedcode.com/blog/aem/what-version-sightly-apache-sling-scripting-htl-engineis-my-aem-using</link>
					<comments>https://sourcedcode.com/blog/aem/what-version-sightly-apache-sling-scripting-htl-engineis-my-aem-using#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Thu, 15 Sep 2022 03:30:47 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Development]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=3760</guid>

					<description><![CDATA[<p>How do I find out which Sightly, Apache Sling Scripting HTL Engine (runtime) version is being used in my AEM environment? You may want to know because while writing code, you would want to know which API is avaiable to use. The Apache Sling Scripting HTL Runtime provides support for executing HTL Java compiled units [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/what-version-sightly-apache-sling-scripting-htl-engineis-my-aem-using">What Version Sightly, Apache Sling Scripting HTL Engine, is my AEM Using?</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>How do I find out which Sightly, Apache Sling Scripting HTL Engine (runtime) version is being used in my AEM environment? You may want to know because while writing code, you would want to know which API is avaiable to use.</p>
<p>The Apache Sling Scripting HTL Runtime provides support for executing HTL Java compiled units produced by the org.apache.sling.scripting.sightly.compiler.java module.</p>
<p>In this article, I will help you find out which versions of the Apache Sling Scripting HTL engine is being installed on your AEM instance.</p>
<h2>There&#8217;s two ways to find out this information.</h2>
<ol>
<li><a href="http://system-console-bundles-ui">System Console Bundles UI</a></li>
<li><a href="#adobe-documentation">Read the documentation below that is provided by Adobe</a></li>
</ol>
<hr class="spacer-larger"/>
<h4 id="system-console-bundles-ui">1. System Console Bundles UI</h4>
<p>Visit the system console bundles UI. <a href="http://localhost:4502/system/console/bundles" rel="noopener" target="_blank">http://localhost:4502/system/console/bundles</a>.</p>
<p>Search for the word &#8220;sightly&#8221; you should be able to see the versions being used.</p>
<p><a href="https://sourcedcode.com/wp-content/uploads/2022/09/osgi-sightly-runtime-screenshot.png"><img decoding="async" src="https://sourcedcode.com/wp-content/uploads/2022/09/osgi-sightly-runtime-screenshot.png" alt="In system console bundle, search for the word 'sightly' you should be able to see the versions being used." width="100%" class="alignnone size-full wp-image-3761" srcset="https://sourcedcode.com/wp-content/uploads/2022/09/osgi-sightly-runtime-screenshot.png 1219w, https://sourcedcode.com/wp-content/uploads/2022/09/osgi-sightly-runtime-screenshot-300x146.png 300w, https://sourcedcode.com/wp-content/uploads/2022/09/osgi-sightly-runtime-screenshot-1024x498.png 1024w, https://sourcedcode.com/wp-content/uploads/2022/09/osgi-sightly-runtime-screenshot-768x374.png 768w, https://sourcedcode.com/wp-content/uploads/2022/09/osgi-sightly-runtime-screenshot-600x292.png 600w" sizes="(max-width: 1219px) 100vw, 1219px" /></a><br />
<em>In system console bundle, search for the word &#8216;sightly&#8217; you should be able to see the versions being used.</em></p>
<p><a href="https://sourcedcode.com/wp-content/uploads/2022/09/comparing-sling-org-apache-sling-scripting-sightly-compiler-versions.png"><img decoding="async" src="https://sourcedcode.com/wp-content/uploads/2022/09/comparing-sling-org-apache-sling-scripting-sightly-compiler-versions.png" alt="Taking a look at the release tags from git for org.apache.sling.scripting.sightly.compiler" width="200" class="alignnone size-full wp-image-3761" /></a><br />
<em>Apache&#8217;s release tags from Github for <a href="https://github.com/apache/sling-org-apache-sling-scripting-sightly-compiler/tags" rel="noopener" target="_blank">org.apache.sling.scripting.sightly.compiler</a></em></p>
<p>From what I analyzed here, looking at the <strong>build number</strong>, it looks like this number is in fact the version of the Sling Scripting HTL Engine. Take a closer look at the system console bundle screenshot and compare it with the <a href="https://github.com/apache/sling-org-apache-sling-scripting-sightly-compiler/tags" rel="noopener" target="_blank">Apache documentation</a> presented on Github, you can see &lt;major>.&lt;minor&gt;.&lt;patch&gt;-&lt;qualifier&gt;-<strong>&lt;build number&gt;</strong>.</p>
<div class="codecolorer-container xml default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br /></div></td><td><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #000000; font-weight: bold;">&lt;major<span style="color: #000000; font-weight: bold;">&gt;</span></span>.<span style="color: #000000; font-weight: bold;">&lt;minor<span style="color: #000000; font-weight: bold;">&gt;</span></span>.<span style="color: #000000; font-weight: bold;">&lt;patch<span style="color: #000000; font-weight: bold;">&gt;</span></span>-<span style="color: #000000; font-weight: bold;">&lt;qualifier<span style="color: #000000; font-weight: bold;">&gt;</span></span>-<span style="color: #000000; font-weight: bold;">&lt;build</span> number<span style="color: #000000; font-weight: bold;">&gt;</span></div></td></tr></tbody></table></div>
<hr class="spacer-larger"/>
<h4 id="adobe-documentation">2. Read the documentation below that is provided by Adobe</h4>
<p>If you take a closer look at Adobe&#8217;s own documentation from git, it actually says:</p>
<ol>
<li>An implementation of version <a href="https://github.com/adobe/htl-spec/blob/1.1/SPECIFICATION.md" rel="noopener" target="_blank">1.1 of the language specification</a> will be made available in AEM 6.1; release 16 February 2015.</li>
<li>An implementation of version <a href="https://github.com/adobe/htl-spec/blob/1.2/SPECIFICATION.md" rel="noopener" target="_blank">1.2 of the language specification</a> will be made available in AEM 6.2; release 30 March 2016.</li>
<li>An implementation of version <a href="https://github.com/adobe/htl-spec/blob/1.3/SPECIFICATION.md" rel="noopener" target="_blank">1.3 of the language specification</a> is available in AEM 6.3; release 15 December 2016.</li>
<li>An implementation of version <a href="https://github.com/adobe/htl-spec/blob/1.4/SPECIFICATION.md" rel="noopener" target="_blank">1.4 of the language specification</a> is available in AEM 6.3 SP3 and AEM 6.4 SP1; release 18 June 2018.</li>
</ol>
<p>Reference: <a href="https://github.com/adobe/htl-spec" rel="noopener" target="_blank">HTML Template Language Specification</a></p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/what-version-sightly-apache-sling-scripting-htl-engineis-my-aem-using">What Version Sightly, Apache Sling Scripting HTL Engine, is my AEM Using?</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/what-version-sightly-apache-sling-scripting-htl-engineis-my-aem-using/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>AEM Components are not showing up on Page Templates</title>
		<link>https://sourcedcode.com/blog/aem/aem-components-are-not-showing-up-on-page-templates</link>
					<comments>https://sourcedcode.com/blog/aem/aem-components-are-not-showing-up-on-page-templates#comments</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Sun, 11 Sep 2022 18:37:43 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Author]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=3715</guid>

					<description><![CDATA[<p>As an AEM content author, you will sometimes notice that no components are available in the parsys (drag and drop area). You try to double-click on the parsys or try to view components on the component&#8217;s finder, and nothing shows up. This is because the page mis-configured to allow components to be used on the [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/aem-components-are-not-showing-up-on-page-templates">AEM Components are not showing up on Page Templates</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>As an AEM content author, you will sometimes notice that no components are available in the parsys (drag and drop area). You try to double-click on the parsys or try to view components on the component&#8217;s finder, and nothing shows up. This is because the page mis-configured to allow components to be used on the page. </p>
<p>Before we solve this issue, you must understand that AEM templates are made up of two different types of templates; static templates and editable templates. Static templates ensure that template structures are only created and modified by the developer, while editable templates are template structures that can be created and modified by the authors.</p>
<p><strong>In this article, you will be given instructions on how to enable allowed components to be used on Static templates &#038; Editable Templates.</strong></p>
<ol>
<li><a href="#how-to-allow-components-to-be-used-on-static-templates">How to allow components to be use on Static Templates</a></li>
<li><a href="#how-to-allow-components-to-be-used-on-editable-templates">How to allow components to be use on Editable Templates</a></ol>
<div class="mention-block">In this article, we will configure allowed components as an admin. If you don&#8217;t have the correct permissions to access these configuration areas, you can contact your administrator to provide you with the correct rights. Typically template configuration permissions are restricted to super authors.</div>
<hr class="spacer-large" />
<h2 id="how-to-allow-components-to-be-used-on-static-templates">A. How to allow components to be use on Static Templates</h2>
<p>After the creation of the page using a static template, follow the steps below to enable components. Please make sure the steps below are followed when you have the page opened. </p>
<h5>1. On a static AEM template, you will realize that the parsys has no available components. From the component finder, you can find empty results.</h5>
<p><a href="https://sourcedcode.com/wp-content/uploads/2022/09/1.static-template-no-available-components.png"><img loading="lazy" decoding="async" src="https://sourcedcode.com/wp-content/uploads/2022/09/1.static-template-no-available-components.png" alt="" width="1607" height="616" class="alignnone size-full wp-image-3720" srcset="https://sourcedcode.com/wp-content/uploads/2022/09/1.static-template-no-available-components.png 1607w, https://sourcedcode.com/wp-content/uploads/2022/09/1.static-template-no-available-components-300x115.png 300w, https://sourcedcode.com/wp-content/uploads/2022/09/1.static-template-no-available-components-1024x393.png 1024w, https://sourcedcode.com/wp-content/uploads/2022/09/1.static-template-no-available-components-768x294.png 768w, https://sourcedcode.com/wp-content/uploads/2022/09/1.static-template-no-available-components-1536x589.png 1536w, https://sourcedcode.com/wp-content/uploads/2022/09/1.static-template-no-available-components-600x230.png 600w" sizes="(max-width: 1607px) 100vw, 1607px" /></a></p>
<h5>2. From the page, enter design mode by clicking on the top right drop-down button; select on &#8220;design&#8221; and the page will flash. (if not please refresh the page).</h5>
<p><a href="https://sourcedcode.com/wp-content/uploads/2022/09/2.static-template-no-available-components-design-mode.png"><img loading="lazy" decoding="async" src="https://sourcedcode.com/wp-content/uploads/2022/09/2.static-template-no-available-components-design-mode.png" alt="" width="442" height="419" class="alignnone size-full wp-image-3716" srcset="https://sourcedcode.com/wp-content/uploads/2022/09/2.static-template-no-available-components-design-mode.png 442w, https://sourcedcode.com/wp-content/uploads/2022/09/2.static-template-no-available-components-design-mode-300x284.png 300w" sizes="(max-width: 442px) 100vw, 442px" /></a></p>
<h5>3. Click on the target parsys, and click on the page icon; this should make visible of Touch UI modal with options inside.</h5>
<p><a href="https://sourcedcode.com/wp-content/uploads/2022/09/3.static-template-no-available-components-design-mode-button.png"><img loading="lazy" decoding="async" src="https://sourcedcode.com/wp-content/uploads/2022/09/3.static-template-no-available-components-design-mode-button.png" alt="" width="1581" height="618" class="alignnone size-full wp-image-3724" srcset="https://sourcedcode.com/wp-content/uploads/2022/09/3.static-template-no-available-components-design-mode-button.png 1581w, https://sourcedcode.com/wp-content/uploads/2022/09/3.static-template-no-available-components-design-mode-button-300x117.png 300w, https://sourcedcode.com/wp-content/uploads/2022/09/3.static-template-no-available-components-design-mode-button-1024x400.png 1024w, https://sourcedcode.com/wp-content/uploads/2022/09/3.static-template-no-available-components-design-mode-button-768x300.png 768w, https://sourcedcode.com/wp-content/uploads/2022/09/3.static-template-no-available-components-design-mode-button-1536x600.png 1536w, https://sourcedcode.com/wp-content/uploads/2022/09/3.static-template-no-available-components-design-mode-button-600x235.png 600w" sizes="(max-width: 1581px) 100vw, 1581px" /></a></p>
<h5>4. Select components via group or individual component&#8217;s that you would like to enable, and then click on save.</h5>
<p><a href="https://sourcedcode.com/wp-content/uploads/2022/09/4.static-template-no-available-components-design-mode-save.png"><img loading="lazy" decoding="async" src="https://sourcedcode.com/wp-content/uploads/2022/09/4.static-template-no-available-components-design-mode-save.png" alt="" width="1598" height="636" class="alignnone size-full wp-image-3725" srcset="https://sourcedcode.com/wp-content/uploads/2022/09/4.static-template-no-available-components-design-mode-save.png 1598w, https://sourcedcode.com/wp-content/uploads/2022/09/4.static-template-no-available-components-design-mode-save-300x119.png 300w, https://sourcedcode.com/wp-content/uploads/2022/09/4.static-template-no-available-components-design-mode-save-1024x408.png 1024w, https://sourcedcode.com/wp-content/uploads/2022/09/4.static-template-no-available-components-design-mode-save-768x306.png 768w, https://sourcedcode.com/wp-content/uploads/2022/09/4.static-template-no-available-components-design-mode-save-1536x611.png 1536w, https://sourcedcode.com/wp-content/uploads/2022/09/4.static-template-no-available-components-design-mode-save-600x239.png 600w" sizes="(max-width: 1598px) 100vw, 1598px" /></a></p>
<h5>5. Making sure you refresh the page, and navigate back to &#8220;edit&#8221; mode (by clicking on the drop down in the top right hand side), scroll down to the page to the target parsys. Now you should see a + button when you click on it. In the component&#8217;s finder, you are able to see the available components too. At this point, you should be able to drag and drop components into the parsys.</h5>
<p><a href="https://sourcedcode.com/wp-content/uploads/2022/09/5.static-template-no-available-components-now-available.png"><img loading="lazy" decoding="async" src="https://sourcedcode.com/wp-content/uploads/2022/09/5.static-template-no-available-components-now-available.png" alt="" width="1591" height="630" class="alignnone size-full wp-image-3722" srcset="https://sourcedcode.com/wp-content/uploads/2022/09/5.static-template-no-available-components-now-available.png 1591w, https://sourcedcode.com/wp-content/uploads/2022/09/5.static-template-no-available-components-now-available-300x119.png 300w, https://sourcedcode.com/wp-content/uploads/2022/09/5.static-template-no-available-components-now-available-1024x405.png 1024w, https://sourcedcode.com/wp-content/uploads/2022/09/5.static-template-no-available-components-now-available-768x304.png 768w, https://sourcedcode.com/wp-content/uploads/2022/09/5.static-template-no-available-components-now-available-1536x608.png 1536w, https://sourcedcode.com/wp-content/uploads/2022/09/5.static-template-no-available-components-now-available-600x238.png 600w" sizes="(max-width: 1591px) 100vw, 1591px" /></a></p>
<div class="mention-block">When the configuration is enabled allow component&#8217;s to be used on a page, developers should find the configuration saved in CRX/DE, /etc/designs/my-site/jcr:content/${template}. Making sure if you are a developer, save this configuration into your code to ensure that the configurations. You&#8217;ll realize in the node consist of a new property named &#8220;components&#8221;; this is where the configuration is saved. <a href="https://sourcedcode.com/wp-content/uploads/2022/09/static.component-avaiable.png"><img loading="lazy" decoding="async" src="https://sourcedcode.com/wp-content/uploads/2022/09/static.component-avaiable.png" alt="" width="1087" height="271" class="alignnone size-full wp-image-3730" srcset="https://sourcedcode.com/wp-content/uploads/2022/09/static.component-avaiable.png 1087w, https://sourcedcode.com/wp-content/uploads/2022/09/static.component-avaiable-300x75.png 300w, https://sourcedcode.com/wp-content/uploads/2022/09/static.component-avaiable-1024x255.png 1024w, https://sourcedcode.com/wp-content/uploads/2022/09/static.component-avaiable-768x191.png 768w, https://sourcedcode.com/wp-content/uploads/2022/09/static.component-avaiable-600x150.png 600w" sizes="(max-width: 1087px) 100vw, 1087px" /></a></div>
<hr class="spacer-larger" />
<h2 id="how-to-allow-components-to-be-used-on-editable-templates">B. How to allow components to be use on Editable Templates</h2>
<p>After the creation of the page using an editable template, follow the steps below to enable components. Please make sure the steps below are followed when you have the page opened. </p>
<h5>1. On a editable AEM template, you will realize that the parsys has no available components. From the component finder, you can find empty results.</h5>
<p><a href="https://sourcedcode.com/wp-content/uploads/2022/09/6.editable-template-no-components.png"><img loading="lazy" decoding="async" src="https://sourcedcode.com/wp-content/uploads/2022/09/6.editable-template-no-components.png" alt="" width="1650" height="603" class="alignnone size-full wp-image-3719" srcset="https://sourcedcode.com/wp-content/uploads/2022/09/6.editable-template-no-components.png 1650w, https://sourcedcode.com/wp-content/uploads/2022/09/6.editable-template-no-components-300x110.png 300w, https://sourcedcode.com/wp-content/uploads/2022/09/6.editable-template-no-components-1024x374.png 1024w, https://sourcedcode.com/wp-content/uploads/2022/09/6.editable-template-no-components-768x281.png 768w, https://sourcedcode.com/wp-content/uploads/2022/09/6.editable-template-no-components-1536x561.png 1536w, https://sourcedcode.com/wp-content/uploads/2022/09/6.editable-template-no-components-600x219.png 600w" sizes="(max-width: 1650px) 100vw, 1650px" /></a></p>
<h5>2. From the top left options of the editor.html, click on the second icon. A drop down should be visible. Click on the &#8220;edit template&#8221; button, and you should be redirected to the editable template page.</h5>
<p><a href="https://sourcedcode.com/wp-content/uploads/2022/09/7.editable-template-no-components-edit-template-button-2.png"><img loading="lazy" decoding="async" src="https://sourcedcode.com/wp-content/uploads/2022/09/7.editable-template-no-components-edit-template-button-2.png" alt="" width="1606" height="752" class="alignnone size-full wp-image-3723" /></a></p>
<h5>3. From the editable template page, click on the target parsys; there should be some options made visible. Click on the icon that looks like a cog, and the components policies UI should be visible.</h5>
<p><a href="https://sourcedcode.com/wp-content/uploads/2022/09/8.editable-template-no-components-edit-template-page-polices.png"><img loading="lazy" decoding="async" src="https://sourcedcode.com/wp-content/uploads/2022/09/8.editable-template-no-components-edit-template-page-polices.png" alt="" width="1602" height="418" class="alignnone size-full wp-image-3717" srcset="https://sourcedcode.com/wp-content/uploads/2022/09/8.editable-template-no-components-edit-template-page-polices.png 1602w, https://sourcedcode.com/wp-content/uploads/2022/09/8.editable-template-no-components-edit-template-page-polices-300x78.png 300w, https://sourcedcode.com/wp-content/uploads/2022/09/8.editable-template-no-components-edit-template-page-polices-1024x267.png 1024w, https://sourcedcode.com/wp-content/uploads/2022/09/8.editable-template-no-components-edit-template-page-polices-768x200.png 768w, https://sourcedcode.com/wp-content/uploads/2022/09/8.editable-template-no-components-edit-template-page-polices-1536x401.png 1536w, https://sourcedcode.com/wp-content/uploads/2022/09/8.editable-template-no-components-edit-template-page-polices-600x157.png 600w" sizes="(max-width: 1602px) 100vw, 1602px" /></a></p>
<h5>4. Polices UI</h5>
<p>Editable templates handles allowed component&#8217;s configuration differently than static templates. They are defined with component policies. Component policies are configurations that is saved under /conf/my-product/wcm/*; and will be bound to a component. Unlike static templates, these configurations can be shared (which means that you can define a policy once, and re-use it over and over again without the overhead of redefining these again). When you see &#8220;Select Policies&#8221;, these are policies that are defined by either the developer or super author.</p>
<p>If your organization already configured some component policies, then some options will be visible, and if not, create your own! Most of the time, there will be some pre-configured options for you to select. Please understand that component policies are binding to one component (most common component policies be configured, will be the wcm/foundation/components/responsivegrid component (after all, this out of the box component created by Adobe allows content authors to drag and drop components on to the page).</p>
<p>In this scenario, we will create a new policy. We add in a title and description, so that in the future, other editable templates that are created can re-use this policy. Next select the component group of individual components that you will want to be allowed on the page. Click save.<br />
<a href="https://sourcedcode.com/wp-content/uploads/2022/09/9.editable-template-no-components-edit-template-page-polices-allow-general.png"><img loading="lazy" decoding="async" src="https://sourcedcode.com/wp-content/uploads/2022/09/9.editable-template-no-components-edit-template-page-polices-allow-general.png" alt="" width="1574" height="632" class="alignnone size-full wp-image-3721" srcset="https://sourcedcode.com/wp-content/uploads/2022/09/9.editable-template-no-components-edit-template-page-polices-allow-general.png 1574w, https://sourcedcode.com/wp-content/uploads/2022/09/9.editable-template-no-components-edit-template-page-polices-allow-general-300x120.png 300w, https://sourcedcode.com/wp-content/uploads/2022/09/9.editable-template-no-components-edit-template-page-polices-allow-general-1024x411.png 1024w, https://sourcedcode.com/wp-content/uploads/2022/09/9.editable-template-no-components-edit-template-page-polices-allow-general-768x308.png 768w, https://sourcedcode.com/wp-content/uploads/2022/09/9.editable-template-no-components-edit-template-page-polices-allow-general-1536x617.png 1536w, https://sourcedcode.com/wp-content/uploads/2022/09/9.editable-template-no-components-edit-template-page-polices-allow-general-600x241.png 600w" sizes="(max-width: 1574px) 100vw, 1574px" /></a></p>
<h5>5. Making sure you refresh the page, and head back to &#8220;edit&#8221; mode (by clicking on the drop down in the top right hand side), scroll down to the page to the target parsys. Now you should see a + button when you click on it. In the component&#8217;s finder, you are able to see the available components too. At this point, you should be able to drag and drop components into the parsys.</h5>
<p><a href="https://sourcedcode.com/wp-content/uploads/2022/09/10.editable-template-no-components-now-available.png"><img loading="lazy" decoding="async" src="https://sourcedcode.com/wp-content/uploads/2022/09/10.editable-template-no-components-now-available.png" alt="" width="1577" height="606" class="alignnone size-full wp-image-3718" srcset="https://sourcedcode.com/wp-content/uploads/2022/09/10.editable-template-no-components-now-available.png 1577w, https://sourcedcode.com/wp-content/uploads/2022/09/10.editable-template-no-components-now-available-300x115.png 300w, https://sourcedcode.com/wp-content/uploads/2022/09/10.editable-template-no-components-now-available-1024x393.png 1024w, https://sourcedcode.com/wp-content/uploads/2022/09/10.editable-template-no-components-now-available-768x295.png 768w, https://sourcedcode.com/wp-content/uploads/2022/09/10.editable-template-no-components-now-available-1536x590.png 1536w, https://sourcedcode.com/wp-content/uploads/2022/09/10.editable-template-no-components-now-available-600x231.png 600w" sizes="(max-width: 1577px) 100vw, 1577px" /></a></p>
<div class="mention-block">When component policies are defined, you developers should be able to find this saved configuration under, /conf/my-site/settings/wcm/policies/*.</div>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/aem-components-are-not-showing-up-on-page-templates">AEM Components are not showing up on Page Templates</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/aem-components-are-not-showing-up-on-page-templates/feed</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>AEM Granite UI Coral 3 Number Field Default Value</title>
		<link>https://sourcedcode.com/blog/aem/aem-granite-ui-coral-3-number-field-default-value</link>
					<comments>https://sourcedcode.com/blog/aem/aem-granite-ui-coral-3-number-field-default-value#comments</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Wed, 07 Sep 2022 03:17:53 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Touch UI]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=3651</guid>

					<description><![CDATA[<p>This article is for how can we set the default positive or negative integer value for the Granite UI 1.0 Coral 3 numberfield, granite/ui/components/coral/foundation/form/numberfield. Apparently the Granite UI 1.0 documentation for the granite/ui/components/coral/foundation/form/numberfield, does not support default value configuration for the numberfield. Keep reading&#8230; I mean, they do&#8230; you can set a default value for [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/aem-granite-ui-coral-3-number-field-default-value">AEM Granite UI Coral 3 Number Field Default Value</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>This article is for how can we set the <strong>default</strong> positive or negative integer value for the Granite UI 1.0 Coral 3 numberfield, granite/ui/components/coral/foundation/form/numberfield.</p>
<p>Apparently the Granite UI 1.0 <a href="https://developer.adobe.com/experience-manager/reference-materials/6-5/granite-ui/api/jcr_root/libs/granite/ui/components/foundation/form/numberfield/index.html" rel="noopener" target="_blank">documentation for the <strong>granite/ui/components/coral/foundation/form/numberfield</strong></a>, does not support default value configuration for the numberfield. Keep reading&#8230;</p>
<p>I mean, they do&#8230; you can set a default value for the <strong>granite/ui/components/coral/foundation/form/numberfield</strong> by setting the <strong>value</strong> property with a positive or negative integer; this works well when a new component is dragged into your editable page, but components that are already exist in the authored page will not be able to set this default value.</p>
<hr class="spacer-medium" />
<p><strong>This is an example of the Touch UI XML configuration, set with the value of 100; this works well when a new component is dragged into your editable page, <span style="color: red;">but components that are already exist in the authored page will not be able to set this default value</span>. This is a problem for existing components because this configuration will set the value to BLANK, when the component is being saved.</p>
<p>Follow this blog below to solve this problem.</strong><br />
<em>Here you can see line:9 it has a value set to 100.</em></p>
<div class="codecolorer-container xml default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br /></div></td><td><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;numberfieldExample</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp;<span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp;<span style="color: #000066;">sling:resourceType</span>=<span style="color: #ff0000;">&quot;granite/ui/components/coral/foundation/form/numberfield&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp;<span style="color: #000066;">allowDecimals</span>=<span style="color: #ff0000;">&quot;false&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp;<span style="color: #000066;">allowNegative</span>=<span style="color: #ff0000;">&quot;true&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp;<span style="color: #000066;">fieldLabel</span>=<span style="color: #ff0000;">&quot;Number Field&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp;<span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;./numberfieldExample&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp;<span style="color: #000066;">required</span>=<span style="color: #ff0000;">&quot;{Boolean}true&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp;<span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;100&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/numberfieldExample<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></div></td></tr></tbody></table></div>
<p><a class="foobox fbx-instance fbx-link" href="https://sourcedcode.com/wp-content/uploads/2022/09/number-field-showing-as-blank.png"><img decoding="async" src="https://sourcedcode.com/wp-content/uploads/2022/09/number-field-showing-as-blank.png" width="300px" alt="Example of existing components not able to make visible, the value property (default value); however, for all new components that are dragged on the page, the default value is set accordingly."/></a><br />
<em>Example of existing components not able to make visible, the value property (default value); however, for all new components that are dragged on the page, the default value is set accordingly.</em></p>
<hr class="spacer-larger" />
<h2>Solving this problem with Custom Code</h2>
<p>We can solve this problem by introducing a new client library to the author&#8217;s editor.html. The client library should have dependencies=&#8221;[cq.authoring.editor.sites.page] and categories=&#8221;[cq.authoring.editor.sites.page.hook]. </p>
<p>What is actually happening in the code below is that it tries to find all coral3-NumberInput, input fields, from the Touch UI popup. And then, for each input field element, wether if the element is empty and has a non-empty data-default value (HTML data attribute). When this condition is met, the empty input field will set the defaultValue. If a value exists for the input field element, it will be left alone.</p>
<p><strong>The code is very simple, take a look at the implementation below:</strong><br />
<strong>Custom JavaScript to the editor.html</strong></p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>document<span style="color: #339933;">,</span> $<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #3366CC;">&quot;use strict&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// trigger function after foundation-contentloaded</span><br />
&nbsp; &nbsp; $<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">on</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;foundation-contentloaded&quot;</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// find all coral3-NumberInput from the Touch UI popup from the editor.html</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; setDefaultValue<span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.coral3-NumberInput&quot;</span><span style="color: #339933;">,</span> e.<span style="color: #660066;">target</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">function</span> setDefaultValue<span style="color: #009900;">&#40;</span>el<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; el.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>i<span style="color: #339933;">,</span> element<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">var</span> $el <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span>element<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>$el.<span style="color: #660066;">length</span> <span style="color: #339933;">&gt;</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">var</span> fieldVal <span style="color: #339933;">=</span> $el.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">var</span> defaultVal <span style="color: #339933;">=</span> $el.<span style="color: #660066;">data</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'defaultvalue'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>fieldVal <span style="color: #339933;">&amp;&amp;</span> defaultVal<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $el.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span>defaultVal<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>document<span style="color: #339933;">,</span> Granite.$<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<div class="mention-block">
<strong>AEMaaCS Changes:</strong><br />
I realized AEMaaCS uses difference CSS classes when the granite/ui/components/coral/foundation/form/numberfield is rendered on the touch UI, and the Javascript above needs to be improved. Please try to use the JS below to get it working as expected, when working with AEMaaCS. line:6 is the change where we are targeting the coral-numberinput element instead.</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>document<span style="color: #339933;">,</span> $<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #3366CC;">&quot;use strict&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// trigger function after foundation-contentloaded</span><br />
&nbsp; &nbsp; $<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">on</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;foundation-contentloaded&quot;</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// find all &lt;coral-numberinput&gt; from the Touch UI popup from the editor.html</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; setDefaultValue<span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;coral-numberinput&quot;</span><span style="color: #339933;">,</span> e.<span style="color: #660066;">target</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">function</span> setDefaultValue<span style="color: #009900;">&#40;</span>el<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; el.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>i<span style="color: #339933;">,</span> element<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">var</span> $el <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span>element<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>$el.<span style="color: #660066;">length</span> <span style="color: #339933;">&gt;</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">var</span> fieldVal <span style="color: #339933;">=</span> $el.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">var</span> defaultVal <span style="color: #339933;">=</span> $el.<span style="color: #660066;">data</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'defaultvalue'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>fieldVal <span style="color: #339933;">&amp;&amp;</span> defaultVal<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $el.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span>defaultVal<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>document<span style="color: #339933;">,</span> Granite.$<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
</div>
<p><strong>XML Touch UI configuration</strong><br />
Please notice the granite:data field that has been added from line 9-11. The custom JavaScript will read the defaultValue property from this block of code, and will use it to configure the default integer for this field.</p>
<div class="codecolorer-container xml default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br /></div></td><td><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;numberfieldExample</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp;<span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp;<span style="color: #000066;">sling:resourceType</span>=<span style="color: #ff0000;">&quot;granite/ui/components/coral/foundation/form/numberfield&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp;<span style="color: #000066;">allowDecimals</span>=<span style="color: #ff0000;">&quot;false&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp;<span style="color: #000066;">allowNegative</span>=<span style="color: #ff0000;">&quot;true&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp;<span style="color: #000066;">fieldLabel</span>=<span style="color: #ff0000;">&quot;Number Field&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp;<span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;./numberfieldExample&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp;<span style="color: #000066;">required</span>=<span style="color: #ff0000;">&quot;{Boolean}true&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;granite:data</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">defaultValue</span>=<span style="color: #ff0000;">&quot;100&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/numberfieldExample<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></div></td></tr></tbody></table></div>
<p><a class="foobox fbx-instance fbx-link" href="https://sourcedcode.com/wp-content/uploads/2022/09/number-field-showing-as-default-working.png"><img decoding="async" src="https://sourcedcode.com/wp-content/uploads/2022/09/number-field-showing-as-default-working.png" alt="Example of existing components now able to set the default value accordingly." width="300px" class="alignnone size-full wp-image-3685" /></a><br />
<em>Example of existing components now able to set the default value accordingly.</em></p>
<hr class="spacer-larger" />
<h2>Installing the Custom Code to the Editor.html</h2>
<div class="mention-block">If you would like to skip all the steps below, download the entire client library example, <a href="https://sourcedcode.com/wp-content/uploads/2022/09/clientlib-authoring-numberfield-example.zip" rel="noopener" target="_blank">click here</a> (please understand that this code is not deployable to AEM).</div>
<p></p>
<p><strong>Step 1.</strong><br />
Create a new folder in your project like<br />
path: /apps/sourcedcode/clientlibs/clientlib-authoring-numberfield-example</p>
<p><strong>Step 2.</strong><br />
Create an .content.xml file right under the folder with contents like:<br />
path: /apps/sourcedcode/clientlibs/clientlib-authoring-numberfield-example/.content.xml</p>
<div class="codecolorer-container xml default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span><br />
<span style="color: #000000; font-weight: bold;">&lt;jcr:root</span> <span style="color: #000066;">xmlns:cq</span>=<span style="color: #ff0000;">&quot;http://www.day.com/jcr/cq/1.0&quot;</span> <span style="color: #000066;">xmlns:jcr</span>=<span style="color: #ff0000;">&quot;http://www.jcp.org/jcr/1.0&quot;</span><br />
&nbsp; &nbsp; <span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;cq:ClientLibraryFolder&quot;</span><br />
&nbsp; &nbsp; <span style="color: #000066;">dependencies</span>=<span style="color: #ff0000;">&quot;[cq.authoring.editor.sites.page]&quot;</span><br />
&nbsp; &nbsp; <span style="color: #000066;">categories</span>=<span style="color: #ff0000;">&quot;[cq.authoring.editor.sites.page.hook]&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></div></td></tr></tbody></table></div>
<p><strong>Step 3.</strong><br />
Create an empty css.txt file right under the folder like:<br />
path: /apps/sourcedcode/clientlibs/clientlib-authoring-numberfield-example/css.txt</p>
<p><strong>Step 4.</strong><br />
Create a js.txt file right under the folder like below with the contents:<br />
path: /apps/sourcedcode/clientlibs/clientlib-authoring-numberfield-example/js.txt</p>
<div class="codecolorer-container xml default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br /></div></td><td><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">#<span style="color: #000066;">base</span>=js<br />
granite-ui-numberfield-default-value.js</div></td></tr></tbody></table></div>
<hr class="spacer-large"/>
<div class="mention-block">If you would like to skip all the steps below, download the entire client library example, <a href="https://sourcedcode.com/wp-content/uploads/2022/09/clientlib-authoring-numberfield-example.zip" rel="noopener" target="_blank">click here</a> (please understand that this code is not deployable to AEM).</div>
<hr class="spacer-large"/>
<p><strong>Step 5.</strong><br />
Create an empty js folder under that folder that just have been created like:<br />
path: /apps/sourcedcode/clientlibs/clientlib-authoring-numberfield-example/js</p>
<p><strong>Step 6.</strong><br />
Create a JavaScript file within the js folder with the contents:<br />
path: /apps/sourcedcode/clientlibs/clientlib-authoring-numberfield-example/js/granite-ui-numberfield-default-value.js</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>document<span style="color: #339933;">,</span> $<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #3366CC;">&quot;use strict&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// trigger function after foundation-contentloaded</span><br />
&nbsp; &nbsp; $<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">on</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;foundation-contentloaded&quot;</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// find all coral3-NumberInput from the Touch UI popup from the editor.html</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; setDefaultValue<span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.coral3-NumberInput&quot;</span><span style="color: #339933;">,</span> e.<span style="color: #660066;">target</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">function</span> setDefaultValue<span style="color: #009900;">&#40;</span>el<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; el.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>i<span style="color: #339933;">,</span> element<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">var</span> $el <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span>element<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>$el.<span style="color: #660066;">length</span> <span style="color: #339933;">&gt;</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">var</span> fieldVal <span style="color: #339933;">=</span> $el.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">var</span> defaultVal <span style="color: #339933;">=</span> $el.<span style="color: #660066;">data</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'defaultvalue'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>fieldVal <span style="color: #339933;">&amp;&amp;</span> defaultVal<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $el.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span>defaultVal<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>document<span style="color: #339933;">,</span> Granite.$<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<div class="mention-block">
<strong>AEMaaCS Changes:</strong><br />
I realized AEMaaCS uses difference CSS classes when the granite/ui/components/coral/foundation/form/numberfield is rendered on the touch UI, and the Javascript above needs to be improved. Please try to use the JS below to get it working as expected, when working with AEMaaCS. line:6 is the change where we are targeting the coral-numberinput element instead.</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>document<span style="color: #339933;">,</span> $<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #3366CC;">&quot;use strict&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// trigger function after foundation-contentloaded</span><br />
&nbsp; &nbsp; $<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">on</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;foundation-contentloaded&quot;</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// find all &lt;coral-numberinput&gt; from the Touch UI popup from the editor.html</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; setDefaultValue<span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;coral-numberinput&quot;</span><span style="color: #339933;">,</span> e.<span style="color: #660066;">target</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">function</span> setDefaultValue<span style="color: #009900;">&#40;</span>el<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; el.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>i<span style="color: #339933;">,</span> element<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">var</span> $el <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span>element<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>$el.<span style="color: #660066;">length</span> <span style="color: #339933;">&gt;</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">var</span> fieldVal <span style="color: #339933;">=</span> $el.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">var</span> defaultVal <span style="color: #339933;">=</span> $el.<span style="color: #660066;">data</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'defaultvalue'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>fieldVal <span style="color: #339933;">&amp;&amp;</span> defaultVal<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $el.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span>defaultVal<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>document<span style="color: #339933;">,</span> Granite.$<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
</div>
<p><strong>Step 7.</strong><br />
Use your maven skills to push the code into AEM. </p>
<div class="mention-block">If you would like to download the entire client library example, <a href="https://sourcedcode.com/wp-content/uploads/2022/09/clientlib-authoring-numberfield-example.zip" rel="noopener" target="_blank">click here</a> (please understand that this code is not deployable to AEM).</div>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/aem-granite-ui-coral-3-number-field-default-value">AEM Granite UI Coral 3 Number Field Default Value</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/aem-granite-ui-coral-3-number-field-default-value/feed</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
			</item>
		<item>
		<title>Find all AEM Pages with Specific Page Properties with Query Builder API</title>
		<link>https://sourcedcode.com/blog/aem/find-all-aem-pages-with-specific-page-properties-with-query-builder-api</link>
					<comments>https://sourcedcode.com/blog/aem/find-all-aem-pages-with-specific-page-properties-with-query-builder-api#comments</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Sun, 21 Aug 2022 16:23:16 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Search]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=3707</guid>

					<description><![CDATA[<p>The Query Builder is a great tool that allows us to search for nodes in the JCR. We often as AEM developers use this tool to build a query for us to use in the backend to build query descriptions (predicates); the set of predicates produced will call the Predicate Evaluator which knows how to [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/find-all-aem-pages-with-specific-page-properties-with-query-builder-api">Find all AEM Pages with Specific Page Properties with Query Builder API</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>The Query Builder is a great tool that allows us to search for nodes in the JCR. We often as AEM developers use this tool to build a query for us to use in the backend to build query descriptions (predicates); the set of predicates produced will call the Predicate Evaluator which knows how to handle that specific predicate for XPath, filtering, and facet extraction.</p>
<p>In this article, we will be sharing query examples to find all AEM pages with specific page page properties using the<strong> Query Builder Debugger</strong> tool.</p>
<hr class="spacer-large" />
<h2>1. Find all AEM pages with a single page property</h2>
<p>Find all pages under /content/we-retail,<br />
and has page properties set with cq:productMaster == &#8216;/var/commerce/products/we-retail/wo/pants/faba_running_pants&#8217;<br />
show max results.</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">path<span style="color: #339933;">=/</span>content<span style="color: #339933;">/</span>we<span style="color: #339933;">-</span>retail<br />
type<span style="color: #339933;">=</span>cq<span style="color: #339933;">:</span>Page<br />
property<span style="color: #339933;">=</span>jcr<span style="color: #339933;">:</span>content<span style="color: #339933;">/</span>cq<span style="color: #339933;">:</span>productMaster<br />
property.<span style="color: #006633;">value</span><span style="color: #339933;">=</span> <br />
<span style="color: #339933;">/</span>var<span style="color: #339933;">/</span>commerce<span style="color: #339933;">/</span>products<span style="color: #339933;">/</span>we<span style="color: #339933;">-</span>retail<span style="color: #339933;">/</span>wo<span style="color: #339933;">/</span>pants<span style="color: #339933;">/</span>faba_running_pants<br />
p.<span style="color: #006633;">limit</span><span style="color: #339933;">=-</span><span style="color: #cc66cc;">1</span></div></td></tr></tbody></table></div>
<p><a href="http://localhost:4502/libs/cq/search/content/querydebug.html?_charset_=UTF-8&#038;query=path%3D%2Fcontent%2Fwe-retail%0D%0Atype%3Dcq%3APage%0D%0Aproperty%3Djcr%3Acontent%2Fcq%3AproductMaster%0D%0Aproperty.value%3D%09%0D%0A%2Fvar%2Fcommerce%2Fproducts%2Fwe-retail%2Fwo%2Fpants%2Ffaba_running_pants%0D%0Ap.limit%3D-1" rel="noopener" target="_blank">http://localhost:4502/libs/cq/search/content/querydebug.html?_charset_=UTF-8&#038;query=path%3D%2Fcontent%2Fwe-retail%0D%0Atype%3Dcq%3APage%0D%0Aproperty%3Djcr%3Acontent%2Fcq%3AproductMaster%0D%0Aproperty.value%3D%09%0D%0A%2Fvar%2Fcommerce%2Fproducts%2Fwe-retail%2Fwo%2Fpants%2Ffaba_running_pants%0D%0Ap.limit%3D-1</a></p>
<h3>Example Code</h3>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br />78<br />79<br />80<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.SlingHttpServletRequest</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.SlingHttpServletResponse</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.servlets.SlingAllMethodsServlet</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.resource.Resource</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.resource.ResourceResolver</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.resource.ResourceResolverFactory</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.osgi.service.component.annotations.Component</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.osgi.service.component.annotations.Reference</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.day.cq.search.QueryBuilder</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.day.cq.search.result.SearchResult</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.day.cq.search.result.Hit</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.day.cq.search.Query</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.json.JSONArray</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.json.JSONObject</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.servlet.Servlet</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.IOException</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Collections</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Map</span><span style="color: #339933;">;</span><br />
<br />
@<span style="color: #003399;">Component</span><span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; service <span style="color: #339933;">=</span> Servlet.<span style="color: #000000; font-weight: bold;">class</span>,<br />
&nbsp; &nbsp; property <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;sling.servlet.paths=/bin/queryservlet&quot;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;sling.servlet.methods=GET&quot;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#41;</span><br />
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> QueryServlet <span style="color: #000000; font-weight: bold;">extends</span> SlingAllMethodsServlet <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; @<span style="color: #003399;">Reference</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> ResourceResolverFactory resolverFactory<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; @<span style="color: #003399;">Reference</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> QueryBuilder queryBuilder<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; @Override<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> doGet<span style="color: #009900;">&#40;</span>SlingHttpServletRequest request, SlingHttpServletResponse response<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">IOException</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; response.<span style="color: #006633;">setContentType</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;application/json&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; response.<span style="color: #006633;">setCharacterEncoding</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;UTF-8&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">final</span> Map<span style="color: #339933;">&lt;</span><span style="color: #003399;">String</span>, Object<span style="color: #339933;">&gt;</span> authInfo <span style="color: #339933;">=</span> <span style="color: #003399;">Collections</span>.<span style="color: #006633;">singletonMap</span><span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ResourceResolverFactory.<span style="color: #006633;">SUBSERVICE</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;sourcedCodeSystemUser&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#40;</span>ResourceResolver resourceResolver <span style="color: #339933;">=</span> resolverFactory.<span style="color: #006633;">getServiceResourceResolver</span><span style="color: #009900;">&#40;</span>authInfo<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">String</span> queryPath <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;/content/we-retail&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">String</span> queryType <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;cq:Page&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">String</span> queryProperty <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;jcr:content/cq:productMaster&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">String</span> queryPropertyValue <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;/var/commerce/products/we-retail/wo/pants/faba_running_pants&quot;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Map<span style="color: #339933;">&lt;</span><span style="color: #003399;">String</span>, String<span style="color: #339933;">&gt;</span> queryParams <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HashMap<span style="color: #339933;">&lt;&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; queryParams.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;path&quot;</span>, queryPath<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; queryParams.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;type&quot;</span>, queryType<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; queryParams.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;property&quot;</span>, queryProperty<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; queryParams.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;property.value&quot;</span>, queryPropertyValue<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Query query <span style="color: #339933;">=</span> queryBuilder.<span style="color: #006633;">createQuery</span><span style="color: #009900;">&#40;</span>PredicateGroup.<span style="color: #006633;">create</span><span style="color: #009900;">&#40;</span>queryParams<span style="color: #009900;">&#41;</span>, resourceResolver.<span style="color: #006633;">adaptTo</span><span style="color: #009900;">&#40;</span>javax.<span style="color: #006633;">jcr</span>.<span style="color: #006633;">Session</span>.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">SearchResult</span> result <span style="color: #339933;">=</span> query.<span style="color: #006633;">getResult</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; JSONArray resultsArray <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> JSONArray<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>Hit hit <span style="color: #339933;">:</span> result.<span style="color: #006633;">getHits</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Resource resource <span style="color: #339933;">=</span> hit.<span style="color: #006633;">getResource</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; JSONObject pageData <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> JSONObject<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pageData.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;path&quot;</span>, resource.<span style="color: #006633;">getPath</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; resultsArray.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span>pageData<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; JSONObject jsonResponse <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> JSONObject<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jsonResponse.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;results&quot;</span>, resultsArray<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; response.<span style="color: #006633;">getWriter</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">write</span><span style="color: #009900;">&#40;</span>jsonResponse.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; JSONObject errorResponse <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> JSONObject<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; errorResponse.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;error&quot;</span>, <span style="color: #0000ff;">&quot;An error occurred while processing the request.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; response.<span style="color: #006633;">getWriter</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">write</span><span style="color: #009900;">&#40;</span>errorResponse.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p><strong>Curl Example</strong></p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">curl <span style="color: #339933;">-</span>X GET http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//localhost:4502/bin/queryservlet</span></div></td></tr></tbody></table></div>
<p><strong>Output</strong></p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #009900;">&#123;</span><br />
&nbsp; <span style="color: #0000ff;">&quot;results&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;path&quot;</span><span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;/content/we-retail/en&quot;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span>,<br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;path&quot;</span><span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;/content/we-retail/de&quot;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// ... more paths</span><br />
&nbsp; <span style="color: #009900;">&#93;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<hr class="spacer-large" />
<h2>2. Find all AEM pages with multiple page properties</h2>
<p>Find all pages under /content/we-retail,<br />
and has page properties set with cq:productMaster == &#8216;/var/commerce/products/we-retail/wo/pants/faba_running_pants&#8217;<br />
and has page properties set with cq:template == &#8216;/conf/we-retail/settings/wcm/templates/product-page&#8217;<br />
show max results.</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">path<span style="color: #339933;">=/</span>content<span style="color: #339933;">/</span>we<span style="color: #339933;">-</span>retail<br />
type<span style="color: #339933;">=</span>cq<span style="color: #339933;">:</span>Page<br />
path<span style="color: #339933;">=/</span>content<span style="color: #339933;">/</span>we<span style="color: #339933;">-</span>retail<br />
type<span style="color: #339933;">=</span>cq<span style="color: #339933;">:</span>Page<br />
group.1_property<span style="color: #339933;">=</span>jcr<span style="color: #339933;">:</span>content<span style="color: #339933;">/</span>cq<span style="color: #339933;">:</span>productMaster<br />
group.1_property.<span style="color: #006633;">value</span><span style="color: #339933;">=</span> <br />
<span style="color: #339933;">/</span>var<span style="color: #339933;">/</span>commerce<span style="color: #339933;">/</span>products<span style="color: #339933;">/</span>we<span style="color: #339933;">-</span>retail<span style="color: #339933;">/</span>wo<span style="color: #339933;">/</span>pants<span style="color: #339933;">/</span>faba_running_pants<br />
group.2_property<span style="color: #339933;">=</span>jcr<span style="color: #339933;">:</span>content<span style="color: #339933;">/</span>cq<span style="color: #339933;">:</span>template<br />
group.2_property.<span style="color: #006633;">value</span><span style="color: #339933;">=</span> <br />
<span style="color: #339933;">/</span>conf<span style="color: #339933;">/</span>we<span style="color: #339933;">-</span>retail<span style="color: #339933;">/</span>settings<span style="color: #339933;">/</span>wcm<span style="color: #339933;">/</span>templates<span style="color: #339933;">/</span>product<span style="color: #339933;">-</span>page<br />
p.<span style="color: #006633;">limit</span><span style="color: #339933;">=-</span><span style="color: #cc66cc;">1</span></div></td></tr></tbody></table></div>
<p><a href="http://localhost:4502/libs/cq/search/content/querydebug.html?_charset_=UTF-8&#038;query=path%3D%2Fcontent%2Fwe-retail%0D%0Atype%3Dcq%3APage%0D%0Agroup.1_property%3Djcr%3Acontent%2Fcq%3AproductMaster%0D%0Agroup.1_property.value%3D%09%0D%0A%2Fvar%2Fcommerce%2Fproducts%2Fwe-retail%2Fwo%2Fpants%2Ffaba_running_pants%0D%0Agroup.2_property%3Djcr%3Acontent%2Fcq%3Atemplate%0D%0Agroup.2_property.value%3D%09%0D%0A%2Fconf%2Fwe-retail%2Fsettings%2Fwcm%2Ftemplates%2Fproduct-page%0D%0Ap.limit%3D-1" rel="noopener" target="_blank">http://localhost:4502/libs/cq/search/content/querydebug.html?_charset_=UTF-8&#038;query=path%3D%2Fcontent%2Fwe-retail%0D%0Atype%3Dcq%3APage%0D%0Agroup.1_property%3Djcr%3Acontent%2Fcq%3AproductMaster%0D%0Agroup.1_property.value%3D%09%0D%0A%2Fvar%2Fcommerce%2Fproducts%2Fwe-retail%2Fwo%2Fpants%2Ffaba_running_pants%0D%0Agroup.2_property%3Djcr%3Acontent%2Fcq%3Atemplate%0D%0Agroup.2_property.value%3D%09%0D%0A%2Fconf%2Fwe-retail%2Fsettings%2Fwcm%2Ftemplates%2Fproduct-page%0D%0Ap.limit%3D-1</a></p>
<h3>Example Code</h3>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br />78<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.SlingHttpServletRequest</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.SlingHttpServletResponse</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.servlets.SlingAllMethodsServlet</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.resource.Resource</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.resource.ResourceResolver</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.resource.ResourceResolverFactory</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.osgi.service.component.annotations.Component</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.osgi.service.component.annotations.Reference</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.day.cq.search.QueryBuilder</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.day.cq.search.result.SearchResult</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.day.cq.search.result.Hit</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.day.cq.search.Query</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.json.JSONArray</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.json.JSONObject</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.servlet.Servlet</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.IOException</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Collections</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Map</span><span style="color: #339933;">;</span><br />
<br />
@<span style="color: #003399;">Component</span><span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; service <span style="color: #339933;">=</span> Servlet.<span style="color: #000000; font-weight: bold;">class</span>,<br />
&nbsp; &nbsp; property <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;sling.servlet.paths=/bin/queryservlet&quot;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;sling.servlet.methods=GET&quot;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#41;</span><br />
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> QueryServlet <span style="color: #000000; font-weight: bold;">extends</span> SlingAllMethodsServlet <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; @<span style="color: #003399;">Reference</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> ResourceResolverFactory resolverFactory<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; @<span style="color: #003399;">Reference</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> QueryBuilder queryBuilder<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; @Override<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> doGet<span style="color: #009900;">&#40;</span>SlingHttpServletRequest request, SlingHttpServletResponse response<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">IOException</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; response.<span style="color: #006633;">setContentType</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;application/json&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; response.<span style="color: #006633;">setCharacterEncoding</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;UTF-8&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">final</span> Map<span style="color: #339933;">&lt;</span><span style="color: #003399;">String</span>, Object<span style="color: #339933;">&gt;</span> authInfo <span style="color: #339933;">=</span> <span style="color: #003399;">Collections</span>.<span style="color: #006633;">singletonMap</span><span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ResourceResolverFactory.<span style="color: #006633;">SUBSERVICE</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;sourcedCodeSystemUser&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#40;</span>ResourceResolver resourceResolver <span style="color: #339933;">=</span> resolverFactory.<span style="color: #006633;">getServiceResourceResolver</span><span style="color: #009900;">&#40;</span>authInfo<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Map<span style="color: #339933;">&lt;</span><span style="color: #003399;">String</span>, String<span style="color: #339933;">&gt;</span> queryParams <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HashMap<span style="color: #339933;">&lt;&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; queryParams.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;path&quot;</span>, <span style="color: #0000ff;">&quot;/content/we-retail&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; queryParams.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;type&quot;</span>, <span style="color: #0000ff;">&quot;cq:Page&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; queryParams.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;group.1_property&quot;</span>, <span style="color: #0000ff;">&quot;jcr:content/cq:productMaster&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; queryParams.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;group.1_property.value&quot;</span>, <span style="color: #0000ff;">&quot;/var/commerce/products/we-retail/wo/pants/faba_running_pants&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; queryParams.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;group.2_property&quot;</span>, <span style="color: #0000ff;">&quot;jcr:content/cq:template&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; queryParams.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;group.2_property.value&quot;</span>, <span style="color: #0000ff;">&quot;/conf/we-retail/settings/wcm/templates/product-page&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; queryParams.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;p.limit&quot;</span>, <span style="color: #0000ff;">&quot;-1&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Query query <span style="color: #339933;">=</span> queryBuilder.<span style="color: #006633;">createQuery</span><span style="color: #009900;">&#40;</span>PredicateGroup.<span style="color: #006633;">create</span><span style="color: #009900;">&#40;</span>queryParams<span style="color: #009900;">&#41;</span>, resourceResolver.<span style="color: #006633;">adaptTo</span><span style="color: #009900;">&#40;</span>javax.<span style="color: #006633;">jcr</span>.<span style="color: #006633;">Session</span>.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003399;">SearchResult</span> result <span style="color: #339933;">=</span> query.<span style="color: #006633;">getResult</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; JSONArray resultsArray <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> JSONArray<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>Hit hit <span style="color: #339933;">:</span> result.<span style="color: #006633;">getHits</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Resource resource <span style="color: #339933;">=</span> hit.<span style="color: #006633;">getResource</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; JSONObject pageData <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> JSONObject<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pageData.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;path&quot;</span>, resource.<span style="color: #006633;">getPath</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; resultsArray.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span>pageData<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; JSONObject jsonResponse <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> JSONObject<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jsonResponse.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;results&quot;</span>, resultsArray<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; response.<span style="color: #006633;">getWriter</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">write</span><span style="color: #009900;">&#40;</span>jsonResponse.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; JSONObject errorResponse <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> JSONObject<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; errorResponse.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;error&quot;</span>, <span style="color: #0000ff;">&quot;An error occurred while processing the request.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; response.<span style="color: #006633;">getWriter</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">write</span><span style="color: #009900;">&#40;</span>errorResponse.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<div class="mention-block"><strong>For other ways to find AEM pages on AEM using the query builder</strong>, checkout this article -><br />
<a href="/blog/aem/find-all-aem-pages-with-tags-with-query-builder" rel="noopener" target="_blank">Find all AEM Pages with Tags with Query Builder API</a>
</div>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/find-all-aem-pages-with-specific-page-properties-with-query-builder-api">Find all AEM Pages with Specific Page Properties with Query Builder API</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/find-all-aem-pages-with-specific-page-properties-with-query-builder-api/feed</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
		<item>
		<title>AEM Granite UI Multifield Maximum Items Validation</title>
		<link>https://sourcedcode.com/blog/aem/aem-granite-ui-multifield-maximum-items-validation</link>
					<comments>https://sourcedcode.com/blog/aem/aem-granite-ui-multifield-maximum-items-validation#comments</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Sat, 16 Jul 2022 22:34:04 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Touch UI]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=3586</guid>

					<description><![CDATA[<p>For almost all cases of AEM implementations, adding validation for maximum items for the Granite UI Multifield is a must. In this article, we will put together a script that will register a new validator (foundation.validation.validator) to the foundation-registry (the foundation-registry is used in the Granite UI framework). In this solution, we will be utilizing [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/aem-granite-ui-multifield-maximum-items-validation">AEM Granite UI Multifield Maximum Items Validation</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>For almost all cases of AEM implementations, adding validation for maximum items for the Granite UI Multifield is a must. In this article, we will put together a script that will register a new validator (foundation.validation.validator) to the foundation-registry (the foundation-registry is used in the Granite UI framework). In this solution, we will be utilizing the jQuery Validation library (the validation library used by Granite UI is achieved by using the jQuery Validation plugin). </p>
<p><a href="https://sourcedcode.com/blog/aem/add-aem-custom-frontend-css-javascript-editor-html" rel="noopener" target="_blank">We must register a client library specifically targeting the author, which is specific to customizing page authoring</a>, which will inject JavaScript into the context of the page and execute the registry and scripts.</p>
<div class="mention-block">
After the installation of this validation code, you should be able to just include <strong>two additional properties</strong> to the <a href="https://developer.adobe.com/experience-manager/reference-materials/6-5/granite-ui/api/jcr_root/libs/granite/ui/components/coral/foundation/form/multifield/index.html" rel="noopener" target="_blank">multifield Granite UI component</a>, and it should be validating as expected:</p>
<p>Two fields:<br />
<strong>granite:class=&#8221;granite-ui-validation-multifield-max-items&#8221;</strong><br />
<strong>validation=&#8221;max-items-2&#8243;</strong></p>
<p>Example:</p>
<div class="codecolorer-container xml default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #000000; font-weight: bold;">&lt;navigationLinksMultifield</span><br />
&nbsp; &nbsp; <span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; <span style="color: #000066;">granite:class</span>=<span style="color: #ff0000;">&quot;granite-ui-validation-multifield-max-items&quot;</span><br />
&nbsp; &nbsp; <span style="color: #000066;">validation</span>=<span style="color: #ff0000;">&quot;max-items-2&quot;</span><br />
&nbsp; &nbsp; <span style="color: #000066;">sling:resourceType</span>=<span style="color: #ff0000;">&quot;granite/ui/components/coral/foundation/form/multifield&quot;</span><br />
&nbsp; &nbsp; <span style="color: #000066;">composite</span>=<span style="color: #ff0000;">&quot;{Boolean}true&quot;</span><br />
&nbsp; &nbsp; <span style="color: #000066;">fieldLabel</span>=<span style="color: #ff0000;">&quot;Navigation Links&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; ...</div></td></tr></tbody></table></div>
</div>
<hr class="spacer-large" />
<h2>Follow the steps below to have this setup</h2>
<div class="mention-block">
If you would like, completely download the clientlib-author client library <a href="https://sourcedcode.com/wp-content/uploads/2022/07/clientlib-author.zip">here</a>. This ZIP archive will include all the steps from 1-7.
</div>
<hr class="spacer-large" />
<h6> Step 1</h6>
<p>In your repository, create a new client library folder under your brand&#8217;s /apps/clientlib folder like:<br />
<span class="code-highlight-primary">path: ./sourcedcode/ui.apps/src/main/content/jcr_root/apps/sourcedcode/clientlibs/clientlib-author</span></p>
<p><a href="https://sourcedcode.com/wp-content/uploads/2022/07/clientlibrary-path.png"><img loading="lazy" decoding="async" src="https://sourcedcode.com/wp-content/uploads/2022/07/clientlibrary-path.png" alt="" width="1077" height="341" class="alignnone size-full wp-image-3597" srcset="https://sourcedcode.com/wp-content/uploads/2022/07/clientlibrary-path.png 1077w, https://sourcedcode.com/wp-content/uploads/2022/07/clientlibrary-path-300x95.png 300w, https://sourcedcode.com/wp-content/uploads/2022/07/clientlibrary-path-1024x324.png 1024w, https://sourcedcode.com/wp-content/uploads/2022/07/clientlibrary-path-768x243.png 768w, https://sourcedcode.com/wp-content/uploads/2022/07/clientlibrary-path-600x190.png 600w" sizes="(max-width: 1077px) 100vw, 1077px" /></a></p>
<hr class="spacer-large" />
<h6> Step 2</h6>
<p>In the newly created folder, create an .content.xml file and include the text found below:<br />
<span class="code-highlight-primary">path: ./sourcedcode/ui.apps/src/main/content/jcr_root/apps/sourcedcode/clientlibs/clientlib-author/.content.xml</span></p>
<div class="codecolorer-container xml default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span><br />
<span style="color: #000000; font-weight: bold;">&lt;jcr:root</span> <span style="color: #000066;">xmlns:cq</span>=<span style="color: #ff0000;">&quot;http://www.day.com/jcr/cq/1.0&quot;</span> <span style="color: #000066;">xmlns:jcr</span>=<span style="color: #ff0000;">&quot;http://www.jcp.org/jcr/1.0&quot;</span><br />
&nbsp; &nbsp; <span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;cq:ClientLibraryFolder&quot;</span><br />
&nbsp; &nbsp; <span style="color: #000066;">categories</span>=<span style="color: #ff0000;">&quot;[cq.authoring.editor.sites.page.hook]&quot;</span><br />
&nbsp; &nbsp; <span style="color: #000066;">dependencies</span>=<span style="color: #ff0000;">&quot;[cq.authoring.editor.sites.page]&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></div></td></tr></tbody></table></div>
<p>This method is specific to customizing page authoring in AEM, for more information about this topic, <a href="https://sourcedcode.com/blog/aem/add-aem-custom-frontend-css-javascript-editor-html" rel="noopener" target="_blank">click here</a>.</p>
<hr class="spacer-large" />
<h6> Step 3</h6>
<p>In the newly created folder, create an js folder (leave this empty).<br />
<span class="code-highlight-primary">path: ./sourcedcode/ui.apps/src/main/content/jcr_root/apps/sourcedcode/clientlibs/clientlib-author/js</span></p>
<hr class="spacer-large" />
<div class="mention-block">
If you would like, completely download the clientlib-author client library <a href="https://sourcedcode.com/wp-content/uploads/2022/07/clientlib-author.zip">here</a>. This ZIP archive will include all the steps from 1-7.
</div>
<hr class="spacer-large" />
<h6> Step 4</h6>
<p>In the newly created js folder, create a file named granite-ui-multifield-max-items.js and paste in the JavaScript found below:<br />
<span class="code-highlight-primary">path: ./sourcedcode/ui.apps/src/main/content/jcr_root/apps/sourcedcode/clientlibs/clientlib-author/js/granite-ui-multifield-max-items.js</span></p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br />78<br />79<br />80<br />81<br />82<br />83<br />84<br />85<br />86<br />87<br />88<br />89<br />90<br />91<br />92<br />93<br />94<br />95<br />96<br />97<br />98<br />99<br />100<br />101<br />102<br />103<br />104<br />105<br />106<br />107<br />108<br />109<br />110<br />111<br />112<br />113<br />114<br />115<br />116<br />117<br />118<br />119<br />120<br />121<br />122<br />123<br />124<br />125<br />126<br />127<br />128<br />129<br />130<br />131<br />132<br />133<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #339933;">;</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>$<span style="color: #339933;">,</span> Coral<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #3366CC;">'use strict'</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp;* Granite UI Validation - Multifield Max Items<br />
&nbsp; &nbsp; &nbsp;*<br />
&nbsp; &nbsp; &nbsp;* @class MultifieldMaxItems<br />
&nbsp; &nbsp; &nbsp;* @classdesc registering Granite UI validation for the multifield maximum items.<br />
&nbsp; &nbsp; &nbsp;* This custom JavaScript validation ensures the number of multifield items does not exceed the maximum number<br />
&nbsp; &nbsp; &nbsp;* of items in the touch ui.<br />
&nbsp; &nbsp; &nbsp;*<br />
&nbsp; &nbsp; &nbsp;* Example Granite UI Multifield block:<br />
&nbsp; &nbsp; &nbsp;* &lt;navigationLinksMultifield<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jcr:primaryType=&quot;nt:unstructured&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; granite:class=&quot;granite-ui-validation-multifield-max-items&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; validation=&quot;max-items-2&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sling:resourceType=&quot;granite/ui/components/coral/foundation/form/multifield&quot;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ...<br />
&nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">var</span> MultifieldMaxItems <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">var</span> CONST <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TARGET_GRANITE_UI<span style="color: #339933;">:</span> <span style="color: #3366CC;">'.granite-ui-validation-multifield-max-items'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; VALIDATION_PROPERTY<span style="color: #339933;">:</span> <span style="color: #3366CC;">'validation'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; VALIDATION_VALUE_PREFIX<span style="color: #339933;">:</span> <span style="color: #3366CC;">'max-items'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ERROR_MESSAGE<span style="color: #339933;">:</span> <span style="color: #3366CC;">'Max allowed items is {0}'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ERROR_TOOLTIP_ID<span style="color: #339933;">:</span> Coral.<span style="color: #660066;">commons</span>.<span style="color: #660066;">getUID</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DEFAULT_MAX_SIZE<span style="color: #339933;">:</span> &nbsp;<span style="color: #CC0000;">100</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Initializes the MultifieldMaxItems<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* @private<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">function</span> init<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// if dialog does not exist on the page, escape.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>$<span style="color: #009900;">&#40;</span>CONST.<span style="color: #660066;">TARGET_GRANITE_UI</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// register foundation validation for multi-field, max size</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $<span style="color: #009900;">&#40;</span>window<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">adaptTo</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'foundation-registry'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">register</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'foundation.validation.validator'</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; selector<span style="color: #339933;">:</span> CONST.<span style="color: #660066;">TARGET_GRANITE_UI</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; validate<span style="color: #339933;">:</span> <span style="color: #000066; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>el<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">var</span> max <span style="color: #339933;">=</span> _getMaxSizeValue<span style="color: #009900;">&#40;</span>el<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>el.<span style="color: #660066;">items</span>.<span style="color: #660066;">length</span> <span style="color: #339933;">&gt;</span> max<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span> CONST.<span style="color: #660066;">ERROR_MESSAGE</span>.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'{0}'</span><span style="color: #339933;">,</span> max<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; show<span style="color: #339933;">:</span> <span style="color: #000066; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>el<span style="color: #339933;">,</span> message<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _handleError<span style="color: #009900;">&#40;</span>el<span style="color: #339933;">,</span> message<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; clear<span style="color: #339933;">:</span> <span style="color: #000066; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>el<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">var</span> max <span style="color: #339933;">=</span> _getMaxSizeValue<span style="color: #009900;">&#40;</span>el<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>el.<span style="color: #660066;">items</span>.<span style="color: #660066;">length</span> <span style="color: #339933;">&lt;=</span> max<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// set field to valid if max size fits within the rules</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">var</span> $el <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span>el<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">var</span> fieldAPI <span style="color: #339933;">=</span> $el.<span style="color: #660066;">adaptTo</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'foundation-field'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>fieldAPI <span style="color: #339933;">&amp;&amp;</span> fieldAPI.<span style="color: #660066;">setInvalid</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fieldAPI.<span style="color: #660066;">setInvalid</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// remove tooltip</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#'</span> <span style="color: #339933;">+</span> CONST.<span style="color: #660066;">ERROR_TOOLTIP_ID</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Gets the max-items value set in the &quot;validation&quot; granite ui property.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* @private<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* @param {HTMLElement} el is the validation HTML block with an existing validation attribute<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">function</span> _getMaxSizeValue<span style="color: #009900;">&#40;</span>el<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">var</span> validationName <span style="color: #339933;">=</span> el.<span style="color: #660066;">getAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'data-'</span> <span style="color: #339933;">+</span> CONST.<span style="color: #660066;">VALIDATION_PROPERTY</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>validationName<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">var</span> max <span style="color: #339933;">=</span> validationName.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span>CONST.<span style="color: #660066;">VALIDATION_VALUE_PREFIX</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'-'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>max<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span> parseInt<span style="color: #009900;">&#40;</span>max<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span> CONST.<span style="color: #660066;">DEFAULT_MAX_SIZE</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* Handles the displaying of error messages<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* @private<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* @param {HTMLElement} el is the validation HTML block with an existing validation attribute<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;* @param {String} message is error message returned by the validate method, in the registry of foundation.validation.validator.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">function</span> _handleError<span style="color: #009900;">&#40;</span>el<span style="color: #339933;">,</span> message<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">var</span> $el <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span>el<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// set foundation field to show as invalid</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">var</span> fieldAPI <span style="color: #339933;">=</span> $el.<span style="color: #660066;">adaptTo</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'foundation-field'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>fieldAPI <span style="color: #339933;">&amp;&amp;</span> fieldAPI.<span style="color: #660066;">setInvalid</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fieldAPI.<span style="color: #660066;">setInvalid</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// set foundation field to show as invalid</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">var</span> error <span style="color: #339933;">=</span> $el.<span style="color: #660066;">data</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'foundation-validation.internal.error'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>error<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; error.<span style="color: #660066;">content</span>.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">=</span> message<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>error.<span style="color: #660066;">parentNode</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $el.<span style="color: #660066;">after</span><span style="color: #009900;">&#40;</span>error<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; error.<span style="color: #660066;">show</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; error <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">new</span> Coral.<span style="color: #660066;">Tooltip</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; error.<span style="color: #660066;">variant</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'error'</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; error.<span style="color: #660066;">interaction</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'off'</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; error.<span style="color: #660066;">placement</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'bottom'</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; error.<span style="color: #660066;">target</span> <span style="color: #339933;">=</span> el<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; error.<span style="color: #660066;">content</span>.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">=</span> message<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; error.<span style="color: #660066;">open</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; error.<span style="color: #660066;">id</span> <span style="color: #339933;">=</span> CONST.<span style="color: #660066;">ERROR_TOOLTIP_ID</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $el.<span style="color: #660066;">data</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'foundation-validation.internal.error'</span><span style="color: #339933;">,</span> error<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $el.<span style="color: #660066;">after</span><span style="color: #009900;">&#40;</span>error<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; init<span style="color: #339933;">:</span> init<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; MultifieldMaxItems.<span style="color: #660066;">init</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#40;</span>jQuery<span style="color: #339933;">,</span> Coral<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<hr class="spacer-large" />
<h6> Step 5</h6>
<p>In your repository, create a css.txt and js.txt file<br />
<span class="code-highlight-primary">path: ./sourcedcode/ui.apps/src/main/content/jcr_root/apps/sourcedcode/clientlibs/clientlib-author/css.txt</span></p>
<p><span class="code-highlight-primary">path: ./sourcedcode/ui.apps/src/main/content/jcr_root/apps/sourcedcode/clientlibs/clientlib-author/js.txt</span></p>
<p>A valid client library must include these two files.</p>
<hr class="spacer-large" />
<h6> Step 6</h6>
<p>Edit the js.txt file to include:</p>
<p><span class="code-highlight-primary">path: ./sourcedcode/ui.apps/src/main/content/jcr_root/apps/sourcedcode/clientlibs/clientlib-author/js.txt</span></p>
<div class="codecolorer-container xml default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br /></div></td><td><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">#base=js<br />
granite-ui-multifield-max-items.js</div></td></tr></tbody></table></div>
<hr class="spacer-large" />
<h6> Step 7</h6>
<p>Edit your Granite UI Multifield component to include two new properties:<br />
<strong>granite:class=&#8221;granite-ui-validation-multifield-max-items&#8221;</strong><br />
<strong>validation=&#8221;max-items-2&#8243;</strong></p>
<p>Example: In this example, we have ensured that the maximum items that can be used in the multifield is 2 items.</p>
<div class="codecolorer-container xml default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br /></div></td><td><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #000000; font-weight: bold;">&lt;navigationLinksMultifield</span><br />
&nbsp; &nbsp; <span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; <span style="color: #000066;">granite:class</span>=<span style="color: #ff0000;">&quot;granite-ui-validation-multifield-max-items&quot;</span><br />
&nbsp; &nbsp; <span style="color: #000066;">validation</span>=<span style="color: #ff0000;">&quot;max-items-2&quot;</span><br />
&nbsp; &nbsp; <span style="color: #000066;">sling:resourceType</span>=<span style="color: #ff0000;">&quot;granite/ui/components/coral/foundation/form/multifield&quot;</span><br />
&nbsp; &nbsp; <span style="color: #000066;">composite</span>=<span style="color: #ff0000;">&quot;{Boolean}true&quot;</span><br />
&nbsp; &nbsp; <span style="color: #000066;">fieldLabel</span>=<span style="color: #ff0000;">&quot;Navigation Links&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;field</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">sling:resourceType</span>=<span style="color: #ff0000;">&quot;granite/ui/components/coral/foundation/container&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;./navLinks&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;items</span> <span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;linkLabel</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">sling:resourceType</span>=<span style="color: #ff0000;">&quot;granite/ui/components/coral/foundation/form/textfield&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">fieldLabel</span>=<span style="color: #ff0000;">&quot;Link Label&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;./linkLabel&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">required</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;linkPath</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">sling:resourceType</span>=<span style="color: #ff0000;">&quot;granite/ui/components/coral/foundation/form/pathfield&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">fieldLabel</span>=<span style="color: #ff0000;">&quot;Link Path&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;./linkPath&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">required</span>=<span style="color: #ff0000;">&quot;true&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">rootPath</span>=<span style="color: #ff0000;">&quot;/content&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;linkTarget</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">sling:resourceType</span>=<span style="color: #ff0000;">&quot;granite/ui/components/coral/foundation/form/select&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">fieldLabel</span>=<span style="color: #ff0000;">&quot;CTA Link Target&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;./linkTarget&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;items</span> <span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;self</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">selected</span>=<span style="color: #ff0000;">&quot;{Boolean}true&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">text</span>=<span style="color: #ff0000;">&quot;Same Page&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;_self&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;blank</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">text</span>=<span style="color: #ff0000;">&quot;New Tab&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;_blank&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;/items<span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;/linkTarget<span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;/items<span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;/field<span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
<span style="color: #000000; font-weight: bold;">&lt;/navigationLinksMultifield<span style="color: #000000; font-weight: bold;">&gt;</span></span></div></td></tr></tbody></table></div>
<hr class="spacer-large" />
<h6> Step 8</h6>
<p>The Granite UI Multifield validation should be working as expected.</p>
<p><a href="https://sourcedcode.com/wp-content/uploads/2022/07/granite-ui-validation-multifield-max-items.png"><img decoding="async" src="https://sourcedcode.com/wp-content/uploads/2022/07/granite-ui-validation-multifield-max-items.png" alt="Granite UI Multifield Max Items Validation Screenshot" /></a></p>
<hr class="spacer-large" />
<div class="mention-block">
You have successfully added Granite UI Multifield maximum items validation! </p>
<p>For another in-depth tutorial for how to add Granite UI RichText Max Characters Length Validation, <a href="https://sourcedcode.com/blog/aem/touch-ui/aem-richtext-max-characters-length-validation">click here</a></div>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/aem-granite-ui-multifield-maximum-items-validation">AEM Granite UI Multifield Maximum Items Validation</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/aem-granite-ui-multifield-maximum-items-validation/feed</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>Add AEM Custom Frontend CSS JavaScript Editor.html</title>
		<link>https://sourcedcode.com/blog/aem/add-aem-custom-frontend-css-javascript-editor-html</link>
					<comments>https://sourcedcode.com/blog/aem/add-aem-custom-frontend-css-javascript-editor-html#comments</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Sat, 16 Jul 2022 20:51:14 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Touch UI]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=3582</guid>

					<description><![CDATA[<p>I would like to re-share one of my existing blog articles on how to add a custom client library for the AEM Author Editor (editor.html). It&#8217;s a very simple configuration that requires one dependency and one client category. This method is specific to customizing page authoring in AEM. Click on this link for exactly how [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/add-aem-custom-frontend-css-javascript-editor-html">Add AEM Custom Frontend CSS JavaScript Editor.html</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>I would like to re-share one of my existing blog articles on how to add a custom client library for the AEM Author Editor (editor.html). It&#8217;s a very simple configuration that requires one dependency and one client category. This method is specific to customizing page authoring in AEM.</p>
<p>Click on this link for exactly how this can be set up, <a href="https://sourcedcode.com/blog/aem/adding-custom-client-library-for-aem-author-editor-touch-ui">https://sourcedcode.com/blog/aem/adding-custom-client-library-for-aem-author-editor-touch-ui</a></p>
<p><strong>Usecases for adding custom CSS or JavaScript to the editor.html would be:</strong></p>
<ol>
<li>Including custom styling from the UI for the Granite UI fields.</li>
<li>Including custom Granite UI JavaScript validations such as <a href="https://sourcedcode.com/blog/aem/touch-ui/aem-richtext-max-characters-length-validation">richtext maximum characters</a> or multifield maximum items.</li>
<li>Including custom processes such as deleting component properties based on Granite UI configurations.</li>
<li>Including JavaScript injections into a page based on the window.location.pathname or searchParams.</li>
</ol>
<p>All in all, the sky is the limit on customizations that you can add to the editor.html. Click on this link for exactly how this can be set up, <a href="https://sourcedcode.com/blog/aem/adding-custom-client-library-for-aem-author-editor-touch-ui">https://sourcedcode.com/blog/aem/adding-custom-client-library-for-aem-author-editor-touch-ui</a></p>
<div class="mention-block">
If you want to learn how to create client libraries for the authoring environment that only target specific components checkout this article <a href="https://sourcedcode.com/blog/aem/what-are-aem-extraclientlibs">here</a>.
</div>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/add-aem-custom-frontend-css-javascript-editor-html">Add AEM Custom Frontend CSS JavaScript Editor.html</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/add-aem-custom-frontend-css-javascript-editor-html/feed</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>AEM i18n Not Showing Translations</title>
		<link>https://sourcedcode.com/blog/aem/aem-i18n-not-showing-translations</link>
					<comments>https://sourcedcode.com/blog/aem/aem-i18n-not-showing-translations#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Fri, 15 Jul 2022 20:53:23 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[i18n]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=3568</guid>

					<description><![CDATA[<p>A common question for AEM developers is, why are my i18n translations not showing up in my AEM environment? Recently, I have seen this problem coming up and I have the solution just for you. During deployment, whether it is from AEM Author or Publish, when deploying new dictionary keys, it&#8217;s uncommon for new i18n [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/aem-i18n-not-showing-translations">AEM i18n Not Showing Translations</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>A common question for AEM developers is, why are my i18n translations not showing up in my AEM environment? Recently, I have seen this problem coming up and I have the solution just for you.</p>
<p>During deployment, whether it is from AEM Author or Publish, when deploying new dictionary keys, it&#8217;s uncommon for new i18n configurations to not show up immediately after all the bundles have been installed and restarted. But when this happens, it&#8217;s because sometimes the Apache Sling I18N Supportorg.apache.sling.i18n is not registering the new dictionary keys that have been installed. In this article, I will provide a manual way for you to solve this problem.</p>
<hr class="spacer-large"/>
<div class="mention-block">
<h2>2 ways to solve this problem</h2>
<ol>
<li><a href="#Restart-the-Apache-Sling-I18N-Supportorg.apache.sling.i18n-bundle">Restart the Apache Sling I18N Supportorg.apache.sling.i18n bundle</a></li>
<li><a href="#Restart-AEM">Restart AEM</a></li>
</ol>
</div>
<hr class="spacer-large"/>
<h3 id="Restart-the-Apache-Sling-I18N-Supportorg.apache.sling.i18n-bundle">1. Restart the Apache Sling I18N Supportorg.apache.sling.i18n bundle</h3>
<ol>
<li>Login to your AEM instance as admin</li>
<li>Visit OSGI bundles console via <a href="http://localhost:4502/system/console/bundles" rel="noopener" target="_blank">http://localhost:4502/system/console/bundles</a></li>
<li>Search for <strong>Apache Sling I18N Supportorg.apache.sling.i18n</strong>; you can use CTRL + F to find text on the browser</li>
<li>Press on the stop button. This will stop the <strong>Apache Sling I18N Supportorg.apache.sling.i18n</strong> bundle; you should be able to see the status of the bundle set to &#8220;Resolved&#8221;</li>
<li>Refresh the page</li>
<li>Press on the play button. This will stop the <strong>Apache Sling I18N Supportorg.apache.sling.i18n</strong> bundle; you should be able to see the status of the bundle set to &#8220;Active&#8221;</li>
<li>Head back to the page with the page with the i18n translations not working as expected, and you should see the dictionary value loaded as expected</li>
</ol>
<hr class="spacer-large"/>
<h3 id="Restart-AEM">2. Restart AEM</h3>
<p>In this step, you can simple restart AEM, and the Apache <strong>Sling I18N Supportorg.apache.sling.i18n</strong> bundle should be active.</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/aem-i18n-not-showing-translations">AEM i18n Not Showing Translations</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/aem-i18n-not-showing-translations/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Granite UI Multifield Sightly Traverse &#124; Iterate Simple Example</title>
		<link>https://sourcedcode.com/blog/aem/granite-ui-multifield-sightly-traverse-iterate-simple-example</link>
					<comments>https://sourcedcode.com/blog/aem/granite-ui-multifield-sightly-traverse-iterate-simple-example#comments</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Fri, 24 Jun 2022 01:58:27 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Sightly]]></category>
		<category><![CDATA[Touch UI]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=3526</guid>

					<description><![CDATA[<p>In this article, we will share an example on on how we can iterate and traverse through multifield nodes that have been generated by the Touch UI using Sightly in a very simple way. Going through this article, we will be setting up multifield Granite UI links (as if we are building a menu navigation). [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/granite-ui-multifield-sightly-traverse-iterate-simple-example">Granite UI Multifield Sightly Traverse | Iterate Simple Example</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>In this article, we will share an example on on how we can iterate and traverse through multifield nodes that have been generated by the Touch UI using Sightly in a very simple way.</p>
<p>Going through this article, we will be setting up multifield Granite UI links (as if we are building a menu navigation). Each link will define it&#8217;s own path, label, and target. Take a look at both screenshots below. One screenshot indicates how a multifield Granite UI field will look like, and in the second screenshot displays how saved nodes would look like in the crx/de console.</p>
<p><a class="foobox fbx-instance fbx-link" href="https://sourcedcode.com/wp-content/uploads/2022/06/multi-list-1-1.png"><img decoding="async" src="https://sourcedcode.com/wp-content/uploads/2022/06/multi-list-1-1.png" alt="Touch UI - show casing multifield link configurations screenshot" /></a><br />
<a  class="foobox fbx-instance fbx-link"  href="https://sourcedcode.com/wp-content/uploads/2022/06/multi-list-2.png"><img decoding="async" src="https://sourcedcode.com/wp-content/uploads/2022/06/multi-list-2.png" alt="CRX/DE saved link nodes from the Touch UI screenshot" /></a></p>
<hr class="spacer-large"/>
<h3>Step 1. Touch UI Configuration</h3>
<p>Putting together a very basic Touch UI configuration using tabs to organize our Granite UI fields. Here we will place the entire configuration under:<br />
<strong>/apps/sourcedcode/components/content/multilistexample/_cq_dialog/.content.xml</strong>. </p>
<p>line: 34, declaring a multifield<br />
line: 42, declaring multifield > label<br />
line: 48, declaring multifield > path<br />
line: 55, declaring multifield > target</p>
<div class="codecolorer-container xml default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br />78<br />79<br />80<br />81<br />82<br />83<br /></div></td><td><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;jcr:root</span> <span style="color: #000066;">xmlns:sling</span>=<span style="color: #ff0000;">&quot;http://sling.apache.org/jcr/sling/1.0&quot;</span> <span style="color: #000066;">xmlns:cq</span>=<span style="color: #ff0000;">&quot;http://www.day.com/jcr/cq/1.0&quot;</span> <span style="color: #000066;">xmlns:jcr</span>=<span style="color: #ff0000;">&quot;http://www.jcp.org/jcr/1.0&quot;</span> <span style="color: #000066;">xmlns:nt</span>=<span style="color: #ff0000;">&quot;http://www.jcp.org/jcr/nt/1.0&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp;<span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp;<span style="color: #000066;">jcr:title</span>=<span style="color: #ff0000;">&quot;Multi List Example&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp;<span style="color: #000066;">sling:resourceType</span>=<span style="color: #ff0000;">&quot;cq/gui/components/authoring/dialog&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;content</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">sling:resourceType</span>=<span style="color: #ff0000;">&quot;granite/ui/components/foundation/container&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;layout</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">sling:resourceType</span>=<span style="color: #ff0000;">&quot;granite/ui/components/foundation/layouts/tabs&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;nav&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;items</span> <span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;generalSettings</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">jcr:title</span>=<span style="color: #ff0000;">&quot;General Settings&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">sling:resourceType</span>=<span style="color: #ff0000;">&quot;granite/ui/components/foundation/section&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;layout</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">sling:resourceType</span>=<span style="color: #ff0000;">&quot;granite/ui/components/foundation/layouts/fixedcolumns&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;nav&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;items</span> <span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;column</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">sling:resourceType</span>=<span style="color: #ff0000;">&quot;granite/ui/components/coral/foundation/container&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;items</span> <span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;linkOptions</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">jcr:title</span>=<span style="color: #ff0000;">&quot;Links Options&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">sling:resourceType</span>=<span style="color: #ff0000;">&quot;granite/ui/components/coral/foundation/form/fieldset&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;items</span> <span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;links</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">sling:resourceType</span>=<span style="color: #ff0000;">&quot;granite/ui/components/coral/foundation/form/multifield&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">composite</span>=<span style="color: #ff0000;">&quot;{Boolean}true&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">fieldLabel</span>=<span style="color: #ff0000;">&quot;Links&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;field</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">sling:resourceType</span>=<span style="color: #ff0000;">&quot;granite/ui/components/coral/foundation/container&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;./links&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;items</span> <span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;linkLabel</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">sling:resourceType</span>=<span style="color: #ff0000;">&quot;granite/ui/components/coral/foundation/form/textfield&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">fieldLabel</span>=<span style="color: #ff0000;">&quot;Link Label&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;./linkLabel&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">required</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;linkPath</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">sling:resourceType</span>=<span style="color: #ff0000;">&quot;granite/ui/components/coral/foundation/form/pathfield&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">fieldLabel</span>=<span style="color: #ff0000;">&quot;Link Path&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;./linkPath&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">required</span>=<span style="color: #ff0000;">&quot;true&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">rootPath</span>=<span style="color: #ff0000;">&quot;/content&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;linkTarget</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">sling:resourceType</span>=<span style="color: #ff0000;">&quot;granite/ui/components/coral/foundation/form/select&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">fieldLabel</span>=<span style="color: #ff0000;">&quot;Link Target&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;./linkTarget&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;items</span> <span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;self</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">selected</span>=<span style="color: #ff0000;">&quot;{Boolean}true&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">text</span>=<span style="color: #ff0000;">&quot;Same Page&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;_self&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;blank</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;nt:unstructured&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">text</span>=<span style="color: #ff0000;">&quot;New Tab&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;_blank&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/items<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/linkTarget<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/items<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/field<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/links<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/items<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/linkOptions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/items<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/column<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/items<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/generalSettings<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/items<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/content<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/jcr:root<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></div></td></tr></tbody></table></div>
<hr class="spacer-large"/>
<h3>Step 2. Sightly HTL Front-end</h3>
<p>A very simple way to get a list of objects to iterate through will be to use Sling Model&#8217;s backend and Sling Specific Annotations. Together the mechanism combined will enable the Sightly HTL code to receive a List<Resource>, which you can use this list to iterate through each item, to display nav link configurations that were set by the authors.</p>
<p>Using the Sightly <strong>data-sly-list</strong> API, we can traverse through each item from the List<Resources>. Iterating through each item returns an Resource.class onbject, which it has a getValueMap() public getter method. With this getter method we can get the valueMap object and reveal the configurations that are set by the authors.</p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;cmp-multilistexample&quot;</span></span><br />
<span style="color: #009900;"> &nbsp; &nbsp; data-sly-use.cmp<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;com.sourcedcode.core.models.content.MultiListExample&quot;</span>&gt;</span><br />
&nbsp; <span style="color: #009900;">&lt;sly data-sly-list.<span style="color: #000066;">link</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;${cmp.links}&quot;</span>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;${link.valueMap.linkPath}&quot;</span> <span style="color: #000066;">target</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;${link.valueMap.linkTarget}&quot;</span> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;noopener&quot;</span>&gt;</span>${link.valueMap.linkLabel}<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span><br />
&nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>sly&gt;</span><br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></div></td></tr></tbody></table></div>
<hr class="spacer-large"/>
<h3>Step 3. Sling Model Java Backend</h3>
<p>Sling Model&#8217;s backend and Sling Specific Annotations. Together the mechanism combined will enable the Sightly HTL code to receive a List<Resource>.</p>
<div class="mention-block">
<strong>Pro Tip:</strong><br />
<strong>Decrease your AEM development time using our AEM Sling Model Cheat Sheet Reference Guide! <a href="https://sourcedcode.com/blog/aem/aem-sling-model-injectors-annotations-cheat-sheet-reference-guide" rel="noopener" target="_blank">View Guide</a></strong>.
</div>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.sourcedcode.core.models.content</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">lombok.Getter</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.resource.Resource</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.models.annotations.DefaultInjectionStrategy</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.models.annotations.Model</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.models.annotations.injectorspecific.ChildResource</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.inject.Named</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.List</span><span style="color: #339933;">;</span><br />
<br />
@Model<span style="color: #009900;">&#40;</span>adaptables <span style="color: #339933;">=</span> Resource.<span style="color: #000000; font-weight: bold;">class</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; defaultInjectionStrategy <span style="color: #339933;">=</span> DefaultInjectionStrategy.<span style="color: #006633;">OPTIONAL</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MultiListExample <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; @Getter<br />
&nbsp; &nbsp; @ChildResource<br />
&nbsp; &nbsp; @Named<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;links&quot;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> List<span style="color: #339933;">&lt;</span>Resource<span style="color: #339933;">&gt;</span> links<span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<hr class="spacer-large"/>
<h3>Step 4. Results</h3>
<p>Work your maven magic, and build the code. Once your backend bundle and Sightly HTL code are aligned, you should be able to see the links like here in the screenshot.<br />
<a class="foobox fbx-instance fbx-link"  href="https://sourcedcode.com/wp-content/uploads/2022/06/multi-list-3.png"><img decoding="async" src="https://sourcedcode.com/wp-content/uploads/2022/06/multi-list-3.png" alt="Links Results" /></a></p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/granite-ui-multifield-sightly-traverse-iterate-simple-example">Granite UI Multifield Sightly Traverse | Iterate Simple Example</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/granite-ui-multifield-sightly-traverse-iterate-simple-example/feed</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
		<item>
		<title>How to change a user&#8217;s password on AEM</title>
		<link>https://sourcedcode.com/blog/aem/how-to-change-a-users-password-on-aem</link>
					<comments>https://sourcedcode.com/blog/aem/how-to-change-a-users-password-on-aem#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Thu, 23 Jun 2022 03:23:20 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=3496</guid>

					<description><![CDATA[<p>During development, sometimes our environments are not set up with single Sign-On, so creating users manually will be a manual task in our AEM environment. When creating users manually, AEM engineers need to insert a secure password, and sometimes the password will be lost. Updating user passwords for non-single sign-on users is very simple. In [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/how-to-change-a-users-password-on-aem">How to change a user&#8217;s password on AEM</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>During development, sometimes our environments are not set up with single Sign-On, so creating users manually will be a manual task in our AEM environment. When creating users manually, AEM engineers need to insert a secure password, and sometimes the password will be lost.</p>
<p>Updating user passwords for non-single sign-on users is very simple. In this article, we will go through the process of how to change a user&#8217;s password.</p>
<hr class="spacer-large" />
<h2>Step 1</h2>
<p>Log into your AEM environment as an <strong>Admin</strong> user.</p>
<h2>Step 2</h2>
<p>Visit the classic useradmin panel at <a href="http://localhost:4502/useradmin" rel="noopener" target="_blank">http://localhost:4502/useradmin</a><br />
<a class="foobox fbx-instance fbx-link" href="https://sourcedcode.com/wp-content/uploads/2022/06/change-password-1.png"><img decoding="async" style="height:200px;" src="https://sourcedcode.com/wp-content/uploads/2022/06/change-password-1.png" alt="AEM User Admin Panel" /></a></p>
<hr class="spacer-medium" />
<h2>Step 3</h2>
<p>Search for the target user and double-click on the user. The UI should update on the right-hand side with the user&#8217;s details.<br />
<a class="foobox fbx-instance fbx-link" href="https://sourcedcode.com/wp-content/uploads/2022/06/change-password-2.png"><img decoding="async" style="height:200px;" src="https://sourcedcode.com/wp-content/uploads/2022/06/change-password-2.png" alt="AEM User Admin Panel with Details" /></a></p>
<hr class="spacer-medium" />
<h2>Step 4</h2>
<p>Click on the &#8220;set password&#8221;; this should activate the popup.</p>
<p>Within the popup, please fill in the correct details:<br />
<strong>Your Password</strong>: Insert the admin password<br />
<strong>Password</strong>: Insert the user&#8217;s new password<br />
<strong>Confirm Password</strong>: Insert the user&#8217;s new password to confirm.<br />
<a class="foobox fbx-instance fbx-link" href="https://sourcedcode.com/wp-content/uploads/2022/06/change-password-3.png"><img decoding="async" style="height:200px;" src="https://sourcedcode.com/wp-content/uploads/2022/06/change-password-3.png" alt="Set Password" /></a></p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/how-to-change-a-users-password-on-aem">How to change a user&#8217;s password on AEM</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/how-to-change-a-users-password-on-aem/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Importing rep:policy nodes in the ui.content maven content package</title>
		<link>https://sourcedcode.com/blog/aem/importing-rep-policy-nodes-in-the-ui-content-maven-content-package</link>
					<comments>https://sourcedcode.com/blog/aem/importing-rep-policy-nodes-in-the-ui-content-maven-content-package#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Thu, 23 Jun 2022 00:07:07 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Content]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=3491</guid>

					<description><![CDATA[<p>While working on a new AEM project (typically using https://github.com/adobe/aem-project-archetype), we might sometimes want to deploy new content with rep:policy nodes in particular, to give permission controls to allow jcr:read everyone to view the root content pages like /content/sourcedcode. There comes when a problem while building the ui.content maven module. Sometimes the rep:policy node is [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/importing-rep-policy-nodes-in-the-ui-content-maven-content-package">Importing rep:policy nodes in the ui.content maven content package</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>While working on a new AEM project (typically using <a href="https://github.com/adobe/aem-project-archetype">https://github.com/adobe/aem-project-archetype</a>), we might sometimes want to deploy new content with rep:policy nodes in particular, to give permission controls to allow jcr:read everyone to view the root content pages like /content/sourcedcode. There comes when a problem while building the ui.content maven module. Sometimes the rep:policy node is not imported over. </p>
<p>In this article, we will be configuring your AEM ui.content maven module to import the rep:policy as expected to allow the everyone group to view the /content/sourcedcode folder.</p>
<div class="spacer-large"></div>
<h2>Step 1</h2>
<p>Create a file named _rep_policy.xml under /ui.content/src/main/content/jcr_root/content/sourcedcode/_rep_policy.xml</p>
<div class="codecolorer-container xml default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span><br />
<span style="color: #000000; font-weight: bold;">&lt;jcr:root</span> <span style="color: #000066;">xmlns:jcr</span>=<span style="color: #ff0000;">&quot;http://www.jcp.org/jcr/1.0&quot;</span> <span style="color: #000066;">xmlns:rep</span>=<span style="color: #ff0000;">&quot;internal&quot;</span><br />
&nbsp; &nbsp; <span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;rep:ACL&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;allow</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;rep:GrantACE&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">rep:principalName</span>=<span style="color: #ff0000;">&quot;everyone&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">rep:privileges</span>=<span style="color: #ff0000;">&quot;{Name}[jcr:read]&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span><br />
<span style="color: #000000; font-weight: bold;">&lt;/jcr:root<span style="color: #000000; font-weight: bold;">&gt;</span></span></div></td></tr></tbody></table></div>
<div class="spacer-medium"></div>
<h2>Step 2</h2>
<p>Update and add the _rep_policy.xml file, within /ui.content/src/main/content/META-INF/vault/filter.xml</p>
<div class="codecolorer-container xml default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span><br />
<span style="color: #000000; font-weight: bold;">&lt;workspaceFilter</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;filter</span> <span style="color: #000066;">root</span>=<span style="color: #ff0000;">&quot;/content/whitelabel/rep:policy&quot;</span> <span style="color: #000066;">mode</span>=<span style="color: #ff0000;">&quot;merge&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span><br />
<span style="color: #000000; font-weight: bold;">&lt;/workspaceFilter<span style="color: #000000; font-weight: bold;">&gt;</span></span></div></td></tr></tbody></table></div>
<div class="spacer-medium"></div>
<h2>Step 3</h2>
<p>Ensure that the /ui.content/pom.xml has the correct plugins installed. <strong>Make sure the versions are exactly the same</strong> as the configuration as looking like below.</p>
<div class="codecolorer-container xml default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br /></div></td><td><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #000000; font-weight: bold;">&lt;plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span>org.apache.jackrabbit<span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span>filevault-package-maven-plugin<span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span>1.0.1<span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;extensions<span style="color: #000000; font-weight: bold;">&gt;</span></span>true<span style="color: #000000; font-weight: bold;">&lt;/extensions<span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;properties<span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;acHandling<span style="color: #000000; font-weight: bold;">&gt;</span></span>merge<span style="color: #000000; font-weight: bold;">&lt;/acHandling<span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;/properties<span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;/configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
<span style="color: #000000; font-weight: bold;">&lt;/plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
<span style="color: #000000; font-weight: bold;">&lt;plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span>com.day.jcr.vault<span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span>content-package-maven-plugin<span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span>1.0.2<span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;extensions<span style="color: #000000; font-weight: bold;">&gt;</span></span>true<span style="color: #000000; font-weight: bold;">&lt;/extensions<span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;verbose<span style="color: #000000; font-weight: bold;">&gt;</span></span>false<span style="color: #000000; font-weight: bold;">&lt;/verbose<span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;failOnError<span style="color: #000000; font-weight: bold;">&gt;</span></span>true<span style="color: #000000; font-weight: bold;">&lt;/failOnError<span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">&lt;/configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
<span style="color: #000000; font-weight: bold;">&lt;/plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></div></td></tr></tbody></table></div>
<div class="spacer-medium"></div>
<h2>Step 4</h2>
<p>It&#8217;s very important that the <acHandling> is set to merge, or else the ui.content package will always overwrite the rep:policy node from the installed AEM environment. In step #3, make sure line:8 is set to your desires.</p>
<p><strong>other options include:</strong><br />
<strong>ignore</strong>: Ignores the packaged access control and leaves the target unchanged.<br />
<strong>overwrite</strong>: Applies the access control provided with the package to the target. this also removes existing access control.<br />
<strong>merge</strong>: Merge access control provided with the package with the one in the content by replacing the access control entries of corresponding principals (i.e. package first). It never alters access control entries of principals not present in the package.<br />
<strong>merge_preserve</strong>: Merge access control in the content with the one provided with the package by adding the access control entries of principals not present in the content (i.e. content first). It never alters access control entries already existing in the content.<br />
<strong>clear</strong>: Clears all access control on the target system.</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/importing-rep-policy-nodes-in-the-ui-content-maven-content-package">Importing rep:policy nodes in the ui.content maven content package</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/importing-rep-policy-nodes-in-the-ui-content-maven-content-package/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Adding Custom Client Library for AEM Author Editor Touch UI</title>
		<link>https://sourcedcode.com/blog/aem/adding-custom-client-library-for-aem-author-editor-touch-ui</link>
					<comments>https://sourcedcode.com/blog/aem/adding-custom-client-library-for-aem-author-editor-touch-ui#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Wed, 22 Jun 2022 19:03:57 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Client Libraries]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Touch UI]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=3484</guid>

					<description><![CDATA[<p>You can use Clientlibs to extend the default implementation and add new functionality while reusing the default functions, objects, and methods. When customizing, you can create your own clientlib under / apps. Specifically, when you want to add CSS or JavaScript to your AEM Author Editor, Touch UI Dialogs, you would want to create a [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/adding-custom-client-library-for-aem-author-editor-touch-ui">Adding Custom Client Library for AEM Author Editor Touch UI</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>You can use Clientlibs  to extend the default implementation and add new functionality while reusing the default functions, objects, and methods. When customizing, you can create your own clientlib under / apps. </p>
<p>Specifically, when you want to add CSS or JavaScript to your AEM Author Editor, Touch UI Dialogs, you would want to create a new client library. Within your clientlib, it must have the required dependencies and categories. </p>
<div class="mention-block">
If you want to learn how to create client libraries for the authoring environment that only target specific components checkout this article <a href="https://sourcedcode.com/blog/aem/what-are-aem-extraclientlibs">here</a>.
</div>
<p><strong>The custom clientlib for AEM authoring must follow these rules:</strong></p>
<p>1. depend on the authoring clientlib cq.authoring.editor.sites.page<br />
2. be part of the appropriate cq.authoring.editor.sites.page.hook category</p>
<hr class="divider-large"/>
<h3>Example</h3>
<p>An example of a custom client library created for AEM authoring would live in this path (below), and must have the .context.xml configured like so.<br />
<strong>/apps/sourcedcode/clientlibs/clientlib-authoring</strong></p>
<div class="codecolorer-container xml default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span><br />
<span style="color: #000000; font-weight: bold;">&lt;jcr:root</span> <span style="color: #000066;">xmlns:cq</span>=<span style="color: #ff0000;">&quot;http://www.day.com/jcr/cq/1.0&quot;</span> <span style="color: #000066;">xmlns:jcr</span>=<span style="color: #ff0000;">&quot;http://www.jcp.org/jcr/1.0&quot;</span><br />
&nbsp; &nbsp; <span style="color: #000066;">jcr:primaryType</span>=<span style="color: #ff0000;">&quot;cq:ClientLibraryFolder&quot;</span><br />
&nbsp; &nbsp; <span style="color: #000066;">dependencies</span>=<span style="color: #ff0000;">&quot;[cq.authoring.editor.sites.page]&quot;</span><br />
&nbsp; &nbsp; <span style="color: #000066;">categories</span>=<span style="color: #ff0000;">&quot;[cq.authoring.editor.sites.page.hook]&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></div></td></tr></tbody></table></div>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/adding-custom-client-library-for-aem-author-editor-touch-ui">Adding Custom Client Library for AEM Author Editor Touch UI</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/adding-custom-client-library-for-aem-author-editor-touch-ui/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>HTL Java Use-API Code Example</title>
		<link>https://sourcedcode.com/blog/aem/htl-java-use-api-code-example</link>
					<comments>https://sourcedcode.com/blog/aem/htl-java-use-api-code-example#respond</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Tue, 21 Jun 2022 22:49:32 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Sightly]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=3473</guid>

					<description><![CDATA[<p>The HTML Template Language (HTL) Java Use-API allows an HTL file to use data-sly-use to access helper functions in a custom Java class. This allows any sophisticated business logic to be wrapped in Java code, while the HTL code is just responsible for direct markup generation. A simple POJO can be used as a Java [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/htl-java-use-api-code-example">HTL Java Use-API Code Example</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>The HTML Template Language (HTL) Java Use-API allows an HTL file to use data-sly-use to access helper functions in a custom Java class. This allows any sophisticated business logic to be wrapped in Java code, while the HTL code is just responsible for direct markup generation.</p>
<p>A simple POJO can be used as a Java Use-API object, which is instantiated by a specific implementation using the POJO&#8217;s default constructor.</p>
<p>In this article, you will find an example of how the Java Use-API can be bind with a component in AEM. In detail, we will be associating the Java Use-API with the header component.</p>
<hr class="spacer-large">
<h2>Java Use-API Example Code</h2>
<h4>Step 1</h4>
<p>We will place a small little snippet from lines:2-4 which will bind into the simple POJO; inside of the given component,<br />
<strong>/apps/sourcedcode/components/structure/header/header.html</strong></p>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;cmp-header&quot;</span>&gt;</span><br />
&nbsp; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> data-sly-use.header<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;HeaderJavaUseExample&quot;</span>&gt;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h1</span>&gt;</span>${header.path}<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">h1</span>&gt;</span><br />
&nbsp; <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span><br />
&nbsp; <span style="color: #808080; font-style: italic;">&lt;!--/* header Sightly HTL code implementation below */--&gt;</span><br />
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></div></td></tr></tbody></table></div>
<hr class="spacer-medium">
<h4>Step 2</h4>
<p>We will create a simple Java POJO under,<br />
<strong>/apps/sourcedcode/components/structure/header/HeaderJavaUseExample.java</strong></p>
<p>Taking a look closer, line:1 has the package that is the same path as the targeted component.</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">apps.sourcedcode.components.structure.header</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.adobe.cq.sightly.WCMUsePojo</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> HeaderJavaUseExample <span style="color: #000000; font-weight: bold;">extends</span> WCMUsePojo <span style="color: #009900;">&#123;</span><br />
<br />
<br />
&nbsp; &nbsp; @Override<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> activate<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span> <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> getPath<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #0000ff;">&quot;This is an example path&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
<br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<hr class="spacer-medium">
<h4>Step 3</h4>
<p>The Java Pojo extends the WCMUsePojo which makes available all the Global Objects in this naming convention:</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;">getComponent<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
getComponentContext<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
getCurrentDesign<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
getCurrentNode<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
getCurrentPage<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
getCurrentSession<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
getCurrentStyle<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
getDesigner<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
getEditContext<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
getLog<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
getOut<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
getPageManager<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
getReader<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
getRequest<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
getResolver<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
getResource<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
getResourceDesign<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
getResourcePage<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
getResponse<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
getSling<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
getSlyWcmHelper<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
getWcmmode<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
getXssAPI<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></div></td></tr></tbody></table></div>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/htl-java-use-api-code-example">HTL Java Use-API Code Example</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/htl-java-use-api-code-example/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Checking run mode from Sightly HTL in AEM</title>
		<link>https://sourcedcode.com/blog/aem/checking-run-mode-from-sightly-htl-in-aem</link>
					<comments>https://sourcedcode.com/blog/aem/checking-run-mode-from-sightly-htl-in-aem#comments</comments>
		
		<dc:creator><![CDATA[briankasingli]]></dc:creator>
		<pubDate>Mon, 23 May 2022 04:10:08 +0000</pubDate>
				<category><![CDATA[AEM]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Sling Models]]></category>
		<guid isPermaLink="false">https://sourcedcode.com/?p=3513</guid>

					<description><![CDATA[<p>Sometimes during development, we would need to check the run mode in our AEM environment, so we can show different content based on the context. From the Sightly HTL API, it&#8217;s possible to check for the wcmmode, but not the runmode. In this article, we will set up a sling model helper which will be [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/checking-run-mode-from-sightly-htl-in-aem">Checking run mode from Sightly HTL in AEM</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Sometimes during development, we would need to check the run mode in our AEM environment, so we can show different content based on the context. From the Sightly HTL API, it&#8217;s possible to check for the wcmmode, but not the runmode.</p>
<p>In this article, we will set up a sling model helper which will be a sling model, and then use Sightly HTL, data-sly-use, API, to access which run mode we are in. How to check runmode in AEM Sightly HTL can never be this easy.</p>
<div class="mention-block--gold-solid">
<strong>slingSettingsService is a deprecated service</strong><br />
We understand that the slingSettingsService is a deprecated service, and you would still like to find a way to retrieve the run mode where it equals to “development”, “staging”, or “production”, I wrote a new article that can solve this issue, <a href="https://sourcedcode.com/blog/aem/checking-run-mode-from-sightly-htl-in-aem-in-2023" rel="noopener" target="_blank">https://sourcedcode.com/blog/aem/checking-run-mode-from-sightly-htl-in-aem-in-2023</a>. Take a look!
</div>
<hr class="spacer-large" />
<h2>Sightly Code</h2>
<div class="codecolorer-container html4strict default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br /></div></td><td><div class="html4strict codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #808080; font-style: italic;">&lt;!--/* Production */--&gt;</span><br />
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h1</span>&gt;</span>In Development<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">h1</span>&gt;</span><br />
<span style="color: #ddbb00;">&amp;nbsp;</span><br />
<br />
<span style="color: #808080; font-style: italic;">&lt;!--/* Staging */--&gt;</span><br />
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h1</span>&gt;</span>In Staging<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">h1</span>&gt;</span><br />
<span style="color: #ddbb00;">&amp;nbsp;</span><br />
<br />
<span style="color: #808080; font-style: italic;">&lt;!--/* Production */--&gt;</span><br />
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h1</span>&gt;</span>In Production<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">h1</span>&gt;</span><br />
<span style="color: #ddbb00;">&amp;nbsp;</span></div></td></tr></tbody></table></div>
<hr class="spacer-medium" />
<h3>Java Sling Model</h3>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:400px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.sourcedcode.core.models.utils</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.api.SlingHttpServletRequest</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.models.annotations.Default</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.models.annotations.Model</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.models.annotations.injectorspecific.OSGiService</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.models.annotations.injectorspecific.RequestAttribute</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.sling.settings.SlingSettingsService</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.annotation.PostConstruct</span><span style="color: #339933;">;</span><br />
<br />
@Model<span style="color: #009900;">&#40;</span>adaptables <span style="color: #339933;">=</span> SlingHttpServletRequest.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> RunModeHelper <span style="color: #009900;">&#123;</span><br />
<br />
@OSGiService<br />
<span style="color: #000000; font-weight: bold;">private</span> SlingSettingsService slingSettingsService<span style="color: #339933;">;</span><br />
<br />
@RequestAttribute<br />
@<span style="color: #000000; font-weight: bold;">Default</span><span style="color: #009900;">&#40;</span>values <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;null&quot;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> runmode<span style="color: #339933;">;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">boolean</span> hasRunMode <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span><br />
<br />
@PostConstruct<br />
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> init<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<span style="color: #003399;">String</span> runModes <span style="color: #339933;">=</span> slingSettingsService.<span style="color: #006633;">getRunModes</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
hasRunMode <span style="color: #339933;">=</span> runModes.<span style="color: #006633;">contains</span><span style="color: #009900;">&#40;</span>runmode<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">boolean</span> getHasRunMode<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<span style="color: #000000; font-weight: bold;">return</span> hasRunMode<span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>The post <a rel="nofollow" href="https://sourcedcode.com/blog/aem/checking-run-mode-from-sightly-htl-in-aem">Checking run mode from Sightly HTL in AEM</a> appeared first on <a rel="nofollow" href="https://sourcedcode.com">Sourced Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://sourcedcode.com/blog/aem/checking-run-mode-from-sightly-htl-in-aem/feed</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
	</channel>
</rss>
