Posts tagged required
The requirement I was dealing with today in ADF 11g Rich Client Components was the following: we have an input field that is required under certain conditions. Only when one of this cluster of fields has a value, is it required. Otherwise it is optional. The use case was that the fields represent a detail record. There does not need to be a detail record (optional) but if there is one (one of the fields in the detailrecord has a value), then certain fields are mandatory.
The desire was to dynamically set the required-ness of the inputText – depending on whether one of the items in the detail record cluster has a value or not. Dynamically means that when something changes with one of the items, the conditionally required item is immediately refreshed to either required or optional.
It turned out to be fairly easy to implement: the required attribute can be set using an EL expression that refers to a bean method. In the bean we can easily check the values of the other items and determine whether or not based on that assessment the inputText component is mandatory or not. By setting autoSubmit to true for all the items that determine the mandatoriness – and by adding the More >