jsr372-experts@javaserverfaces-spec-public.java.net

[jsr372-experts] Re: [jsr372-experts mirror] JSF_SPEC-1 Multi-field validation proposal

From: Frank Caputo <frank_at_frankcaputo.de>
Date: Fri, 25 Sep 2015 09:40:42 +0200

Hi Ed,

I looked at the branch. Here are my findings:

- Can we hide BeanValidator.getMultiFieldValidationCandidates and BeanValidator$ComponentValueTuple? They seem like an implementation detail
- There are different methods to create the copy of the bean, but don’t we need a deep clone in all cases? Can we do some proxy magic instead?
- The backing bean in the demo implements Cloneable, to make the feature work. This feels uncomfortable.

From my point of view, it seems a little bit unwieldy. Maybe bean validation is not flexible enough to do multi component validation.

Perhaps we should go a special JSF way:

In the markup, we could have something like:

<f:validate components="password1 password2" validate="#{backingBean.multiValidatorMethod}">
        <input jsf:id="password1" jsf:value="#{backingBean.password1}"/>
        <input jsf:id="password2" jsf:value="#{backingBean.password2}"/>
</f:validate>

In java we would have a new interface:

public interface MultiValidator extends EventListener {
    public void validate(FacesContext context, Map<UIInput, Object> componentsToValues) throws ValidatorException;
}

The signature of the validate method is not optimal. But it is tiny and gives the developer everything, she needs.

Ciao Frank


> Am 22.09.2015 um 18:20 schrieb Edward Burns <edward.burns_at_oracle.com>:
>
> Hello Volunteers,
>
> One of the issues I wanted to resolve for our JavaOne EDR is the ancient
> JAVASERVERFACES_SPEC_PUBLIC-1 Multi-field validation. I started working
> on this in earnest on Friday and took inspiration from the excellent
> work done by Bauke and Arjan on OmniFaces <o:validateBean />. Thanks to
> Manfred for pointing that out to me.
>
> I've done the work in the misnamed JAVASERVERFACES-1 branch in Mojarra.
> Thanks to Manfred's work we've moved to java.net git instead of SVN. I
> haven't merged it to master yet, but I have kept the branch up to date
> with master so the merge should be easy.
>
> I've published the proposed API in our snapshot repo at [1].
>
> The complete specification of the feature spans two locations.
>
> 1. The vdldoc for the new tag <f:validateWholeBean> [2]
>
> 2. The javadoc for the existing BeanValidator.validate [3]
>
> Please review this proposal and let me have feedback by 13:00 UTC Friday
> 25 September 2015.
>
> Feel free to check out the JAVASERVERFACES-1 branch if you like. Git
> details are in a message Manfred sent to dev_at_javaserverfaces. [4].
>
> Thanks,
>
> Ed
>
> --
> | edward.burns_at_oracle.com | office: +1 407 458 0017
> | 32 Business days til JavaOne 2015
> | 47 Business days til DOAG 2015
>
> [1] https://maven.java.net/service/local/repositories/snapshots/archive/org/glassfish/javax.faces/2.3.0-m04-SNAPSHOT/javax.faces-2.3.0-m04-20150922.155142-160-documentation.jar/!/javadocs/index.html
>
> [2] https://maven.java.net/service/local/repositories/snapshots/archive/org/glassfish/javax.faces/2.3.0-m04-SNAPSHOT/javax.faces-2.3.0-m04-20150922.155142-160-documentation.jar/!/vdldoc/f/validateWholeBean.html
>
> [3] https://maven.java.net/service/local/repositories/snapshots/archive/org/glassfish/javax.faces/2.3.0-m04-SNAPSHOT/javax.faces-2.3.0-m04-20150922.155142-160-documentation.jar/!/javadocs/javax/faces/validator/BeanValidator.html#validate-javax.faces.context.FacesContext-javax.faces.component.UIComponent-java.lang.Object-
>
> [4] https://java.net/projects/javaserverfaces/lists/dev/archive/2015-09/message/12
>
>