Search in sources :

Example 66 with JspWriter

use of javax.servlet.jsp.JspWriter in project wildfly by wildfly.

the class TestTag method doTag.

@Override
public void doTag() throws JspException, IOException {
    JspWriter out = getJspContext().getOut();
    out.println("Test Tag!");
}
Also used : JspWriter(javax.servlet.jsp.JspWriter)

Example 67 with JspWriter

use of javax.servlet.jsp.JspWriter in project Openfire by igniterealtime.

the class FlashMessageTag method doTag.

@Override
public void doTag() throws IOException {
    final PageContext pageContext = (PageContext) getJspContext();
    final JspWriter jspWriter = pageContext.getOut();
    final HttpSession session = pageContext.getSession();
    for (final String flash : new String[] { SUCCESS_MESSAGE_KEY, WARNING_MESSAGE_KEY, ERROR_MESSAGE_KEY }) {
        final Object flashValue = session.getAttribute(flash);
        if (flashValue != null) {
            jspWriter.append(String.format("<div class='%s'>%s</div>", flash, flashValue));
            session.setAttribute(flash, null);
        }
    }
}
Also used : HttpSession(javax.servlet.http.HttpSession) PageContext(javax.servlet.jsp.PageContext) JspWriter(javax.servlet.jsp.JspWriter)

Example 68 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 69 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 70 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)145 IOException (java.io.IOException)72 JspException (javax.servlet.jsp.JspException)68 HttpServletRequest (javax.servlet.http.HttpServletRequest)17 JspWriteRuntimeException (org.jaffa.presentation.portlet.widgets.taglib.exceptions.JspWriteRuntimeException)14 PageContext (javax.servlet.jsp.PageContext)13 Iterator (java.util.Iterator)9 Engine (org.apache.wiki.api.core.Engine)9 JspContext (javax.servlet.jsp.JspContext)8 JspTagException (javax.servlet.jsp.JspTagException)8 OuterFormTagMissingRuntimeException (org.jaffa.presentation.portlet.widgets.taglib.exceptions.OuterFormTagMissingRuntimeException)7 ArrayList (java.util.ArrayList)6 Properties (java.util.Properties)6 HttpSession (javax.servlet.http.HttpSession)5 BodyContent (javax.servlet.jsp.tagext.BodyContent)5 org.apache.ecs.xhtml.select (org.apache.ecs.xhtml.select)5 Page (org.apache.wiki.api.core.Page)5 HtmlCode (org.compiere.util.HtmlCode)5 MissingParametersRuntimeException (org.jaffa.presentation.portlet.widgets.taglib.exceptions.MissingParametersRuntimeException)5 IPropertyRuleIntrospector (org.jaffa.rules.IPropertyRuleIntrospector)5