当前位置: 首页>>代码示例>>Java>>正文


Java ViewRenderException类代码示例

本文整理汇总了Java中org.jpublish.view.ViewRenderException的典型用法代码示例。如果您正苦于以下问题:Java ViewRenderException类的具体用法?Java ViewRenderException怎么用?Java ViewRenderException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ViewRenderException类属于org.jpublish.view包,在下文中一共展示了ViewRenderException类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: render

import org.jpublish.view.ViewRenderException; //导入依赖的package包/类
/**
 * Render the haml template
 *
 * @param context The JPublishContext
 * @param path    The path to the template
 * @param in      The Reader to read view template from
 * @param out     The Writer to write the rendered view
 * @throws java.io.IOException
 * @throws org.jpublish.view.ViewRenderException
 *
 */
public void render(JPublishContext context, String path, Reader in,
                   Writer out) throws IOException, ViewRenderException {

    String template = FileCopyUtils.copyToString(in); //faster than processing the Reader inside the script
    // thread safe, right?? Promise??
    Object keys[] = context.getKeys(); // the keys must be Strings only

    // transfer the JPublish context to JRuby
    for (Object key : keys) {
        container.put($ + key, context.get((String) key));
    }

    container.put($CONTEXT, context); // pass our jpublish context too
    container.put($HAML_TEMPLATE_KEY, template); // put our template too

    try {
        FileCopyUtils.copy(haml_rb_unit.run().asJavaString(), out); //send it
        container.clear();
    } catch (EvalFailedException e) {
        FileCopyUtils.copy(String.format("[EvalFailedException] %s", e.getMessage()), out);
        e.printStackTrace(); //will be disabled in the final version
    }
}
 
开发者ID:florinpatrascu,项目名称:jpublish,代码行数:35,代码来源:HamlViewRenderer.java

示例2: renderTemplate

import org.jpublish.view.ViewRenderException; //导入依赖的package包/类
private void renderTemplate(JPublishContext context, Page page, Writer out) throws IOException, ViewRenderException {
    context.disableCheckReservedNames(this);
    context.put("page", page);
    if (siteContext.isProtectReservedNames()) {
        context.enableCheckReservedNames(this);
    }
    try {
        Debug.logInfo("Merging template", module);
        Template template = siteContext.getTemplateManager().getTemplate(page.getFullTemplateName());
        template.merge(context, page, out);
    } catch (Exception e) {
        throw new ViewRenderException(e);
    }
}
 
开发者ID:gildaslemoal,项目名称:elpi,代码行数:15,代码来源:GenericViewRenderer.java

示例3: createViewContext

import org.jpublish.view.ViewRenderException; //导入依赖的package包/类
protected Object createViewContext(JPublishContext context, String path) throws ViewRenderException {
    HttpServletRequest request = context.getRequest();
    HttpServletResponse response = context.getResponse();

    WrappingTemplateModel.setDefaultObjectWrapper(FreeMarkerWorker.getDefaultOfbizWrapper());
    Map contextMap = new HashMap();
    SimpleHash root = new SimpleHash(FreeMarkerWorker.getDefaultOfbizWrapper());
    try {
        Object[] keys = context.getKeys();
        for (int i = 0; i < keys.length; i++) {
            String key = (String) keys[i];
            Object value = context.get(key);
            if (value != null) {
                contextMap.put(key, value);
                //no longer wrapping; let FM do it if needed, more efficient
                //root.put(key, FreeMarkerWorker.getDefaultOfbizWrapper().wrap(value));
                root.put(key, value);
            }
        }
        root.put("context", FreeMarkerWorker.getDefaultOfbizWrapper().wrap(contextMap));
        root.put("cachedInclude", new JpCacheIncludeTransform()); // only adding this in for JP!
        //root.put("jpublishContext", FreeMarkerWorker.getDefaultOfbizWrapper().wrap(context));
        FreeMarkerViewHandler.prepOfbizRoot(root, request, response);
    } catch (Exception e) {
        throw new ViewRenderException(e);
    }
    return root;
}
 
开发者ID:gildaslemoal,项目名称:elpi,代码行数:29,代码来源:FreeMarkerViewRenderer.java

示例4: render

import org.jpublish.view.ViewRenderException; //导入依赖的package包/类
/**
 * Render the view.
 *
 * @param context The JPublishContext
 * @param path    The path to the template
 * @param in      The Reader to read view template from
 * @param out     The Writer to write the rendered view
 * @throws java.io.IOException
 * @throws org.jpublish.view.ViewRenderException
 *
 */
