THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
...
Just as an example, we can examine the username and password values. If either or both properties are empty, return INPUT, so that we can collect a valid Logon. Otherwise, return SUCCESS.
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
package tutorial; import com.opensymphony.xwork2.ActionSupport; public class Logon extends ActionSupport { public String execute() throws Exception { if (isInvalid(getUsername())) return INPUT; if (isInvalid(getPassword())) return INPUT; return SUCCESS; } private boolean isInvalid(String value) { return (value == null || value.length() == 0); } private String username; public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } private String password; public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } } |
...
The framework automaticaly populates the username and password properties for us. All that's left to do is checking to see if either property is empty.
For more about Actions, see Architecture in the Core Developers Guide.
Next | Onward to Selecting Results |
---|---|
Prev | Return to Hello World |