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

[jsr372-experts] Re: Concerns about validateWholeBean

From: arjan tijms <arjan.tijms_at_gmail.com>
Date: Mon, 8 Feb 2016 16:40:13 +0100

Hi Micheal,

Good you're looking at the validateWholeBean.

Just wondering, could you take a look at
http://showcase.omnifaces.org/validators/validateBean to see if the
OmniFaces version is closer to what you need, or if it runs into the same
issues? validateWholeBean and o:validateBean are related (even share some
code), but the latter takes a somewhat different approach.

Also, can you check if there's perhaps some overlap with your issue and
this one: https://java.net/jira/browse/JAVASERVERFACES-4083

Thanks!

Kind regards,
Arjan Tijms






On Sun, Feb 7, 2016 at 1:58 PM, Michael Müller <
michael.mueller_at_mueller-bruehl.de> wrote:

> Hi experts,
>
> In a real worl application hospitals and people of the healthcare sector
> have to report comprehensiove information to a central institute. For each
> domain the user might fullfill a form - from a handfull of input fields up
> to a tabbed page with several hundresds of fields or lists. Usuall it takes
> some time to fullfill such a form. Thus, the user may store the data at any
> time and continue after a break. Once he has finished, he "sends" the data
> to the institute.
>
> Some requirements:
> - provide the user straight feedback
> - offer or hide conditional fields depending on the previous user input
> - check the input, thus it is compatible to the database at any time
> - check the whole form whnen the user clicks onto the send button
>
> I made some tests, how to solve this with our new multi field validation.
>
> Provide straight feedback and store at any time needs to use ajax: Every
> single field is pushed into the model to store an intermediate version.
>
> And to provide straight feedback on conditional fields or interacting
> fields requires an immediate multi field validation. It seems (unless I did
> not understand it right), that we can't use validateWholeBean for this. As
> the name states, it validates the whole bean and not a single group. As a
> workarround I split the data and used multiple backing beans for a single
> form. I tried to validate just after the input using ajax. Sadly,
> validateWholeBeans became active only after clicking the submit button.
>
> Here an excerpt of the form:
>
> <div jsf:id="age">
> <f:ajax render="age">
> <h:message for="ageValidator"/>
> <h:inputText id="ageDays" value="#{grouper.ageDays}">
> <f:validateBean id="ageValidator"
> validationGroups="javax.validation.groups.Default,de.muellerbruehl.jsf23.Age"/>
> </h:inputText>
> <h:message for="ageDays"/>
>
> <h:inputText id="ageYears" value="#{grouper.ageYears}">
> <f:validateBean
> validationGroups="javax.validation.groups.Default,de.muellerbruehl.jsf23.Age"/>
> </h:inputText>
> <h:message for="ageYears"/>
> <f:validateWholeBean value="#{grouper}"
> validationGroups="de.muellerbruehl.jsf23.Age" id="ageValidator"/>
> </f:ajax>
> </div>
>
> <div jsf:id="email">
> <f:ajax render="emailValidator">
> <h:message for="ageValidator"/>
> <h:inputText value="#{emailBean.email1}">
> <f:validateBean
> validationGroups="javax.validation.groups.Default,de.muellerbruehl.jsf23.Email"/>
> </h:inputText>
>
> <h:inputText value="#{emailBean.email2}">
> <f:validateBean
> validationGroups="javax.validation.groups.Default,de.muellerbruehl.jsf23.Email"/>
> </h:inputText>
>
> <f:validateWholeBean value="#{emailBean}"
> validationGroups="de.muellerbruehl.jsf23.Email" id="emailValidator"/>
> </f:ajax>
> </div>
>
> <h:commandButton value="submit"/>
>
> No matter, whether I include the f:validateWholeBean into the f:ajax, it
> it validated on submit only.
>
> I propose to enhance the multi field validation:
>
> - let the user define a couple of multi field validation
> (f:validateWholeBean or a new tag like f:validateGroup)
> - if a single field of this group is validated, validate the whole group
> too (no matter whether the validateWholeBean is place into a f:ajax)
>
> or
> - add an attribute validateGroup="someGroup" to the f:validateBean tag,
> e.g.
> <f:validateBean
> validationGroups="javax.validation.groups.Default,de.muellerbruehl.jsf23.Email"
> validateGroup="de.muellerbruehl.jsf23.Email"/>
> - on a partial request (in case of ajax), if validateGroup is declared,
> create a temp. copy of the bean and perform a group validation for the
> declared group.
>
> What do you think about this?
>
>
> --
>
> Herzliche Grüße - Best Regards,
>
> Michael Müller
> Brühl, Germany
> blog.mueller-bruehl.de
> it-rezension.de
> @muellermi
>
>
> Read my books
> "Web Development with Java and JSF": <https://leanpub.com/jsf>
> https://leanpub.com/jsf
> "Java Lambdas und (parallel) Streams" Deutsche Ausgabe:
> <https://leanpub.com/lambdas-de>https://leanpub.com/lambdas-de
> "Java Lambdas and (parallel) Streams" English edition:
> <https://leanpub.com/lambdas>https://leanpub.com/lambdas
>
>