public void inject(final ActionRequest actionRequest, final Targets targets) { final ActionRuntime actionRuntime = actionRequest.getActionRuntime(); final RouteChunk routeChunk = actionRuntime.getRouteChunk(); if (!routeChunk.hasMacrosOnPath()) { // no action path macros at all, just exit return; } // inject final String[] actionPath = actionRequest.getActionPathChunks(); int ndx = actionPath.length - 1; RouteChunk chunk = routeChunk; while (chunk.parent() != null) { final PathMacros pathMacros = chunk.pathMacros(); if (pathMacros != null) { injectMacros(actionPath[ndx], pathMacros, targets); } ndx--; chunk = chunk.parent(); } }
public void inject(Object target, ActionRequest actionRequest) { ActionConfig config = actionRequest.getActionConfig(); ActionConfigSet set = config.getActionConfigSet(); if (set.actionPathMacros== null) { return; } String[] actionPathChunks = actionRequest.getActionPathChunks(); for (int i = 0; i < set.actionPathMacros.length; i++) { ActionConfigSet.PathMacro macro = set.actionPathMacros[i]; int ndx = macro.ndx; String name = macro.name; String value = actionPathChunks[ndx]; int leftLen = macro.left.length(); int rightLen = macro.right.length(); if (leftLen + rightLen > 0) { // there is additional prefix and/or suffix value = value.substring(leftLen, value.length() - rightLen); } BeanUtil.setDeclaredPropertyForcedSilent(target, name, value); } } }