Search in sources :

Example 6 with JspWriter

use of javax.servlet.jsp.JspWriter in project head by mifos.

the class MifosImageTag method doStartTag.

/**
     * Function to render the tag
     *
     * @throws JspException
     */
@Override
public int doStartTag() throws JspException {
    JspWriter out = pageContext.getOut();
    ResourceBundle resource = getResourceBundle();
    path = resource.getString(getId());
    try {
        out.println(render());
    } catch (IOException e) {
        e.printStackTrace();
    }
    return SKIP_BODY;
}
Also used : ResourceBundle(java.util.ResourceBundle) IOException(java.io.IOException) JspWriter(javax.servlet.jsp.JspWriter)

Example 7 with JspWriter

use of javax.servlet.jsp.JspWriter in project jodd by oblac.

the class UrlTag method doTag.

@Override
public void doTag() throws JspException {
    PageContext pageContext = (PageContext) getJspContext();
    URLCoder.Builder builder = URLCoder.build(baseUrl);
    for (int i = 0; i < attrs.size(); i += 2) {
        builder.queryParam(attrs.get(i), attrs.get(i + 1));
    }
    if (var == null) {
        JspWriter out = pageContext.getOut();
        try {
            out.print(builder.toString());
        } catch (IOException ioex) {
        // ignore
        }
    } else {
        pageContext.setAttribute(var, builder.toString());
    }
}
Also used : URLCoder(jodd.util.URLCoder) PageContext(javax.servlet.jsp.PageContext) IOException(java.io.IOException) JspWriter(javax.servlet.jsp.JspWriter)

Example 8 with JspWriter

use of javax.servlet.jsp.JspWriter in project jstorm by alibaba.

the class ErrorTag method doTag.

@Override
public void doTag() throws JspException {
    JspWriter out = getJspContext().getOut();
    try {
        StringBuilder sb = new StringBuilder();
        if (e == null || e.size() == 0) {
        //                sb.append("<span class='glyphicon glyphicon-ok-sign ok-msg'></span>");
        //                sb.append("<span class='ok-msg'>N</span>");
        } else {
            String gly_cls = "glyphicon-remove-sign";
            String a_cls = "error-msg";
            String err_mgs = getErrorMsg();
            if (isWarning) {
                gly_cls = "glyphicon-exclamation-sign";
                a_cls = "warning-msg";
            }
            String err_content = getErrorContent();
            sb.append(String.format("<span tabindex='0' class='tip-msg pop %s'>%s</span>", a_cls, err_mgs));
            sb.append(String.format("<div class='hidden pop-content'>%s</div>", err_content));
        }
        out.write(sb.toString());
    } catch (IOException e) {
        throw new JspException("Error: " + e.getMessage());
    }
}
Also used : JspException(javax.servlet.jsp.JspException) IOException(java.io.IOException) JspWriter(javax.servlet.jsp.JspWriter)

Example 9 with JspWriter

use of javax.servlet.jsp.JspWriter in project jstorm by alibaba.

the class StatusTag method doTag.

@Override
public void doTag() throws JspException {
    JspWriter out = getJspContext().getOut();
    try {
        String label = "default";
        switch(status.toLowerCase()) {
            case STARTING:
                label = "primary";
                break;
            case ACTIVE:
                label = "success";
                break;
            case KILLED:
                label = "warning";
                break;
            case INACTIVE:
                label = "default";
                break;
            case REBALANCING:
                label = "info";
                break;
        }
        String result = String.format("<span class='label label-%s'>%s</span>", label, status);
        out.write(result);
    } catch (IOException e) {
        throw new JspException("Error: " + e.getMessage());
    }
}
Also used : JspException(javax.servlet.jsp.JspException) IOException(java.io.IOException) JspWriter(javax.servlet.jsp.JspWriter)

Example 10 with JspWriter

use of javax.servlet.jsp.JspWriter 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

JspWriter (javax.servlet.jsp.JspWriter)46 JspException (javax.servlet.jsp.JspException)20 IOException (java.io.IOException)19 HttpServletRequest (javax.servlet.http.HttpServletRequest)9 Properties (java.util.Properties)6 HtmlCode (org.compiere.util.HtmlCode)6 org.apache.ecs.xhtml.select (org.apache.ecs.xhtml.select)5 ArrayList (java.util.ArrayList)3 Iterator (java.util.Iterator)3 List (java.util.List)3 HttpSession (javax.servlet.http.HttpSession)3 JspContext (javax.servlet.jsp.JspContext)3 PageContext (javax.servlet.jsp.PageContext)3 org.apache.ecs.xhtml.option (org.apache.ecs.xhtml.option)3 Element (org.dom4j.Element)3 StringWriter (java.io.StringWriter)2 Collection (java.util.Collection)2 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)2 DisplaySectionBean (org.akaza.openclinica.bean.submit.DisplaySectionBean)2 org.apache.ecs.xhtml.br (org.apache.ecs.xhtml.br)2