简化OFBiz中MyTasks.ftl模板代码
OFBiz有很长的发展历史,所以有些代码会显得有些陈旧,这里以MyTasks.ftl为例,说明可以调整的点:
- 使用
is_even_item
简化隔行着色的处理; - 使用
workEffort.currentStatusId
替代workEffort.getString("currentStatusId")
; - 使用
{"statusId": workEffort.currentStatusId}
替代Static["org.apache.ofbiz.base.util.UtilMisc"].toMap("statusId", workEffort.currentStatusId)
; - status项不可能为空,不需要追加
!
。
以下为完整的diff:
-- a/applications/workeffort/template/task/MyTasks.ftl
+++ b/applications/workeffort/template/task/MyTasks.ftl
@@ -29,15 +29,13 @@ under the License.
<td>${uiLabelMap.WorkEffortPriority}</td>
<td>${uiLabelMap.WorkEffortStatus}</td>
</tr>
- <#assign alt_row = false>
<#list tasks as workEffort>
- <tr<#if alt_row> class="alternate-row"</#if>>
- <td>${(workEffort.estimatedStartDate)!}</td>
+ <tr<#if workEffort?is_even_item> class="alternate-row"</#if>>
+ <td>${workEffort.estimatedStartDate!}</td>
<td><a href="<@ofbizUrl>WorkEffortSummary?workEffortId=${workEffort.workEffortId}</@ofbizUrl>">${workEffort.workEffortName}</a></td>
<td>${workEffort.priority!}</td>
- <td>${(delegator.findOne("StatusItem", Static["org.apache.ofbiz.base.util.UtilMisc"].toMap("statusId", workEffort.getString("currentStatusId")), true).get("description",locale))!}</td>
+ <td>${delegator.findOne("StatusItem", {"statusId": workEffort.currentStatusId}, true).get("description", locale)}</td>
</tr>
- <#assign alt_row = !alt_row>
</#list>
</table>
<#if (activities.size() > 0)>