How should the developer inject the title property in this model?

A developer is working on the following Sling Model that is being used in a component.

@Model(adaptables = SlingHttpServletRequest.class, defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL)

public class SampleModel {

@Inject

private Page currentPage;

private boolead matchingTitle;

@PostConstruct

private void init(){

matchingTitle = title.equals(currentPage.getName());

}

public boolean isMatchingTitle(){

return matchingTitle;

}

}

The model must check if the configured value of the jct:title property for the component matches the same name of the current page. If the jcr:title property of the component has NOT been configured, then isMatchingTitle() must return false.

How should the developer inject the title property in this model?
A . "@ValueMapValue
@Via(""jcr:title"")
@Required
private String titile;"
B . "@ValueMapValue
@Named(""jcr:title"") @Default(values = """")
private String titile;"

C . "@ValueMapValue
@Named(""jcr:title"")
@Required
private String titile;"
D . "@ValueMapValue
@Via(""jcr:title"") @Default(values = """")
private String titile;"

Answer: B

Latest AD0-E116 Dumps Valid Version with 94 Q&As

Latest And Valid Q&A | Instant Download | Once Fail, Full Refund

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments