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


Java ViewRenderer类代码示例

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


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

示例1: get

import org.jpublish.view.ViewRenderer; //导入依赖的package包/类
/** Get the content from the given path and merge it with
    the given context.
    
    @param path The content path
    @param context The current context
    @return The content as a String
    @throws Exception Any Exception
*/

public String get(String path, JPublishContext context) throws Exception{
    if(log.isDebugEnabled())
        log.debug("Getting dynamic content element for path " + path);
    
    StringWriter writer = null;
    StringReader reader = null;
    
    try{
        writer = new StringWriter();
        reader = new StringReader(get(path));
        
        String name = PathUtilities.makeRepositoryURI(getName(), path);
        ViewRenderer renderer = siteContext.getViewRenderer();
        renderer.render(context, name, reader, writer);
        
        return writer.toString();
    } finally {
        IOUtilities.close(writer);
        IOUtilities.close(reader);
    }
}
 
开发者ID:florinpatrascu,项目名称:jpublish,代码行数:31,代码来源:ServletContextRepository.java

示例2: merge

import org.jpublish.view.ViewRenderer; //导入依赖的package包/类
/**
 * Merge the given page with the template.
 *
 * @param context The current context
 * @param page    The page
 * @param out     The OutputStream
 * @throws TemplateMergeException Exception while merging the template
 *                                and the page.
 */

public void merge(JPublishContext context, Page page, Writer out)
        throws TemplateMergeException {
    Reader reader = null;
    try {
        executeActions(context);

        CharacterEncodingMap characterEncodingMap = (CharacterEncodingMap) context.get("characterEncodingMap");
        String templateEncoding = characterEncodingMap.getTemplateEncoding();

        String path = PathUtilities.makeTemplateURI(getPath());
        ViewRenderer renderer = siteContext.getViewRenderer();
        reader = getReader(templateEncoding);
        renderer.render(context, path, reader, out);

        if (log.isDebugEnabled()) {
            log.debug("Merge complete.");
        }

    } catch (Exception e) {
        throw new TemplateMergeException(e.getMessage(), e);
    } finally {
        IOUtilities.close(reader);
    }
}
 
开发者ID:florinpatrascu,项目名称:jpublish,代码行数:35,代码来源:Template.java

示例3: loadCustom

import org.jpublish.view.ViewRenderer; //导入依赖的package包/类
private void loadCustom() throws Exception {
    ClassLoader cl = Thread.currentThread().getContextClassLoader();
    InputStream in = new FileInputStream(siteContext.getConfigurationFile());
    Configuration configuration = new XMLConfiguration(in);

    Iterator renderElements = configuration.getChildren("page-renderer").iterator();
    while (renderElements.hasNext()) {
        Configuration viewRendererConfiguration = (Configuration) renderElements.next();
        String renderName = viewRendererConfiguration.getAttribute("name");
        String className = viewRendererConfiguration.getAttribute("classname");
        ViewRenderer renderer = (ViewRenderer) cl.loadClass(className).newInstance();
        renderer.setSiteContext(siteContext);
        renderer.loadConfiguration(viewRendererConfiguration);
        renderer.init();
        Debug.logInfo("Added renderer [" + renderName + "] - [" + className + "]", module);
        renderers.put(renderName, renderer);
    }
}
 
开发者ID:gildaslemoal,项目名称:elpi,代码行数:19,代码来源:GenericViewRenderer.java

示例4: get

import org.jpublish.view.ViewRenderer; //导入依赖的package包/类
/**
 * Get the content from the given path and merge it with
 * the given context.
 *
 * @param path    The content path
 * @param context The current context
 * @return The content as a String
 * @throws Exception Any Exception
 */

public String get(String path, JPublishContext context) throws Exception {
    if (log.isDebugEnabled())
        log.debug("Getting dynamic content element for path " + path);

    StringWriter writer = null;
    BufferedReader reader = null;
    Reader in = null;

    try {
        in = new StringReader(loadContent(path));
        reader = new BufferedReader(in);
        writer = new StringWriter();

        String name = PathUtilities.makeRepositoryURI(getName(), path);
        ViewRenderer renderer = siteContext.getViewRenderer();
        renderer.render(context, name, reader, writer);

        return writer.toString();
    } catch (FileNotFoundException e) {
        log.error(e.getMessage());
        throw new FileNotFoundException("File not found: " + path);
    } finally {
        IOUtilities.close(reader);
        IOUtilities.close(writer);
        IOUtilities.close(in);
    }
}
 
开发者ID:florinpatrascu,项目名称:jpublish,代码行数:38,代码来源:FileSystemRepository.java

