java simplescalar_Java TemplateDirectiveBody.render方法代碼示例

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

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

示例1: execute

​點讚 3

import freemarker.template.TemplateDirectiveBody; //導入方法依賴的package包/類

@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 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");

}

}

開發者ID:kuali,項目名稱:kc-rice,代碼行數:23,

示例2: execute

​點讚 3

import freemarker.template.TemplateDirectiveBody; //導入方法依賴的package包/類

@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 paramWrap = new HashMap(

params);

paramWrap.put(OUT_BEAN, DEFAULT_WRAPPER.wrap(vote));

Map origMap = DirectiveUtils

.addParamsToVariable(env, paramWrap);

body.render(env.getOut());

DirectiveUtils.removeParamsFromVariable(env, paramWrap, origMap);

}

開發者ID:huanzhou,項目名稱:jeecms6,代碼行數:25,

示例3: execute

​點讚 3

import freemarker.template.TemplateDirectiveBody; //導入方法依賴的package包/類

@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 paramWrap = new HashMap(

params);

paramWrap.put(OUT_BEAN, DEFAULT_WRAPPER.wrap(content));

Map origMap = DirectiveUtils

.addParamsToVariable(env, paramWrap);

body.render(env.getOut());

DirectiveUtils.removeParamsFromVariable(env, paramWrap, origMap);

}

開發者ID:huanzhou,項目名稱:jeecms6,代碼行數:23,

示例4: getBodyContent

​點讚 3

import freemarker.template.TemplateDirectiveBody; //導入方法依賴的package包/類

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;

}

開發者ID:wayshall,項目名稱:onetwo,代碼行數:19,

示例5: execute

​點讚 3

import freemarker.template.TemplateDirectiveBody; //導入方法依賴的package包/類

@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 paramWrap = new HashMap(

params);

paramWrap.put(OUT_BEAN, DEFAULT_WRAPPER.wrap(ad));

Map origMap = DirectiveUtils

.addParamsToVariable(env, paramWrap);

body.render(env.getOut());

DirectiveUtils.removeParamsFromVariable(env, paramWrap, origMap);

}

開發者ID:huanzhou,項目名稱:jeecms6,代碼行數:17,

示例6: execute

​點讚 3

import freemarker.template.TemplateDirectiveBody; //導入方法依賴的package包/類

@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 paramWrap = new HashMap(

params);

paramWrap.put(OUT_BEAN, DEFAULT_WRAPPER.wrap(model));

Map origMap = DirectiveUtils

.addParamsToVariable(env, paramWrap);

body.render(env.getOut());

DirectiveUtils.removeParamsFromVariable(env, paramWrap, origMap);

}

開發者ID:huanzhou,項目名稱:jeecms6,代碼行數:25,

示例7: execute

​點讚 3

import freemarker.template.TemplateDirectiveBody; //導入方法依賴的package包/類

@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(" direction must be child of override", env);

}

TemplateDirectiveBody parent = current.parentBody;

if (parent == null) {

throw new TemplateException("not found parent for ", env);

}

parent.render(env.getOut());

}

開發者ID:HunanTV,項目名稱:fw,代碼行數:17,

示例8: executeTyped

​點讚 2

import freemarker.template.TemplateDirectiveBody; //導入方法依賴的package包/類

protected void executeTyped(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body)

throws TemplateException, IOException {

CommonVarMaps> varMaps = CommonVarMaps.getRawMaps(params);

boolean restoreValues = TransformUtil.getBooleanArg(params, "restoreValues", true);

boolean clearValues = TransformUtil.getBooleanArg(params, "clearValues", false);

CommonVarMaps skipSet = new CommonVarMaps<>(

TransformUtil.getBooleanArg(params, "skipSetCtxVars", false),

TransformUtil.getBooleanArg(params, "skipSetGlobalCtxVars", false),

TransformUtil.getBooleanArg(params, "skipSetReqAttribs", false));

CommonVarMaps> origValues = null;

if (restoreValues && !clearValues) {

origValues = ExtractVarsMethod.extractVars(CommonVarMaps.getRawSequences(varMaps), true, env);

}

SetVarsMethod.setVars(varMaps, skipSet, env);

if (body != null) {

body.render(env.getOut());

}

if (clearValues) {

ClearVarsMethod.clearVars(CommonVarMaps.getRawSequences(varMaps), env);

} else if (restoreValues) {

SetVarsMethod.setVars(origValues, env);

}

}

