Example usage for javax.servlet.jsp JspWriter write

List of usage examples for javax.servlet.jsp JspWriter write

Introduction

In this page you can find the example usage for javax.servlet.jsp JspWriter write.

Prototype

public void write(int c) throws IOException 

Source Link

Document

Writes a single character.

Usage

From source file:org.kuali.mobility.icons.tags.WebIconCSSTag.java

@Override
public void doTag() throws JspException, IOException {
    PageContext pageContext = (PageContext) getJspContext();
    JspWriter out = pageContext.getOut();
    HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();

    // If there is theme info, add that
    if (!StringUtils.isEmpty(icon.getTheme())) {
        out.write("img[data-kme-icon=" + icon.getName() + "][data-kme-theme=" + icon.getTheme() + "], ");
        out.write("[data-kme-theme=" + icon.getTheme() + "] img[data-kme-icon=" + icon.getName() + "]{ ");
    } else {//from ww w .  java  2  s.co m
        out.write("img[data-kme-icon=" + icon.getName() + "]{");
    }
    out.write("background-image: url('" + getBackgroundImageURL(request.getContextPath()) + "');");
    out.write("}");
}

From source file:org.kuali.mobility.icons.tags.WebIconTag.java

@Override
public void doTag() throws JspException, IOException {
    PageContext pageContext = (PageContext) getJspContext();
    HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
    JspWriter out = pageContext.getOut();

    // Write out a link to a transparent pixel for a placeholder
    out.write("<img src=\"" + request.getContextPath() + "/images/pixel.png\"");

    // Write the data-kme-icon attribute that will be used with css to select the icon
    out.write(" data-kme-icon=\"");
    out.write(icon);/*from   w  ww  .j  a va  2s .c om*/
    out.write("\"");

    // Write the data-kme-theme that will be used by css to use themed icon
    if (!StringUtils.isEmpty(theme)) {
        out.write(" data-kme-theme=\"");
        out.write(theme);
        out.write("\"");
    }

    out.write(" />");
}

From source file:org.kuali.ole.sys.document.web.renderers.GroupTitleLineRenderer.java

protected void renderGroupLevelActions(PageContext pageContext, Tag parentTag) throws JspException {
    JspWriter out = pageContext.getOut();

    try {/* w  w w  . j a  va  2s  . c  om*/
        out.write(this.buildGroupActionsBeginning());

        this.renderGroupActions(pageContext, parentTag);
        String nameSpaceCode = OLEConstants.Account.ACCOUNT_NAMESPACE;

        boolean hasPermission = KimApiServiceLocator.getPermissionService().hasPermission(
                GlobalVariables.getUserSession().getPerson().getPrincipalId(), nameSpaceCode,
                OLEConstants.Account.UPLOAD_BUDGET);

        if (hasPermission) {
            this.renderUploadCell(pageContext, parentTag);
        }

        out.write(this.buildGroupActionsColumnEnding());
    } catch (IOException ioe) {
        throw new JspException("Difficulty rendering group level actions", ioe);
    }
}

From source file:org.kuali.ole.sys.document.web.renderers.GroupTitleLineRenderer.java

/**
 * Oy, the big one...this one actually renders instead of returning the HTML in a String. This is because it's kind of complex
 * (and a likely target for future refactoring)
 *
 * @param pageContext the page contex to render to
 * @param parentTag the tag that is requesting all the rendering
 * @throws JspException thrown if something goes wrong
 *//* w w w.j av  a  2s .  co  m*/
