// the logical outcome received from the (current) view state
Position position = peek();
if (!START_OUTCOME.equals(outcome)) {
transition(position, outcome);
}
State state = position.getState();
String viewId = null;
boolean redirect = false;
// Advance through states until we again encounter the
// need to render a view state
while (true) {
if (state instanceof ActionState) {
ActionState astate = (ActionState) state;
if (log().isTraceEnabled()) {
log().trace("-->ActionState(method=" + astate.getMethod() + ")");
}
try {
MethodBinding mb = context.getApplication().
createMethodBinding(astate.getMethod(), ACTION_STATE_SIGNATURE);
outcome = (String) mb.invoke(context, ACTION_STATE_PARAMETERS);
} catch (Exception e) {
fireOnException(e);
}
transition(position, outcome);
state = position.getState();
continue;
} else if (state instanceof EndState) {
if (log().isTraceEnabled()) {
log().trace("-->EndState()");
}
pop();
position = peek();
if (position == null) {
stop(context);
} else {
transition(position, outcome);
state = position.getState();
continue;
}
viewId = ((EndState) state).getViewId();
redirect = ((EndState) state).isRedirect();
break;
} else if (state instanceof SubdialogState) {
SubdialogState sstate = (SubdialogState) state;
if (log().isTraceEnabled()) {
log().trace("-->SubdialogState(dialogName="
+ sstate.getDialogName() + ")");
}
Dialog subdialog = (Dialog) dialogs(context).get(sstate.getDialogName());
if (subdialog == null) {
throw new IllegalStateException("Cannot find dialog definition '"
+ sstate.getDialogName() + "'");
}
start(subdialog);
position = peek();
state = position.getState();
continue;
} else if (state instanceof ViewState) {
viewId = ((ViewState) state).getViewId();
redirect = ((ViewState) state).isRedirect();
if (log().isTraceEnabled()) {
log().trace("-->ViewState(viewId="
+ ((ViewState) state).getViewId()
+ ",redirect=" + ((ViewState) state).isRedirect()
+ ")");
}
break;
} else {
throw new IllegalStateException
("State '" + state.getName()
+ "' of dialog '" + position.getDialog().getName()
+ "' is of unknown type '" + state.getClass().getName() + "'");
}
}
// Navigate to the requested view identifier (if any)
if (viewId == null) {