-
1. Re: JSF form (application) validation with SEAM
christian.bauer Feb 22, 2008 4:32 PM (in response to javacoryd)Just do it in your actions, like this.
-
2. Re: JSF form (application) validation with SEAM
keithnaas Feb 22, 2008 5:26 PM (in response to javacoryd)If you want to do any fancy styling of the bad field values, you could even call FacesMessages.addToControl() with your input fields component id. Note, that the component id will need to be fully qualified. So for instance if the component id is
username
and it is inside a form with an id ofform
, the
addToControl(form:username
) should do the trick. There is likely an easier way to do this now :) -
3. Re: JSF form (application) validation with SEAM
javacoryd Feb 22, 2008 9:16 PM (in response to javacoryd)Thanks everyone for the reply. This works great!
One question on this one. Will this solution work with fields under a ui:repeat?
Thanks,
Cory.
-
4. Re: JSF form (application) validation with SEAM
keithnaas Feb 22, 2008 9:45 PM (in response to javacoryd)Are you referring to the fully qualified component id? If so, then no out of the box it won't work with input fields in any repeating container such as a ui:repeat or h:dataTable. However, you can attempt to structure the componentId much the same way that the UIData does, namely to prepend the rowindex to the component id. So if your component is username, it is in a ui:repeat and the row index is 2, use
addToControl(form:2:username
). -
5. Re: JSF form (application) validation with SEAM
jimk1723 Feb 23, 2008 1:33 AM (in response to javacoryd)Not to derail, but has anyone in forum-land tinkered with using Drools for this kind of non-invariant validation?
-
6. Re: JSF form (application) validation with SEAM
luke.maurer Apr 3, 2008 10:31 PM (in response to javacoryd)Well, if you count login checking as form validation, then yes :-D
Come to think of it, maybe I'm not kidding - RuleBasedIdentity is a good example of a binary decision made using a quick Drools operation. I haven't done any performance testing, but AFAICT Drools is optimized for this sort of use case, so maybe a case could be made for using Drools for form validation. Certainly it's what I thought of when I read the OP's talk of business rules.
-
7. Re: JSF form (application) validation with SEAM
rhills Jun 3, 2008 3:12 AM (in response to javacoryd)I have a similar problem, with a group of related checkboxes that the user must select one or more of. I've got the validation working in the action, but I'm having trouble getting a validation error message to appear near the checkboxes.
The checkboxes are generated from a list via a h:selectManyCheckbox so trying to hook the message to one of those would be kludgy and fragile. They're inside their own rich:simpleTogglePanel, but the addToControl(..) method seems uninterested in attaching to an element that isn't an input field.
Is there some way of defining a named anchor point that I can target with a RichFaces method, or will I have to fudge it by creating a dedicated attribute on my action to hold/display my error message?