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