@@ -97,6 +97,7 @@ public class CustomFormController implements Serializable {
9797 private ModelManager modelManager = null ;
9898 private List <CustomFormSection > sections ;
9999 private String supportedExpressions = "" ;
100+ private String errorMessage = "" ;
100101
101102 @ Inject
102103 WorkflowService workflowService ;
@@ -121,6 +122,14 @@ public List<CustomFormSection> getSections() {
121122 return sections ;
122123 }
123124
125+ public String getErrorMessage () {
126+ return errorMessage ;
127+ }
128+
129+ public void setErrorMessage (String error ) {
130+ this .errorMessage = error ;
131+ }
132+
124133 /**
125134 * WorkflowEvent listener to update the current FormDefinition.
126135 *
@@ -200,7 +209,10 @@ public void computeFieldDefinition(ItemCollection workitem) throws ModelExceptio
200209 sections = parseSectionList (rootElement , false , workitem );
201210 }
202211 } catch (ParserConfigurationException | SAXException | IOException e ) {
203- logger .warning ("Unable to parse custom form definition: " + e .getMessage ());
212+ errorMessage = "Invalid form definition! - Model=" + workitem .getModelVersion ()
213+ + " TaskID=" + workitem .getTaskID () + " Error="
214+ + e .getMessage ();
215+ logger .warning (errorMessage );
204216 return ;
205217 }
206218
@@ -209,8 +221,8 @@ public void computeFieldDefinition(ItemCollection workitem) throws ModelExceptio
209221 }
210222
211223 /**
212- * This method overwrite the 'readOnly' status flag for all sections.
213- * Note: sections can be embedded in optional subForms.
224+ * This method overwrite the 'readOnly' status flag for all sections. Note:
225+ * sections can be embedded in optional subForms.
214226 *
215227 * @param readOnly
216228 */
@@ -238,8 +250,8 @@ public void setReadOnly(boolean readOnly) {
238250 }
239251
240252 /**
241- * This helper method pareses a parent-node for 'imixs-form-section'
242- * tags and returns a list of CustomFormSections
253+ * This helper method pareses a parent-node for 'imixs-form-section' tags and
254+ * returns a list of CustomFormSections
243255 *
244256 * @param parentNode - the parent node to be parsed
245257 * @param readOnly - if true, all items will become readonly independent from
@@ -272,7 +284,8 @@ private List<CustomFormSection> parseSectionList(Element parentNode, boolean rea
272284 eSectionElement .getAttribute ("label" ),
273285 eSectionElement .getAttribute ("columns" ),
274286 eSectionElement .getAttribute ("path" ),
275- defaultReadOnly );
287+ defaultReadOnly ,
288+ eSectionElement .getAttribute ("options" ));
276289 customSection .setItems (findItems (eSectionElement ,
277290 customSection .getColumns (), defaultReadOnly , workitem ));
278291 result .add (customSection );
@@ -428,7 +441,7 @@ private boolean evaluateBoolean(String expression) throws ModelException {
428441 } else {
429442 throw new ModelException (ModelException .INVALID_MODEL_ENTRY ,
430443 "The custom-form expression is not allowed: "
431- + expression );
444+ + expression + " - expression missing in 'customform.expressions' " );
432445 }
433446
434447 } else {
@@ -484,8 +497,8 @@ private InputStream getFileFromResourceAsStream(String fileName) {
484497 /**
485498 * This method updates the custom Field Definition based on a given workitem.
486499 * The method first looks if the task associated with the workitem contains a
487- * bpmn:DataObject containing a custom definition.
488- * The result is stored into the item <code>txtWorkflowEditorCustomForm</code>.
500+ * bpmn:DataObject containing a custom definition. The result is stored into the
501+ * item <code>txtWorkflowEditorCustomForm</code>.
489502 * <p>
490503 * In case the model does not provide a custom Field Definition but the workitem
491504 * has stored one the method returns the existing one and did not update the
@@ -508,25 +521,28 @@ public String updateCustomFieldDefinition(ItemCollection workitem)
508521
509522 /**
510523 * Helper method that reads a form definition from an optional
511- * <code>bpmn:DataObject</code> associated with the current task element.
512- * A <code>bpmn:DataObject</code> must contain a `form-tag` containing the form
513- * definition.
514- * If not matching <code>bpmn:DataObject</code> is defined the method returns an
515- * empty
516- * string.
524+ * <code>bpmn:DataObject</code> associated with the current task element. A
525+ * <code>bpmn:DataObject</code> must contain a `form-tag` containing the form
526+ * definition. If not matching <code>bpmn:DataObject</code> is defined the
527+ * method returns an empty string.
517528 *
518529 * @param workitem
519530 * @return
520531 */
521532 @ SuppressWarnings ("unchecked" )
522533 private String fetchFormDefinitionFromModel (ItemCollection workitem ) {
534+
535+ // return if no modelversion is defined
536+ if (workitem == null || workitem .getModelVersion ().isBlank ()) {
537+ return "" ;
538+ }
523539 ItemCollection task ;
524540 try {
525541 BPMNModel model = modelManager .getModelByWorkitem (workitem );
526542 task = modelManager .loadTask (workitem , model );
527543
528544 } catch (ModelException e ) {
529- logger .warning ("unable to parse data object in model: " + e .getMessage ());
545+ logger .fine ("unable to parse data object in model: " + e .getMessage ());
530546 return "" ;
531547 }
532548
0 commit comments