Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache Tapestry - IF with several conditions

I need to get 2 java fields in the one Tapestry table column. Every of my fields can be null. Can I write if condition in single line (2 fields in one IF operator), or I must write inner condition for second field?

Now I have this:

<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>
like image 459
Denys Avatar asked Mar 16 '15 08:03

Denys


2 Answers

JAVA

public boolean isSubjectQuantityAndUnitMeasurePopulated() {
    return subject.subjectQuantity != null && subject.unitMeasure != null;
}

TML

<t:if test="subjectQuantityAndUnitMeasurePopulated">
    <tr>
        <td>Subject count:</td>
        <td>${subject.subjectQuantity} ${subject.unitMeasure}</td>
    </tr>
</t:if>
like image 150
lance-java Avatar answered Dec 21 '22 23:12

lance-java


You can have any no of condition in your java code. Please refer below code.

Scrub.tml

  <t:if test="sitelistUtility">
        <label> ${sitelist.utility.name}</label>
  </t:if>

Scrub.java

public boolean isSitelistUtility() {
      return sitelist != null && sitelist.getUtility() != null;
  }
like image 24
Rakesh Singh Balhara Avatar answered Dec 22 '22 00:12

Rakesh Singh Balhara