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


Java TemplateDirectiveBody类代码示例

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


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

示例1: createTagRenderer

import freemarker.template.TemplateDirectiveBody; //导入依赖的package包/类
@Override
@SuppressWarnings("nls")
protected TagRenderer createTagRenderer(HtmlMutableListState state, Environment env, Map<?, ?> params,
	TemplateDirectiveBody body, TemplateModel[] loopVars) throws TemplateModelException
{
	String tag = "div";
	if( params.containsKey("tag") )
	{
		tag = ((SimpleScalar) params.get("tag")).getAsString();
	}

	boolean hideDisabledOptions = false;
	if( params.containsKey("hideDisabledOptions") )
	{
		hideDisabledOptions = ((TemplateBooleanModel) params.get("hideDisabledOptions")).getAsBoolean();
	}

	return new ButtonListTagRenderer(tag, (HtmlListState) state, env, body, loopVars, hideDisabledOptions);
}
 
开发者ID:equella,项目名称:Equella,代码行数:20,代码来源:ButtonListDirective.java

示例2: ButtonListTagRenderer

import freemarker.template.TemplateDirectiveBody; //导入依赖的package包/类
@SuppressWarnings("nls")
public ButtonListTagRenderer(String tag, HtmlListState state, Environment env, TemplateDirectiveBody body,
	TemplateModel[] loopVars, boolean hideDisabledOptions)
{
	super(tag, state); //$NON-NLS-1$
	this.wrapper = (BeansWrapper) env.getObjectWrapper();
	this.listState = state;
	this.body = body;
	this.loopVars = loopVars;
	this.hideDisabledOptions = hideDisabledOptions;

	this.hiddenId = new AppendedElementId(state, "_hid");
	ScriptVariable valVar = new ScriptVariable("val");
	JSStatements changeBody = new AssignStatement(new ElementValueExpression(hiddenId), valVar);

	JSHandler lsChangeHandler = state.getHandler(JSHandler.EVENT_CHANGE);
	if( lsChangeHandler != null )
	{
		changeBody = StatementBlock.get(changeBody, lsChangeHandler);
	}
	clickFunc = new SimpleFunction(JSHandler.EVENT_CHANGE, state, changeBody, valVar);
}
 
开发者ID:equella,项目名称:Equella,代码行数:23,代码来源:ButtonListDirective.java

示例3: execute

