Hello,

Has anyone figured out a reasonable way to handle bindings from backing beans to "non-anemic" domain models, whose setters may throw exceptions when a value breaks some business rule?

For example, imagine an object with an 'employee' property bound to a select list

<h:selectOneListBox value="#{backingBean.modelObject.employee}"/>

where the setEmployee() could throw an IllegalArgumentException. (invalid employee selected, etc.)

Is there any way to trap that exception and have it be treated the same as a validation failure? what I'm trying to do is avoid having to write the same business rules in both the presentation layer and business layer.

What's the best practice for handling this? I recognize there may not be any good answer, and that this is a universal problem with all JavaBeans-oriented web frameworks. It's no different with Struts and ActionForms except that JSF handles non-string properties. :-) but I was hoping that this would spark some good discussion nonetheless in case I'm missing something.

Thanks,
-- Bill
--
Bill Schneider
Chief Architect

Vecna Technologies, Inc.
5004 Lehigh Road
College Park, MD 20740
[EMAIL PROTECTED]
t: 240-737-1640
f: 301-699-3180

Reply via email to