開發者ID:ilscipio,項目名稱:scipio-erp,代碼行數:29,

示例9: executeTyped

​點讚 2

import freemarker.template.TemplateDirectiveBody; //導入方法依賴的package包/類

protected void executeTyped(Environment env, Map 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 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,

示例10: setLocalVariables

​點讚 2

import freemarker.template.TemplateDirectiveBody; //導入方法依賴的package包/類

/**

* 設置局部變量

*

* @param variables

* 變量

* @param env

* Environment

* @param body

* TemplateDirectiveBody

*/

protected void setLocalVariables(Map variables, Environment env, TemplateDirectiveBody body) throws TemplateException, IOException {

Map sourceVariables = new HashMap();

for (String name : variables.keySet()) {

TemplateModel sourceVariable = FreemarkerUtils.getVariable(name, env);

sourceVariables.put(name, sourceVariable);

}

FreemarkerUtils.setVariables(variables, env);

body.render(env.getOut());

FreemarkerUtils.setVariables(sourceVariables, env);

}

開發者ID:justinbaby,項目名稱:my-paper,代碼行數:21,

示例11: execute

​點讚 2

import freemarker.template.TemplateDirectiveBody; //導入方法依賴的package包/類

@Override

public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException {

List list = categoryMapper.selectCategoryList();

env.setVariable("list", DEFAULT_WRAPPER.wrap(list));

System.out.println("##:"+JSON.toJSON(params));

if (body != null) {

body.render(env.getOut());

} else {

throw new RuntimeException("missing body");

}

}

開發者ID:blogshun,項目名稱:ants-project,代碼行數:12,

示例12: execute

​點讚 2

import freemarker.template.TemplateDirectiveBody; //導入方法依賴的package包/類

@SuppressWarnings("rawtypes")

@Override

public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body)

throws TemplateException, IOException {

if (log.isTraceEnabled()) {

log.trace(params);

}

TemplateModel pProduct = (TemplateModel) params.get("product");

SimpleScalar pType = (SimpleScalar) params.get("type");

if (pProduct != null && pProduct instanceof BeanModel && pType != null) {

Product product = null;

String type = null;

Object beanModel = ((BeanModel) pProduct).getWrappedObject();

if (beanModel instanceof Product) {

product = (Product) beanModel;

} else {

throw new IllegalArgumentException("The source-object must be of type Product");

}

if (pType != null)

type = pType.getAsString();

PriceResult result = product.getPrice();

if (result != null && type != null) {

Double price = result.getPrice(type);

if (price != null && price > 0 && body != null) {

body.render(env.getOut());

}

}

}

}

開發者ID:geetools,項目名稱:geeCommerce-Java-Shop-Software-and-PIM,代碼行數:38,

示例13: execute

​點讚 2

import freemarker.template.TemplateDirectiveBody; //導入方法依賴的package包/類

@Override

public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body)

throws TemplateException, IOException {

long start = System.currentTimeMillis();

StringWriter sw = new StringWriter();

body.render(sw);

env.getOut().write(sw.toString() + "" + (System.currentTimeMillis() - start) + "ms");

}

開發者ID:geetools,項目名稱:geeCommerce-Java-Shop-Software-and-PIM,代碼行數:11,

示例14: execute

​點讚 2

import freemarker.template.TemplateDirectiveBody; //導入方法依賴的package包/類

@SuppressWarnings("rawtypes")

@Override

public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body)

throws TemplateException, IOException {

TemplateModel pValue = (TemplateModel) params.get("value");

SimpleScalar pVar = (SimpleScalar) params.get("var");

if (pVar == null)

throw new IllegalArgumentException("The var parameter cannot be null in set-directive");

String var = pVar.getAsString();

Object value = null;

if (pValue != null) {

if (pValue instanceof StringModel) {

value = ((StringModel) pValue).getWrappedObject();

} else if (pValue instanceof SimpleHash) {

value = ((SimpleHash) pValue).toMap();

} else {

value = DeepUnwrap.unwrap(pValue);

}

} else if (body != null) {

StringWriter sw = new StringWriter();

try {

body.render(sw);

value = sw.toString().trim();

} finally {

IOUtils.closeQuietly(sw);

}

}

env.setVariable(var, DefaultObjectWrapper.getDefaultInstance().wrap(value));

}