import freemarker.template.TemplateDirectiveBody; //导入依赖的package包/类
@Override
public synchronized void execute(Environment env, @SuppressWarnings("rawtypes") Map params,
        TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException {
    entered++;
    notifyAll();
    final long startTime = System.currentTimeMillis();
    while (!released) {
        // To avoid blocking the CI server forever is something goes wrong:
        if (System.currentTimeMillis() - startTime > BLOCKING_TEST_TIMEOUT) {
            LOG.error("JUnit test timed out");
        }
        try {
            wait(1000);
        } catch (InterruptedException e) {
            LOG.error("JUnit test was interrupted");
        }
    }
    LOG.debug("Blocker released");
}
 
开发者ID:apache,项目名称:incubator-freemarker-online-tester,代码行数:20,代码来源:FreeMarkerServiceTest.java

示例4: execute

import freemarker.template.TemplateDirectiveBody; //导入依赖的package包/类
@Override
public void execute(Environment env, @SuppressWarnings("rawtypes") Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException {
	HttpServletRequest request = RequestHolder.getRequest();

	String uri = request.getRequestURI();
	StringBuilder sb = new StringBuilder();

	Iterator<Menu> iterator = loader.iterator();
	// System.out.println("iterator:" + iterator + " url:" + request.getRequestURI());
	while (iterator.hasNext()) {
		Menu menu = iterator.next();
		boolean active = uri.equals(menu.getUrl());
		sb.append("<li");
		if (active) {
			sb.append(" class=\"active\"");
		}
		sb.append("><a href=\"");
		sb.append(menu.getUrl());
		sb.append("\"><span class=\"isw-grid\"></span><span class=\"text\">");
		sb.append(menu.getName());
		sb.append("</span></a></li>");
	}
	env.getOut().write(sb.toString());
}
 
开发者ID:tanhaichao,项目名称:leopard,代码行数:25,代码来源:MenuTemplateDirective.java

示例5: execute

import freemarker.template.TemplateDirectiveBody; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException {
	Long articleCategoryId = FreemarkerUtils.getParameter(ARTICLE_CATEGORY_ID_PARAMETER_NAME, Long.class, params);

	ArticleCategory articleCategory = articleCategoryService.find(articleCategoryId);

	List<ArticleCategory> articleCategories;
	if (articleCategoryId != null && articleCategory == null) {
		articleCategories = new ArrayList<ArticleCategory>();
	} else {
		boolean useCache = useCache(env, params);
		String cacheRegion = getCacheRegion(env, params);
		Integer count = getCount(params);
		if (useCache) {
			articleCategories = articleCategoryService.findChildren(articleCategory, count, cacheRegion);
		} else {
			articleCategories = articleCategoryService.findChildren(articleCategory, count);
		}
	}
	setLocalVariable(VARIABLE_NAME, articleCategories, env, body);
}
 
开发者ID:justinbaby,项目名称:my-paper,代码行数:22,代码来源:ArticleCategoryChildrenListDirective.java

示例6: execute

import freemarker.template.TemplateDirectiveBody; //导入依赖的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

示例7: execute

import freemarker.template.TemplateDirectiveBody; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException {
	Long memberId = FreemarkerUtils.getParameter(MEMBER_ID_PARAMETER_NAME, Long.class, params);
	Long productId = FreemarkerUtils.getParameter(PRODUCT_ID_PARAMETER_NAME, Long.class, params);

	Member member = memberService.find(memberId);
	Product product = productService.find(productId);

	List<Consultation> consultations;
	boolean useCache = useCache(env, params);
	String cacheRegion = getCacheRegion(env, params);
	Integer count = getCount(params);
	List<Filter> filters = getFilters(params, Brand.class);
	List<Order> orders = getOrders(params);
	if ((memberId != null && member == null) || (productId != null && product == null)) {
		consultations = new ArrayList<Consultation>();
	} else {
		if (useCache) {
			consultations = consultationService.findList(member, product, true, count, filters, orders, cacheRegion);
		} else {
			consultations = consultationService.findList(member, product, true, count, filters, orders);
		}
	}
	setLocalVariable(VARIABLE_NAME, consultations, env, body);
}
 
开发者ID:justinbaby,项目名称:my-paper,代码行数:26,代码来源:ConsultationListDirective.java

示例8: execute

import freemarker.template.TemplateDirectiveBody; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException {
	Long memberId = FreemarkerUtils.getParameter(MEMBER_ID_PARAMETER_NAME, Long.class, params);
	Long productId = FreemarkerUtils.getParameter(PRODUCT_ID_PARAMETER_NAME, Long.class, params);
	Type type = FreemarkerUtils.getParameter(TYPE_PARAMETER_NAME, Type.class, params);

	Member member = memberService.find(memberId);
	Product product = productService.find(productId);

	List<Review> reviews;
	if ((memberId != null && member == null) || (productId != null && product == null)) {
		reviews = new ArrayList<Review>();
	} else {
		boolean useCache = useCache(env, params);
		String cacheRegion = getCacheRegion(env, params);
		Integer count = getCount(params);
		List<Filter> filters = getFilters(params, Review.class);
		List<Order> orders = getOrders(params);
		if (useCache) {
			reviews = reviewService.findList(member, product, type, true, count, filters, orders, cacheRegion);
		} else {
			reviews = reviewService.findList(member, product, type, true, count, filters, orders);
		}
	}
	setLocalVariable(VARIABLE_NAME, reviews, env, body);
}
 
开发者ID:justinbaby,项目名称:my-paper,代码行数:27,代码来源:ReviewListDirective.java

示例9: execute

import freemarker.template.TemplateDirectiveBody; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException {
	Long articleCategoryId = FreemarkerUtils.getParameter(ARTICLE_CATEGORY_ID_PARAMETER_NAME, Long.class, params);
	Long[] tagIds = FreemarkerUtils.getParameter(TAG_IDS_PARAMETER_NAME, Long[].class, params);

	ArticleCategory articleCategory = articleCategoryService.find(articleCategoryId);
	List<Tag> tags = tagService.findList(tagIds);

	List<Article> articles;
	if ((articleCategoryId != null && articleCategory == null) || (tagIds != null && tags.isEmpty())) {
		articles = new ArrayList<Article>();
	} else {
		boolean useCache = useCache(env, params);
		String cacheRegion = getCacheRegion(env, params);
		Integer count = getCount(params);
		List<Filter> filters = getFilters(params, Article.class);
		List<Order> orders = getOrders(params);
		if (useCache) {
			articles = articleService.findList(articleCategory, tags, count, filters, orders, cacheRegion);
		} else {
			articles = articleService.findList(articleCategory, tags, count, filters, orders);
		}
	}
	setLocalVariable(VARIABLE_NAME, articles, env, body);
}
 
开发者ID:justinbaby,项目名称:my-paper,代码行数:26,代码来源:ArticleListDirective.java

示例10: execute

import freemarker.template.TemplateDirectiveBody; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException {
	Long productCategoryId = FreemarkerUtils.getParameter(PRODUCT_CATEGORY_ID_PARAMETER_NAME, Long.class, params);

	ProductCategory productCategory = productCategoryService.find(productCategoryId);

	List<ProductCategory> productCategories;
	if (productCategoryId != null && productCategory == null) {
		productCategories = new ArrayList<ProductCategory>();
	} else {
		boolean useCache = useCache(env, params);
		String cacheRegion = getCacheRegion(env, params);
		Integer count = getCount(params);
		if (useCache) {
			productCategories = productCategoryService.findChildren(productCategory, count, cacheRegion);
		} else {
			productCategories = productCategoryService.findChildren(productCategory, count);
		}
	}
	setLocalVariable(VARIABLE_NAME, productCategories, env, body);
}
 
开发者ID:justinbaby,项目名称:my-paper,代码行数:22,代码来源:ProductCategoryChildrenListDirective.java

示例11: execute

import freemarker.template.TemplateDirectiveBody; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException {
	Long productCategoryId = FreemarkerUtils.getParameter(PRODUCT_CATEGORY_ID_PARAMETER_NAME, Long.class, params);

	ProductCategory productCategory = productCategoryService.find(productCategoryId);

	List<ProductCategory> productCategories;
	if (productCategoryId != null && productCategory == null) {
		productCategories = new ArrayList<ProductCategory>();
	} else {
		boolean useCache = useCache(env, params);
		String cacheRegion = getCacheRegion(env, params);
		Integer count = getCount(params);
		if (useCache) {
			productCategories = productCategoryService.findParents(productCategory, count, cacheRegion);
		} else {
			productCategories = productCategoryService.findParents(productCategory, count);
		}
	}
	setLocalVariable(VARIABLE_NAME, productCategories, env, body);
}
 
开发者ID:justinbaby,项目名称:my-paper,代码行数:22,代码来源:ProductCategoryParentListDirective.java

示例12: execute

import freemarker.template.TemplateDirectiveBody; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException {
	Boolean hasBegun = FreemarkerUtils.getParameter(HAS_BEGUN_PARAMETER_NAME, Boolean.class, params);
	Boolean hasEnded = FreemarkerUtils.getParameter(HAS_ENDED_PARAMETER_NAME, Boolean.class, params);

	List<Promotion> promotions;
	boolean useCache = useCache(env, params);
	String cacheRegion = getCacheRegion(env, params);
	Integer count = getCount(params);
	List<Filter> filters = getFilters(params, Promotion.class);
	List<Order> orders = getOrders(params);
	if (useCache) {
		promotions = promotionService.findList(hasBegun, hasEnded, count, filters, orders, cacheRegion);
	} else {
		promotions = promotionService.findList(hasBegun, hasEnded, count, filters, orders);
	}
	setLocalVariable(VARIABLE_NAME, promotions, env, body);
}
 
开发者ID:justinbaby,项目名称:my-paper,代码行数:19,代码来源:PromotionListDirective.java

示例13: execute

import freemarker.template.TemplateDirectiveBody; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException {
	Long articleCategoryId = FreemarkerUtils.getParameter(ARTICLE_CATEGORY_ID_PARAMETER_NAME, Long.class, params);

	ArticleCategory articleCategory = articleCategoryService.find(articleCategoryId);

	List<ArticleCategory> articleCategories;
	if (articleCategoryId != null && articleCategory == null) {
		articleCategories = new ArrayList<ArticleCategory>();
	} else {
		boolean useCache = useCache(env, params);
		String cacheRegion = getCacheRegion(env, params);
		Integer count = getCount(params);
		if (useCache) {
			articleCategories = articleCategoryService.findParents(articleCategory, count, cacheRegion);
		} else {
			articleCategories = articleCategoryService.findParents(articleCategory, count);
		}
	}
	setLocalVariable(VARIABLE_NAME, articleCategories, env, body);
}
 
开发者ID:justinbaby,项目名称:my-paper,代码行数:22,代码来源:ArticleCategoryParentListDirective.java

示例14: render

import freemarker.template.TemplateDirectiveBody; //导入依赖的package包/类
@Override
public void render(Environment env, Map params, TemplateDirectiveBody body) throws IOException, TemplateException {
    if (getSubject() == null || getSubject().getPrincipal() == null) {
        if (log.isDebugEnabled()) {
            log.debug("Subject does not exist or does not have a known identity (aka 'principal').  "
                    + "Tag body will be evaluated.");
        }

        renderBody(env, body);
    } else {
        if (log.isDebugEnabled()) {
            log.debug("Subject exists or has a known identity (aka 'principal').  "
                    + "Tag body will not be evaluated.");
        }
    }
}
 
开发者ID:srarcbrsent,项目名称:tc,代码行数:17,代码来源:GuestTag.java

示例15: execute

import freemarker.template.TemplateDirectiveBody; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
@Override
public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body)
    throws TemplateException, IOException {
    SimpleScalar pVar = (SimpleScalar) params.get("var");

    List<RetailStore> retailStoreList = retailStores.enabledRetailStores();

    if (pVar != null) {
        // Sets the result into the current template as if using <#assign
        // name=model>.
        env.setVariable(pVar.getAsString(), DefaultObjectWrapper.getDefaultInstance().wrap(retailStoreList));
    } else {
        // Sets the result into the current template as if using <#assign
        // name=model>.
        env.setVariable("retailStores", DefaultObjectWrapper.getDefaultInstance().wrap(retailStoreList));
    }
}
 
开发者ID:geetools,项目名称:geeCommerce-Java-Shop-Software-and-PIM,代码行数:19,代码来源:FetchRetailStoresDirective.java


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