コマンド オブジェクトの一部であるオブジェクトにデータをバインドしようとしています。オブジェクトを使用しようとすると、オブジェクトは null のままです。おそらく私は gsp で正しいデータを提供していませんが、何が間違っているのかわかりません!
フィールド名が「book.title」のフォームを送信すると、これがコマンドオブジェクトにマップされると予想されます..しかし、これは失敗します..タイトルは[null]のままです
コマンドオブジェクトとフォームを変更して、文字列タイトルをプロパティとして使用するたびに、それが機能します..
// the form that submits the data
<g:form>
<g:textField name="book.title" value="Lord Of the Rings"/><br>
<br><br>
<g:actionSubmit action="create" value="Create!"/>
</g:form>
// the controller code
def create = { BooksBindingCommand cmd ->
println cmd?.book?.title // the book property always stays null
redirect(action: "index")
}
// the command object
class BooksBindingCommand {
Book book
}
// the book class, simple plain groovy class
class Book {
String title
}
「book.title」のバインディングが失敗する理由について何か提案はありますか?