開發者ID:geetools,項目名稱:geeCommerce-Java-Shop-Software-and-PIM,代碼行數:35,

示例15: execute

​點讚 2

import freemarker.template.TemplateDirectiveBody; //導入方法依賴的package包/類

@Override

public void execute(Environment env, Map params, TemplateModel[] loopVars,

TemplateDirectiveBody body) throws TemplateException, IOException

{

String name = Directives.getStringParam(env, params, "name");

name = Overrides.BLOCK_NAME_PRE+name;

TemplateModel tm = env.getCurrentNamespace().get(name);

if(tm instanceof AdapterTemplateModel)

{

Object o = ((AdapterTemplateModel)tm).getAdaptedObject(null);

if(o instanceof TemplateDirectiveBody)

{

((TemplateDirectiveBody)o).render(env.getOut());

return;

}

}

else if(tm instanceof TemplateDirectiveBody)

{

((TemplateDirectiveBody)tm).render(env.getOut());

return;

}

else if(tm instanceof TemplateScalarModel)

{

String tpl = ((TemplateScalarModel)tm).getAsString();

if(tpl!=null)

{

env.getOut().append(tpl);

return;

}

}

if(body!=null) body.render(env.getOut());

}

開發者ID:fancimage,項目名稱:tern,代碼行數:35,

示例16: execute

​點讚 2

import freemarker.template.TemplateDirectiveBody; //導入方法依賴的package包/類

public void execute(Environment env,

Map params, TemplateModel[] loopVars,

TemplateDirectiveBody body) throws TemplateException, IOException {

String name = DirectiveUtils.getRequiredParam(params, "name");

OverrideDirective.TemplateDirectiveBodyOverrideWraper overrideBody = DirectiveUtils.getOverrideBody(env, name);

if(overrideBody == null) {

if(body != null) {

body.render(env.getOut());

}

}else {

DirectiveUtils.setTopBodyForParentBody(env, new OverrideDirective.TemplateDirectiveBodyOverrideWraper(body,env), overrideBody);

overrideBody.render(env.getOut());

}

}

開發者ID:hosken5,項目名稱:spring-boot-freemarker-showcase,代碼行數:15,

示例17: renderInnerTag

​點讚 2

import freemarker.template.TemplateDirectiveBody; //導入方法依賴的package包/類

public static ByteArrayOutputStream renderInnerTag(TemplateDirectiveBody body) throws TemplateException, IOException{

ByteArrayOutputStream baos=new ByteArrayOutputStream();

if (body==null) return baos;

Writer writer=new PrintWriter(baos);

body.render(writer);

writer.close();

return baos;

}

開發者ID:jerolba,項目名稱:funsteroid,代碼行數:9,

示例18: execute

​點讚 2

import freemarker.template.TemplateDirectiveBody; //導入方法依賴的package包/類

public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body)

throws TemplateException, IOException {

TemplateDirectiveBodyOverrideWraper current = (TemplateDirectiveBodyOverrideWraper) env

.getVariable(DirectiveUtils.OVERRIDE_CURRENT_NODE);

if (current == null) {

throw new TemplateException(" direction must be child of override", env);

}

TemplateDirectiveBody parent = current.parentBody;

if (parent == null) {

throw new TemplateException("not found parent for ", env);

}

parent.render(env.getOut());

}

開發者ID:bignippleboy,項目名稱:ipaas,代碼行數:16,

示例19: execute

​點讚 2

import freemarker.template.TemplateDirectiveBody; //導入方法依賴的package包/類

@SuppressWarnings("unchecked")

