short addition: i see your point and i’ll change that. for now: my previous post contains a list of simple solutions you can use.
regards, gerhard http://www.irian.at Your JSF powerhouse - JSF Consulting, Development and Courses in English and German Professional Support for Apache MyFaces 2009/11/30 Gerhard Petracek <[email protected]> > hi, > > it's a bit different. > the parameter mentioned by jakob is a jsf 2.0 parameter especially for the > jsr 303 integration. > if you set it to true, the not-null constraint will be interpreted like > required (= true). > extval uses it in an abstract class in a similar way. that means: you just > have to use it to explicitly deactivate the behavior described above. > it's automatically available for custom validation interceptors. an > internal example is the validation interceptor of the bean-validation module > (which allows to use jsr 303 with all jsf versions). > > the property validation module of the next release (as well as the > available milestone) overrides this new default behavior so that an empty > field doesn't lead to a null value for validation (due to backward > compatibility reasons). however, you can easily customize this behavior. > > back to the original question: > > extval just delegates to the (configured) jsf length validator. so > basically the behavior depends on the implementation you are using in your > application. > > in this case the default implementation throws an exception because it > isn't aware of empty values. to change this behavior you can: > - register your custom jsf-length-validator implementation (see: > javax.faces.Length) which handles it as you expect it (that's plain jsf) > or > - replace the default extval validation strategy for @Length to ignore > empty values > or > - implement your custom extval annotation > > all 3 possibilities are quite easy. > > regards, > gerhard > > http://www.irian.at > > Your JSF powerhouse - > JSF Consulting, Development and > Courses in English and German > > Professional Support for Apache MyFaces > > > 2009/11/30 Jakob Korherr <[email protected]> > > Hi Markus, >> >> Take a look at the >> javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL >> config parameter in web.xml. >> >> Setting this to true will cause that your property "input" will be null, >> if >> the user submits an empty field and thus @Length will not be processed. >> >> Also take a look at http://jsfatwork.irian.at/semistatic/jsf.html, >> chapter >> 2.12 Validierung fur further information. It's written in german, but I >> assume you're from Germany... >> >> Regards >> >> Jakob Korherr >> >> >> 2009/11/30 Dreher, Markus <[email protected]> >> >> > Hi all, >> > >> > i want to validate a field only when the user filled it out. >> > >> > It's not a reuqired field, but when it is filled out, the input should >> > be at least for example 3 digits. >> > >> > @Length(minimum=3, maximum = 60) >> > private String input; >> > >> > With @Length this leads to a required field. >> > >> > Do i miss something? >> > >> > Regards, >> > >> > Markus >> > >> > >> > >> > >

