Grails コントローラー アクションでは、検証のために、コマンド オブジェクトを使用します。問題は、CommandObject クラスの数が急増したことです。
def publish = { PublishCommand command ->
if (command.hasErrors()) {
return redirect(action: 'errors',params:params)
}
//rest of the code
}
......
Class PublishCommand {
long personId
String name
static constraints = {
personId(nullable: false, blank: false)
name(nullable: false, blank: false)
}
}
PublishCommand クラスは、このデータバインディングと検証の目的でのみ存在します。このようなクラスの数は爆発的に増加しており、アプリケーションのアクションごとに 1 つずつ作成されています。質問は、この PublishCommand を innerClass として持つ方法はありますか? または、それほど多くのクラスを作成する必要がない他の方法はありますか?