public void execute(Environment env, Map params, TemplateModel[] loopVars,

TemplateDirectiveBody body) throws TemplateException, IOException {

CmsSite site = FrontUtils.getSite(env);

Pagination page = contentTagMng.getPageForTag(

FrontUtils.getPageNo(env), FrontUtils.getCount(params));

Map paramWrap = new HashMap(

params);

paramWrap.put(OUT_PAGINATION, DEFAULT_WRAPPER.wrap(page));

paramWrap.put(OUT_LIST, DEFAULT_WRAPPER.wrap(page.getList()));

Map origMap = DirectiveUtils

.addParamsToVariable(env, paramWrap);

InvokeType type = DirectiveUtils.getInvokeType(params);

String listStyle = DirectiveUtils.getString(PARAM_STYLE_LIST, params);

if (InvokeType.sysDefined == type) {

if (StringUtils.isBlank(listStyle)) {

throw new ParamsRequiredException(PARAM_STYLE_LIST);

}

env.include(TPL_STYLE_LIST + listStyle + TPL_SUFFIX, UTF8, true);

FrontUtils.includePagination(site, params, env);

} else if (InvokeType.userDefined == type) {

if (StringUtils.isBlank(listStyle)) {

throw new ParamsRequiredException(PARAM_STYLE_LIST);

}

FrontUtils.includeTpl(TPL_STYLE_LIST, site, env);

FrontUtils.includePagination(site, params, env);

} else if (InvokeType.custom == type) {

FrontUtils.includeTpl(TPL_NAME, site, params, env);

FrontUtils.includePagination(site, params, env);

} else if (InvokeType.body == type) {

body.render(env.getOut());

FrontUtils.includePagination(site, params, env);

} else {

throw new RuntimeException("invoke type not handled: " + type);

}

DirectiveUtils.removeParamsFromVariable(env, paramWrap, origMap);

}

開發者ID:huanzhou,項目名稱:jeecms6,代碼行數:39,

示例20: execute

​點讚 2

import freemarker.template.TemplateDirectiveBody; //導入方法依賴的package包/類

@Override

public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException {

TemplateModel listModel = FtlUtils.getRequiredParameter(params, PARAMS_LIST);

String joiner = FtlUtils.getParameterByString(params, PARAMS_JOINER, "");

if(StringUtils.isBlank(joiner))

joiner = FtlUtils.getParameterByString(params, PARAMS_SEPARATOR, "");//兼容當初定義錯的寫法

Object datas = null;

if(listModel instanceof BeanModel){

datas = ((BeanModel) listModel).getWrappedObject();

}else{

throw new BaseException("error: " + listModel);

}

List> listDatas = LangUtils.asList(datas);

int index = 0;

for(Object data : listDatas){

if(loopVars.length>=1)

loopVars[0] = FtlUtils.wrapAsModel(data);

if(loopVars.length>=2)

loopVars[1] = FtlUtils.wrapAsModel(index);

if(index!=0)

env.getOut().write(joiner);

body.render(env.getOut());

index++;

}

}

開發者ID:wayshall,項目名稱:onetwo,代碼行數:30,

示例21: execute

​點讚 2

import freemarker.template.TemplateDirectiveBody; //導入方法依賴的package包/類

@SuppressWarnings("unchecked")

public void execute(Environment env, Map params, TemplateModel[] loopVars,

TemplateDirectiveBody body) throws TemplateException, IOException {

CmsSite site = FrontUtils.getSite(env);

Pagination page = cmsTopicMng.getPageForTag(getChannelId(params),

getRecommend(params), FrontUtils.getPageNo(env), FrontUtils

.getCount(params));

Map paramWrap = new HashMap(

params);

paramWrap.put(OUT_PAGINATION, DEFAULT_WRAPPER.wrap(page));

paramWrap.put(OUT_LIST, DEFAULT_WRAPPER.wrap(page.getList()));

Map origMap = DirectiveUtils

.addParamsToVariable(env, paramWrap);

InvokeType type = DirectiveUtils.getInvokeType(params);

String listStyle = DirectiveUtils.getString(PARAM_STYLE_LIST, params);

if (InvokeType.sysDefined == type) {

if (StringUtils.isBlank(listStyle)) {

throw new ParamsRequiredException(PARAM_STYLE_LIST);

}

env.include(TPL_STYLE_LIST + listStyle + TPL_SUFFIX, UTF8, true);

FrontUtils.includePagination(site, params, env);

} else if (InvokeType.userDefined == type) {

if (StringUtils.isBlank(listStyle)) {

throw new ParamsRequiredException(PARAM_STYLE_LIST);

}

FrontUtils.includeTpl(TPL_STYLE_LIST, site, env);

FrontUtils.includePagination(site, params, env);

} else if (InvokeType.custom == type) {

FrontUtils.includeTpl(TPL_NAME, site, params, env);

FrontUtils.includePagination(site, params, env);

} else if (InvokeType.body == type) {

body.render(env.getOut());

FrontUtils.includePagination(site, params, env);

} else {

throw new RuntimeException("invoke type not handled: " + type);

}

DirectiveUtils.removeParamsFromVariable(env, paramWrap, origMap);

}

