diff options
author | Artur Signell <artur.signell@itmill.com> | 2008-08-25 05:59:54 +0000 |
---|---|---|
committer | Artur Signell <artur.signell@itmill.com> | 2008-08-25 05:59:54 +0000 |
commit | 3a6e5a11210f1560a3b14b29803eac5386dacf98 (patch) | |
tree | 72369e0df2eb2ccf9d27194c980ee9f9b8607a3d /src/com/itmill/toolkit/ui/AbstractComponent.java | |
parent | 728f60409e3ca3dd8f85fff714b972cbd474b665 (diff) | |
download | vaadin-framework-3a6e5a11210f1560a3b14b29803eac5386dacf98.tar.gz vaadin-framework-3a6e5a11210f1560a3b14b29803eac5386dacf98.zip |
Made #1642 fix more generic by moving implementation to AbstractComponent
svn changeset:5250/svn branch:trunk
Diffstat (limited to 'src/com/itmill/toolkit/ui/AbstractComponent.java')
-rw-r--r-- | src/com/itmill/toolkit/ui/AbstractComponent.java | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/com/itmill/toolkit/ui/AbstractComponent.java b/src/com/itmill/toolkit/ui/AbstractComponent.java index 83502aa40c..634f58dbac 100644 --- a/src/com/itmill/toolkit/ui/AbstractComponent.java +++ b/src/com/itmill/toolkit/ui/AbstractComponent.java @@ -19,6 +19,7 @@ import com.itmill.toolkit.terminal.ErrorMessage; import com.itmill.toolkit.terminal.PaintException; import com.itmill.toolkit.terminal.PaintTarget; import com.itmill.toolkit.terminal.Resource; +import com.itmill.toolkit.terminal.Terminal; /** * An abstract class that defines default implementation for the @@ -121,6 +122,8 @@ public abstract class AbstractComponent implements Component, MethodEventSource private int widthUnit = UNITS_PIXELS; private int heightUnit = UNITS_PIXELS; + private ComponentErrorHandler errorHandler = null; + /* Constructor */ /** @@ -1170,4 +1173,53 @@ public abstract class AbstractComponent implements Component, MethodEventSource return values; } + public interface ComponentErrorEvent extends Terminal.ErrorEvent { + } + + public interface ComponentErrorHandler { + /** + * Handle the component error + * + * @param event + * @return True if the error has been handled False, otherwise + */ + public boolean handleComponentError(ComponentErrorEvent event); + } + + /** + * Gets the error handler for the component. + * + * The error handler is dispatched whenever there is an error processing the + * data coming from the client. + * + * @return + */ + public ComponentErrorHandler getErrorHandler() { + return errorHandler; + } + + /** + * Sets the error handler for the component. + * + * The error handler is dispatched whenever there is an error processing the + * data coming from the client. + * + * If the error handler is not set, the application error handler is used to + * handle the exception. + * + * @param errorHandler + * AbstractField specific error handler + */ + public void setErrorHandler(ComponentErrorHandler errorHandler) { + this.errorHandler = errorHandler; + } + + public boolean handleError(ComponentErrorEvent error) { + if (errorHandler != null) { + return errorHandler.handleComponentError(error); + } + return false; + + } + }
\ No newline at end of file |