Example usage for javax.servlet.jsp JspException JspException

List of usage examples for javax.servlet.jsp JspException JspException

Introduction

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

Prototype

public JspException(String message, Throwable cause) 

Source Link

Document

Constructs a new JspException with the specified detail message and cause.

Usage

From source file:org.springmodules.validation.valang.javascript.taglib.ValangCodebaseTag.java

public int doEndTag() throws JspException {
    try {// www.  j a  v a2  s.  c o m
        JspWriter out = pageContext.getOut();
        if (includeScriptTags) {
            out.write("<script type=\"text/javascript\">\n");
        }
        copy(ValangJavaScriptTranslator.getCodebaseReader(), out);

        if (globalErrorsId != null) {
            out.write("ValangValidator.prototype.globalErrorsId = '" + globalErrorsId + "';\n");
        }
        if (fieldErrorIdSuffix != null) {
            out.write("ValangValidator.prototype.fieldErrorIdSuffix = '" + fieldErrorIdSuffix + "';\n");
        }
        if (logId != null) {
            out.write("ValangValidator.Logger.logId = '" + logId + "';\n");
        }
        if (includeScriptTags) {
            out.write("\n</script>");
        }
        return EVAL_PAGE;
    } catch (IOException e) {
        throw new JspException("Could not write validation codebase", e);
    }
}

From source file:org.lanark.jsr303js.taglib.JSR303JSValidateTag.java

public int doEndTag() throws JspException {
    try {/*from   w  w  w  . ja  v  a 2  s  .  co  m*/
        List<ValidationMetaData> rules = new ArrayList<ValidationMetaData>();
        if (commandName != null) {
            rules.addAll(getValidationMetaDataForCommand());
        }
        String bodyString = null;
        if (bodyContent != null) {
            // body can be a JSON object, specifying date formats, or other extra configuration info
            bodyString = FileCopyUtils.copyToString(bodyContent.getReader());
            bodyString = bodyString.trim().replaceAll("\\s{2,}", " ");
        }

        JspWriter out = pageContext.getOut();
        out.write("<script type=\"text/javascript\" id=\"");
        out.write(commandName + "JSR303JSValidator");
        out.write("\">");
        generator.generateJavaScript(out, commandName, true, bodyString, rules, new MessageSourceAccessor(
                getRequestContext().getWebApplicationContext(), getRequestContext().getLocale()));
        out.write("</script>");
        return EVAL_PAGE;
    } catch (IOException e) {
        throw new JspException("Could not write validation rules", e);
    }
}

From source file:de.micromata.genome.gwiki.web.tags.GWikiIncludeTag.java

@Override
public int doEndTag() throws JspException {

    GWikiElement el = null;/*from   w  w  w.java  2 s. co m*/
    GWikiArtefakt<?> art = null;
    GWikiContext ctx = null;
    GWikiWeb wikiWeb = GWikiWeb.getWiki();
    try {
        if (StringUtils.isEmpty(pageId) == true) {
            ctx = (GWikiContext) pageContext.getAttribute("wikiContext");
            if (ctx == null) {
                throw new RuntimeException("no wikiContext set in GWikiInclude tag with no given pageId");
            }
            el = ctx.getCurrentElement();
            art = getPart(el);
        } else {
            el = wikiWeb.getElement(pageId);
        }
        if (part != null) {
            art = el.getPart(part);
        }
        if (StringUtils.isNotEmpty(chunk) == true) {
            if (part == null && art == null) {
                art = getPart(el);
            }
            if ((art instanceof GWikiWikiPageArtefakt) == false) {
                throw new RuntimeException("Including section, Part is not wiki page");
            }
            GWikiWikiPageArtefakt wpa = (GWikiWikiPageArtefakt) art;
            if (ctx != null) {
                wpa.renderChunk(ctx, chunk);
            } else {
                GWikiStandaloneContext sactx = GWikiStandaloneContext.create();
                // GWikiContext ctx = new GWikiContext(wikiWeb, servlet, request, response)
                wpa.renderChunk(sactx, chunk);
                String outt = sactx.getOutString();
                pageContext.getOut().append(outt);

            }
        } else {
            if (art == null) {
                pageContext.include(wikiWeb.getServletPath() + "/" + pageId);
            } else {
                if ((art instanceof GWikiExecutableArtefakt<?>) == false) {
                    throw new RuntimeException(
                            "Cannot render part because not a executable: " + art + " in page " + pageId);
                }
                GWikiExecutableArtefakt<?> exec = (GWikiExecutableArtefakt<?>) art;
                GWikiStandaloneContext sactx = GWikiStandaloneContext.create();
                exec.render(sactx);
                String outt = sactx.getOutString();
                pageContext.getOut().append(outt);
            }
        }
    } catch (ServletException e) {
        throw new JspException("Servlet exception wile rendering gwiki:include: " + e.getMessage(), e);
    } catch (IOException e) {
        throw new JspException("IO error wile rendering gwiki:include: " + e.getMessage(), e);
    }
    return super.doEndTag();
}