開發者ID:huanzhou,項目名稱:jeecms6,代碼行數:40,

示例22: execute

​點讚 2

import freemarker.template.TemplateDirectiveBody; //導入方法依賴的package包/類

@SuppressWarnings("unchecked")

public void execute(Environment env, Map params, TemplateModel[] loopVars,

TemplateDirectiveBody body) throws TemplateException, IOException {

CmsSite site = FrontUtils.getSite(env);

Pagination page = cmsCommentMng.getPageForTag(null,

getContentId(params), getGreaterThen(params),

getChecked(params), getRecommend(params), getDesc(params),

FrontUtils.getPageNo(env), FrontUtils.getCount(params));

Map paramWrap = new HashMap(

params);

paramWrap.put(OUT_PAGINATION, DEFAULT_WRAPPER.wrap(page));

paramWrap.put(OUT_LIST, DEFAULT_WRAPPER.wrap(page.getList()));

Map origMap = DirectiveUtils

.addParamsToVariable(env, paramWrap);

InvokeType type = DirectiveUtils.getInvokeType(params);

String listStyle = DirectiveUtils.getString(PARAM_STYLE_LIST, params);

if (InvokeType.sysDefined == type) {

if (StringUtils.isBlank(listStyle)) {

throw new ParamsRequiredException(PARAM_STYLE_LIST);

}

env.include(TPL_STYLE_LIST + listStyle + TPL_SUFFIX, UTF8, true);

FrontUtils.includePagination(site, params, env);

} else if (InvokeType.userDefined == type) {

if (StringUtils.isBlank(listStyle)) {

throw new ParamsRequiredException(PARAM_STYLE_LIST);

}

FrontUtils.includeTpl(TPL_STYLE_LIST, site, env);

FrontUtils.includePagination(site, params, env);

} else if (InvokeType.custom == type) {

FrontUtils.includeTpl(TPL_NAME, site, params, env);

FrontUtils.includePagination(site, params, env);

} else if (InvokeType.body == type) {

body.render(env.getOut());

FrontUtils.includePagination(site, params, env);

} else {

throw new RuntimeException("invoke type not handled: " + type);

}

DirectiveUtils.removeParamsFromVariable(env, paramWrap, origMap);

}

開發者ID:huanzhou,項目名稱:jeecms6,代碼行數:41,

示例23: execute

​點讚 2

import freemarker.template.TemplateDirectiveBody; //導入方法依賴的package包/類

@Override

public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException {

String name = DirectivesUtils.getRequiredParameterByString(params, PARAMS_NAME);

OverrideBodyWraper override = DirectivesUtils.getOverrideBody(env, name);

if(override!=null){

if(override.render)

return ;

override.render(env.getOut());

}else{

if(body!=null)

body.render(env.getOut());

}

}

開發者ID:wayshall,項目名稱:onetwo,代碼行數:14,

示例24: executeTyped

​點讚 2

import freemarker.template.TemplateDirectiveBody; //導入方法依賴的package包/類

protected void executeTyped(Environment env, Map 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 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,

示例25: execute

​點讚 2

import freemarker.template.TemplateDirectiveBody; //導入方法依賴的package包/類

@Override

public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body)

throws TemplateException, IOException {

TemplateModel pItem = (TemplateModel) params.get("item");

SimpleScalar pVar = (SimpleScalar) params.get("var");

App app = App.get();

List navItems = app.registryGet(NavigationConstant.NAV_ITEMS);

List navItemIds = app.registryGet(NavigationConstant.NAV_ITEM_IDS);

boolean isActive = false;

String var = null;

if (pVar != null)

var = pVar.getAsString();

if (pItem != null && navItems != null) {

Object navItem = null;

if (pItem instanceof SimpleScalar) {

navItem = ((SimpleScalar) pItem).getAsString();

} else if (pItem instanceof SimpleNumber) {

navItem = Id.valueOf(((SimpleNumber) pItem).getAsNumber());

} else if (pItem instanceof StringModel) {

navItem = ((StringModel) pItem).getWrappedObject();

} else {

navItem = DeepUnwrap.unwrap(pItem);

}

if (navItem instanceof String) {

for (NavigationItem navigationItem : navItems) {

if ((navigationItem.getLabel() != null

&& Str.trimEqualsIgnoreCase((String) navItem, navigationItem.getLabel().str()))

|| Str.trimEqualsIgnoreCase((String) navItem, navigationItem.getDisplayURI())) {

isActive = true;

break;

}

}

} else if (navItem instanceof Id) {

isActive = navItemIds.contains(navItem);

} else if (navItem instanceof NavigationItem) {

isActive = navItemIds.contains(((NavigationItem) navItem).getId());

}

}

if (isActive && Str.isEmpty(var)) {

body.render(env.getOut());

} else {

env.setVariable(var, DefaultObjectWrapper.getDefaultInstance().wrap(isActive));

}

}

