Monday, August 3, 2015

ADF- Checkbox selection will be calculated using Groovy, based on additional helper attribute.

In this blog we will see how to select or deselect checkbox value:

Steps:

Create your EO and VO of Table.
In this Example , i have TransportUnitVO. Here,I want to set a check box value (true or false) to attribute Discard.


create one new transient attribute of type Boolean named as CheckedDis and write groovy as follow in expression field of that attribute.

 Now in a page create one column, drag and drop this attribute in it.
On value changed write below Code in managed bean:

public void discardCheck(ValueChangeEvent valueChangeEvent) {
       Row  row = ADFUtils.getSelectedCurrentRow("TransportUnitVOIterator");
        if(valueChangeEvent.getNewValue().toString().equalsIgnoreCase("true")){
            row.setAttribute("Discard", "true");
        }else{
            row.setAttribute("Discard", "false"); 
        }
    }

After drag and drop, in a page source should be:

<af:selectBooleanCheckbox value="#{row.bindings.CheckedDis.inputValue}"
                                               label="#{row.bindings.CheckedDis.label}"
                                       shortDesc="#{bindings.TransportUnitVO.hints.CheckedDis.tooltip}"
                                     autoSubmit="true" immediate="true" id="sbc1" 
                      valueChangeListener="#{workOrderBean.discardCheck}"/>



Save all changes and run Page:

Output:
After saving details of TransportUnitVO value inserted of attribute Discard is true or false:

                   



No comments:

Post a Comment