From source file:com.agiletec.aps.tags.ExecWidgetTag.java

protected void buildWidgetOutput(IPage page, String[] widgetOutput) throws JspException {
    ServletRequest req = this.pageContext.getRequest();
    RequestContext reqCtx = (RequestContext) req.getAttribute(RequestContext.REQCTX);
    try {/* www .j  av  a2s. co  m*/
        List<IFrameDecoratorContainer> decorators = this.extractDecorators();
        BodyContent body = this.pageContext.pushBody();
        Widget[] widgets = page.getWidgets();
        for (int frame = 0; frame < widgets.length; frame++) {
            reqCtx.addExtraParam(SystemConstants.EXTRAPAR_CURRENT_FRAME, new Integer(frame));
            Widget widget = widgets[frame];
            body.clearBody();
            this.includeWidget(reqCtx, widget, decorators);
            widgetOutput[frame] = body.getString();
        }
    } catch (Throwable t) {
        String msg = "Error detected during widget preprocessing";
        throw new JspException(msg, t);
    }
}

From source file:kr.co.skysoft.framework.taglib.JSR303JSCodebaseTag.java

public int doEndTag() throws JspException {
    try {/*www . j a  va 2s.c  o  m*/
        JspWriter out = pageContext.getOut();
        if (includeScriptTags) {
            out.write("<script type=\"text/javascript\">\n");
        }
        if (globalErrorsId != null) {
            out.write("var tlGlobalErrorsId = '" + globalErrorsId + "';\n");
        }
        if (fieldErrorsIdSuffix != null) {
            out.write("var tlFieldErrorIdSuffix = '" + fieldErrorsIdSuffix + "';\n");
        }
        copy(getCodebaseReader(), out);
        if (includeScriptTags) {
            out.write("\n</script>");
        }
        return EVAL_PAGE;
    } catch (IOException e) {
        throw new JspException("Could not write validation codebase", e);
    }
}

From source file:kr.co.skysoft.framework.taglib.JSR303JSValidateTag.java

public int doEndTag() throws JspException {
    try {/*  w  w w  .  j av  a 2s.  c  o m*/
        List<ValidationMetaData> rules = new ArrayList<ValidationMetaData>();
        if (commandName != null) {
            rules.addAll(getValidationMetaDataForCommand());
            this.addValidVOs(rules);

        }
        String bodyString = null;
        if (bodyContent != null) {
            // body can be a JSON object, specifying date formats, or other extra configuration info
            bodyString = FileCopyUtils.copyToString(bodyContent.getReader());
            bodyString = bodyString.trim().replaceAll("\\s{2,}", " ");
        }

        JspWriter out = pageContext.getOut();
        out.write("<script type=\"text/javascript\" id=\"");
        out.write(commandName + "JSR303JSValidator");
        out.write("\">");
        generator.generateJavaScript(out, commandName, true, bodyString, rules, new MessageSourceAccessor(
                getRequestContext().getWebApplicationContext(), getRequestContext().getLocale()));
        out.write("</script>");
        return EVAL_PAGE;
    } catch (IOException e) {
        throw new JspException("Could not write validation rules", e);
    }
}

From source file:org.springmodules.validation.valang.javascript.taglib.ValangValidateTag.java

protected Collection parseRulesFromBodyContent() throws JspException {
    try {/*from   w w  w .j a v  a 2s.  c o  m*/
        return new ValangParser(bodyContent.getReader()).parseValidation();
    } catch (ParseException e) {
        throw new JspException("Could not parse valang", e);
    }
}

From source file:org.springmodules.validation.bean.annotation.javascript.taglib.BeanAnnotationValidateTag.java

public int doEndTag() throws JspException {
    if (cotvc == null) {
        findConverter();/*from   w w w .  jav  a 2  s.c o  m*/
    }
    try {
        if (commandObj == null) { // favour commandObj over command name
            commandObj = this.pageContext.getAttribute(commandName, PageContext.REQUEST_SCOPE);
            if (commandName == null || commandObj == null) {
                logger.error("Command object not found");
                return EVAL_PAGE;
            }
        }
        JspWriter out = pageContext.getOut();
        Locale locale = getRequestContext().getLocale();
        WebApplicationContext webApplicationContext = getRequestContext().getWebApplicationContext();
        MessageSourceAccessor messages = new MessageSourceAccessor(webApplicationContext, locale);

        out.write("<script type=\"text/javascript\" id=\"" + commandName + "ValangValidator\">\n");
        cotvc.writeJS(commandName, commandObj, globalVar, validateOnSubmit, out, messages);
        out.write("\n</script>");

        return EVAL_PAGE;

    } catch (IOException e) {
        throw new JspException("Could not write validation rules", e);
    }
}

