The main problem here is that Model by design, separated from the hierarchy of components, it is possible to implement a Model that supports a component that will report all errors in relation to a specific component.
Remember to make sure that it implements Detachable so that the related Component disconnected.
If Model performs an expensive operation, you might be interested in using LoadableDetachableModel instead (note that Model.getObject() can be called multiple times).
public class MyComponentAwareModel extends LoadableDetachableModel { private Component comp; public MyComponentAwareModel(Component comp) { this.comp = comp; } protected Object load() { try { return Order.lookupOrderDataFromRemoteService(); } catch (Exception e) { logger.error("Failed silently..."); comp.error("This is an error message"); } return null; } protected void onDetach(){ comp.detach(); } }
Maybe you should try Session.get().error()) .
source share