package jatotutorial.module1;
...
public void handleSubmitRequest(RequestInvocationEvent event)
throws ServletException, IOException
{
// Retrieve the login name & password
String loginName = getDisplayFieldStringValue(CHILD_LOGIN);
String password = getDisplayFieldStringValue(CHILD_PASSWORD);
String theMessage = "";
// Check the login name
// Note, we don't check the password in this example
if (loginName.equalsIgnoreCase("anton") ||
loginName.equalsIgnoreCase("alfki") ||
loginName.equalsIgnoreCase("bonap"))
{
// Instead of returning the login page, display the Customer
// page for the customer that matches the login ID
// theMessage = "Congratulations, " + loginName + ...
// Get a reference to the CustomerModel
CustomersModel customers =
(CustomersModel)getModel(CustomersModel.class);
// Modify the where criteria to reflect the login ID
customers.clearUserWhereCriteria();
customers.addUserWhereCriterion(
CustomersModel.FIELD_CUSTOMERID, loginName.toUpperCase());
// Display the Customer page
getViewBean(CustomerViewBean.class).forwardTo(
event.getRequestContext());
}
else
{
theMessage = "Sorry, " + loginName +
", your login or passsword was incorrect!";
// Set the ouput status message
getDisplayField(CHILD_MESSAGE).setValue(theMessage);
forwardTo();
}
}
|