diff options
author | Leif Åstrand <leif@vaadin.com> | 2012-09-14 16:16:23 +0300 |
---|---|---|
committer | Leif Åstrand <leif@vaadin.com> | 2012-09-14 16:16:23 +0300 |
commit | 7353c3698181bd4ccd0d5d890745ad13ff544ee6 (patch) | |
tree | 07ff48fed59a6f07d6fd9d9fc38e6594eb2b117e /uitest | |
parent | 9fa3585cbd789c1866a7430bf9ac4e3b601727b9 (diff) | |
download | vaadin-framework-7353c3698181bd4ccd0d5d890745ad13ff544ee6.tar.gz vaadin-framework-7353c3698181bd4ccd0d5d890745ad13ff544ee6.zip |
Updated mini tutorial source code (#9499)
Diffstat (limited to 'uitest')
-rw-r--r-- | uitest/src/com/vaadin/tests/minitutorials/v7b1/Addition.java | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/uitest/src/com/vaadin/tests/minitutorials/v7b1/Addition.java b/uitest/src/com/vaadin/tests/minitutorials/v7b1/Addition.java index 7e1c9ecf2a..a91df49508 100644 --- a/uitest/src/com/vaadin/tests/minitutorials/v7b1/Addition.java +++ b/uitest/src/com/vaadin/tests/minitutorials/v7b1/Addition.java @@ -22,14 +22,23 @@ import com.vaadin.ui.AbstractComponent; public class Addition extends AbstractComponent { private int term1; private int term2; + private boolean needsRecalculation = false; public void setTerm1(int value1) { - this.term1 = value1; + term1 = value1; + needsRecalculation = true; + + // Mark the component as dirty to ensure beforeClientResponse will be + // invoked markAsDirty(); } public void setTerm2(int value2) { - this.term2 = value2; + term2 = value2; + needsRecalculation = true; + + // Mark the component as dirty to ensure beforeClientResponse will be + // invoked markAsDirty(); } @@ -39,7 +48,13 @@ public class Addition extends AbstractComponent { @Override public void beforeClientResponse(boolean initial) { - getState().sum = calculateSum(); + super.beforeClientResponse(initial); + if (needsRecalculation) { + needsRecalculation = false; + // This could be an expensive operation that we don't want to do + // every time setTerm1 or setTerm2 is invoked. + getState().sum = calculateSum(); + } } @Override |