Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

Adobe Exam AD0-E134 Topic 1 Question 38 Discussion

Actual exam question for Adobe's AD0-E134 exam
Question #: 38
Topic #: 1
[All AD0-E134 Questions]

A new component called Page Headline needs to be implemented. The only difference to the title component delivered by Adobe's WCM core components is that the text needs to be taken from the current page title instead of jcr.title.

How should a developer implement this request?

A)

1. Create custom component

2. Implement Sling Modal as follows

B)

1. Create proxy component from the core title component

2. Implement sling Model as follows

C)

1. Create proxy component from the core title component

2. Implement Sling Model as follows

Show Suggested Answer Hide Answer
Suggested Answer: C

To implement a new component called 'Page Headline' which takes the text from the current page title instead of jcr:title, you should create a proxy component from the core title component and implement a Sling Model accordingly. Option C demonstrates the correct approach to achieve this functionality.

Here is a detailed explanation of Option C:

Create Proxy Component:

Create a new component in your project that will act as a proxy to the core title component. This involves creating a new component node in the repository that inherits from the core title component.

Example path: /apps/myproject/components/pageHeadline with sling:resourceSuperType set to core/wcm/components/title/v2/title.

Implement Sling Model:

Implement a Sling Model that adapts from SlingHttpServletRequest and Title.class, ensuring it overrides the text fetching logic to retrieve the title from the current page's title.

The model will use @ScriptVariable to inject the current page and @Self to access the core title component's logic.

@Model(adaptables = SlingHttpServletRequest.class, adapters = Title.class, resourceType = 'myproject/components/pageHeadline')

public class PageHeadline implements Title {

@ScriptVariable

private Page currentPage;

@Self @Via(type = ResourceSuperType.class)

private Title title;

@Override

public String getText() {

return currentPage.getTitle();

}

@Override

public String getType() {

return title.getType();

}

}

@Model Annotation: Specifies that this class is a Sling Model and adapts from SlingHttpServletRequest. It is also an adapter for Title.class and applies to the myproject/components/pageHeadline resource type.

@ScriptVariable: Injects the current Page object, which allows access to the current page's properties.

@Self @Via(type = ResourceSuperType.class): Injects the core title component, allowing the reuse of existing logic.

getText() Method: Overrides the getText() method to return the title from the current page instead of the jcr:title.

getType() Method: Delegates to the core title component's getType() method to maintain existing functionality.

This approach leverages the power of Sling Models and the core components to extend functionality while keeping the implementation clean and maintainable.


Adobe Experience Manager - Core Components

Sling Models Documentation

Contribute your Thoughts:

Kaitlyn
2 months ago
I'm just glad they didn't ask us to use a quantum computer to solve this problem. That would be a real headache!
upvoted 0 times
...
Melita
2 months ago
Hmm, I'm not sure about Option B. Wouldn't that require some extra configuration to get the page title? Option C seems cleaner to me.
upvoted 0 times
Dolores
1 months ago
User 3: Option C is the best in my opinion, it seems cleaner.
upvoted 0 times
...
Joseph
1 months ago
User 4: I think Option C is the way to go as well, it looks more efficient.
upvoted 0 times
...
Man
2 months ago
User 2: I agree, Option A looks like a straightforward solution.
upvoted 0 times
...
Aretha
2 months ago
User 1: Option A seems like a good choice.
upvoted 0 times
...
...
Timmy
2 months ago
I agree, Option C is the best solution. Implementing a custom component from scratch seems unnecessary when we can just extend the core title component.
upvoted 0 times
Pansy
1 months ago
Yes, it saves time and effort compared to building a custom component.
upvoted 0 times
...
Jaime
1 months ago
Extending the core functionality is always a good practice.
upvoted 0 times
...
Ramonita
1 months ago
I agree, creating a proxy component from the core title component is more efficient.
upvoted 0 times
...
Gregoria
2 months ago
Option C is definitely the way to go.
upvoted 0 times
...
...
Nichelle
3 months ago
Option C looks like the way to go. Creating a proxy component and using the Sling Model to get the page title seems the most straightforward approach.
upvoted 0 times
Chara
2 months ago
Definitely, using a proxy component and Sling Model simplifies the process of getting the page title.
upvoted 0 times
...
Ettie
2 months ago
I think Option C is the most efficient way to go about this task.
upvoted 0 times
...
Miriam
2 months ago
Yeah, creating a proxy component and using the Sling Model makes it easier to get the page title.
upvoted 0 times
...
Jose
2 months ago
I agree, Option C seems like the best choice for implementing the Page Headline component.
upvoted 0 times
...
...
Louann
3 months ago
I agree with you, Tracey. Creating a custom component seems like the best approach.
upvoted 0 times
...
Tracey
3 months ago
I think the developer should create a custom component for this.
upvoted 0 times
...

Save Cancel