private void convertXFormRepeatToGridData( FormEntryController formEntryController, FieldSpecCollection fieldsFromXForms, Bulletin bulletinLoadedFromXForms) throws Exception { FormEntryModel formModel = formEntryController.getModel(); IFormElement repeatElement = formModel.getForm().getChild(formModel.getFormIndex()); GroupDef castedRepeatDef = (GroupDef) repeatElement; TreeReference repeatTreeReference = (TreeReference) castedRepeatDef.getBind().getReference(); String gridTag = createGridTag(repeatTreeReference); GridFieldSpec foundGridFieldSpec = (GridFieldSpec) fieldsFromXForms.findBytag(gridTag); foundGridFieldSpec.setLabel(getNonNullLabel(castedRepeatDef)); PoolOfReusableChoicesLists allReusableChoiceLists = fieldsFromXForms.getAllReusableChoiceLists(); GridData gridData = new GridData(foundGridFieldSpec, allReusableChoiceLists); handleRepeat(formEntryController, fieldsFromXForms, gridData); bulletinLoadedFromXForms.set(gridTag, gridData.getXmlRepresentation()); }
private void handleRepeat( FormEntryController formEntryController, FieldSpecCollection fieldsFromXForms, GridData gridData) throws Exception { int event = returnToPreivousEventToAvoidConsumingEvent(formEntryController); while ((event = formEntryController.stepToNextEvent()) != FormEntryController.EVENT_END_OF_FORM) { if (event == FormEntryController.EVENT_REPEAT) { FormEntryModel formModel = formEntryController.getModel(); IFormElement element = formModel.getForm().getChild(formModel.getFormIndex()); if (element instanceof GroupDef) { GridRow gridRow = createGridRowWithData( formEntryController, gridData.getSpec(), fieldsFromXForms.getAllReusableChoiceLists()); gridData.addRow(gridRow); } } if (hasNoMoreUserFilledRepeats(event)) return; } }