protected void renderUploadCell(PageContext pageContext, Tag parentTag) throws JspException {
    JspWriter out = pageContext.getOut();

    if (canUpload()) {
        try {
            String hideImport = getHideImportName();
            String showImport = getShowImportName();
            String showLink = getShowLinkName();
            String uploadDiv = getUploadDivName();

            out.write("\n<SCRIPT type=\"text/javascript\">\n");
            out.write("<!--\n");
            out.write("\tfunction " + hideImport + "() {\n");
            out.write("\t\tdocument.getElementById(\"" + showLink + "\").style.display=\"inline\";\n");
            out.write("\t\tdocument.getElementById(\"" + uploadDiv + "\").style.display=\"none\";\n");
            out.write("\t}\n");
            out.write("\tfunction " + showImport + "() {\n");
            out.write("\t\tdocument.getElementById(\"" + showLink + "\").style.display=\"none\";\n");
            out.write("\t\tdocument.getElementById(\"" + uploadDiv + "\").style.display=\"inline\";\n");
            out.write("\t}\n");
            out.write("\tdocument.write(\n");
            out.write("\t\t'<a id=\"" + showLink + "\" href=\"#\" onclick=\"" + showImport
                    + "();return false;\">' +\n");
            out.write("\t\t'<img src=\""
                    + SpringContext.getBean(ConfigurationService.class)
                            .getPropertyValueAsString("externalizable.images.url")
                    + "tinybutton-importlines.gif\" title=\"import file\" alt=\"import file\"' +\n");
            out.write("\t\t'width=\"72\" border=\"0\">' +\n");
            out.write("\t\t'</a>' +\n");
            out.write("\t\t'<div id=\"" + uploadDiv + "\" style=\"display:none;\" >' +\n");

            out.write("\t\t'");

            scriptFileTag.setPageContext(pageContext);
            scriptFileTag.setParent(parentTag);
            scriptFileTag.setProperty(accountingLineGroupDefinition.getImportedLinePropertyPrefix() + "File");
            scriptFileTag.doStartTag();
            scriptFileTag.doEndTag();

            out.write("' +\n");
            out.write("\t\t'");

            uploadButtonTag.setPageContext(pageContext);
            uploadButtonTag.setParent(parentTag);
            uploadButtonTag.setProperty("methodToCall.upload"
                    + StringUtils.capitalize(accountingLineGroupDefinition.getImportedLinePropertyPrefix())
                    + "Lines");
            uploadButtonTag
                    .setAlt("insert " + accountingLineGroupDefinition.getGroupLabel() + " accounting lines");
            uploadButtonTag
                    .setTitle("insert " + accountingLineGroupDefinition.getGroupLabel() + " accounting lines");
            uploadButtonTag.doStartTag();
            uploadButtonTag.doEndTag();

            out.write("' +\n");

            out.write("\t\t'");

            cancelButtonTag.setPageContext(pageContext);
            cancelButtonTag.setParent(parentTag);
            cancelButtonTag.setAlt(
                    "Cancel import of " + accountingLineGroupDefinition.getGroupLabel() + " accounting lines");
            cancelButtonTag.setTitle(
                    "Cancel import of " + accountingLineGroupDefinition.getGroupLabel() + " accounting lines");
            cancelButtonTag.setOnclick(getHideImportName() + "();return false;");
            cancelButtonTag.doStartTag();
            cancelButtonTag.doEndTag();

            out.write("' +\n");

            out.write("\t'</div>');\n");
            out.write("\t//-->\n");
            out.write("</SCRIPT>\n");
            out.write("<NOSCRIPT>\n");
            out.write("\tImport " + accountingLineGroupDefinition.getGroupLabel() + " lines\n");

            noscriptFileTag.setPageContext(pageContext);
            noscriptFileTag.setParent(parentTag);
            noscriptFileTag.setProperty(accountingLineGroupDefinition.getImportedLinePropertyPrefix() + "File");
            noscriptFileTag.doStartTag();
            noscriptFileTag.doEndTag();

            uploadButtonTag.doStartTag();
            uploadButtonTag.doEndTag();

            out.write("</NOSCRIPT>\n");
        } catch (IOException ioe) {
            throw new JspException("Difficulty rendering accounting lines import upload", ioe);
        }
    }
}

From source file:org.kuali.ole.sys.document.web.renderers.LabelRenderer.java

/**
 * // ww w.  j  a v  a2  s. c  om
 * @see org.kuali.ole.sys.document.web.renderers.Renderer#render(javax.servlet.jsp.PageContext, javax.servlet.jsp.tagext.Tag, org.kuali.rice.krad.bo.BusinessObject)
 */
public void render(PageContext pageContext, Tag parentTag) throws JspException {
    try {
        JspWriter out = pageContext.getOut();
        if (!StringUtils.isBlank(labelFor)) {
            out.write("<label for=\"" + labelFor + "\">");
        }
        if (required) {
            out.write(OLEConstants.REQUIRED_FIELD_SYMBOL);
            out.write("&nbsp;");
        }
        if (!StringUtils.isBlank(fullClassNameForHelp) && !StringUtils.isBlank(attributeEntryForHelp)) {
            out.write("<a href=\"");
            out.write(getApplicationURL());
            out.write("/kr/help.do?methodToCall=getAttributeHelpText&amp;businessObjectClassName=");
            out.write(fullClassNameForHelp);
            out.write("&amp;attributeName=");
            out.write(attributeEntryForHelp);
            out.write("\" target=\"_blank\">");
        }
        out.write(label);
        if (!StringUtils.isBlank(fullClassNameForHelp) && !StringUtils.isBlank(attributeEntryForHelp)) {
            out.write("</a>");
        }
        if (!StringUtils.isBlank(labelFor)) {
            out.write("</label>");
        }
    } catch (IOException ioe) {
        throw new JspException("Difficulty rendering label", ioe);
    }
}

