2

I'm trying to make a lookup to a hash table m.notes using concatenated value of position.qid and literal ".qid" like this:

$tag(name="itemId", content=m.notes.(position.qid".qid").itemId)$

I tried different options, but I get runtime error. Can someone correct my syntax?

3 Answers 3

3

Put the 2 items in an array. StringTemplate concatenates all items in an array (or as they call it, a multi-valued-attribute) when it executes a ToString() on it.

[position.qid, ".qid"]

So, if position.qid evaluates to "hello", this expression would become hello.qid.

1
  • 1
    This is correct, although it's not easy to understand. It all happens inside the ST-Template. The answer to the question would be like this: $tag(name="itemId", content=m.notes.([position.qid,".qid"]).itemId)$ Feb 13, 2017 at 7:40
1

Not sure whether such concatenation is possible in string template. Why don't you use a different method that could do the concatenation and return the value.

e.g: position.fullQid instead of position.qid

where,

public String getFullQid(){
return getQid() + ".qid";
}
0

in template group, I can do like this, first, define a concantenate template: concantenate(substr)::="" then use as following (concantenate([position.qid,".qid"]))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.