// Get the action configuration defined in struts.xml ActionConfig config = invocation.getProxy().getConfig(); // Get the SUCCESS result configured for that Action ResultConfig success = config.getResults().get("success"); // Iterate the Params, friendly printing :) for (Map.Entry<String, String> entry : success.getParams().entrySet()) { System.out.println("<param name=\"" + entry.getKey() + "\">" + entry.getValue() + "</param>"); }
public String getName() { return delegate.getName(); }
public Builder(String name, String className) { target = new ResultConfig(name, className); }
ActionInvocation invocation = ActionContext.getContext().getActionInvocation(); ActionProxy proxy = invocation.getProxy(); ActionConfig config = proxy.getConfig(); Map<String, ResultConfig> results = config.getResults(); ResultConfig resultConfig = results.get(Action.SUCCESS); String lastFinalLocation = null; Map<String, String> params = resultConfig.getParams(); if (resultConfig.getClassName().equals("org.apache.struts2.dispatcher.ServletDispatcherResult")) { lastFinalLocation = params.get("location"); } System.out.println("location: " + lastFinalLocation);
for (String resultName : resultNames) { ResultConfig resultConfig = actionConfig.getResults().get(resultName); String resultClassName = resultConfig.getClassName(); || resultClassName.contains("Velocity") || resultClassName.contains("Freemarker")) { if (resultConfig.getParams().get("location") == null) { continue; String location = getViewLocation(resultConfig.getParams().get("location"), namespace); addTempLink(action, location, Link.TYPE_RESULT, resultConfig.getName()); } else { ViewNode view = new ViewNode(stripLocation(location)); subGraph.addNode(view); addTempLink(action, location, Link.TYPE_RESULT, resultConfig.getName()); String locationConfig = resultConfig.getParams().get("location"); if (locationConfig == null) { locationConfig = resultConfig.getParams().get("actionName"); addTempLink(action, location, Link.TYPE_REDIRECT, resultConfig.getName()); } else { ViewNode view = new ViewNode(stripLocation(location)); subGraph.addNode(view); addTempLink(action, location, Link.TYPE_REDIRECT, resultConfig.getName());
/** * Determines if this action mapping will be have a JSF view * * @param inv * The action invocation * @return True if the JSF interceptors should fire */ protected boolean isFacesAction(ActionInvocation inv) { ActionConfig config = inv.getProxy().getConfig(); if (config != null) { ResultConfig resultConfig = config.getResults().get(Action.SUCCESS); Class resClass = null; try { resClass = Class.forName(resultConfig.getClassName()); } catch (ClassNotFoundException ex) { log.warn( "Can't find result class, ignoring as a faces request", ex); } if (resClass != null) { if (resClass.isAssignableFrom(FacesResult.class)) { return true; } } } return false; }
public String toString() { return "wrapper -> " + delegate.toString(); } }
public Result buildResult(ResultConfig resultConfig, Map<String, Object> extraContext) throws Exception { String resultClassName = resultConfig.getClassName(); Result result = null; if (resultClassName != null) { result = (Result) objectFactory.buildBean(resultClassName, extraContext); Map<String, String> params = resultConfig.getParams(); if (params != null) { for (Map.Entry<String, String> paramEntry : params.entrySet()) { try { reflectionProvider.setProperty(paramEntry.getKey(), paramEntry.getValue(), result, extraContext, true); } catch (ReflectionException ex) { if (result instanceof ReflectionExceptionHandler) { ((ReflectionExceptionHandler) result).handle(ex); } } } } } return result; }
} catch (Exception e) { if (LOG.isErrorEnabled()) { LOG.error("There was an exception while instantiating the result of type #0", e, resultConfig.getClassName());
protected String extractAnchorDest(ResultConfig resultConfig, ActionInvocation invocation) { Map<String, String> resultConfigParams = resultConfig.getParams(); for (Iterator i = resultConfigParams.entrySet().iterator(); i.hasNext();) { Map.Entry e = (Map.Entry) i.next(); if (e.getKey().equals("anchorDest")) { String potentialValue = e.getValue() == null ? "" : conditionalParse(e.getValue().toString(), invocation); if (potentialValue != null && potentialValue.length() > 0) { return potentialValue; } } } return null; }
ResultConfig result = orig.getResults().get(name); name = convertParam(name, vars); ResultConfig r = new ResultConfig.Builder(name, convertParam(result.getClassName(), vars)) .addParams(replaceParameters(result.getParams(), vars)) .build(); results.put(name, r);
public Builder addResultConfigs(Collection<ResultConfig> configs) { for (ResultConfig rc : configs) { target.results.put(rc.getName(), rc); } return this; }
public Builder(ResultConfig orig) { target = new ResultConfig(orig); }
protected String extractAnchorDest(ResultConfig resultConfig, ActionInvocation invocation) { Map<String, String> resultConfigParams = resultConfig.getParams(); for (Iterator i = resultConfigParams.entrySet().iterator(); i.hasNext();) { Map.Entry e = (Map.Entry) i.next(); if (e.getKey().equals("anchorDest")) { String potentialValue = e.getValue() == null ? "" : conditionalParse(e.getValue().toString(), invocation); if (potentialValue != null && potentialValue.length() > 0) { return potentialValue; } } } return null; }
public Builder addResultConfig(ResultConfig resultConfig) { target.results.put(resultConfig.getName(), resultConfig); return this; }
public ResultConfig build() { embalmTarget(); ResultConfig result = target; target = new ResultConfig(target); return result; }
protected void extractResultParams(Map<String, String> redirectParams, ResultConfig resultConfig, ActionInvocation invocation) { Map resultConfigParams = resultConfig.getParams(); for (Iterator i = resultConfigParams.entrySet().iterator(); i.hasNext();) { Map.Entry e = (Map.Entry) i.next(); if (!this.getProhibitedResultParams().contains(e.getKey())) { String potentialValue = e.getValue() == null ? "" : conditionalParse(e.getValue().toString(), invocation); if (!suppressEmptyParameters || ((potentialValue != null) && (potentialValue.length() > 0))) { redirectParams.put(e.getKey().toString(), potentialValue); } } } }
public Builder addGlobalResultConfig(ResultConfig resultConfig) { target.globalResultConfigs.put(resultConfig.getName(), resultConfig); return this; }
protected String extractAnchorDest(ResultConfig resultConfig, ActionInvocation invocation) { Map<String, String> resultConfigParams = resultConfig.getParams(); for (Iterator i = resultConfigParams.entrySet().iterator(); i.hasNext();) { Map.Entry e = (Map.Entry) i.next(); if (e.getKey().equals("anchorDest")) { String potentialValue = e.getValue() == null ? "" : conditionalParse(e.getValue().toString(), invocation); if (potentialValue != null && potentialValue.length() > 0) { return potentialValue; } } } return null; }
public WrapperActionForward(ResultConfig delegate) { super(delegate.getName()); this.delegate = delegate; freeze(); }