String base = request.getRequestURI().substring(0,
request.getRequestURI().length()-path.length());
// ensure that there is a form available
// through the rest of the flow
Form form = getForm(config, path, objectModel);
if (form==null) {
throw new IllegalStateException("Action could not obtain the Form");
}
// populate form with request parameters
// population is automatically followed by validation by default.
// If this is not the desired behaviour, the Form class can be subclassed
form.populate(objectModel);
// If the currect form have incorrect values, then process the same page
if (form.getViolations()!=null) {
return EMPTY_MAP;
}
// find and save the action command
String command = getCommand(request);
if ((command==null) || (command.length()==0)) {
// if no command send, process current page
return EMPTY_MAP;
}
// find the action name for the method, which should be performed.
String action = getAction(config, path);
// perform action method
String forward = command;
if ((action!=null) && (action.length()>0)) {
Method method = (Method) methodIndex.get(action);
if (method!=null) {
forward = ((String) method.invoke(this, new Object[]{ command,
form }));
if (forward==null) {
forward = command;
}
}
}
if ((command==null) || (command.length()==0)) {
// if no command send, process current page
return EMPTY_MAP;
}
// if action returns violation, process current form
if ((forward==null) && (form.getViolations()!=null)) {
return EMPTY_MAP;
}
// process forward
String newpath = getForward(config, path, forward);