示例5: get

import org.jpublish.view.ViewRenderer; //导入依赖的package包/类
/**
 * Get the content from the given path and merge it with the given
 * context.  Any actions attached to the content will be executed
 * first.
 *
 * @param path    The content path
 * @param context The current context
 * @return The content as a String
 * @throws Exception Any Exception
 */

public String get(String path, JPublishContext context) throws Exception {
    UtilTimerStack.push( " ==> /"+path);
    executeActions(path, context);

    if (log.isDebugEnabled())
        log.debug("Getting dynamic content element for path " + path);

    StringWriter writer = null;
    BufferedReader reader = null;
    Reader in = null;

    try {

        in = new StringReader(loadContent(path));
        reader = new BufferedReader(in);
        writer = new StringWriter();
        String name = PathUtilities.makeRepositoryURI(getName(), path);
        ViewRenderer renderer = siteContext.getViewRenderer();

        renderer.render(context, name, reader, writer);

        return writer.toString();

    } catch (FileNotFoundException e) {
        log.error(e.getMessage());
        throw new FileNotFoundException("File not found: " + path);
    } finally {
        IOUtilities.close(in);
        IOUtilities.close(reader);
        IOUtilities.close(writer);
        UtilTimerStack.pop( " ==> /"+path);
    }
}
 
开发者ID:florinpatrascu,项目名称:jpublish,代码行数:45,代码来源:ExtendedFileSystemRepository.java

示例6: renderView

import org.jpublish.view.ViewRenderer; //导入依赖的package包/类
/**
 * Internal method which can be used by subclasses to pass the view through
 * the component's view renderer.
 *
 * @param text    The raw view
 * @param context The context
 * @param path    render the View at the given path
 * @return The merged view
 * @throws Exception if errors are encountered at the rendering process time
 */

protected String renderView(String text, String path, JPublishContext context)
        throws Exception {

    ViewRenderer viewRenderer = getViewRenderer();
    StringWriter out = new StringWriter();
    viewRenderer.render(context, path, new StringReader(text), out);
    return out.toString();
}
 
开发者ID:florinpatrascu,项目名称:jpublish,代码行数:20,代码来源:AbstractComponent.java

示例7: getViewRenderer

import org.jpublish.view.ViewRenderer; //导入依赖的package包/类
/**
 * Get the site's ViewRenderer which is used to render content.
 *
 * @return The ViewRenderer
 */

public ViewRenderer getViewRenderer() {
    return viewRenderer;
}
 
开发者ID:florinpatrascu,项目名称:jpublish,代码行数:10,代码来源:SiteContext.java

示例8: getViewRenderer

import org.jpublish.view.ViewRenderer; //导入依赖的package包/类
/**
 * Get the component's view renderer.  This method may return
 * null which indicates that the component should use the default
 * view renderer specified in the SiteContext.
 *
 * @return The view renderer
 */
public ViewRenderer getViewRenderer() {
    return viewRenderer;
}
 
开发者ID:florinpatrascu,项目名称:jpublish,代码行数:11,代码来源:AbstractComponent.java

示例9: setViewRenderer

import org.jpublish.view.ViewRenderer; //导入依赖的package包/类
/**
 * Set the component's view renderer.  Set the value to null
 * to indicate that the component should use the default
 * view renderer specified in the SiteContext.
 *
 * @param viewRenderer The new view renderer
 */
public void setViewRenderer(ViewRenderer viewRenderer) {
    this.viewRenderer = viewRenderer;
}
 
开发者ID:florinpatrascu,项目名称:jpublish,代码行数:11,代码来源:AbstractComponent.java

示例10: getViewRenderer

import org.jpublish.view.ViewRenderer; //导入依赖的package包/类
/**
 * Get the component's view renderer.  This method may return
 * null which indicates that the component should use the default
 * view renderer specified in the SiteContext.
 *
 * @return The view renderer
 */

public ViewRenderer getViewRenderer();
 
开发者ID:florinpatrascu,项目名称:jpublish,代码行数:10,代码来源:JPublishComponent.java

示例11: setViewRenderer

import org.jpublish.view.ViewRenderer; //导入依赖的package包/类
/**
 * Set the component's view renderer.  Set the value to null
 * to indicate that the component should use the default
 * view renderer specified in the SiteContext.
 *
 * @param viewRenderer The new view renderer
 */

public void setViewRenderer(ViewRenderer viewRenderer);
 
开发者ID:florinpatrascu,项目名称:jpublish,代码行数:10,代码来源:JPublishComponent.java


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