I have the following visual snippet which does not work. Can you spot the error?
‘RemoveLeadingZeros’ is a java snippet that returns a String. I then need to see if the string is a length greater than one.
My snippet is marked with the error: “length() is not a method of string”.
It’s difficult to spot the error in my code because THERE’S NOTHING WRONG. The editor is just stupid. I have the exact same pattern but using variables defined as the output to my BO Map, and it works fine. The only difference is that I have a local variable in the middle.
The visual snippet editor tells me that “aptn” does not have a method “length()”. If I mouse over “aptn”, it correctly identifies it as a string. My only conclusion (beyond never ever waste your time in this editor) is that because it’s a java snippet call, the editor doesn’t properly map from java.lang.String to an XSD String.
My solution? Make the ridiculous aptn.toString().length() call.
I guess this is why java.util.String has a .toString() method, to account for poor user interfaces.
UPDATE 2:07PM: This is what I really hate about the visual snippet editor. I went and deleted the snippets that used “aptn” and re-created the whole thing from scratch. No problems.