From source file:org.myjerry.web.taglibs.core.RadioTag.java

@Override
public void doTag() throws JspException, IOException {
    JspWriter out = getJspContext().getOut();
    out.write("<input type=\"radio\" value=\"" + value + "\" name=\"" + name + "\" ");
    if (StringUtils.isNotBlank(selectedValue)) {
        if (selectedValue.equals(value)) {
            out.write("checked=\"checked\" ");
        }/*ww w .j a va 2  s  .  c  om*/
    } else {
        if (onDefault != null && onDefault) {
            out.write("checked=\"checked\" ");
        }
    }
    out.write(" />");
}

From source file:org.opencms.workplace.CmsDialog.java

/**
 * Used to close the current JSP dialog.<p>
 * //from  www.jav  a2s  .  com
 * This method tries to include the URI stored in the workplace settings.
 * This URI is determined by the frame name, which has to be set 
 * in the frame name parameter.<p>
 * 
 * @throws JspException if including an element fails
 */
public void actionCloseDialog() throws JspException {

    // create a map with empty "resource" parameter to avoid changing the folder when returning to explorer file list
    Map<String, String> params = new HashMap<String, String>();
    params.put(PARAM_RESOURCE, "");
    if (isPopup()) {
        try {
            // try to close the popup
            JspWriter out = getJsp().getJspContext().getOut();
            out.write("<html><head></head>\n");
            out.write("<body onload=\"top.close();\">\n");
            out.write("</body>\n");
            out.write("</html>\n");
        } catch (IOException e) {
            // error redirecting, include explorer file list
            getJsp().include(FILE_EXPLORER_FILELIST, null, params);
        }
    } else if (getParamCloseLink() != null) {
        // close link parameter present
        try {
            if (Boolean.valueOf(getParamRedirect()).booleanValue()) {
                // redirect parameter is true, redirect to given close link                 
                getJsp().getResponse().sendRedirect(getParamCloseLink());
            } else {
                // forward JSP
                if (!isForwarded()) {
                    setForwarded(true);
                    CmsRequestUtil.forwardRequest(getParamCloseLink(), getJsp().getRequest(),
                            getJsp().getResponse());
                }
            }
        } catch (Exception e) {
            // forward failed
            throw new JspException(e.getMessage(), e);
        }
    } else if (getParamFramename() != null) {
        // no workplace frame mode (currently used for galleries)
        // frame name parameter found, get URI
        String frameUri = getSettings().getFrameUris().get(getParamFramename());
        // resetting the action parameter
        params.put(PARAM_ACTION, "");
        if (frameUri != null) {
            // URI found, include it
            if (frameUri.startsWith(OpenCms.getSystemInfo().getOpenCmsContext())) {
                // remove context path from URI before inclusion
                frameUri = frameUri.substring(OpenCms.getSystemInfo().getOpenCmsContext().length());
            }
            // include the found frame URI
            getJsp().include(frameUri, null, params);
        } else {
            // no URI found, include the explorer file list
            getJsp().include(FILE_EXPLORER_FILELIST, null, params);
        }
    } else {
        // no frame name parameter found, include the explorer file list
        getJsp().include(FILE_EXPLORER_FILELIST, null, params);
    }
}

From source file:org.openmrs.module.pihmalawi.web.taglibs.QuickProgramsTag.java

/**
 * @see javax.servlet.jsp.tagext.BodyTagSupport#doStartTag()
 *//*from  www . j a v a  2s  .  c  om*/
