Java Code Examples for org.beetl.core.Tag

The following examples show how to use org.beetl.core.Tag. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
public void loading() throws AlbianParserException {
    try {
        FileResourceLoader resourceLoader = new FileResourceLoader(c.getRootPath(), c.getCharset());
        Configuration cfg = Configuration.defaultConfiguration();
        cfg.setHtmlTagSupport(true);
        gt = new GroupTemplate(resourceLoader, cfg);
        StringTemplateResourceLoader rl = new StringTemplateResourceLoader();
        sgt = new GroupTemplate(rl, cfg);
        Map<String, CustomTagConfigurtion> ctcs = c.getCustomTags();
        for (Map.Entry<String, CustomTagConfigurtion> entry : ctcs.entrySet()) {
            CustomTagConfigurtion ctc = entry.getValue();
            Class<? extends Tag> cla = (Class<? extends Tag>) AlbianClassLoader.getInstance().loadClass(ctc.getFullClassname());
            if (null != cla) {
                gt.registerTag(ctc.getName(), cla);
                sgt.registerTag(ctc.getName(), cla);
            }
        }

    } catch (Exception e) {
        throw new AlbianParserException(e);
    }

}
 
Example 2
Source Project: MeetingFilm   Source File: BeetlConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void initOther() {
    groupTemplate.registerFunctionPackage("shiro", new ShiroExt());
    groupTemplate.registerFunctionPackage("tool", new ToolUtil());
    groupTemplate.registerFunctionPackage("kaptcha", new KaptchaUtil());
    groupTemplate.registerTagFactory("dictSelector", new TagFactory() {
        @Override
        public Tag createTag() {
            return dictSelectorTag;
        }
    });

    groupTemplate.registerFunction("env", new Function() {
        @Override
        public String call(Object[] paras, Context ctx) {
            String key = (String)paras[0];
            String value =  env.getProperty(key);
            if(value!=null) {
                return getStr(value);
            }
            if(paras.length==2) {
                return (String)paras[1];
            }
            return null;
        }

        protected String getStr(String str) {
            try {
                return new String(str.getBytes("iso8859-1"),"UTF-8");
            } catch (UnsupportedEncodingException e) {
                throw new RuntimeException(e);
            }
        }
    });
}
 
Example 3
protected void callTag(TagFactory tagFactory)
{

	Tag tag = tagFactory.createTag();
	tag.init(ctx, args, bs);
	tag.render();

}
 
Example 4
/**
 * 返回上下文中对应Tag bean对象
 *
 * @return
 */
@Override
public Tag createTag()
{
	return applicationContext.getBean(name, Tag.class);
}