Package org.openxava.annotations
Annotation Interface Depends
Declares that a property depends on other one(s).
To define several properties, separate them using commas. To depend on a reference, use the qualified name of the key property (that is, for subfamily, use subfamily.number). Like this:
Applies to properties.
OpenXava uses this info in order to know when to recalculate
values of a property in the user interface.
Example:
@Depends("unitPrice")
public BigDecimal getUnitPriceInPesetas() {
if (unitPrice == null) return null;
return unitPrice.multiply(new BigDecimal("166.386")).setScale(0, BigDecimal.ROUND_HALF_UP);
}
In this case if the unitPrice changes in the user interface, the value of
unitPriceInPesetas is recalculated and redisplayed.To define several properties, separate them using commas. To depend on a reference, use the qualified name of the key property (that is, for subfamily, use subfamily.number). Like this:
@ManyToOne
private Subfamily subfamily;
@ManyToOne
private Subfamily subfamilyTo;
@Depends("subfamily.number, subfamilyTo.number")
public String getRangeDescription() {
int subfamilyNumber = getSubfamily() == null ? 0 : getSubfamily().getNumber();
int subfamilyToNumber = getSubfamilyTo() == null ? 0 : getSubfamilyTo().getNumber();
return "FROM SUBFAMILY " + subfamilyNumber + " TO SUBFAMILY " + subfamilyToNumber;
}
Since version 7.5.3, it is possible to indicate just the reference names, without the key.
So, the above @Depends could also be written in this way:
@Depends("subfamily, subfamilyTo")
public String getRangeDescription() {
Note: Since 7.5.3, we can use subfamily instead of subfamily.number for references.- Author:
- Javier Paniza
-
Required Element Summary
Required Elements
-
Element Details
-
value
String valueComma separated list of the properties this property depend on.
-