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


Java Page类代码示例

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


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

示例1: toString

import org.jpublish.Page; //导入依赖的package包/类
/**
 * Return the rendered component.
 *
 * @return The renderered component string
 * @deprecated use renderText or renderPath instead
 */

public String toString() {
    try {
        Page page = (Page) context.get(JPublishContext.JPUBLISH_PAGE);
        return component.render(page.getPath(), context);
    } catch (Exception e) {
        log.error("Error rendering component " + component.getName());
        e.printStackTrace();
        return EMPTY_STRING;
    }
}
 
开发者ID:florinpatrascu,项目名称:jpublish,代码行数:18,代码来源:ComponentWrapper.java

示例2: execute

import org.jpublish.Page; //导入依赖的package包/类
/**
 * Execute the action using the given context.
 *
 * @param context       The current context
 * @param configuration The configuration
 * @throws Exception Any error
 */
public void execute(JPublishContext context, Configuration configuration) throws Exception {
    HttpServletRequest request = (HttpServletRequest) context.get("request");
    HttpServletResponse response = (HttpServletResponse) context.get("response");
    Page page = ((Page) context.get("page"));

    if (page != null) {
        Locale locale = page.getLocale();

        ApplicationContext applicationContext = getApplicationContext(context);
        context.put(SPRING, applicationContext);
        HandlerInterceptor localeChangeInterceptor = (HandlerInterceptor)
                applicationContext.getBean("localeChangeInterceptor");

        if (localeChangeInterceptor != null) {
            try {
                LocaleResolver localeResolver = (LocaleResolver) applicationContext.getBean("localeResolver");
                if (localeResolver != null) {
                    request.setAttribute(DispatcherServlet.LOCALE_RESOLVER_ATTRIBUTE, localeResolver);
                    localeChangeInterceptor.preHandle(request, response, null);
                    locale = localeResolver.resolveLocale(request);
                    MessageSource messageSource = (MessageSource) applicationContext.getBean("messageSource");
                    if (messageSource != null) {
                        context.put(I18N, new MessageSourceAccessor(messageSource, locale));
                    } else {
                        log.error("There is no 'messageSource' defined in your application context." +
                                " Please define one.");
                    }
                } else {
                    log.error("please define a 'localeResolver' bean in your Application context");
                }
            } catch (Exception e) {
                e.printStackTrace();
                log.error("Cannot handle the locale change event");
            }
        }
        page.setLocale(locale);
    }
}
 
开发者ID:florinpatrascu,项目名称:jpublish,代码行数:46,代码来源:SpringI18nSupport.java

示例3: renderTemplate

import org.jpublish.Page; //导入依赖的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


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