You can't.
Validation needs to operate on the object, so you need to flush the AddressEditorDriver
; and because proxies cannot be edited by two request contexts at once, you're forced to use the request context from the other driver, which will give you the same editable proxy as in the other driver, so when you flush the AddressEditorDriver
you're modifying the original proxy.
There are workarounds but they all involve a non-negligible amount of work and code:
- You could clone your proxy (for which there's no easy way to do) before editing it in the
AddressEditorDriver
and applying the changes back to the original proxy after flush. - Maybe you could use an
EditorVisitor
on yourAddressEditorDriver
and validate each field as you visit it, so you don't need to flush the driver (which would update the original proxy) - Similarly, you could use only sub-editors in the
AddressEditor
that would validate the field and report the error instead of updating the proxy (i.e.getValue
returns the original value from the proxy –the one passed tosetValue
– rather than the invalid value from the editor)