Search in sources :

Example 1 with PrintHorizontalFormBuilder

use of org.akaza.openclinica.view.form.PrintHorizontalFormBuilder in project OpenClinica by OpenClinica.

the class PrintTableTag method doTag.

/**
     * This JSP Tag API method creates a instance of PrintHorizontalFormBuilder,
     * then generates that class's XHTML output into the web page. The tag shows
     * all sections of a CRF.
     *
     * @throws JspException
     * @throws IOException
     */
@Override
public void doTag() throws JspException, IOException {
    JspContext context = getJspContext();
    JspWriter tagWriter = context.getOut();
    // This request attribute is generated by the PrintCRf or PrintDataEntry
    // servlets
    List<DisplaySectionBean> listOfDisplayBeans = (ArrayList) context.findAttribute("listOfDisplaySectionBeans");
    StudyBean studyBean = (StudyBean) context.findAttribute("study");
    // EventCRFBean
    EventCRFBean eventCRFBean = (EventCRFBean) context.findAttribute("EventCRFBean");
    String isInternetExplorer = (String) context.findAttribute("isInternetExplorer");
    if (listOfDisplayBeans != null) {
        PrintHorizontalFormBuilder printFormBuilder = new PrintHorizontalFormBuilder();
        // Provide the form-building code with the list of display section
        // beans
        printFormBuilder.setDisplaySectionBeans(listOfDisplayBeans);
        // The body content of the tag contains 'true' or 'false', depending
        // on whether the
        // printed CRF involves data entry (and possible saved data) or not.
        JspFragment fragment = this.getJspBody();
        Writer stringWriter = new StringWriter();
        fragment.invoke(stringWriter);
        if ("true".equalsIgnoreCase(stringWriter.toString())) {
            printFormBuilder.setInvolvesDataEntry(true);
        }
        printFormBuilder.setEventCRFbean(eventCRFBean);
        if ("true".equalsIgnoreCase(isInternetExplorer)) {
            printFormBuilder.setInternetExplorer(true);
        }
        if (studyBean != null) {
            printFormBuilder.setStudyBean(studyBean);
        }
        if ("true".equalsIgnoreCase(stringWriter.toString())) {
            tagWriter.println(printFormBuilder.createMarkup());
        } else
            tagWriter.println(printFormBuilder.createMarkupNoDE());
    } else {
        tagWriter.println("The application could not generate the markup for the printable form.<br />" + "This error may have been caused by the altering of the web page's URL; the URL needs " + "an 'id' or an 'ecId' value in its query string at the URL end.");
    }
}
Also used : DisplaySectionBean(org.akaza.openclinica.bean.submit.DisplaySectionBean) PrintHorizontalFormBuilder(org.akaza.openclinica.view.form.PrintHorizontalFormBuilder) JspFragment(javax.servlet.jsp.tagext.JspFragment) JspContext(javax.servlet.jsp.JspContext) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) StringWriter(java.io.StringWriter) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) ArrayList(java.util.ArrayList) JspWriter(javax.servlet.jsp.JspWriter) StringWriter(java.io.StringWriter) JspWriter(javax.servlet.jsp.JspWriter) Writer(java.io.Writer)

Aggregations

StringWriter (java.io.StringWriter)1 Writer (java.io.Writer)1 ArrayList (java.util.ArrayList)1 JspContext (javax.servlet.jsp.JspContext)1 JspWriter (javax.servlet.jsp.JspWriter)1 JspFragment (javax.servlet.jsp.tagext.JspFragment)1 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)1 DisplaySectionBean (org.akaza.openclinica.bean.submit.DisplaySectionBean)1 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)1 PrintHorizontalFormBuilder (org.akaza.openclinica.view.form.PrintHorizontalFormBuilder)1