當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。