-
1. Re: DRY Edit pages
gavin.king Jun 4, 2007 11:17 PM (in response to awhitford)Actually its a limitation of JSF. You can't write a Validator that validates null.
-
2. Re: DRY Edit pages
stephen.friedrich Jun 5, 2007 10:28 AM (in response to awhitford)Huh?
Either I am not understanding the anwser or Gavin, you did not understand the question.
What if the maximum length changes to 5? Currently you have to update both the entity and the xhtml.
Is there any possibility to avoid this? A JSF component or validator that queries the bean's metadata? -
3. Re: DRY Edit pages
gavin.king Jun 5, 2007 10:50 AM (in response to awhitford)Well, size and maxlength are nothing to do with validation.
Well, I guess maxlength kinda is. I suppose you could argue that its a bad idea that we include the maxlength in there. Take it out if you like... -
4. Re: DRY Edit pages
wsollers Jun 6, 2007 8:40 AM (in response to awhitford)The problem of changing db / entity metadata requiring a second change in the ui is not new and has been around for ever and predates java.
However to make life easier just make a utility f(x) that will grab the entity and check for the field and see if it has a Hibernate annotation or your own custom annotation and get the appropriate metadata (length / precision etc ) you need and then use it.
Maxlength and size both support EL. So you can do a size="#{fieldMetadata.sizeCalc('foo.class', 'field'}" instead of a " size="2".
You can use custom facelets to do the same thing.