Index: DefaultFeatureRuleExpression.java
===================================================================
--- DefaultFeatureRuleExpression.java	(revision 47377)
+++ DefaultFeatureRuleExpression.java	(revision 47378)
@@ -31,7 +31,8 @@
     private static final String FEATURERULEEXPRESSION_PERSISTENCE_DEFINITION_NAME = "FeatureRuleExpression";
 
     private Expression expression;
-    private FeatureSymbolTable symbolTable;
+    private FeatureSymbolTable featureSymbolTable;
+    private SymbolTable symbolTable;
 
     public DefaultFeatureRuleExpression() {
         super(null, null, false, false);
@@ -41,7 +42,8 @@
             boolean checkAtFinishEdition, Expression expression) {
         super(name, description, checkAtUpdate, checkAtFinishEdition);
         this.expression = expression;
-        this.symbolTable = new FeatureSymbolTableImpl();
+        this.featureSymbolTable = new FeatureSymbolTableImpl();
+        this.symbolTable = this.featureSymbolTable.createParent();
     }
 
     @Override
@@ -56,8 +58,8 @@
 
     @Override
     public void validate(EditableFeature feature, FeatureStore featureStore) throws DataException {
-        this.symbolTable.setFeature(feature);
-        Object value = this.expression.execute(symbolTable);
+        this.featureSymbolTable.setFeature(feature);
+        Object value = this.expression.execute(this.symbolTable);
         boolean ok = false;
         if (value != null) {
             if (value instanceof Boolean) {
@@ -95,6 +97,7 @@
             definition.addDynFieldBoolean("checkAtFinishEdition");
             definition.addDynFieldBoolean("checkAtUpdate");
             definition.addDynFieldObject("expression").setClassOfValue(Expression.class);
+            definition.addDynFieldInt("checkWhen").setMandatory(false);
         }
     }
 
@@ -102,29 +105,44 @@
     public void loadFromState(PersistentState state) throws PersistenceException {
         this.name = state.getString("name");
         this.description = state.getString("description");
-        this.checkAtFinishEdition = state.getBoolean("checkAtFinishEdition");
-        this.checkAtUpdate = state.getBoolean("checkAtUpdate");
+        this.checkwhen.set(state.getInt("checkWhen",0));
+        if( state.getBoolean("checkAtFinishEdition") ) {
+            this.checkwhen.setBits(CHECK_WHEN_FINISH_EDITING);
+        }
+        if( state.getBoolean("checkAtUpdate") ) {
+            this.checkwhen.setBits(CHECK_WHEN_INSERT_OR_UPDATE_FEATURE);
+        }
         this.expression = (Expression) state.get("expression");
-        this.symbolTable = new FeatureSymbolTableImpl();
+        this.featureSymbolTable = new FeatureSymbolTableImpl();
+        this.symbolTable = this.featureSymbolTable.createParent();
     }
 
     @Override
     public void saveToState(PersistentState state) throws PersistenceException {
         state.set("name", this.name);
         state.set("description", this.description);
-        state.set("checkAtFinishEdition", this.checkAtFinishEdition);
-        state.set("checkAtUpdate", this.checkAtUpdate);
+        state.set("checkWhen", this.checkwhen.get());
+        state.set("checkAtFinishEdition", this.checkwhen.isSetBits(CHECK_WHEN_FINISH_EDITING));
+        state.set("checkAtUpdate", this.checkwhen.isSetBits(CHECK_WHEN_INSERT_OR_UPDATE_FEATURE));
         state.set("expression", this.expression);
     }
 
     @Override
     public void setCheckAtUpdate(boolean checkAtUpdate) {
-        this.checkAtUpdate = checkAtUpdate;
+        if( checkAtUpdate ) {
+            this.checkwhen.setBits(CHECK_WHEN_INSERT_OR_UPDATE_FEATURE);
+        } else {
+            this.checkwhen.clearBits(CHECK_WHEN_INSERT_OR_UPDATE_FEATURE);
+        }
     }
 
     @Override
     public void setCheckAtFinishEditing(boolean checkAtFinishEditing) {
-        this.checkAtFinishEdition = checkAtFinishEditing;
+        if( checkAtFinishEditing ) {
+            this.checkwhen.setBits(CHECK_WHEN_FINISH_EDITING);
+        } else {
+            this.checkwhen.clearBits(CHECK_WHEN_FINISH_EDITING);
+        }
     }
 
     @Override
@@ -149,8 +167,9 @@
         builder.add_class(this);
         builder.add("name", this.name);
         builder.add("description", this.description);
-        builder.add("checkAtFinishEdition", this.checkAtFinishEdition);
-        builder.add("checkAtUpdate", this.checkAtUpdate);
+        builder.add("checkWhen", this.checkwhen.get());
+        builder.add("checkAtFinishEdition", this.checkwhen.isSetBits(CHECK_WHEN_FINISH_EDITING));
+        builder.add("checkAtUpdate", this.checkwhen.isSetBits(CHECK_WHEN_USER_EDIT_FEATURE));
         builder.add("expression", this.expression.getPhrase());
         return builder;
     }
@@ -159,10 +178,21 @@
     public void fromJson(JsonObject json) {
         this.name = json.getString("name");
         this.description = json.getString("description");
-        this.checkAtFinishEdition = json.getBoolean("checkAtFinishEdition", false);
-        this.checkAtUpdate = json.getBoolean("checkAtUpdate", false);
+        this.checkwhen.set(json.getInt("checkwhen", 0));
+        if( json.getBoolean("checkAtFinishEdition", false) ) {
+            this.checkwhen.setBits(CHECK_WHEN_FINISH_EDITING);
+        }
+        if( json.getBoolean("checkAtUpdate", false) ) {
+            this.checkwhen.setBits(CHECK_WHEN_INSERT_OR_UPDATE_FEATURE);
+        }
         this.expression = ExpressionUtils.createExpression(json.getString("expression", null));
-        this.symbolTable = new FeatureSymbolTableImpl();
+        this.featureSymbolTable = new FeatureSymbolTableImpl();
+        this.symbolTable = this.featureSymbolTable.createParent();
     }
 
+    @Override
+    public void setCheckWhen(int mask) {
+        super.setCheckWhen(mask); 
+    }
+
 }
