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


Java Template.put方法代码示例

本文整理汇总了Java中com.liferay.portal.kernel.template.Template.put方法的典型用法代码示例。如果您正苦于以下问题:Java Template.put方法的具体用法?Java Template.put怎么用?Java Template.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.liferay.portal.kernel.template.Template的用法示例。


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

示例1: transform

import com.liferay.portal.kernel.template.Template; //导入方法依赖的package包/类
/**
 * based on the example of com.liferay.portal.templateparser.Transformer
 *
 * @param contextObjects
 * @param script
 * @param langType
 * @return
 * @throws Exception
 */
public static String transform(Map<String, Object> contextObjects, String script, String templateId, String langType)
        throws Exception {

    if (Validator.isNull(langType)) {
        return null;
    }

    Template template = getTemplate(templateId, script, langType);

    UnsyncStringWriter unsyncStringWriter = new UnsyncStringWriter();

    try {

        if (contextObjects != null) {
            for (String key : contextObjects.keySet()) {
                template.put(key, contextObjects.get(key));
            }
        }

        mergeTemplate(template, unsyncStringWriter, true);

    } catch (Exception e) {
        _log.error(e);
        throw new TransformException("Unhandled exception", e);
    }

    return unsyncStringWriter.toString();
}
 
开发者ID:inofix,项目名称:ch-inofix-timetracker,代码行数:38,代码来源:TemplateUtil.java

示例2: writeTemplate

import com.liferay.portal.kernel.template.Template; //导入方法依赖的package包/类
/**
 * Writes the template's rendering in the portlet response
 *
 * @param request The request
 * @param response The response
 * @param ctx The template context
 * @param templateResourcePath The template to write
 *
 * @throws IOException Thrown if something goes wrong when writing the response
 * @throws TemplateException Thrown if something goes wrong when processing the template
 */
private void writeTemplate(RenderRequest request, RenderResponse response, Map<String, Object> ctx, String templateResourcePath) throws TemplateException, IOException {
    TemplateResource templateResource = this.templateResourceLoader.getTemplateResource(templateResourcePath);
    Template template = this.templateManager.getTemplate(templateResource, false);

    this.templateManager.addTaglibSupport(template, this.portal.getHttpServletRequest(request), this.portal.getHttpServletResponse(response));
    this.enrichTemplateContext(request, response, template);

    Set<Entry<String, Object>> contextObjects = ctx.entrySet();
    for(Entry<String, Object> obj : contextObjects) {
        template.put(obj.getKey(), obj.getValue());
    }

    template.processTemplate(response.getWriter());
}
 
开发者ID:savoirfairelinux,项目名称:flashlight-search,代码行数:26,代码来源:TemplatedPortlet.java

示例3: enrichTemplateContext

import com.liferay.portal.kernel.template.Template; //导入方法依赖的package包/类
/**
 * Puts commonly used variables in the template context
 * @param request The request
 * @param response The response
 * @param template The template
 */
private void enrichTemplateContext(RenderRequest request, RenderResponse response, Template template) {
    template.put(TemplateVariable.LOCALE.getVariableName(), request.getLocale());
    template.put(TemplateVariable.PORTLET_CONTEXT.getVariableName(), this.getPortletContext());
    template.put(TemplateVariable.REQUEST.getVariableName(), request);
    template.put(TemplateVariable.RESPONSE.getVariableName(), response);
    template.put(TemplateVariable.THEME_DISPLAY.getVariableName(), request.getAttribute(WebKeys.THEME_DISPLAY));
    template.put(TemplateVariable.USER_INFO.getVariableName(), request.getAttribute(PortletRequest.USER_INFO));
}
 
开发者ID:savoirfairelinux,项目名称:flashlight-search,代码行数:15,代码来源:TemplatedPortlet.java

示例4: render

import com.liferay.portal.kernel.template.Template; //导入方法依赖的package包/类
@Override
public String render(
	RenderRequest renderRequest, RenderResponse renderResponse) {

	if (_log.isDebugEnabled()) {
		_log.debug("ViewMVCRenderCommand.render()");
	}
		
	// Hide portlet if we are on the search page

	if (getCurrentFriendlyURL(renderRequest).equals(_gSearchConfiguration.searchPortletPage())) {
		renderRequest.setAttribute(WebKeys.PORTLET_CONFIGURATOR_VISIBILITY, false);
	}
	
	Template template =
		(Template) renderRequest.getAttribute(WebKeys.TEMPLATE);

	// Set namespace (a convenience alias for $id).

	String portletNamespace = renderResponse.getNamespace();
	template.put(GSearchMiniWebKeys.PORTLET_NAMESPACE, portletNamespace);

	// Autocomplete on/off.
	
	template.put(
		GSearchMiniWebKeys.AUTO_COMPLETE_ENABLED, 
		_gSearchConfiguration.enableAutoComplete());

	// Autocomplete request delay.
	
	template.put(
		GSearchMiniWebKeys.AUTO_COMPLETE_REQUEST_DELAY, 
		_gSearchConfiguration.autoCompleteRequestDelay());
	
	
	// Set request timeout.
	
	template.put(
		GSearchMiniWebKeys.REQUEST_TIMEOUT,
		_gSearchConfiguration.requestTimeout());
	
	// Set query min length.
	
	template.put(
		GSearchMiniWebKeys.QUERY_MIN_LENGTH,
		_gSearchConfiguration.queryMinLength());
			
	// Enable / disable JS console logging messages.
	
	template.put(
		GSearchMiniWebKeys.JS_DEBUG_ENABLED,
		_gSearchConfiguration.jsDebuggingEnabled());

	// Set search page url.

	template.put(
		GSearchMiniWebKeys.SEARCHPAGE_URL, _portal.getPortalURL(renderRequest) +
		  _gSearchConfiguration.searchPortletPage());
			
	// Set autocomplete/suggestions resource url.

	template.put(
		GSearchMiniWebKeys.SUGGESTIONS_URL,
		createResourceURL(renderResponse, GSearchMiniResourceKeys.GET_SUGGESTIONS));
	
	return "MiniView";
}
 
开发者ID:peerkar,项目名称:liferay-gsearch,代码行数:68,代码来源:ViewMVCRenderCommand.java


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