From a1db20b7fbac60cc530fe0a12facdf2e2f879195 Mon Sep 17 00:00:00 2001 From: Ahmad Vazirna Date: Fri, 21 Jun 2024 23:54:12 +0200 Subject: [PATCH 1/2] Register model construct done event --- src/main/java/org/javarosa/core/model/actions/Action.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/javarosa/core/model/actions/Action.java b/src/main/java/org/javarosa/core/model/actions/Action.java index 50c7e0f61d..da98bf368e 100644 --- a/src/main/java/org/javarosa/core/model/actions/Action.java +++ b/src/main/java/org/javarosa/core/model/actions/Action.java @@ -18,11 +18,12 @@ public abstract class Action implements Externalizable { // Events that can trigger an action public static final String EVENT_XFORMS_READY = "xforms-ready"; + public static final String EVENT_XFORMS_MODEL_CONSTRUCT_DONE = "xforms-model-construct-done"; public static final String EVENT_XFORMS_REVALIDATE = "xforms-revalidate"; public static final String EVENT_JR_INSERT = "jr-insert"; public static final String EVENT_QUESTION_VALUE_CHANGED = "xforms-value-changed"; private static final String[] allEvents = new String[]{EVENT_JR_INSERT, - EVENT_QUESTION_VALUE_CHANGED, EVENT_XFORMS_READY, EVENT_XFORMS_REVALIDATE}; + EVENT_QUESTION_VALUE_CHANGED, EVENT_XFORMS_READY, EVENT_XFORMS_REVALIDATE, EVENT_XFORMS_MODEL_CONSTRUCT_DONE}; private String name; From 64e693c690eb77144451222579eb4720fed73aa9 Mon Sep 17 00:00:00 2001 From: Ahmad Vazirna Date: Mon, 24 Jun 2024 10:40:36 +0200 Subject: [PATCH 2/2] Add method to trigger xforms-model-construct-done event --- src/main/java/org/javarosa/core/model/FormDef.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/org/javarosa/core/model/FormDef.java b/src/main/java/org/javarosa/core/model/FormDef.java index 0b93a05c19..aea4a62269 100755 --- a/src/main/java/org/javarosa/core/model/FormDef.java +++ b/src/main/java/org/javarosa/core/model/FormDef.java @@ -141,6 +141,7 @@ public class FormDef implements IFormElement, IMetaData, private ActionController actionController; //If this instance is just being edited, don't fire end of form events private boolean isCompletedInstance; + private boolean newInstance; private boolean mProfilingEnabled = false; private boolean useExpressionCaching; @@ -1376,6 +1377,12 @@ public void postProcessInstance() { } } + public void finilizeInitialization() { + if (newInstance) { + actionController.triggerActionsFromEvent(Action.EVENT_XFORMS_MODEL_CONSTRUCT_DONE, this); + } + } + /** * Reads the form definition object from the supplied stream. * @@ -1465,6 +1472,7 @@ public void initialize(boolean newInstance, boolean isCompletedInstance, Instanc actionController.triggerActionsFromEvent(Action.EVENT_XFORMS_READY, this); } this.isCompletedInstance = isCompletedInstance; + this.newInstance = newInstance; if (!isReadOnly) { initAllTriggerables(); }