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?
- "@ValueMapValue
@Via(""jcr:title"")
@Required
private String titile;" - "@ValueMapValue
@Named(""jcr:title"")
@Default(values = """")
private String titile;" - "@ValueMapValue
@Named(""jcr:title"")
@Required
private String titile;" - "@ValueMapValue
@Via(""jcr:title"")
@Default(values = """")
private String titile;"
Reveal Solution Next Question