Chapter 3. Working with Struts 2 actions
This chapter covers
- Bundling actions into packages
- Implementing actions
- Introducing object-backed properties and ModelDriven actions
- Uploading files
With the overviews and introductions behind us, it’s time to study the core components of Struts 2. First up, actions. As we’ve learned, actions do the core work for each request. They contain the business logic, hold the data, and then select the result that should render the result page. This is an action-oriented framework; actions are at its heart. In the end, you’ll spend much of your time as a Struts 2 developer working with actions.
This chapter will give you everything you need to start building your application’s actions. Using the XML-based mechanism for declarative architecture, we’ll explore all of the options available to us when we declare our actions, see some convenience classes that aid development of actions, and cover the most common ways of carrying data in the action. The previous chapter used JavaBeans properties. We’ll also see how interceptors work together with actions to provide much of the framework’s functionality. In fact, we’ll end with a useful case study of a file upload action. We will also start to develop our full-featured sample application, the Struts 2 Portfolio, to help demonstrate the concepts and techniques of this chapter.