Apache Tapestry - 如果有几个条件

Den*_*nys 4 if-statement tapestry

我需要在一个 Tapestry 表列中获取 2 个 java 字段。我的每个字段都可以为空。我可以在单行中编写 if 条件(一个 IF 运算符中的两个字段),还是必须为第二个字段编写内部条件?

现在我有这个:

<t:if test="${subject.subjectQuantity}">
    <t:if test="${subject.unitMeasure}">
        <tr>
            <td>Subject count:</td>
            <td>${subject.subjectQuantity} ${subject.unitMeasure}</td>
        </tr>
    </t:if>
</t:if>
Run Code Online (Sandbox Code Playgroud)

lan*_*ava 5

爪哇

public boolean isSubjectQuantityAndUnitMeasurePopulated() {
    return subject.subjectQuantity != null && subject.unitMeasure != null;
}
Run Code Online (Sandbox Code Playgroud)

TML

<t:if test="subjectQuantityAndUnitMeasurePopulated">
    <tr>
        <td>Subject count:</td>
        <td>${subject.subjectQuantity} ${subject.unitMeasure}</td>
    </tr>
</t:if>
Run Code Online (Sandbox Code Playgroud)