1

WebアプリケーションでtagCloudを作成しています。2つのリストをレンダリングするメソッドがあります。

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);
    }

次のような行で、tagCloudにこれら2つのリストを使用したいと思います。

<a href="/Topics/topicView?topicId=${topicList.id}" rel="8">${topicList.topicName.raw()}</a>

topicCountリストのインデックスを「rel」(単語のサイズ)に使用し、トピックを表示する要素自体に使用したいのですが、どうすればよいですか?

4

1 に答える 1

1

2 つのリストを作成する代わりに、各トピックとそのカウントを 1 つのオブジェクト ( と呼びましょうTopicWithCount) に格納し、1 つのList<TopicWithCount>.

于 2012-05-19T11:37:43.283 に答える