/** * Sets the {@link jodd.madvoc.ActionRequest#setNextActionPath(String) next action request} for the chain. */ @Override public void render(final ActionRequest actionRequest, final Object resultValue) { final Chain chainResult; if (resultValue == null) { chainResult = Chain.to(StringPool.EMPTY); } else { if (resultValue instanceof String) { chainResult = Chain.to((String)resultValue); } else { chainResult = (Chain) resultValue; } } final String resultBasePath = actionRequest.getActionRuntime().getResultBasePath(); final String resultPath = resultMapper.resolveResultPathString(resultBasePath, chainResult.path()); actionRequest.setNextActionPath(resultPath); }
/** * Redirects to the given location. Provided path is parsed, action is used as a value context. */ @Override public void render(final ActionRequest actionRequest, final Object resultValue) { final PermRedirect redirectResult; if (resultValue == null) { redirectResult = PermRedirect.to(StringPool.SLASH); } else { if (resultValue instanceof String) { redirectResult = PermRedirect.to((String)resultValue); } else { redirectResult = (PermRedirect) resultValue; } } final String resultBasePath = actionRequest.getActionRuntime().getResultBasePath(); final String redirectValue = redirectResult.path(); final String resultPath; if (redirectValue.startsWith("http://") || redirectValue.startsWith("https://")) { resultPath = redirectValue; } else { resultPath = resultMapper.resolveResultPathString(resultBasePath, redirectValue); } final HttpServletRequest request = actionRequest.getHttpServletRequest(); final HttpServletResponse response = actionRequest.getHttpServletResponse(); String path = beanTemplateParser.parseWithBean(resultPath, actionRequest.getAction()); DispatcherUtil.redirectPermanent(request, response, path); }
resultPath = resultMapper.resolveResultPathString(resultBasePath, redirectPath);
@Test void testAlias2() { WebApp webapp = new WebApp(); webapp.start(); ActionsManager actionsManager = webapp.madvocContainer().lookupComponent(ActionsManager.class); actionsManager.registerAction(BooAction.class, "foo2", null); actionsManager.registerPathAlias("/boo.foo2.xxx", "/aliased"); ResultMapper resultMapper = webapp.madvocContainer().lookupComponent(ResultMapper.class); ActionMethodParser actionMethodParser = webapp.madvocContainer().lookupComponent(ActionMethodParser.class); ActionRuntime cfg = parse(actionMethodParser, "fixtures.tst.BooAction#foo2"); String path = cfg.getActionPath(); String resultPath = resultMapper.resolveResultPathString(path, null); assertEquals("/aliased", resultPath); }