struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ersinghlovepreet@gmail.com" <ersinghlovepr...@gmail.com>
Subject Re: Call a forward or a redirect inside an interceptor.
Date Mon, 09 Mar 2015 06:20:42 GMT
You can use dynamic url redirecting in this case :----
This works like
in struts.xml you have to define result mapping.
<result name="redirect" type="redirect">${url}</result>

and in action you will define some getter setter like :
private String url;

public String getUrl() {
   return url;
}
 public void setUrl(String url) {
   this.url=url;
}

But in case of Interceptor getter setter is not working so You can just set
the value in stack like:
invocation.getStack().set("url", "actionUrl");
and just return a "redirect" from interceptor instead of invocation.invoke()

BUT BE CAREFUL THIS WILL NOT LET ANY ACTION TO WORK IF YOU DOES NOT DEFINE
ANY CONDITION 
MAKE IF CONDITION TO ONLY THOSE ACTION WHICH YOU DON'T WANT TO EXECUTE AND
FOR REST MAKE INVOCATION.INVOKE() 
LIKE FOR EXAMPLE 

if(invocation.getProxy().getActionName().equals("DemoAction"))
{
	invocation.getStack().set("url", "DemoAction2");
	return "redirect";
}
return invocation.invoke();
i have made this redirect only for action DemoAction , for rest i just
define invocation.invoke

For further clarification Please feel free to reply on this post 
enjoy 
Thanks and regards 
Lovepreet Singh



--
View this message in context: http://struts.1045723.n5.nabble.com/Call-a-forward-or-a-redirect-inside-an-interceptor-tp3484464p5717505.html
Sent from the Struts - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message