O'Reilly logo

Struts 2 Design and Programming: A Tutorial by Budi Kurniawan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 19. Custom Result Types

Struts ships with standard result types such as Dispatcher and Stream. This chapter explains how you can write a custom result type. An example, a CAPTCHA image producing result type, is also discussed.

Overview

A result type must implement the com.opensymphony.xwork2.Result interface. This interface has one method, execute, whose signature is as follows.

<LINELENGTH>90</LINELENGTH>
void execute(ActionInvocation invocation)

This method gets called when the result is executed. A result type author can write the code that will be run when an instance of the result type executes.

Note

ActionInvocation was explained in Chapter 18, “Custom Interceptors.”

The org.apache.struts2.dispatcher.StrutsResultSupport class is a base class ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required