grailsを使用したWebフォーラムの作成に問題があります。私のコントローラでは、私はウェブサイトの仕事のための標準的なトピックを作成する必要があります、私はチュートリアルのコードを使用しています。だから私の質問です:どのように私はこのコードの作業のために標準のトピックを作成するのですか?標準トピックの作成
私が作成する必要がある部分はラインで11
コントローラです:
class ForumController {
def springSecurityService
def home() {
[sections:Section.listOrderByTitle()]
}
def topic(long topicId) {
Topic topic = Topic.get(topicId)
if (topic == null){
}
params.max = 10
params.sort = 'createDate'
params.order = 'desc'
[threads:DiscussionThread.findAllByTopic(topic, params),
numberOfThreads:DiscussionThread.countByTopic(topic), topic:topic]
}
def thread(long threadId) {
DiscussionThread thread = DiscussionThread.get(threadId)
params.max = 10
params.sort = 'createDate'
params.order = 'asc'
[comments:Comment.findAllByThread(thread, params),
numberOfComments:Comment.countByThread(thread), thread:thread]
}
@Secured(['ROLE_USER'])
def postReply(long threadId, String body) {
def offset = params.offset
if (body != null && body.trim().length() > 0) {
DiscussionThread thread = DiscussionThread.get(threadId)
def commentBy = springSecurityService.currentUser
new Comment(thread:thread, commentBy:commentBy, body:body).save()
// go to last page so user can view his comment
def numberOfComments = Comment.countByThread(thread)
def lastPageCount = numberOfComments % 10 == 0 ? 10 : numberOfComments % 10
offset = numberOfComments - lastPageCount
}
redirect(action:'thread', params:[threadId:threadId, offset:offset])
}
}
あなたが求めていることは少し不明です。あなたはウェブフォーラムを作成しており、デフォルトの「トピック」を設定する方法は不明ですか?この文脈では、トピックはどういう意味ですか?トピックは単に投稿の名前ですか、それとも投稿のカテゴリですか? –
ええ、英語は私の最初の言語ではありません。申し訳ありませんが、私は 'Topic'ドメインクラスの初期インスタンスを作成しようとしています。 'トピック'は投稿のカテゴリです –