0

I have a text component, and within it I have the text.jsp. To the text component, I added the property jcr:title and assigned value "Text" to it. In the text.jsp, I added the following snippet to read the jcr:title property.

String strText = properties.get("jcr:title", String.class);

I find that the strText is always having value null. Any idea what could be wrong? I am also attaching the component hierarchy here. component tree

jpr
  • 185
  • 3
  • 6
  • 20
  • 1
    Properties you wish to retrieve through properties.get() needs to be added to the content resource, not the component. Not sure what you actually meant by text component, the component itself or the content resource of type text – rakhi4110 Sep 22 '14 at 09:37
  • Thanks rakhi4110. That was the problem. I was so focussed on getting it from the component, I didnt bother about changing the content and see. – jpr Sep 22 '14 at 09:51

1 Answers1

1

The text component does not have the property jcr:title. So it returns null value.

If you update the same in your template mapped (sling:resourceSuperType) component_jsp file, you can get the title.

Jens
  • 20,533
  • 11
  • 60
  • 86
Yasodha
  • 11
  • 1