開發者ID:geetools,項目名稱:geeCommerce-Java-Shop-Software-and-PIM,代碼行數:52,

示例26: execute

​點讚 2

import freemarker.template.TemplateDirectiveBody; //導入方法依賴的package包/類

@SuppressWarnings("rawtypes")

@Override

public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body)

throws TemplateException, IOException {

SimpleScalar keyScalar = (SimpleScalar) params.get("key");

SimpleScalar valueScalar = (SimpleScalar) params.get("value");

String key = null;

String value = null;

// --------------------------------------------------------

// Attempt to fetch the key.

// --------------------------------------------------------

if (keyScalar != null) {

key = keyScalar.getAsString().trim();

}

if (key == null || "".equals(key.trim())) {

throw new IllegalArgumentException(

"The key parameter cannot be null or empty when specifying an import parameter");

}

// --------------------------------------------------------

// Attempt to get value from directive body.

// --------------------------------------------------------

if (body != null) {

StringWriter sw = new StringWriter();

try {

body.render(sw);

String bodyValue = sw.toString();

if (bodyValue != null && !"".equals(bodyValue.trim())) {

value = bodyValue.trim();

}

} finally {

IOUtils.closeQuietly(sw);

}

}

// --------------------------------------------------------

// Attempt to get value from directive attribute.

// --------------------------------------------------------

if (value == null && valueScalar != null) {

value = valueScalar.getAsString().trim();

}

if (key != null && value != null) {

env.getOut().write(new StringBuilder(URLEncoder.encode(key, "UTF-8")).append("=")

.append(URLEncoder.encode(value, "UTF-8")).append("\n").toString());

}

}

開發者ID:geetools,項目名稱:geeCommerce-Java-Shop-Software-and-PIM,代碼行數:56,

示例27: execute

​點讚 2

import freemarker.template.TemplateDirectiveBody; //導入方法依賴的package包/類

@SuppressWarnings("unchecked")

public void execute(Environment env, Map params, TemplateModel[] loopVars,

TemplateDirectiveBody body) throws TemplateException, IOException {

CmsSite site = FrontUtils.getSite(env);

Integer parentId = DirectiveUtils.getInt(PARAM_PARENT_ID, params);

Integer siteId = DirectiveUtils.getInt(PARAM_SITE_ID, params);

boolean hasContentOnly = getHasContentOnly(params);

Pagination page;

if (parentId != null) {

page = channelMng.getChildPageForTag(parentId, hasContentOnly,

FrontUtils.getPageNo(env), FrontUtils.getCount(params));

} else {

if (siteId == null) {

siteId = site.getId();

}

page = channelMng.getTopPageForTag(siteId, hasContentOnly,

FrontUtils.getPageNo(env), FrontUtils.getCount(params));

}

Map paramWrap = new HashMap(

params);

paramWrap.put(OUT_PAGINATION, DEFAULT_WRAPPER.wrap(page));

Map origMap = DirectiveUtils

.addParamsToVariable(env, paramWrap);

InvokeType type = DirectiveUtils.getInvokeType(params);

String listStyle = DirectiveUtils.getString(PARAM_STYLE_LIST, params);

if (InvokeType.sysDefined == type) {

if (StringUtils.isBlank(listStyle)) {

throw new ParamsRequiredException(PARAM_STYLE_LIST);

}

env.include(TPL_STYLE_LIST + listStyle + TPL_SUFFIX, UTF8, true);

} else if (InvokeType.userDefined == type) {

if (StringUtils.isBlank(listStyle)) {

throw new ParamsRequiredException(PARAM_STYLE_LIST);

}

FrontUtils.includeTpl(TPL_STYLE_LIST, site, env);

} else if (InvokeType.custom == type) {

FrontUtils.includeTpl(TPL_NAME, site, params, env);

} else if (InvokeType.body == type) {

body.render(env.getOut());

} else {

throw new RuntimeException("invoke type not handled: " + type);

}

DirectiveUtils.removeParamsFromVariable(env, paramWrap, origMap);

}

