當前位置: 首頁>>代碼示例>>Java>>正文


Java Environment.getOut方法代碼示例

本文整理匯總了Java中freemarker.core.Environment.getOut方法的典型用法代碼示例。如果您正苦於以下問題:Java Environment.getOut方法的具體用法?Java Environment.getOut怎麽用?Java Environment.getOut使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在freemarker.core.Environment的用法示例。


在下文中一共展示了Environment.getOut方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: execute

import freemarker.core.Environment; //導入方法依賴的package包/類
@SuppressWarnings({ "unchecked", "rawtypes" })
public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException {
	AdPosition adPosition;
	Long id = getId(params);
	boolean useCache = useCache(env, params);
	String cacheRegion = getCacheRegion(env, params);
	if (useCache) {
		adPosition = adPositionService.find(id, cacheRegion);
	} else {
		adPosition = adPositionService.find(id);
	}
	if (body != null) {
		setLocalVariable(VARIABLE_NAME, adPosition, env, body);
	} else {
		if (adPosition != null && adPosition.getTemplate() != null) {
			try {
				Map<String, Object> model = new HashMap<String, Object>();
				model.put(VARIABLE_NAME, adPosition);
				Writer out = env.getOut();
				new Template("adTemplate", new StringReader(adPosition.getTemplate()), freeMarkerConfigurer.getConfiguration()).process(model, out);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}
}
 
開發者ID:justinbaby,項目名稱:my-paper,代碼行數:27,代碼來源:AdPositionDirective.java

示例2: execute

import freemarker.core.Environment; //導入方法依賴的package包/類
/**
 * @see freemarker.template.TemplateDirectiveModel#execute(freemarker.core.Environment,
 *      java.util.Map, freemarker.template.TemplateModel[],
 *      freemarker.template.TemplateDirectiveBody)
 */
@SuppressWarnings("rawtypes")
@Override
public void execute(Environment env, Map argsUntyped, TemplateModel[] loopVars, TemplateDirectiveBody body)
        throws TemplateException, IOException {
    String output = makeLinkFromFtl(env, UtilGenerics.<String, TemplateModel>checkMap(argsUntyped), loopVars, body);
    Writer out = env.getOut();
    if (output != null) out.write(output);
}
 
開發者ID:ilscipio,項目名稱:scipio-erp,代碼行數:14,代碼來源:PageLinkDirective.java

示例3: getWriterFromEnvironment

import freemarker.core.Environment; //導入方法依賴的package包/類
public static Appendable getWriterFromEnvironment(Environment env) {
    if (env != null) {
        Writer out = env.getOut();
        if (out != null) {
            return out;
        }
    }
    return null;
}
 
開發者ID:ilscipio,項目名稱:scipio-erp,代碼行數:10,代碼來源:FtlContextFetcher.java

示例4: executeTyped

import freemarker.core.Environment; //導入方法依賴的package包/類
protected void executeTyped(Environment env, Map<String, TemplateModel> params, TemplateModel[] loopVars, TemplateDirectiveBody body)
        throws TemplateException, IOException {
    Writer writer = env.getOut();
    
    // NOTE: this can only work if we already had a RenderWriter. 
    // if not, don't even bother trying.
    if (writer instanceof RenderWriter) {
        Map<String, Object> context = ContextFtlUtil.getContext(env);
        WidgetRenderTargetState renderTargetState = WidgetRenderTargetExpr.getRenderTargetState(context);
        if (renderTargetState.isEnabled()) {
            String name = TransformUtil.getStringNonEscapingArg(params, "name");
            String containsExpr = TransformUtil.getStringNonEscapingArg(params, "contains");
            String location = "unknown-location"; // FIXME
            ModelFtlWidget widget = new ModelVirtualSectionFtlWidget(name, location, containsExpr);
            
            WidgetRenderTargetState.ExecutionInfo execInfo = renderTargetState.handleShouldExecute(widget, writer, context, null);
            if (!execInfo.shouldExecute()) {
                return;
            }
            try {
                if (body != null) {
                    body.render((Writer) execInfo.getWriterForElementRender());
                }
            } finally {
                execInfo.handleFinished(context); // SCIPIO: return logic
            }
            return;
        }
    }
    
    body.render(writer);
}
 
開發者ID:ilscipio,項目名稱:scipio-erp,代碼行數:33,代碼來源:VirtualSectionDirective.java

示例5: executeGenerics

import freemarker.core.Environment; //導入方法依賴的package包/類
public void executeGenerics(Environment env, Map<String, TemplateModel> params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException {
	List<String> args = params.entrySet().stream()
			.map(this::mapArgKeys)
			.collect(Collectors.toList());

	final ViewFunctionParams vfParams = new ViewFunctionParams().name( name ).args( args ).portalRequest( this.portalRequest );

	Writer out = env.getOut();
	out.append(this.viewFunctionService.execute( vfParams ).toString());
	out.close();
}
 
開發者ID:tineikt,項目名稱:xp-lib-freemarker,代碼行數:12,代碼來源:PortalViewFunction.java

示例6: execute

import freemarker.core.Environment; //導入方法依賴的package包/類
@SuppressWarnings("rawtypes")
public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException {
	Member currentMember = memberService.getCurrent();
	if (body != null) {
		setLocalVariable(VARIABLE_NAME, currentMember, env, body);
	} else {
		if (currentMember != null) {
			Writer out = env.getOut();
			out.write(currentMember.getUsername());
		}
	}
}
 
開發者ID:justinbaby,項目名稱:my-paper,代碼行數:13,代碼來源:CurrentMemberDirective.java

示例7: execute

import freemarker.core.Environment; //導入方法依賴的package包/類
@SuppressWarnings("rawtypes")
public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException {
	RequestAttributes requestAttributes = RequestContextHolder.currentRequestAttributes();
	if (requestAttributes != null) {
		Message message = (Message) requestAttributes.getAttribute(FLASH_MESSAGE_ATTRIBUTE_NAME, RequestAttributes.SCOPE_REQUEST);
		if (body != null) {
			setLocalVariable(VARIABLE_NAME, message, env, body);
		} else {
			if (message != null) {
				Writer out = env.getOut();
				out.write("$.message(\"" + message.getType() + "\", \"" + message.getContent() + "\");");
			}
		}
	}
}
 
開發者ID:justinbaby,項目名稱:my-paper,代碼行數:16,代碼來源:FlashMessageDirective.java

示例8: execute

import freemarker.core.Environment; //導入方法依賴的package包/類
@Override
@SuppressWarnings("unchecked")
public void execute(Environment env, @SuppressWarnings("rawtypes") Map params, TemplateModel[] loopVars,
	TemplateDirectiveBody body) throws TemplateException, IOException
{
	Object section = params.get("section"); //$NON-NLS-1$
	if( section == null )
	{
		throw new SectionsRuntimeException("Section is null"); //$NON-NLS-1$
	}
	if( section instanceof AdapterTemplateModel )
	{
		Object wrapped = ((AdapterTemplateModel) section).getAdaptedObject(Object.class);
		if( wrapped instanceof SectionId )
		{
			SectionId sectionId = (SectionId) wrapped;
			RenderContext context = getSectionWriter();
			AbstractRenderedComponent<HtmlComponentState> component = (AbstractRenderedComponent<HtmlComponentState>) context
				.getSectionForId(sectionId);
			component.setRendererType(context, "null"); //$NON-NLS-1$
			ResultListCollector results = new ResultListCollector(false);
			try
			{
				context.processEvent(new RenderEvent(context, sectionId.getSectionId(), results));
			}
			catch( Exception e )
			{
				throw new RuntimeException(e);
			}
			HtmlComponentState state = component.getState(context);
			TagRenderer renderer = createTagRenderer((HtmlMutableListState) state, env, params, body, loopVars);
			state.setBeenRendered(true);
			state.fireRendererCallback(context, renderer);
			setupStyles(renderer, params);

			try( SectionWriter writer = new SectionWriter(env.getOut(), context) )
			{
				writer.render(renderer);
			}
		}
		else
		{
			throw new SectionsRuntimeException("Need a sectionId"); //$NON-NLS-1$
		}
	}
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:47,代碼來源:AbstractListDirective.java

示例9: execute

import freemarker.core.Environment; //導入方法依賴的package包/類
@NonNullByDefault(false)
@SuppressWarnings({"unchecked", "nls", "rawtypes"})
@Override
public void execute(Environment env, Map params, TemplateModel[] arg2, TemplateDirectiveBody body)
	throws TemplateException, IOException
{
	RenderContext info = getSectionWriter();
	try
	{
		Object model = params.get("section"); //$NON-NLS-1$
		if( model instanceof AdapterTemplateModel )
		{
			Object wrapped = ((AdapterTemplateModel) model).getAdaptedObject(Object.class);
			if( wrapped != null )
			{
				SectionRenderable renderable = getRenderable(wrapped, params);
				if( renderable == null )
				{
					return;
				}
				if( renderable instanceof StyleableRenderer )
				{
					((StyleableRenderer) renderable).setStyles(getParam("style", params),
						getParam("class", params), getParam("id", params));
				}
				if( renderable instanceof NestedRenderable && body != null && getBodyField(env) != null )
				{
					((NestedRenderable) renderable).setNestedRenderable(new BodyDirectiveRenderable(body));
				}
				SectionWriter writer = new SectionWriter(env.getOut(), info);
				writer.preRender(renderable);
				renderable.realRender(writer);
			}
		}
		else
		{
			throw new RuntimeException("'section' parameter to render macro was not of the appropriate type (was "
				+ model.getClass() + ").  Perhaps you named your section property the same as a method name?");
		}
	}
	catch( Exception e )
	{
		throw Throwables.propagate(e);
	}
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:46,代碼來源:AbstractRenderDirective.java

示例10: setEnv

import freemarker.core.Environment; //導入方法依賴的package包/類
public void setEnv(Environment env) {
    this.env = env;
    if (out == null && env != null) {
        this.out = env.getOut();
    }
}
 
開發者ID:ilscipio,項目名稱:scipio-erp,代碼行數:7,代碼來源:CmsRenderTemplate.java

示例11: executeTyped

import freemarker.core.Environment; //導入方法依賴的package包/類
protected void executeTyped(Environment env, Map<String, TemplateModel> params, TemplateModel[] loopVars, TemplateDirectiveBody body)
            throws TemplateException, IOException {
        Writer writer = env.getOut();
        
        // NOTE: this can only work if we already had a RenderWriter. 
        // if not, don't even bother trying.
        if (writer instanceof RenderWriter) {
            Map<String, Object> context = ContextFtlUtil.getContext(env);
            WidgetRenderTargetState renderTargetState = WidgetRenderTargetExpr.getRenderTargetState(context);
            if (renderTargetState.isEnabled()) {
                String dirName = TransformUtil.getStringArg(params, "dirName");
                //TemplateHashModel dirArgs = (TemplateHashModel) params.get("dirArgs");
                
                String id = null;
                String name = null; // TODO?: this may not work as expected if we do this...
                // TODO: review
//                if (dirArgs != null) {
//                    TemplateScalarModel idModel = (TemplateScalarModel) dirArgs.get("id");
//                    if (idModel != null) {
//                        id = LangFtlUtil.getAsStringNonEscaping(idModel);
//                        if ("section".equals(dirName)) {
//                            TemplateScalarModel containerIdModel = (TemplateScalarModel) dirArgs.get("containerId");
//                            if (containerIdModel != null) {
//                                String containerId = LangFtlUtil.getAsStringNonEscaping(containerIdModel);
//                                if (UtilValidate.isNotEmpty(containerId)) {
//                                    id = containerId;
//                                }
//                            }
//                        }
//                    }
//                } else {
                id = TransformUtil.getStringNonEscapingArg(params, "id");
                name = TransformUtil.getStringNonEscapingArg(params, "name");
//                }

                String location = "unknown-location"; // FIXME
                ModelFtlWidget widget = new ModelFtlWidget(name, dirName, location, id);
                
                WidgetRenderTargetState.ExecutionInfo execInfo = renderTargetState.handleShouldExecute(widget, writer, context, null);
                if (!execInfo.shouldExecute()) {
                    return;
                }
                try {
                    if (body != null) {
                        body.render((Writer) execInfo.getWriterForElementRender());
                    }
                } finally {
                    execInfo.handleFinished(context); // SCIPIO: return logic
                }
                return;
            }
        }
        
        body.render(writer);
    }
 
開發者ID:ilscipio,項目名稱:scipio-erp,代碼行數:56,代碼來源:RenderTargetDirective.java

示例12: execute

import freemarker.core.Environment; //導入方法依賴的package包/類
public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException {
    final String componentPath = (params.containsKey(PARAM_PATH) ? params.get(PARAM_PATH).toString() : "" );

    Writer out = env.getOut();
    out.append("<!--# COMPONENT " + componentPath + " -->");
}
 
開發者ID:tineikt,項目名稱:xp-lib-freemarker,代碼行數:7,代碼來源:ComponentDirective.java

示例13: FieldRender

import freemarker.core.Environment; //導入方法依賴的package包/類
public FieldRender(Environment env,Record r)
{
	this.env = env;
	this.out = env.getOut();
	this.r = r;
}
 
開發者ID:fancimage,項目名稱:tern,代碼行數:7,代碼來源:Field.java


注:本文中的freemarker.core.Environment.getOut方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。