Today, while Anil and I were testing some new Ajax enhancements for the form widgets that Anil is working on I have realized that the use- when attribute works in this way:

use-when="example==null"

is evaluated to:

TRUE if the example variable is declared and null
FALSE  if the example variable is declared and not null
FLASE if the example variable is NOT declared

In fact for the Beanshell interpreter (by the way... should we consider to use Groovy instead of Beanshell for the use-when scripts too?) an undeclared variable is void but not null.

There may be situations where the variable is not declared; it seems natural to me to use, in these situations, the field with use- when="example==null".

However, there is a solution for this:

use-when="example==void || example==null"

but it is extra code (especially because we have to escape the | symbol with the & notation). Or we may just remove the use-when attribute for the default field; I mean:

instead of:

<field name="statusId" use-when="example==null">...</field>
<field name="statusId" use-when="example!=null">...</field>

use the equivalent version (that works also if the example variable is not declared):

<field name="statusId">...</field>
<field name="statusId" use-when="example!=null">...</field>

Should we introduce this pattern?

Jacopo

Reply via email to