1 25 26 package net.killingar.webwork; 27 28 import webwork.dispatcher.ViewMapping; 29 import webwork.dispatcher.ViewActionWrapper; 30 import webwork.config.Configuration; 31 32 public class RedirectViewMapping implements ViewMapping 33 { 34 private ViewMapping delegate; 35 private String redirectionPrefix; 36 private static final String configPrefix = "redirect:"; 37 38 public RedirectViewMapping(ViewMapping delegate) 39 { 40 this.delegate = delegate; 41 42 redirectionPrefix = "webwork.action.standard.Redirect."+Configuration.get("webwork.action.extension")+"?url="; 43 } 44 45 public Object getView(String action, String viewName) 46 { 47 Object view = delegate.getView(action, viewName); 48 if ("redirect".equals(viewName)) 49 view = redirectionPrefix + view; 50 if (view != null && view instanceof ViewActionWrapper) 51 { 52 ViewActionWrapper wrapper = (ViewActionWrapper)view; 53 54 if (wrapper.getActionName().startsWith(configPrefix)) 55 { 56 view = new ViewActionWrapper(wrapper.getActionName().substring(configPrefix.length()), wrapper.getParams()); 57 view = redirectionPrefix + view; 58 } 59 } 60 61 return view; 62 } 63 } | Popular Tags |