I have spring webflow applicaiton, which has a contact info page and while submitting the form, it goes to spring validator.
And executing validations, if any wrong data then we adding a error message to validationcontext. Using ${errorMessags} we list the error messages.
But I have a scenario where I need to show a warning message to user in middle of page.
Either through spring validation or spring flowscope variable in Spring Validator
Is there any way to do it?
Thanks in Advance!!!
Why do you want to do that on validator? Do you want to show that warning in next view?
I guess you could set message in or in to flashScope variable and show it on next page.
Related
I'm using Spring Boot with Vaadin and. By using the #Autowired SpringNavigator, I have also set the error view:
navigator.setErrorView(ErrorView.class);
But when I type wrong URL like http://localhost:8080/asdf .
I always get the Spring Boot's Whitelabel error page. I know that I can set custom HTML page for the error like
/resources/public/error/404.html
but this is HTML way, I would like to use Vaadin with components,
the best solution would be the mentioned error view.
I am working on Struts 1.1 to Spring 4 mvc migration project. In struts code action errors are getting displayed in JSP using the action messages are getting from applicationresources.properties file. This property file has errors.header and errors.footer which will be added for every error message. What is the equivalent solution in spring mvc to add header and footer for errors.
Kiran
I am using spring validation to validate the Rest Controller input, I would appreciate if any one can tell me is there a possibility of throwing custom message in case of exception and the custom message should come from database rather than from a properties file.
You can achieve this by setting a custom validation message source on Spring's LocalValidatorFactoryBean.
Your message source needs to implement the MessageSource interface and read its messages from the database.
Reference:
http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/validation/beanvalidation/LocalValidatorFactoryBean.html#setValidationMessageSource-org.springframework.context.MessageSource-
http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/context/MessageSource.html
Can we display error messages in one jsp but in 2 different forms.I am validating my bean using spring validation.Its working fine but if there is an error in the binding results then I am able to display the error message in the form from where action is executed but not in the other resultant form.
is the error tag in spring validation is mapped to jsp form from where that action is called.
Your BindingResults is just an object, which you can put in your Model and use on the page however you want. You may need to put it into Session if you plan to use it on a separate form.
I my application I have created custom AuthenticationFailureHandler and LogoutSuccess handler classes.
Now I want to pass messages from these classes to JSP which should be accessed using struts2 jstl tags.
I dont want to use url parameters for passing messages to jsp page.(login.action?msg=abc)
Any ideas on this?
One of the way to do it, is to put your message to session. In JSP you can access session like that:
<s:property value="#session.message"/>