Forum Stats

  • 3,816,718 Users
  • 2,259,226 Discussions
  • 7,893,550 Comments

Discussions

How to check if select one choice component only contains 1 option?

User_8YH96
User_8YH96 Member Posts: 1 Green Ribbon

Hello all.

On the page I'm currently developing there is a popup which contains a tree table component with multiple columns and select one choice components, and one child disclosure also containing an soc component.

I am seeking a way to check if there is only one select item choice in the soc dropdown, and if so, I want the soc to default to the only available choice.

The soc components are populated dynamically and so may contain a varying number of elements in each dropdown. I have been trying to find a way to count the number of elements in the dropdown but have not found a successful way to count the number of items for both parent and child node lov/soc components.

So basically, I want to check if the soc item list count equals "1". If there is only "1" item option, then default the soc to that value.

Thank you for reading.

My Jdeveloper version is 12.2.1.4

Answers

  • Timo Hahn
    Timo Hahn Senior Principal Technical Consultant - Oracle ACE Director Member, Moderator Posts: 38,299 Red Diamond

    A selectOneChoice gets its items from an f:selectItems tag value property. This value is pointing to a collection and you should be able to count the number of items in the collection.

    As you say you dynamically create this collection (an ArrayList I guess), so you can get the number of items using ArrayList.size() method.


    Timo

    User_8YH96
  • Timo Hahn
    Timo Hahn Senior Principal Technical Consultant - Oracle ACE Director Member, Moderator Posts: 38,299 Red Diamond

    User, you said that the LOV is built dynamically. This I don't see from your code sample.

    Anyway, I don't know if you can use EL to get the info you are looking for. In a bean, you can get the select items and get their size via java. I don't understand what you mean by getting the number of parent nodes.

    Setting the selectOneChoice to the first element (or only element) is done by setting the value property of the af:seleectOneChoice to the value of the first element. This can be done in the bean too.


    Timo

  • Timo Hahn
    Timo Hahn Senior Principal Technical Consultant - Oracle ACE Director Member, Moderator Posts: 38,299 Red Diamond

    It's only one f:selectItems statement, but the data used is coming from the node so it can change each time the node changes.

    Do you have a reproducible test case build on the HR DB schema?


    Timo