java - how to render Map<String, String> to template and use there -
i trying render key,value map template , show there in way:
@(twittsifollow: map[string, string]) ..... @if(twittsifollow != null) { @for((key, value) <- twittsifollow) { @key @value } }
it says, wrong. there scala tag map keys values?
here method:
public static map<string, string> alltwitts(list<long> otherids) { map<string, string> results=new hashmap<string, string>(); (long id: otherids) { query selected_twitt = jpa.em().createquery("select u.twitt twitt u " + " u.whose = ?").setparameter(1, id); string twowner = user.getoneuser(id); string twitt = (string) selected_twitt.getsingleresult(); results.put(twowner, twitt); } return results; }
then render template in place:
map<string, string> twittsifollow = twitt.alltwitts(idusersiamfollowing); return ok(microblog.render(twittsifollow));
now saying: [nonuniqueresultexception: result returns more 1 elements]
thanks
simply
@for((key, value) <- twittsifollow) { @key @value }
btw, if using scala, twittsifollow
should never null. prefer using option
.
Comments
Post a Comment