開發者ID:huanzhou,項目名稱:jeecms6,代碼行數:47,

示例28: execute

​點讚 2

import freemarker.template.TemplateDirectiveBody; //導入方法依賴的package包/類

public void execute(Environment env, Map params, TemplateModel[] loopVars,

TemplateDirectiveBody body) throws TemplateException, IOException {

// ---------------------------------------------------------------------

// 處理參數

int countParam = 0;

boolean countParamSet = false;

boolean hrParam = false;

Iterator paramIter = params.entrySet().iterator();

while (paramIter.hasNext()) {

Map.Entry ent = (Map.Entry) paramIter.next();

String paramName = (String) ent.getKey();

TemplateModel paramValue = (TemplateModel) ent.getValue();

if (paramName.equals(PARAM_NAME_COUNT)) {

if (!(paramValue instanceof TemplateNumberModel)) {

throw new TemplateModelException("The \"" + PARAM_NAME_HR

+ "\" parameter " + "must be a number.");

}

countParam = ((TemplateNumberModel) paramValue).getAsNumber()

.intValue();

countParamSet = true;

if (countParam < 0) {

throw new TemplateModelException("The \"" + PARAM_NAME_HR

+ "\" parameter " + "can't be negative.");

}

} else if (paramName.equals(PARAM_NAME_HR)) {

if (!(paramValue instanceof TemplateBooleanModel)) {

throw new TemplateModelException("The \"" + PARAM_NAME_HR

+ "\" parameter " + "must be a boolean.");

}

hrParam = ((TemplateBooleanModel) paramValue).getAsBoolean();

} else {

throw new TemplateModelException("Unsupported parameter: "

+ paramName);

}

}

if (!countParamSet) {

throw new TemplateModelException("The required \""

+ PARAM_NAME_COUNT + "\" paramter" + "is missing.");

}

if (loopVars.length > 1) {

throw new TemplateModelException(

"At most one loop variable is allowed.");

}

// Yeah, it was long and boring...

// ---------------------------------------------------------------------

// 真正開始處理輸出內容

Writer out = env.getOut();

if (body != null) {

for (int i = 0; i < countParam; i++) {

// 輸出


如果 參數hr 設置為true

if (hrParam && i != 0) {

out.write("


");

}

// 設置循環變量

if (loopVars.length > 0) {

loopVars[0] = new SimpleNumber(i + 1);

}

// 執行標簽內容(same as in FTL).

body.render(env.getOut());

}

}

}

開發者ID:hosken5,項目名稱:spring-boot-freemarker-showcase,代碼行數:74,

示例29: renderBody

​點讚 2

import freemarker.template.TemplateDirectiveBody; //導入方法依賴的package包/類

protected void renderBody(Environment env, TemplateDirectiveBody body) throws IOException, TemplateException {

if (body != null) {

body.render(env.getOut());

}

}

開發者ID:GojaFramework,項目名稱:goja,代碼行數:6,

示例30: execute

​點讚 2

import freemarker.template.TemplateDirectiveBody; //導入方法依賴的package包/類

@SuppressWarnings("unchecked")

public void execute(Environment env, Map params, TemplateModel[] loopVars,

TemplateDirectiveBody body) throws TemplateException, IOException {

CmsSite site = FrontUtils.getSite(env);

Integer parentId = DirectiveUtils.getInt(PARAM_PARENT_ID, params);

Integer siteId = DirectiveUtils.getInt(PARAM_SITE_ID, params);

boolean hasContentOnly = getHasContentOnly(params);

List list;

if (parentId != null) {

list = channelMng.getChildListForTag(parentId, hasContentOnly);

} else {

if (siteId == null) {

siteId = site.getId();

}

list = channelMng.getTopListForTag(siteId, hasContentOnly);

}

Map paramWrap = new HashMap(

params);

paramWrap.put(OUT_LIST, DEFAULT_WRAPPER.wrap(list));

Map origMap = DirectiveUtils

.addParamsToVariable(env, paramWrap);

InvokeType type = DirectiveUtils.getInvokeType(params);

String listStyle = DirectiveUtils.getString(PARAM_STYLE_LIST, params);

if (InvokeType.sysDefined == type) {

if (StringUtils.isBlank(listStyle)) {

throw new ParamsRequiredException(PARAM_STYLE_LIST);

}

env.include(TPL_STYLE_LIST + listStyle + TPL_SUFFIX, UTF8, true);

} else if (InvokeType.userDefined == type) {

if (StringUtils.isBlank(listStyle)) {

throw new ParamsRequiredException(PARAM_STYLE_LIST);

}

FrontUtils.includeTpl(TPL_STYLE_LIST, site, env);

} else if (InvokeType.custom == type) {

FrontUtils.includeTpl(TPL_NAME, site, params, env);

} else if (InvokeType.body == type) {

body.render(env.getOut());

} else {

throw new RuntimeException("invoke type not handled: " + type);

}

DirectiveUtils.removeParamsFromVariable(env, paramWrap, origMap);

}

開發者ID:huanzhou,項目名稱:jeecms6,代碼行數:45,

示例31: execute

​點讚 2

import freemarker.template.TemplateDirectiveBody; //導入方法依賴的package包/類

@SuppressWarnings("unchecked")

public void execute(Environment env, Map params, TemplateModel[] loopVars,

TemplateDirectiveBody body) throws TemplateException, IOException {

CmsSite site = FrontUtils.getSite(env);

int pageNo = FrontUtils.getPageNo(env);

int count = FrontUtils.getCount(params);

String query = getQuery(params);

String workplace= getWorkplace(params);

String category= getCategory(params);

Integer siteId = getSiteId(params);

Integer channelId = getChannelId(params);

Date startDate = getStartDate(params);

Date endDate = getEndDate(params);

Pagination page;

try {

String path = realPathResolver.get(Constants.LUCENE_PATH);

page = luceneContentSvc.searchPage(path, query,category,workplace, siteId, channelId,

startDate, endDate, pageNo, count);

} catch (ParseException e) {

throw new RuntimeException(e);

}

Map paramWrap = new HashMap(

params);

paramWrap.put(OUT_PAGINATION, DEFAULT_WRAPPER.wrap(page));

paramWrap.put(OUT_LIST, DEFAULT_WRAPPER.wrap(page.getList()));

Map origMap = DirectiveUtils

.addParamsToVariable(env, paramWrap);

InvokeType type = DirectiveUtils.getInvokeType(params);

String listStyle = DirectiveUtils.getString(PARAM_STYLE_LIST, params);

if (InvokeType.sysDefined == type) {

if (StringUtils.isBlank(listStyle)) {

throw new ParamsRequiredException(PARAM_STYLE_LIST);

}

env.include(TPL_STYLE_LIST + listStyle + TPL_SUFFIX, UTF8, true);

FrontUtils.includePagination(site, params, env);

} else if (InvokeType.userDefined == type) {

if (StringUtils.isBlank(listStyle)) {

throw new ParamsRequiredException(PARAM_STYLE_LIST);

}

FrontUtils.includeTpl(TPL_STYLE_LIST, site, env);

FrontUtils.includePagination(site, params, env);

} else if (InvokeType.custom == type) {

FrontUtils.includeTpl(TPL_NAME, site, params, env);

FrontUtils.includePagination(site, params, env);

} else if (InvokeType.body == type) {

body.render(env.getOut());

FrontUtils.includePagination(site, params, env);

} else {

throw new RuntimeException("invoke type not handled: " + type);

}

DirectiveUtils.removeParamsFromVariable(env, paramWrap, origMap);

}

開發者ID:huanzhou,項目名稱:jeecms6,代碼行數:54,

示例32: setLocalVariable

​點讚 1

import freemarker.template.TemplateDirectiveBody; //導入方法依賴的package包/類

/**

* 設置局部變量

*

* @param name

* 名稱

* @param value

* 變量值

* @param env

* Environment

* @param body

* TemplateDirectiveBody

*/

protected void setLocalVariable(String name, Object value, Environment env, TemplateDirectiveBody body) throws TemplateException, IOException {

TemplateModel sourceVariable = FreemarkerUtils.getVariable(name, env);

FreemarkerUtils.setVariable(name, value, env);

body.render(env.getOut());

FreemarkerUtils.setVariable(name, sourceVariable, env);

}

開發者ID:justinbaby,項目名稱:my-paper,代碼行數:19,

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值