public void render(JPublishContext context, String path, Reader in, Writer out)
        throws ViewRenderException, IOException {

    CharacterEncodingMap characterEncodingMap = siteContext.getCharacterEncodingManager().getMap(path);
    String encoding = characterEncodingMap.getPageEncoding();

    if (!initialized) {
        preInit();
        initialized = true;
    }

    if (log.isDebugEnabled()) {
        log.debug("render(" + path + ")");
        log.debug("Character encoding: " + encoding);
    }

    Map model = new HashMap();
    Object[] keys = context.getKeys();
    for (int i = 0; i < keys.length; i++) {
        String key = (String) keys[i];
        model.put(key, context.get(key));
    }

    String stgName = TEMPLATE_PROTOCOL_NAME;
    String stPath = EMPTY_STRING;

    try {
        InternalURI uri = InternalURIParser.getInstance().parse(path);
        String protocol = uri.getProtocol();

        if (protocol.equalsIgnoreCase(TEMPLATE_PROTOCOL_NAME)) {
            // nothing for now
        } else if (protocol.equalsIgnoreCase("repository")) {
            stgName = ((RepositoryURI) uri).getRepositoryName();
        } else {
            throw new Exception("Protocol " + protocol + " not supported");
        }

        stPath = uri.getPath();
        int delim = stPath.indexOf(".");
        if (delim >= 0) {
            stPath = stPath.substring(0, delim);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    StringTemplateGroup stg = (StringTemplateGroup) stGroups.get(stgName);
    StringTemplate st = stg.getInstanceOf(stPath, model);
    FileCopyUtils.copy(st.toString(), out);
}
 
开发者ID:florinpatrascu,项目名称:jpublish,代码行数:63,代码来源:StringTemplateViewRenderer.java

示例5: render

import org.jpublish.view.ViewRenderException; //导入依赖的package包/类
/**
 * @see org.jpublish.view.ViewRenderer#render(org.jpublish.JPublishContext, java.io.InputStream, java.io.OutputStream)
 */
public void render(JPublishContext context, String path, InputStream in, OutputStream out) throws IOException, ViewRenderException {
    render(context, path, new InputStreamReader(in), new OutputStreamWriter(out));
}
 
开发者ID:gildaslemoal,项目名称:elpi,代码行数:7,代码来源:GenericViewRenderer.java

示例6: createViewContext

import org.jpublish.view.ViewRenderException; //导入依赖的package包/类
/** Create the 'root' context for the template engine.  This method can be
    overridden in subclasses in case the viewContext needs to be populated
    with additional values.  The default implementation wraps the existing
    JPublishContext in a class which is useable by FreeMarker.

    @param context The JPublishContext
    @param path The path to the template
    @return Object The 'root' template context
    @throws ViewRenderException
*/

protected Object createViewContext(JPublishContext context, 
String path) throws ViewRenderException{
    FreeMarkerViewContext viewContext =
        new FreeMarkerViewContext(context);
    return viewContext;
}
 
开发者ID:florinpatrascu,项目名称:jpublish,代码行数:18,代码来源:FreeMarkerViewRenderer.java

示例7: render

import org.jpublish.view.ViewRenderException; //导入依赖的package包/类
/** Render the view.

    @param context The JPublishContext
    @param path The path to the template
    @param in The Reader to read view template from
    @param out The Writer to write the rendered view
    @throws IOException 
    @throws ViewRenderException
*/

public void render(JPublishContext context, String path, Reader in, 
Writer out) throws IOException, ViewRenderException{
    int c = -1;
    while((c = in.read()) != -1){
        out.write((char)c);
    }
}
 
开发者ID:florinpatrascu,项目名称:jpublish,代码行数:18,代码来源:RawViewRenderer.java

示例8: render

import org.jpublish.view.ViewRenderException; //导入依赖的package包/类
/** Render the view.

    @param context The JPublishContext
    @param path The path to the template
    @param in The InputStream to read view template from
    @param out The OutputStream to write the rendered view
    @throws IOException 
    @throws ViewRenderException
*/

public void render(JPublishContext context, String path, InputStream in, 
OutputStream out) throws IOException, ViewRenderException{
    render(context, path, new InputStreamReader(in), 
        new OutputStreamWriter(out));
}
 
开发者ID:florinpatrascu,项目名称:jpublish,代码行数:16,代码来源:FreeMarkerViewRenderer.java

示例9: render

import org.jpublish.view.ViewRenderException; //导入依赖的package包/类
/**
 * Render the view.
 *
 * @param context The JPublishContext
 * @param path    The path to the template
 * @param in      The InputStream to read view template from
 * @param out     The OutputStream to write the rendered view
 * @throws IOException
 * @throws ViewRenderException
 */

public void render(JPublishContext context, String path, InputStream in, OutputStream out)
        throws IOException, ViewRenderException {

    render(context, path, new InputStreamReader(in), new OutputStreamWriter(out));
}
 
开发者ID:florinpatrascu,项目名称:jpublish,代码行数:17,代码来源:VelocityViewRenderer.java


注:本文中的org.jpublish.view.ViewRenderException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。