数字字典为key -value对,使用一个通用方法如下
1.
@IocBean
public class SysDicSelectOptionTag extends GeneralVarTagBinding {
@Inject
private SysDictService sysDictService;
@Override
public void render() {
String dicCode = Strings.sNull(this.getAttributeValue("code"));
Sys_dict dict;
if (Strings.isNotBlank(dicCode)) {
dict = sysDictService.fetch(Cnd.where("code", "=", dicCode));
}else{
return;
}
String parentId= dict.getId();
List<Sys_dict> lst= sysDictService.query(Cnd.where("parentId","=",parentId).asc("location"));
for (Sys_dict channel : lst) {
this.binds(channel);
this.doBodyRender();
}
}
}
加入tag
```
<#dic_bycode_list code="workflow" var="o2">
${o2.name!}
</#dic_bycode_list>
别忘了注册在setup.java
for (ViewMaker vm : config.getViewMakers()) {
if (vm instanceof BeetlViewMaker) {
((BeetlViewMaker)vm).groupTemplate.registerTagFactory("dic_bycode_list", ()->ioc.get(SysDicSelectOptionTag.class));
}
}
```