-
Notifications
You must be signed in to change notification settings - Fork 328
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
Fixing problem: validation errors ignored on redirects. Closes #476 #725
Merged
Merged
Changes from 2 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
cff51ec
Fixing problem: validation ignored on redirects.
renanigt c96221c
Importing the correct IllegalStateException.
renanigt f543fa9
Fixing indentation.
renanigt 07912a9
Checking for validator erros on method use from Result.
renanigt 64c3c07
Minor refactoring.
renanigt 7a2b82b
Adding classes that handles errors.
renanigt 7205e22
Minor.
renanigt c41ff72
Merge with branch master
renanigt 3a287f1
Merge branch 'master' into validationIgnoredOnRedirects
renanigt 117aac0
Removing unnecessary components since now we have Messages component.
renanigt b9614f9
Adding feature to handle errors.
renanigt f2af267
Undo changes on VRaptor.java
renanigt 274adc9
Minor fixing.
renanigt b89218e
Minor
renanigt c31c1b5
Improving based on Turini's suggestion.
renanigt cb49d2b
Fixing a typo.
renanigt fa16133
Adding hadnleErrors just in instanceFor method call
renanigt 7b7f243
Checking if Severity is ERROR
renanigt 9869b7c
Improvements based on Lucas's suggestions.
renanigt ae22e99
Improvements based on Lucas's suggestion.
renanigt bb4c60a
Improving tests.
renanigt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,8 @@ | |
import br.com.caelum.vraptor.View; | ||
import br.com.caelum.vraptor.interceptor.TypeNameExtractor; | ||
import br.com.caelum.vraptor.ioc.Container; | ||
import br.com.caelum.vraptor.validator.Validator; | ||
import br.com.caelum.vraptor.view.Results; | ||
|
||
/** | ||
* A basic implementation of a Result | ||
|
@@ -48,28 +50,41 @@ public class DefaultResult extends AbstractResult { | |
private final Container container; | ||
private final ExceptionMapper exceptions; | ||
private final TypeNameExtractor extractor; | ||
private Validator validator; | ||
|
||
private Map<String, Object> includedAttributes; | ||
private boolean responseCommitted = false; | ||
|
||
|
||
/** | ||
* @deprecated CDI eyes only | ||
*/ | ||
protected DefaultResult() { | ||
this(null, null, null, null); | ||
this(null, null, null, null, null); | ||
} | ||
|
||
@Inject | ||
public DefaultResult(HttpServletRequest request, Container container, ExceptionMapper exceptions, TypeNameExtractor extractor) { | ||
public DefaultResult(HttpServletRequest request, Container container, ExceptionMapper exceptions, TypeNameExtractor extractor, | ||
Validator validator) { | ||
this.request = request; | ||
this.container = container; | ||
this.extractor = extractor; | ||
this.includedAttributes = new HashMap<>(); | ||
this.exceptions = exceptions; | ||
this.validator = validator; | ||
} | ||
|
||
@Override | ||
public <T extends View> T use(Class<T> view) { | ||
if(view.isAssignableFrom(Results.json()) && validator.hasErrors()) { | ||
throw new IllegalStateException( | ||
"There are validation errors and you forgot to specify where to go. Please add in your method " | ||
+ "something like:\n" | ||
+ "validator.onErrorUse(page()).of(AnyController.class).anyMethod();\n" | ||
+ "or any view that you like.\n" | ||
+ "If you didn't add any validation error, it is possible that a conversion error had happened."); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. bad indent There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. thanks @lucascs . ;-) |
||
|
||
responseCommitted = true; | ||
return container.instanceFor(view); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Receive validationErrors here, instead of Validator. And check for
hasUnhandledErrors
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Messages?