public int doStartTag() throws JspException {
    JspWriter o = pageContext.getOut();

    try {

        List<ProgramWorkflowState> states = getStates(stateIds);
        List<ProgramWorkflowState> initialStates = getStates(initialStateIds);
        List<ProgramWorkflowState> terminalStates = getStates(terminalStateIds);

        ProgramWorkflow programWorkflow = initialStates.get(0).getProgramWorkflow();
        Program program = programWorkflow.getProgram();
        Patient patient = Context.getPatientService().getPatient(patientId);

        PatientState currentState = null;
        if (currentPatientProgram(program, patient) != null) {
            currentState = currentPatientProgram(program, patient)
                    .getCurrentState(initialStates.get(0).getProgramWorkflow());
        }

        boolean quickProgramsAvailable = false;
        if (!patient.isDead()) {
            if (!hasOpenProgramWorkflow(programWorkflow, patient)) {
                // no or closed program enrollment available
                for (ProgramWorkflowState pws : initialStates) {
                    quickProgramsAvailable = true;
                    o.write(enrollForm(program, patient, pws));
                }
            } else {
                // open program enrollment available
                for (ProgramWorkflowState pws : states) {
                    if (!(currentState != null && currentState.getState().equals(pws))) {
                        quickProgramsAvailable = true;
                        o.write(changeToStateSubmitTag("Change", currentPatientProgram(program, patient),
                                pws.getProgramWorkflow(), pws, "'dateForPWS" + pws.getId() + "'") + " to "
                                + pws.getConcept().getName() + " on "
                                + dateTag("dateForPWS" + pws.getId(), "dateForPWS") + " at "
                                + currentPatientProgram(program, patient).getLocation().getName() + "<br/>");
                    }
                }
                for (ProgramWorkflowState pws : terminalStates) {
                    if (!(currentState != null && currentState.getState().equals(pws))) {
                        quickProgramsAvailable = true;
                        o.write(changeToStateSubmitTag("Complete", currentPatientProgram(program, patient),
                                pws.getProgramWorkflow(), pws, "'dateForPWS" + pws.getId() + "'") + " with "
                                + pws.getConcept().getName() + " on "
                                + dateTag("dateForPWS" + pws.getId(), "dateForPWS") + " at "
                                + currentPatientProgram(program, patient).getLocation().getName() + "<br/>");
                    }
                }
            }
        }
        if (!quickProgramsAvailable) {
            o.write("(not available)<br/>");
        }
    } catch (Throwable e) {
        try {
            o.write("Unknown error, call help!");
        } catch (IOException e1) {
        }
        log.error("Could not write to pageContext", e);
    }
    release();
    return SKIP_BODY;
}

From source file:org.posterita.pos.taglib.BPartnerSearchTag.java

public int doStartTag() throws JspException {
    JspWriter out = pageContext.getOut();
    bpartnerId = 0;/*from  w w w.  j a  va  2  s. com*/
    bpartnerValue = "";
    try {
        HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();

        Object form = request.getAttribute(name);

        if (form == null) {
            form = request.getSession().getAttribute(name);
        }

        String value = (String) BeanUtils.getSimpleProperty(form, property);
        if (value != null && value.trim().length() > 0) {
            bpartnerId = Integer.parseInt(value);
        }

        if (bpartnerId > 0) {
            MBPartner bPartner = new MBPartner(TmkJSPEnv.getCtx((HttpServletRequest) pageContext.getRequest()),
                    bpartnerId, null);
            bpartnerValue = bPartner.getName();
        }
    } catch (Exception ex) {
        log.log(Level.SEVERE, "Could not get value of BPartner", ex);
        bpartnerId = -1;
    }

    queryId = property + "Query";
    resultId = property + "SearchResult";

    input bpInput = new input();
    bpInput.setID(property);
    bpInput.setName(property);
    bpInput.setType(input.TYPE_HIDDEN);
    if (bpartnerId > 0) {
        bpInput.setValue(bpartnerId);
    }

    input queryInput = new input();
    queryInput.setType(input.TYPE_TEXT);
    queryInput.setID(queryId);
    queryInput.setValue(bpartnerValue);
    queryInput.setDisabled(disabled);
    queryInput.setSize(size);

    div resultDiv = new div();
    resultDiv.setID(resultId);
    resultDiv.setClass("autocomplete");

    div mainDiv = new div();
    mainDiv.addElement(bpInput);
    mainDiv.addElement(queryInput);
    mainDiv.addElement(resultDiv);
    mainDiv.addElement(getAjaxScript());

    try {
        out.write(mainDiv.toString());
    } catch (Exception ex) {
        throw new JspException(ex);
    }

    return SKIP_BODY;
}

From source file:org.rhq.enterprise.gui.legacy.taglib.Pagination.java

@Override
public final int doStartTag() throws JspException {
    HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
    JspWriter out = pageContext.getOut();

    if (pageList.size() == pageList.getTotalSize()) {
        return SKIP_BODY;
    }// ww w. j a  v a  2 s. com

    path = request.getContextPath();

    if (this.pageList.getPageControl() == null) {
        log.error("PageLists must have valid pageControls");
    }

    this.currentPage = this.pageList.getPageControl().getPageNumber() + 1;
    if (this.pageSize == PageControl.SIZE_UNLIMITED) {
        this.totalPages = 1;
    } else {
        this.totalPages = (int) Math
                .ceil((double) this.pageList.getTotalSize() / this.pageList.getPageControl().getPageSize());
    }

    this.pageSize = this.pageList.getPageControl().getPageSize();

    try {
        out.write(createPagination());
    } catch (Exception e) {
        throw new JspException("could not generate output ", e);
    }

    return SKIP_BODY;
}