spring-webflow
spring-webflow copied to clipboard
Add support for client-side validation driven by domain model constraints / metadata [SWF-1335]
Keith Donald opened SWF-1335 and commented
It should be possible to define validation constraints once, either within the domain model itself, or as Rules applied to domain model objects, and have these constraints enforced client-side by validating controls such as text fields and date choosers.
Attachments:
- DojoWidgetRenderer.patch (743 bytes)
Issue Links:
- #1364 Add support for invoking a validator after view model binding
4 votes, 2 watchers
Arnljot Arntsen commented
This is easy to implement.
The class org.springframework.faces.ui.DojoWidgetRenderer doesn't take into consideration that the constraints attribute of DojoWidgets is a bit particular.
Today the "getDojoAttributesAsString" will not treat the "constraints" attribute differently from any other attribute.
So jsf code that says constraints="{datePattern:'dd.MM.yyyy'} is rendered as constraints='{datePattern:'dd.MM.yyyy'}'. This breaks the dojo javascript, and your widget will fail.
In a local patch to this class we've declared a final static field in the class: private static final String KEY_CONSTRAINTS = "constraints";
And in the method taken this into consideration and included the key when evaluating the value: if (value instanceof String && !KEY_CONSTRAINTS.equalsIgnoreCase(key)) { attrs.append("'" + value + "'"); } else { attrs.append(value.toString()); }
All this information is relevant to spring faces of "spring-webflow-2.0.8.RELEASE"
Arnljot Arntsen commented
Maybe it's the wrong issue? Maybe there should be a new separate issue for the short commings of DojoWidgetRenderer.
But it's hard to tell since spring-faces is going to be a new separate toplevel project.