/** * Called when a submission occurs with a form state token but there is no formState in session. This typically * happens when the user has waited so long to complete the form that the session timed out. */ protected View handleNoSuchFormStateOnSubmit(String formStateToken) throws RepositoryException { // Redirect to the current page _with_ the invalid token, this will render an error message. return new RedirectWithTokenView(context.getMainContent(), formStateToken); }
@Override protected View handleNoSuchFormState(String formStateToken) throws RepositoryException { return new SessionExpiredView(NodeUtil.getNodeIdentifierIfPossible(context.getMainContent())); }
protected ArrayList<FormStepState> getSteps() throws RepositoryException { Node currentPage = context.getMainContent(); Node currentStepContent = NavigationUtils.findParagraphOfType(currentPage, FormStepParagraph.class); ArrayList<FormStepState> steps = new ArrayList<>(); if (formState != null) { Iterator<FormStepState> stepsIt = formState.getSteps().values().iterator(); while (stepsIt.hasNext()) { FormStepState step = stepsIt.next(); if (step.getParagraphUuid().equals(NodeUtil.getNodeIdentifierIfPossible(currentStepContent))) { break; } steps.add(step); } } return steps; }
/** * Returns the UUID according to components/formCondition or the first child page with a paragraph of type {@link FormStepParagraph}. */ @Override protected String getNextPage() throws RepositoryException { // Find first child with step paragraph Iterator<Node> conditionParagraphIterator = NavigationUtils.getParagraphsOfType(getConfigurationNode(), "form:components/formCondition").iterator(); String nextPageUUID = NavigationUtils.findNextPageBasedOnCondition(conditionParagraphIterator, this.getFormState().getValues()); if(nextPageUUID == null) { Iterator<Node> contentIterator = NodeUtil.getNodes(context.getMainContent(), new NodeTypePredicate(NodeTypes.Page.NAME)).iterator(); nextPageUUID = NavigationUtils.findFirstPageWithParagraphOfType(contentIterator, FormStepParagraph.class); } return nextPageUUID; } }
@Override protected String getNextPage() throws RepositoryException { // Find next paragraph based on condition Node currentPage = context.getMainContent(); Node formStepParagraph = NavigationUtils.findParagraphOfType(currentPage, FormStepParagraph.class); Iterator<Node> conditionParagraphIterator = NavigationUtils.getParagraphsOfType(formStepParagraph, "form:components/formCondition").iterator(); String nextPageUUID = NavigationUtils.findNextPageBasedOnCondition(conditionParagraphIterator, this.getFormState().getValues()); if(nextPageUUID == null) { // Find first sibling with step paragraph Iterator<Node> contentIterator = NodeUtil.getNodes(startPage, new NodeTypePredicate(NodeTypes.Page.NAME)).iterator(); NavigationUtils.advanceIteratorTilAfter(contentIterator, currentPage); nextPageUUID = NavigationUtils.findFirstPageWithParagraphOfType(contentIterator, FormStepParagraph.class); } return nextPageUUID; } }
final Node mainContent = new I18nNodeWrapper(context.getMainContent()); try { formStateToken = getFormStateToken();