I’m creating a tagCloud in my web application. I’ve a method that renders 2 lists:
public static void tagCloud(){
List<Topic> topics = Topic.find("order by topicName asc").fetch();
List<Tutorial> tutorials = Tutorial.find("order by id asc").fetch();
List<Integer> topicCount = new ArrayList<Integer>();
for(int i = 0; i < topics.size(); i++){
int z = 0;
for(int j = 0; j < tutorials.size(); j++){
if (tutorials.get(j).getTopic().equals(topics.get(i))){
z++;
topicCount.add(z);
}
}
}
render (topics, topicCount);
}
I want to use those 2 lists for the tagCloud in a line similar to this one:
<a href="/Topics/topicView?topicId=${topicList.id}" rel="8">${topicList.topicName.raw()}</a>
I want to use the indexes in topicCount list to be “rel” (size of the words) and topics to be the element itself to be shown, how can i do that?
Instead of having two lists, I would store each topic with its count in a single object (let’s call it
TopicWithCount), and use a singleList<TopicWithCount>.