Using HashMap in EL expression to set component properties in Oracle ADF

Sharing is Caring

Basic requirement while using EL on pages in ADF, we use bean variables, binding attributes, iterators in expression to check conditions, to set properties for components as Enable-Disable, Visible, inline style etc.
In the same way, we can use collections like Array, HashMap in EL expression, I know it is pretty simple but has seen many threads on OTN asking how to use HashMap in expression So here I am taking a very simple example

I have 5 input text on the page and I have to enable-disable some fields based on its id value, there are two buttons on the page


as you can see on click of the first button, input field 1,3 and 5 should be disabled and on click of second button af:inputText 2 and 4 should be disabled
so for this purpose, I have used a HashMap in the managed bean

    private HashMap fieldVal = new HashMap();

    public void setFieldVal(HashMap fieldVal) {
        this.fieldVal = fieldVal;

    public HashMap getFieldVal() {
        return fieldVal;

values in HashMap are populated using id value of inputTexts on the page as key, this id will be passed as a parameter in HashMap in expression
see how expression used in disabled property of inputText-

HashMap in EL expression

in same way expression for all inputText is set

<af:panelFormLayout id="pfl1" partialTriggers="b1 b2">
                    <af:inputText label="Label 1" id="it1" disabled="#{EnableDisableBean.fieldVal['it1']}"/>
                    <af:inputText label="Label 2" id="it2"
                    <af:inputText label="Label 3" id="it3"
                    <af:inputText label="Label 4" id="it4"
                    <af:inputText label="Label 5" id="it5" autoSubmit="true"

now see code on buttons, simply setting values against key

    /**Method to disable inputText (1,3,5) on basis of id value
     * @param actionEvent
    public void disable135Action(ActionEvent actionEvent) {
        fieldVal.put("it1", true);
        fieldVal.put("it2", false);
        fieldVal.put("it3", true);
        fieldVal.put("it4", false);
        fieldVal.put("it5", true);


    /**Method to disable inputText (2,4) on basis of id value
 * @param actionEvent
    public void disable24Action(ActionEvent actionEvent) {
fieldVal.put("it1", false);
fieldVal.put("it2", true);
fieldVal.put("it3", false);
fieldVal.put("it4", true);
fieldVal.put("it5", false);

Run Application and see what is on page
On Click of First Button

On Click of Second Button

Happy learning 🙂

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *