@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); }
@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); }
@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"); }
@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()); }
@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); }
@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(); } } } }
@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); }
@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); }
@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); }
@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); }
@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); }
@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); }
@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); }
@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."); } } }
@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)); } }
@SuppressWarnings("rawtypes") @Override public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException { try { SimpleNumber pFor = (SimpleNumber) params.get("for"); Number forMillis = null; if (pFor != null) { forMillis = pFor.getAsNumber(); try { Thread.sleep(forMillis.longValue()); } catch (InterruptedException e) { e.printStackTrace(); } } } catch (Throwable t) { t.printStackTrace(); } }
public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException { String name = Directives.getStringParam(env, params, "name"); name = BLOCK_NAME_PRE+name; Namespace ns = env.getCurrentNamespace(); if(ns.get(name) == null) /*block���ܶ�α���д�����ж�����ģ���е�����Ϊ����*/ { //java.io.Writer out = new java.io.StringWriter(); //body.render(out); env.getCurrentNamespace().put(name, body); //env.getCurrentNamespace().put(name, out.toString()); //env.setLocalVariable(name, out.toString()); } }
@Override public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException { // Check if no parameters were given: if (!params.isEmpty()) { throw new TemplateModelException( getClass().getSimpleName() + " doesn't allow parameters."); } if (loopVars.length != 0) { throw new TemplateModelException( getClass().getSimpleName() + " doesn't allow loop variables."); } // If there is non-empty nested content: if (body != null) { // Executes the nested body. Same as <#nested> in FTL, except // that we use our own writer instead of the current output writer. body.render(new JsonEscapingFilterWriter(env.getOut())); } else { throw new RuntimeException("missing body"); } }
public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException { String tagBeginHtml = tagBegin(params); if (loopVars.length > 1) { // todo throw new TemplateModelException("At most one loop variable is allowed."); } // --------------------------------------------------------------------- // 真正开始处理输出内容 Writer out = env.getOut(); if (body != null) { out.write(tagBeginHtml); StringWriter sOut = new StringWriter(); // 执行标签内容(same as <#nested> in FTL). body.render(sOut); out.write(sOut.getBuffer().toString()); out.write(FisResource.getCssHook()); out.write("\n</head>\n"); } }
public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException { String name = null; TemplateModel paramValue = (TemplateModel) params.get("name"); if (paramValue != null) { name = ((TemplateScalarModel) paramValue).getAsString(); } if (name == null || "".equals(name)) { return; } try { String url = fisRes.require(name); } catch (FisException e) { throw new TemplateException(e.getMessage(), e, env); } }
public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException { String tagBeginHtml = tagBegin(params); Writer out = env.getOut(); if (body != null) { out.write(tagBeginHtml); StringWriter sOut = new StringWriter(); body.render(sOut); out.write(sOut.getBuffer().toString()); out.write("\n</body>\n"); try { out.write(fisRes.getRenderFrag("js")); } catch (FisException e) { throw new TemplateException(e.getMessage(), e, env); } out.write(fisRes.getRenderScript()); } }
@SuppressWarnings("rawtypes") @Override public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException { if (body == null) { return; } if (loopVars.length != 0) { throw new TemplateModelException("Trim directive doesn't allow loop variables"); } StringWriter bodyWriter = new StringWriter(); body.render(bodyWriter); String trimmed = getTrimmer(params).trim(bodyWriter.toString()); Writer out = env.getOut(); out.write(trimmed); }
@Override public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException { //û�в�����ѭ�� if (!params.isEmpty()) { throw new TemplateModelException( "This directive doesn't allow parameters." ); } if(loopVars.length != 0 ) { throw new TemplateModelException( "This directive doesn't allow loop variables." ); } if(body != null ){ body.render(new UpperCaseFilterWriter(env.getOut())); }else{ throw new RuntimeException( "missing body" ); } }
protected String getBodyContent(TemplateDirectiveBody body){ StringWriter sw = null; String bodyContent = ""; try { // body.render(env.getOut()); if(body!=null){ sw = new StringWriter(); body.render(sw); bodyContent = sw.toString(); } } catch (Exception e) { LangUtils.throwBaseException("render error : " + e.getMessage(), e); // e.printStackTrace(); } finally{ LangUtils.closeIO(sw); } return bodyContent; }
@SuppressWarnings("unchecked") public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException { Integer siteId = getSiteId(params); if (siteId == null) { siteId = FrontUtils.getSite(env).getId(); } Integer ctgId = getCtgId(params); Boolean enabled = getEnabled(params); if (enabled == null) { enabled = true; } List<CmsFriendlink> list = cmsFriendlinkMng.getList(siteId, ctgId, enabled); Map<String, TemplateModel> paramWrap = new HashMap<String, TemplateModel>( params); paramWrap.put(OUT_LIST, DEFAULT_WRAPPER.wrap(list)); Map<String, TemplateModel> origMap = DirectiveUtils .addParamsToVariable(env, paramWrap); body.render(env.getOut()); DirectiveUtils.removeParamsFromVariable(env, paramWrap, origMap); }
@SuppressWarnings("unchecked") public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException { Integer count = getCount(params); if (count == null) { count=Integer.MAX_VALUE; } Boolean def=getDef(params); List<CmsVoteTopic>voteTopicList=cmsVoteTopicMng.getList(def,getSiteId(params), count); Map<String, TemplateModel> paramWrap = new HashMap<String, TemplateModel>( params); paramWrap.put(OUT_LIST, DEFAULT_WRAPPER.wrap(voteTopicList)); Map<String, TemplateModel> origMap = DirectiveUtils .addParamsToVariable(env, paramWrap); body.render(env.getOut()); DirectiveUtils.removeParamsFromVariable(env, paramWrap, origMap); }
@SuppressWarnings("unchecked") public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException { Integer id = DirectiveUtils.getInt(PARAM_ID, params); CmsAdvertising ad = null; if (id != null) { ad = cmsAdvertisingMng.findById(id); } Map<String, TemplateModel> paramWrap = new HashMap<String, TemplateModel>( params); paramWrap.put(OUT_BEAN, DEFAULT_WRAPPER.wrap(ad)); Map<String, TemplateModel> origMap = DirectiveUtils .addParamsToVariable(env, paramWrap); body.render(env.getOut()); DirectiveUtils.removeParamsFromVariable(env, paramWrap, origMap); }
@SuppressWarnings("unchecked") public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException { Integer siteId = getSiteId(params); if (siteId == null) { siteId = FrontUtils.getSite(env).getId(); } List<CmsFriendlinkCtg> list = cmsFriendlinkCtgMng.getList(siteId); Map<String, TemplateModel> paramWrap = new HashMap<String, TemplateModel>( params); paramWrap.put(OUT_LIST, DEFAULT_WRAPPER.wrap(list)); Map<String, TemplateModel> origMap = DirectiveUtils .addParamsToVariable(env, paramWrap); body.render(env.getOut()); DirectiveUtils.removeParamsFromVariable(env, paramWrap, origMap); }
@SuppressWarnings("unchecked") public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException { CmsSite site = FrontUtils.getSite(env); CmsVoteTopic vote; Integer id = getId(params); if (id != null) { vote = cmsVoteTopicMng.findById(id); } else { Integer siteId = getSiteId(params); if (siteId == null) { siteId = site.getId(); } vote = cmsVoteTopicMng.getDefTopic(siteId); } Map<String, TemplateModel> paramWrap = new HashMap<String, TemplateModel>( params); paramWrap.put(OUT_BEAN, DEFAULT_WRAPPER.wrap(vote)); Map<String, TemplateModel> origMap = DirectiveUtils .addParamsToVariable(env, paramWrap); body.render(env.getOut()); DirectiveUtils.removeParamsFromVariable(env, paramWrap, origMap); }
@SuppressWarnings("unchecked") public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException { Integer id = DirectiveUtils.getInt(PARAM_ID, params); CmsModel model; if (id != null) { model = modelMng.findById(id); } else { String path = DirectiveUtils.getString(PARAM_PATH, params); if (StringUtils.isBlank(path)) { // 如果path不存在,那么id必须存在。 throw new ParamsRequiredException(PARAM_ID); } model = modelMng.findByPath(path); } Map<String, TemplateModel> paramWrap = new HashMap<String, TemplateModel>( params); paramWrap.put(OUT_BEAN, DEFAULT_WRAPPER.wrap(model)); Map<String, TemplateModel> origMap = DirectiveUtils .addParamsToVariable(env, paramWrap); body.render(env.getOut()); DirectiveUtils.removeParamsFromVariable(env, paramWrap, origMap); }
@SuppressWarnings("unchecked") public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException { Integer id = getId(params); Boolean next = DirectiveUtils.getBool(PRAMA_NEXT, params); Content content; if (next == null) { content = contentMng.findById(id); } else { CmsSite site = FrontUtils.getSite(env); Integer channelId = DirectiveUtils.getInt(PARAM_CHANNEL_ID, params); content = contentMng.getSide(id, site.getId(), channelId, next); } Map<String, TemplateModel> paramWrap = new HashMap<String, TemplateModel>( params); paramWrap.put(OUT_BEAN, DEFAULT_WRAPPER.wrap(content)); Map<String, TemplateModel> origMap = DirectiveUtils .addParamsToVariable(env, paramWrap); body.render(env.getOut()); DirectiveUtils.removeParamsFromVariable(env, paramWrap, origMap); }
@SuppressWarnings("rawtypes") public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException { OverrideDirective.TemplateDirectiveBodyOverrideWraper current = (OverrideDirective.TemplateDirectiveBodyOverrideWraper) env .getVariable(DirectiveUtils.OVERRIDE_CURRENT_NODE); if (current == null) { throw new TemplateException("<@super/> direction must be child of override", env); } TemplateDirectiveBody parent = current.parentBody; if (parent == null) { throw new TemplateException("not found parent for <@super/>", env); } parent.render(env.getOut()); }
@Override public void render(Environment env, Map params, TemplateDirectiveBody body) throws IOException, TemplateException { if (getSubject() != null && getSubject().isAuthenticated()) { if (_logger.isDebugEnabled()) { _logger.debug("Subject exists and is authenticated. Tag body will be evaluated."); } renderBody(env, body); } else { if (_logger.isDebugEnabled()) { _logger.debug("Subject does not exist or is not authenticated. Tag body will not be evaluated."); } } }
@SuppressWarnings("rawtypes") @Override public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException { String name = DirectiveKit.getRequiredParam(params, "name"); TemplateDirectiveBodyOverrideWraper overrideBody = DirectiveKit.getOverrideBody(env, name); if (overrideBody == null) { if (body != null) { body.render(env.getOut()); } } else { DirectiveKit.setTopBodyForParentBody( new TemplateDirectiveBodyOverrideWraper(body, env), overrideBody); overrideBody.render(env.getOut()); } }
@SuppressWarnings("rawtypes") @Override public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException { TemplateDirectiveBodyOverrideWraper current = (TemplateDirectiveBodyOverrideWraper) env.getVariable(DirectiveKit.OVERRIDE_CURRENT_NODE); if (current == null) { throw new TemplateException("<@super/> direction must be child of override", env); } TemplateDirectiveBody parent = current.parentBody; if (parent == null) { throw new TemplateException("not found parent for <@super/>", env); } parent.render(env.getOut()); }
@SuppressWarnings("rawtypes") @Override public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException { String name = DirectiveKit.getRequiredParam(params, "name"); params.remove("name"); if (!name.endsWith(".ftl")) { name = name + ".ftl"; } String encoding = DirectiveKit.getParam(params, "encoding", StringPool.UTF_8); String includeTemplateName = TemplateCache.getFullTemplatePath(env, getTemplatePath(env), name); Configuration configuration = env.getConfiguration(); final Template template = configuration.getTemplate(includeTemplateName, env.getLocale(), encoding, true); for (Object key : params.keySet()) { TemplateModel paramModule = new SimpleScalar(params.get(key).toString()); env.setVariable(key.toString(), paramModule); } env.include(template); }
@Override public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException { try{ Map<String,Object> paramsViewlet=MacroHelper.extractParams(params); if (body!=null){ ByteArrayOutputStream baos=MacroHelper.renderInnerTag(body); paramsViewlet.put("renderedBody", new String(baos.toByteArray()).trim()); } ModeletAndView mv=viewlet.control(paramsViewlet); if (mv!=null){ StringModel templateModel = (StringModel) env.getDataModel().get(FreemarkerViewRenderer.ROOT_MODEL); if (templateModel!=null){ Map map = ((MapWrapper)templateModel.getWrappedObject()).get(); paramsViewlet.putAll(map); } paramsViewlet.putAll(mv.getModel()); freemarkerTemplateRenderer.render(mv.getTemplate(), paramsViewlet, env.getOut()); } }catch(RuntimeException e){ logger.error("Exception executing "+viewlet.getClass()+". Error "+e.getMessage()); e.printStackTrace(); } }
@SuppressWarnings("rawtypes") public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException { System.out.println("upper start"); // Check if no parameters were given: if (!params.isEmpty()) { throw new TemplateModelException( "This directive doesn't allow parameters."); } if (loopVars.length != 0) { throw new TemplateModelException( "This directive doesn't allow loop variables."); } // If there is non-empty nested content: if (body != null) { // Executes the nested body. Same as <#nested> in FTL, except // that we use our own writer instead of the current output writer. body.render(new UpperCaseFilterWriter(env.getOut())); } else { throw new RuntimeException("missing body"); } System.out.println("upper end"); }
public FreemarkerListRenderer(HtmlMutableListState state, Environment env, TemplateDirectiveBody body, TemplateModel[] loopVars) { super("ul", state); //$NON-NLS-1$ this.wrapper = (BeansWrapper) env.getObjectWrapper(); this.listState = state; this.body = body; this.loopVars = loopVars; }
public FreemarkerCheckListRenderer(BooleanListRenderer renderer, Environment env, TemplateDirectiveBody body, TemplateModel[] loopVars) { super("ul", renderer.getListState()); //$NON-NLS-1$ this.wrapper = (BeansWrapper) env.getObjectWrapper(); this.body = body; this.loopVars = loopVars; this.renderer = renderer; }