New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Interceptor can't override a Result's attribute after use redirectTo. #696
Comments
Try do this using the Something like: @AroundCall
public void intercept(SimpleInterceptorStack stack) {
String moduleName = method.getController().getType().getSimpleName() + "/" + method.getMethod().getName();
result.include("module", moduleName);
stack.next();
} |
Renan, I think I don't have a |
Really, sorry. Add it as attribute. Try this: @Intercepts
public class ModuleInterceptor {
@Inject
private Result result;
@Inject
private ControllerMethod method;
@AroundCall
public void intercept(SimpleInterceptorStack stack) {
String moduleName = method.getController().getType().getSimpleName() + "/" + method.getMethod().getName();
result.include("module", moduleName);
stack.next();
}
} |
@armoucar when you test it, please report here. |
Tested the suggested code, problem is still happening. |
I'll do some tests and will report the result here. Thanks for the test. |
Have you tried requesting |
Yes. When I call |
Thanks. When I'm at home, I'll do some tests. |
I don't understand the problem and the goal. What's happens right now? And Remember that redirect don't stop the flow. So if there us some code after Sorry if I don't understand your case. |
If I really understand your problem @armoucar, here worked fine, with no problem. But remember what @garcia-jj said:
|
You can't have just a method with |
Otávio, The interceptor is intercepting both requests - normal requisition and redirect. On the second request (redirect), it tries to override an attribute on My solution now is use HttpServletRequest object. I just put an attribute there and it works like a charm even when redirecting. In some place that I don't remember, I read that vraptor stores Renan, I made that on the last test. Thank you guys. |
Arthur, thank you. Now I see your point. And you is right: vraptor uses flash to store all result values to use in |
I did the follow test and worked fine: Contoller: @Path("/index")
public void index() {
result.redirectTo(this).add();
}
@Path("/add")
public void add() {
} Interceptor: @Intercepts
public class ModuleInterceptor {
@Inject
private Result result;
@Inject
private ControllerMethod method;
@AroundCall
public void intercept(SimpleInterceptorStack stack) {
String moduleName = method.getController().getType().getSimpleName() + "/" + method.getMethod().getName();
result.include("module", moduleName);
stack.next();
}
} |
OK Renan, I'll test it today again and give you a feedback just after. Thankyou |
I did some tests and for me it's still happening. Tested with |
@armoucar when you try access the path /, the I tried exactly as you pushed. |
I cloned you project and run here, I got the expected result. It works!! IndexController/index2 |
It works for me too. When I access /, the browser was redirected to /index2 and printed: It works!! IndexController/index2. |
Same server, guys? The only change I made to do to run the blank project on tomcat was turn the To run with vraptor |
Try remove the scope and run it with vraptor 4.1.0-RC1. |
Tomcat doens't have an own |
The default scope is compile, so if you don't define it, the scope is compile. I'm using tomcat 7. |
On Wildfly |
Yeah, this 'problem' (at least happening to me) is very weird. I made some tests using: It has worked on wildfly but no on both tomcats. To be sure that was testing the same thing, I generated a package with maven and deployed them using the managing UI of each server. Uploaded the |
Thank you Arthur. I'll do some tests tonight. |
I downloaded and tested it on tomcat 7, and I got the expected result again. It works!! IndexController/index2 |
No. But I'll do it. |
Arthur, you can enable debug for the logger category I don't know if I can do this test tonight. So if you can do this debug, will help us to understand what's happens. Thank you. |
There is a bug involving tomcat 7 jsp compiler when using java 8. Maybe this is an collateral effect. But it should to work when using tomcat 8. Did you test it, right? |
I'll do this test when I'm at home. Tomcat 7 + Java 8. |
Sorry for delay... @Turini @garcia-jj @lucascs I did the test and when using Tomcat 7 + Java 8 I really got the wrong result. So, I think this problem isn't a VRaptor bug. |
But It works using tomcat 8 + java 8? |
I didn't test tomcat 8 + java 8. I tested tomcat 8 + java 7 and since But I can do this test. :-) On Monday, August 4, 2014, Rodrigo Turini notifications@github.com wrote:
|
As I said before: "There is a bug involving tomcat 7 jsp compiler when using java 8. Maybe this is an collateral effect. But it should to work when using tomcat 8." |
I'll do a test with Tomcat 8 + Java 8. :-) On Monday, August 4, 2014, Rodrigo Turini notifications@github.com wrote:
|
I did the test, and with Tomcat 8 + Java 8 the error also occur. |
so we can't close the issue. It must to work at servlet containers. |
Really. I understood was a Tomcat bug and not a VRaptor bug. Sorry. :-) |
@armoucar, I've tested with:
and both works as expected. |
OS X Mavericks. I'll one more test in few moments with the last version of VRaptor. |
can you test again with this war? (The same use case) |
Works on my machine too: Windows 8.1 |
Tried to use your .war but it doesn't start on my Tomcat. There are no logs about the application, only tomcat's:
Also, Fetched the last vraptor master branch, installed it, used in the same blank-project that I pushed to github and it is still the same: Java 8 + Tomcat 7, Tomcat 8. 👎 |
i have tested and work too. |
this is really weird, I ask for different users to test it and works as |
@Turini I'll also do a test when I'm at home, using Linux + Tomcat 7 and 8 + Java 8. |
New Tomcat:
Java 8:
OS infos:
mvn clean install:
blank-project vraptor deps:
|
Can someone here test it using VRaptor |
yep, as the problem was happening to me, i'll try it again. _Ar_thur _Mou_ra _Car_valho 2014-10-20 13:36 GMT+01:00 Rodrigo Turini notifications@github.com:
|
Works fine for me too. |
I'm closing the issue, but we can reopen if the problem persist in your env :) thanks |
This bug is happening on 4.0.0-Final version.
I've created a new project with the blank-project to emulate the problem.
An Interceptor was created to populate a String in the Result instance. It populates well the strings although when I show this parameter in my view, it shows me the first value populated by the interceptor (it doesn't override it). For the code below, If I try to show
${module}
in my JSP, when requesting/
, it shows meIndexController/index
- it should showIndexController/index2
I tested the code below and it works fine. The problem happens only when populating using interceptors.
The text was updated successfully, but these errors were encountered: