navigation

How Oracle ADF Checkboxes Work (af:selectBooleanCheckbox)

How Oracle ADF Checkboxes Work (af:selectBooleanCheckbox)

Are you absolutely sure how af:selectBooleanCheckbox in ADF works? I’m not.

 

How ADF Checkboxes Work (af_selectBooleanCheckbox) 1

Every time when I need to use a value from af:selectBooleanCheckbox I need to recall in which situation what value will be returned.

Here you can find a short example of different returned values depending the binding Items getting values calls. If we add some different values for the checkbox in page definition file, we can be absolutely sure that the behavior is not predictable for a regular developer.

C:\Users\Monika\Desktop\How ADF Checkboxes Work (af_selectBooleanCheckbox) 2.png

For the experiment I will try to print the different values for one select boolean checkbox in different ways – ValueChangeEvent, EL Expression, Binding and Model values:

C:\Users\Monika\Desktop\How ADF Checkboxes Work (af_selectBooleanCheckbox) 3.png

How ADF Checkboxes Work (af_selectBooleanCheckbox) 4

How ADF Checkboxes Work (af_selectBooleanCheckbox) 5

As you can see all conventional ways to get the value from the Bean are limited to the Boolean value of the component. The only way I know to get the logical value of the component is to get it from the View Object.

C:\Users\Monika\Desktop\How ADF Checkboxes Work (af_selectBooleanCheckbox) 6.png

Be careful using af:selectBooleanCheckbox and be happy if you can skip it.

The next hidden treasure is about the default value of the check boxes. So,

Stay tuned #dreamixblog

 

Teodor Ognianov

Qualified IT professional focused on software development having rich background with Oracle technologies. Deep knowledge in Business Intelligence, It project management. Familiar with broad set of Java EE frameworks, including Oracle ADF, database servers as Oracle Database (9i, 10g, 11g), Database Replications, Heterogeneous Service. Teodor is a team player with good coaching skills, providing assistance with patience and deep understanding of knowledge sharing. Responsible and highly motivated.

More Posts - Website

Follow Me:
LinkedInGoogle PlusReddit

Do you want more great blogs like this?

Subscribe for Dreamix Blog now!

  • Dario

    Well, component named af:selectBooleanCheckbox can only work with boolean values. :)
    If model contains some other type of values(like “R”/”N” as in your example), you need to convert them with custom jsf converter(or by using implicit one which is created by ADF from mapping in pageDef file like in your example).

    Also, you are not taking into account JSF/ADF lifecycle: valueChangeListener is triggered before values are applied to the model so something like row.getAttribute(“…”) will return old value. Correct way to handle this is to first invoke: valueChangeEvent.getComponent().processUpdates(FacesContext.getCurrentInstance()) and then retrieve value from the model.

    • teodorognianov

      Thank you for the remarks. You are absolutely right!
      Thanks

    • Thanks, Dario. That opens a whole new chapter on the topic.

  • Ashwani Rathi

    I am using a boolean checkbox(af:selectBooleanCheckbox) in a drop down, like:

    embedded in a
    but here the keyboard short cut (spacebar) to check/ uncheck the checkbox is not working.
    I have checked the functionality of a standard checkbox which is not embedded in a dropdown where the space bar is working properly.

    Does anyone has any idea of any such problem when we use in a dropdown and how can we make it work?

    Thanks,
    Ashwani

    • Teodor Ognianov

      Hello Ashwani,

      Thank you for the comment!

      Which version of JDeveloper and ADF are using?

      • Ashwani Rathi

        Following are the versions used:
        JDev Version : 11.1.1.9.0
        ADF Business Components : 11.1.1.66.73