From source file:net.jcreate.e3.tree.taglib.TreeTag.java

public int doEndTag() throws JspException {
    TreeModel treeModel = NodeUtils.convert(this.nodes, this.idParentIds);
    WebTreeBuilder treeBuilder = BuilderFactory.getInstance(this.builder);
    WebContext context = new JspPageWebContext(this.pageContext);
    System.out.println("context path=" + context.getContextPath());
    treeBuilder.init(context);/*from  w  w w  .  java 2 s  . c  o m*/
    java.util.Iterator keys = dynamicAttributes.keySet().iterator();
    while (keys.hasNext()) {
        Object key = keys.next();
        Object value = dynamicAttributes.get(key);
        this.setProperty(treeBuilder, (String) key, value);
    }
    /**
     * @todo: ???TreeDirector
     */
    TreeDirector director = new DefaultTreeDirector();
    director.setComparator(getRealComparator());
    if (visitor != null) {
        director.setNodeVisitor(visitor);
    }
    director.build(treeModel, treeBuilder);
    String treeScript = treeBuilder.getTreeScript();
    JspWriter writer = this.pageContext.getOut();
    cleanUp();
    try {
        writer.print(treeScript);
    } catch (IOException e) {
        e.printStackTrace();
        throw new JspException(e.getMessage(), e);
    }
    return super.doEndTag();
}

From source file:com.agiletec.plugins.jpmyportalplus.aps.tags.CustomizableWidgetsTag.java

@Override
public int doStartTag() throws JspException {
    RequestContext reqCtx = (RequestContext) this.pageContext.getRequest().getAttribute(RequestContext.REQCTX);
    List<WidgetCheckInfo> checkInfos = new ArrayList<WidgetCheckInfo>();
    IPageUserConfigManager pageUserConfigManager = (IPageUserConfigManager) ApsWebApplicationUtils
            .getBean(JpmyportalplusSystemConstants.PAGE_USER_CONFIG_MANAGER, pageContext);
    IMyPortalPageModelManager myportalModelConfigManager = (IMyPortalPageModelManager) ApsWebApplicationUtils
            .getBean(JpmyportalplusSystemConstants.MYPORTAL_MODEL_CONFIG_MANAGER, this.pageContext);
    try {//from  w  w w  .  j  a v  a  2s  .  com
        Lang currentLang = (Lang) this.pageContext.getSession()
                .getAttribute(JpmyportalplusSystemConstants.SESSIONPARAM_CURRENT_LANG);
        IPage currentPage = (IPage) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_PAGE);
        Widget[] customShowletConfig = this.getCustomShowletConfig(currentPage);
        Widget[] showletsToRender = pageUserConfigManager.getShowletsToRender(currentPage, customShowletConfig);
        List<String> allowedShowlets = new ArrayList<String>();
        Map<String, WidgetType> customizableShowlets = this.getCustomizableShowlets(pageUserConfigManager);
        allowedShowlets.addAll(customizableShowlets.keySet());
        Map<Integer, MyPortalFrameConfig> modelConfig = myportalModelConfigManager
                .getPageModelConfig(currentPage.getModel().getCode());
        Frame[] frames = currentPage.getModel().getConfiguration();
        for (int i = 0; i < frames.length; i++) {
            //Frame frame = frames[i];
            MyPortalFrameConfig frameConfig = (null != modelConfig) ? modelConfig.get(i) : null;
            if (null != frameConfig && !frameConfig.isLocked()) {
                Widget showlet = showletsToRender[i];
                if (null != showlet && allowedShowlets.contains(showlet.getType().getCode())) {
                    WidgetCheckInfo info = new WidgetCheckInfo(showlet.getType(), true, currentLang);
                    allowedShowlets.remove(showlet.getType().getCode());
                    checkInfos.add(info);
                }
            }
        }
        for (int i = 0; i < allowedShowlets.size(); i++) {
            String code = allowedShowlets.get(i);
            WidgetType type = customizableShowlets.get(code);
            WidgetCheckInfo info = new WidgetCheckInfo(type, false, currentLang);
            checkInfos.add(info);
        }
        BeanComparator comparator = new BeanComparator("title");
        Collections.sort(checkInfos, comparator);
        this.pageContext.setAttribute(this.getVar(), checkInfos);
    } catch (Throwable t) {
        _logger.error("error in doStartTag", t);
        throw new JspException("Error on doStartTag", t);
    }
    return super.doStartTag();
}