Java Reference
In-Depth Information
Listing 4-4. Using the Action Interface
import com.opensymphony.xwork2.Action;
public class HelloWorldAction implements Action{
//..
public String execute() {
return SUCCESS;
}
}
ActionSupport Class
The ActionSupport class implements the Action interface and provides an implementation of the
execute() method that returns the SUCCESS value. The ActionSupport class also implements some
interfaces that provide support for validation, localization, and internationalization, as illustrated in
the code fragment of the ActionSupport class in Listing 4-5.
Listing 4-5. ActionSupportClass
public class ActionSupport implements Action, Validateable, ValidationAware,TextProvider,
LocaleProvider, Serializable {
...
public String execute(){
return SUCCESS;
}
}
Listing 4-6 shows the code fragment through which the ActionSupport class can be used to provide
validation.
Listing 4-6. Using ActionSupport
import com.opensymphony.xwork2.ActionSupport;
public class LoginAction extends ActionSupport{
private String username;
private String password;
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
 
Search WWH ::




Custom Search