0

This code snippet is supposed to get the page properties in sling.

Why am I receiving this error: Please check if the declared type is right and if the method exists.

private String properties;

public void setProperties(String properties){
    this.properties = property;       
    ValueMap property = (ValueMap) properties.getAttribute("properties");
    pageTitle = property.get("pageTitle", "");
}  
Delmon Young
  • 2,013
  • 5
  • 39
  • 51
  • This code is kind of a mess, and the edits people have been making aren't helping. It won't compile as-is, so perhaps you could show us the code you're *actually* using, and what the actual error you're getting is. – Edward Falk May 28 '13 at 18:31
  • sorry @EdwardFalk made some revisions. – Delmon Young May 28 '13 at 18:34
  • It's still wrong. Does this even compile? You're declaring **property** *after* you first use it. And as Jigar has pointed out, class String doesn't have a **getAttribute()** method. Who is calling **setProperties()** and where is the argument coming from? I think the error message means exactly what it says: You need to check to see if "String" is the right declaration for "properties". – Edward Falk May 28 '13 at 19:40

1 Answers1

2

properties is of type String which doesn't have the methods you are trying to access

jmj
  • 237,923
  • 42
  • 401
  • 438
  • thanks for replying @Jigar, so then I'm really confused how do you access the methods I'm trying to use? – Delmon Young May 28 '13 at 18:26
  • from where you got the reference of those methods, may be check java doc of the library you are using and change the tpe – jmj May 28 '13 at 18:44
  • thanks @Jigar properties is a "ValueMap" that I needed to pass in not a string. good call! – Delmon Young May 29 '13 at 02:08