Skip to content
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

Updating ParameterLoader to work like an Interceptor, so the ControllerMethod isn't executed when a notFound() occurs. #31

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

rafaelGuerreiro
Copy link
Contributor

Sorry about closing the PR #29, but I've had to correct my branches.
ParameterLoad should be an interceptor and shouldn't call the ControllerMethod when the entity's ID isn't found. This solves the issue #13.

…lerMethod when the entity's ID isn't found. This solves issue #13.
if (!containsLoadAnnotation(method)) return;


@AroundCall
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if it always call stack.next(), you could use @BeforeCall instead

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't always calls stack.next(). When the loaded entity is null, in line 94, the interceptor is interrupted after setting result.notFound();

@Turini
Copy link
Member

Turini commented Feb 27, 2015

@rafaelGuerreiro I couldn't test it yeat. Did you test it in a real project?

but the code looks good to me 👍

…method when ExecuteMethod executes the controller's method.
@rafaelGuerreiro
Copy link
Contributor Author

@Turini, sorry, I didn't test in a real project. But I did a few minutes ago. And it didn't work =S

I made a new commit changing from FlashScoped to MethodInfo. And now it works.

Could you, please, explain the FlashScoped to me?

@Turini
Copy link
Member

Turini commented Mar 2, 2015

The flash scope keeps the request params for one more request after a
redirect. So, it's important to use it here. What doesn't work in your test?

@rafaelGuerreiro
Copy link
Contributor Author

Well, when using FlashScope, the object wasn't setted on the ControllerMethod. It was passed as a new instance.

When changing to MethodInfo, it started working properly.

This happens when changing from an Observer to an Interceptor.

It doesn't make much sense why FlashScope works with observer, since no redirect was made after the actual request, right?

@rafaelGuerreiro
Copy link
Contributor Author

This commit is a nice to have as well. Can it be merged?

@Turini
Copy link
Member

Turini commented Aug 3, 2015

sorry @rafaelGuerreiro, really busy week! I'll take a look on it asap

@@ -95,7 +118,12 @@ public void load(@Observes ControllerFound event) {
}
}
}
flash.includeParameters(method, args);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did you remove this line? it's an important/expected behavior

@Turini
Copy link
Member

Turini commented Aug 3, 2015

I left a few comments, @rafaelGuerreiro. thks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants