ジャワ
@Inject
private ComponentResources resources;
public boolean isActiveMenuItemIndex() {
String item = resources.getPageName().toString();
return item.contains("Index");
}
TML
<t:if test="${activeMenuItemIndex}">
<li class="active">
<t:pageLink page="Index">Index</t:pageLink>
</li>
<p:else>
<li>
<t:pageLink page="Index">Index</t:pageLink>
</li>
</p:else>
</t:if>
これは私の最初のアイデアであり、機能しますが、アイテムごとに個別のメソッドを作成し、t:if
それらのすべてに対して TML でタグを使用する必要があります。この問題のより良い解決策はありますか?