bean-validation

Spring validation errors tag not working completely with webflow + portlet

我的未来我决定 提交于 2019-12-11 11:31:36
问题 I have a small project (using Spring 4.2.0, Spring Webflow 2.4.2, Hibernate validator 5.2.2) that is working as expected in the servlet world, but after having transformed it to a portlet, the validation feedback in JSP doesn't work fully as expected anymore. For a form that looks like this: <form:form modelAttribute="person" action="${flowExecutionUrl}"> <form:input path="voornaam"/> .... </form:form> This still works in the portlet (so I get at least the confirmation that my validation

Bean Validation constraints in a shared library

守給你的承諾、 提交于 2019-12-11 10:28:50
问题 I have many jsf2 web projects that use the same validation constraints. Can I put all these constraints in a shared library? If yes, can I supply traslations for the validation messages? If yes, how can I achieve it in a standard way? Is the following package structure correct? commons.jar library: commons.jar | + library | | | + CustomConstraint1.class | + CustomConstraint2.class | + ValidationMessages_it.properties + ValidationMessages_en.properties + ValidationMessages_de.properties 回答1:

Validation with an EJB service call, possible with JSF validator or JSR303 bean validation?

时光总嘲笑我的痴心妄想 提交于 2019-12-11 09:48:11
问题 i want to validate my username using a select. if the username already is present in the database, validation fails. i found some annotations for primefaces like this for example: @Size(min=2,max=5) private String name; i didnt found a annotation solution for something like this: try { dao.findUserByUserName(userName); message = new FacesMessage ("Invalid username!", "Username Validation Error"); message.setDetail("Username already exists!"); message.setSeverity(FacesMessage.SEVERITY_ERROR);

Conditionally prevent cascading validation

和自甴很熟 提交于 2019-12-11 09:45:16
问题 Given the classes: class Foo { @Size(max = 1) @Valid private List<Bar> bars; } class Bar { @NotBlank private String snafu; } How can validation be applied that prevents Bar.snafu being validated when the Size constraint on Foo.bars failed? I though that i can achieve that with group conversion and the definition of a group sequence. but i failed configuring it the way i want. Even though it looks like, defining fail-fast is not an option. 回答1: The following solves this issue: interface

Is there a converter for String?

浪子不回头ぞ 提交于 2019-12-11 09:03:38
问题 For converting String values in JSF bean validation, which converter will be used? Like for numeric values we use <f:convertNumber> and for date we use <f:convertDataTime> . My code snipest are as follows: JSF page: <h:inputText id="Name" label="Name" value="#{employee.eName}"/> <h:message for="Name" styleClass="errorMessages"/> Bean class: public class Employee implements Serializable{ @NotNull @Size(min = 3, max = 30) String eName; } 回答1: String doesn't have a default converter. Request

Put validation messages into database

浪子不回头ぞ 提交于 2019-12-11 08:14:36
问题 I want to put validation messages used by Bean Validation (JSR 303) ex.: javax.validation.constraints.AssertFalse.message=must be false javax.validation.constraints.AssertTrue.message=must be true ... into a database so that when an administrator adds a new language he can adds the translations for that language. I know how to access a resource bundle mapped from a database but I can't figure out how to extend/customize the bean validation classes so they can access the validation messages

How to validate model with eclipselink jpa

孤人 提交于 2019-12-11 07:03:03
问题 I hava a model, and i need to validate model with eclipselink jpa and i add anotation @NotEmpty validate name if empty, but when i save/persist model, validate not work @Entity public class Role { @Id private String id; @NotEmpty private String name; public String getId() { return id; } public void setId(String id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } } my jpa configuration xml like this <?xml version="1.0" encoding=

Spring-mvc validation error not being picked from property file

爷,独闯天下 提交于 2019-12-11 06:58:14
问题 Using spring-mvc build in JSR303 bean validation and its working fine except for one issue, messages are not being picked from property file. My Web-application is being created with maven and this is current structure Main -java -resources -bundles -message.properties -webapp XML file <beans:bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource"> <beans:property name="basenames"> <beans:list> <beans:value>bundles/messages</beans:value> <beans:value

Have Spring respond with 400 (instead of 500) in case of a request header validation error

北城以北 提交于 2019-12-11 05:26:22
问题 When using validation for parameters of a Spring MVC @RequestMapping method, Spring responds with with different status codes depending on the type of the parameter: For invalid @RequestBody parameters, Spring responds with 400 For invalid @RequestHeader , @PathVariable , and @RequestParam parameters, Spring responds with 500. Can this be changed so that Spring responds with the same 400 response in all cases? This is my code: @Controller @Validated public class WebController {

Omnifaces validateBean: can not get showMessageFor attirbute to work

痴心易碎 提交于 2019-12-11 05:14:09
问题 I am using Omnifaces <o:validateBean /> to use JSR303 bean validation with a class level constraint. My question is based on a former question about how to attach message to specific components. Since Omnifaces 2.6 there is a showMessageFor attribute which solves my question at that time completely (so big thanks to the developers of Omnifaces library ;-). My problem is that I can not get it to work. Here is my setting. I have three input fields, two of them are coupled in a class level