javaee / mojarra

PLEASE NOTE: This project has moved to Eclipse Foundation and will be archived under the JavaEE GitHub Organization. After Feb. 1, 2021, the new location will be github.com/javaee/mojarra. Mojarra - Oracle's implementation of the JavaServer Faces specification
https://github.com/eclipse-ee4j/mojarra
Other
164 stars 58 forks source link

Bean Validator is called multiple times #4126

Open javaserverfaces opened 8 years ago

javaserverfaces commented 8 years ago

When using Bean validation, component binding and ajax together, the validation is added at every ajax call to the validator list of the component. This results in multiple calls and displaying the validation message multiple times.

Example:

<h:inputText id="input" validator="#{bean.validate}" binding="#{bean.component}">
  <f:ajax />
</h:inputText>

Affected Versions

[2.2.12]

javaserverfaces commented 8 years ago

Reported by mwalliczek

javaserverfaces commented 8 years ago

mwalliczek said: Environment: Apache Deltaspike 1.5.4, Primefaces 5.3.5, Omnifaces 2.2

javaserverfaces commented 8 years ago

zhangxinyuan said: Hi, Can you provide a test war application for this bug?

javaserverfaces commented 8 years ago

Was assigned to ZhangXinyuan

javaserverfaces commented 7 years ago

This issue was imported from java.net JIRA JAVASERVERFACES-4122

edburns commented 6 years ago

Please see this important message regarding community contributions to Mojarra.

https://javaee.groups.io/g/jsf-spec/message/30

Also, please consider joining that group, as that group has taken the place of the old dev@javaserverfaces.java.net mailing list.

Thanks,

Ed Burns

svenhaag commented 6 years ago

I have the same issue. f:ajax even is not necessary to reproduce it. Affected version 2.3.3.

@Getter @Setter private transient HtmlInputText myField; public void validate(final FacesContext context, final UIComponent component, Object value) {...}

When validate is called, myField has 2 validators attached, instead of only 1. After each submit another additional vaildator is appended - using javax.faces.view.ViewScoped.

Only MethodExpression validators seem to be affected!

BalusC commented 4 years ago

This usually happens when the binding attribute incorrectly references a bean which is not in the request scope. In other words, this usually only happens when the whole physical component tree is incorrectly saved in the HTTP session and shared across multiple HTTP requests. This is against the recommendations in JSF specification. See also https://stackoverflow.com/q/14911158/157882