 |
Step 1: Identification
The Identification step is defined below. It contains name and password of a prospective user, as well as "Security Flag" property, which instructs the wizard to ask a security question.
public class StepSignup extends WizardStep {
// Business properties: name, password, retyped password
private String name;
public String getName() {return name;}
public void setName(String name) {
this.name = name;
}
private String password;
public String getPassword() {return password;}
public void setPassword(String password) {
this.password = password;
}
private String confirmPassword;
public String getConfirmPassword() {return confirmPassword;}
public void setConfirmPassword(String confirmPassword) {
this.confirmPassword = confirmPassword;
}
// Flag that user wants to supply security information
private boolean personalize;
public boolean getPersonalize() {return personalize;}
public void setPersonalize(boolean personalize) {
this.personalize = personalize;
}
// Validation method, used by both outgoing steps
// Validation is normally performed directly in a transition class,
// but in this case is defined in this step, because same
// validation rules are used by two transitions.
public boolean validateNameAndPassword() {
boolean valid = true;
if ( name == null || name.length() < 3 ) {
valid = false;
getWizard().getWizardErrors().put(
"loginsignupcontrol.usernametooshort",
new String[] {name}
);
}
if ( password == null || password.length() < 5 ) {
valid = false;
getWizard().getWizardErrors().put(
"loginsignupcontrol.passwordtooshort", null
);
} else if ( !password.equals(confirmPassword) ) {
valid = false;
getWizard().getWizardErrors().put(
"loginsignupcontrol.passwordnotequal", null
);
}
return valid;
}
// Create Signup node
public StepSignup(SignupWizard value, String name) {
super(value, name);
}
// Instructs the node to clear boolean values. Usually called
// before the properties are about to be updated.
public void resetBooleans() {
setPersonalize(false);
}
}
In signup wizard business data related to wizard steps is stored in the steps themselves. If a user cancels the signup procedure, the wizard is disposed and domain model is not updated.
|