上QQ阅读APP看书,第一时间看更新
Chapter 3. Posting Messages
You have used Grails scaffolding to create some skeleton pages that manage users and roles. You will now learn the basics of web application development in Grails and implement the first of our user's goals to post messages.
The first user story could go something like this. As a team member, I want to be able to send a message to the rest of my team, so that I can share important information with my teammates.
To accomplish this goal, you are going to implement the following:
- A page to allow users to post messages
- A home page to display all messages in a chronological order
You will need to take the following steps to implement the above items:
- Create a domain class to represent messages
- Create a controller to handle user actions for messages
- Create a view to allow users to enter message data
- Create a controller to handle requests for the home page of the application
- Create a view for the home page
- Validate the message data input by the user
- Use GORM (Grail's Object Relational Mapping) to persist the message
- Use GORM to retrieve the messages in chronological order