In the Struts2 framework, when I call this code in the JSP:
if(test='item.value > 0')
It will execute the following Java code:
getItem().getValue() > 0
Does this framework also allow support for boolean
attributes? Instead of a get()
method, they are usually called "is"
. For example, public boolean isValid()
instead of public boolean getValid
. If I do the following struts code:
if(test='item.valid')
will it call the appropriate isValid()
method or will it fail to find a getValid()
method and thus return null
?
It will call either isValid()
or getValid()
if one exist. If both methods exist which one will be called is not guaranteed by the Java reflection API. See Class#getDeclaredMethods()
. Also Struts2 internally uses method caching, so the first one gets into cache will be used for the next time. So, use one of this methods to access properties.