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

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

From: arjan tijms <arjan.tijms_at_gmail.com>
Date: Fri, 25 Sep 2015 10:38:15 +0200

Hi,

On Fri, Sep 25, 2015 at 9:40 AM, Frank Caputo <frank_at_frankcaputo.de> wrote:
> - There are different methods to create the copy of the bean, but don’t we need a deep clone in all cases?

Not really. Suppose I have a bean with instance fields for a
MyComplexDependency and two Strings, then only bind those two Strings
to input components, and subsequently only apply BV constraints to
these two Strings. In this case a full clone (copy) of the bean is not
needed in order to test the constraints.

Note that the copy strategies are based on
http://showcase.omnifaces.org/validators/validateBean


> Can we do some proxy magic instead?

I'm not sure. A proxy's purpose is to ultimately call through to the
bean it's proxying. In this case you don't want that, as the original
bean should not be polluted with invalid values in case validation
fails.


> - The backing bean in the demo implements Cloneable, to make the feature work. This feels uncomfortable.

Serializable is another option, and perhaps more accepted. Quite a lot
of backing beans already implement it since a number of (CDI) scopes
require it. If you know that all values to be validated will be set
and/or there's never any previous state to be taken into account, the
"new instance" strategy is normally the best one.

Kind regards,
Arjan Tijms


>
> 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
>>
>>
>