Object popped = session.getContext().popFromStack();
if (!(popped instanceof ObsSubmissionElement)) {
throw new IllegalStateException("Popped an element from the stack but it wasn't an ObsSubmissionElement!");
}
ObsSubmissionElement element = (ObsSubmissionElement) popped;
if (session.getContext().getMode() != FormEntryContext.Mode.VIEW && element.hasWhenValueThen()) {
if (element.getId() == null) {
throw new IllegalStateException("<obs> must have an id attribute to define when-then actions");
}
out.println("<script type=\"text/javascript\">");
out.println("jQuery(function() { htmlForm.setupWhenThen('" + element.getId() + "', "
+ simplifyWhenThen(element.getWhenValueThenDisplaySection()) + ", "
+ simplifyWhenThen(element.getWhenValueThenJavascript()) + ", "
+ simplifyWhenThen(element.getWhenValueElseJavascript())
+ "); });");
out.println("</script>");
}
}