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