Thursday, February 11, 2016

Cascading LOV : Default Value

Issue: In Cascading LOV's if one of the child LOV's had single value then it should be selected by default as soon as the user selects the value in parent LOV


Solution: 

The trick is to access the ViewAccessor of the LOV, check the estimated row count and if it is 1 then get the value and set it to the attribute of the View object.

Creating RowImpl for the view object and in the getter of the attribute add the following code


    /**     * Gets the attribute value for the calculated attribute LocationId.
     * @return the LocationId
     */
    public Number getLocationId() {
        return this.getLocationsLOV1().getRowCount() == 1
                 ? ((DBSequence)this.getLocationsLOV1().first().getAttribute("LocationId")).getSequenceNumber()
                 : (Number)getAttributeInternal(LOCATIONID);
    }

No comments:

Post a Comment