private String processThisFragment(PageContext context) throws PageAction { // determine what controller to use Object controller = getController(context.getRequest()); PageView view = null; if (controller == null) { // some views can specify their controller try { view = getView(null, context.getRequest()); ProviderAndName controllerProviderAndName = view.getController(); if (controllerProviderAndName != null) { controller = getController( controllerProviderAndName.getProvider(), controllerProviderAndName.getName()); } } catch (Exception ex) { // this probably means we didn't find a view. Pass now to fail later } // TODO determine the controller from the view if (controller == null) { // go with the blank controller controller = emptyController; } } context.setController(controller); // let the controller handle the request // TODO: refactor because fragment controllers can now also return a FragmentRequest Object resultObject = handleRequestWithController(context); if (resultObject instanceof PageAction) { throw (PageAction) resultObject; } String result = (String) resultObject; // check if there was redirect (other than via a thrown PageAction) if (result != null && result.startsWith("redirect:")) { String toApplicationUrl = result.substring("redirect:".length()); throw new Redirect(toApplicationUrl); } // If the controller returns a simple string, we interpret that as a view in the requested // provider. // The controller should return "*:viewName" to search all providers. if (result != null && result.indexOf(':') <= 0) { result = context.getRequest().getMappedProviderName() + ":" + result; } // determine what view to use // (if the controller requests the default view, and we have it from earlier, we use that) if (result != null || view == null) { view = getView(result, context.getRequest()); } context.setView(view); String output = view.render(context); return output; }