Forum Stats

  • 3,839,204 Users
  • 2,262,465 Discussions
  • 7,900,894 Comments

Discussions

Defaulting selectonechoice dropdown that is a component of an af:treetable

User_8YH96
User_8YH96 Member Posts: 9 Green Ribbon

Hello,

I am seeking a way to default the selectonechoice component's starting choice in a popup.

The use case is that if the dropdown only has 1 choice populated in the list, then the list will default to that choice in the selectonechoice dropdown.

If there is more than 1 choice in the list, then the dropdown should default to a null 'no selection' choice on the list by default.

Additionally, the selectonechoice component in mind is a part of a treetable structure, and I am attempting to get both parent and child selectonechoice dropdowns to default in the structure.

I have made a mockup using the HR schema that somewhat fits the design of the page I am trying to implement this feature on:

Tagged:

Comments

  • User_8YH96
    User_8YH96 Member Posts: 9 Green Ribbon

    <af:form id="f1">

          <af:panelGridLayout id="pgl1">

            <af:gridRow height="100%" id="gr1">

              <af:gridCell width="100%" halign="center" valign="middle" id="gc1">

                <af:selectOneChoice value="#{bindings.DepartmentsView1_1.inputValue}"

                          label="#{bindings.DepartmentsView1_1.label}" autoSubmit="true"

                          immediate="true"

                          required="#{bindings.DepartmentsView1_1.hints.mandatory}"

                          shortDesc="#{bindings.DepartmentsView1_1.hints.tooltip}" id="soc1">

                  <f:selectItems value="#{bindings.DepartmentsView1_1.items}" id="si1"/>

                  <f:validator binding="#{bindings.DepartmentsView1_1.validator}"/>

                </af:selectOneChoice>

                <af:button text="Employees" id="b1">

                  <af:showPopupBehavior popupId="p1"/>

                </af:button>

              </af:gridCell>

            </af:gridRow>

          </af:panelGridLayout>

          <af:popup childCreation="deferred" autoCancel="disabled" id="p1" contentDelivery="lazyUncached"

               binding="#{backingBeanScope.TestBean.testPopup}">

            <af:dialog id="d2">

              <f:facet name="buttonBar"/>

              <af:treeTable value="#{bindings.EmployeesView1_3.treeModel}" var="node" partialTriggers="::soc1"

                     rowSelection="single" id="tt1">

                <f:facet name="nodeStamp">

                  <af:column id="c1" width="100" headerText="Empployee Id">

                    <af:outputText value="#{node.bindings.EmployeeId.inputValue}" id="ot1"/>

                  </af:column>

                </f:facet>

                <af:column id="c2" width="200" headerText="First Name">

                  <af:outputText value="#{node.bindings.FirstName.inputValue}" id="ot2"/>

                </af:column>

                <af:column id="c3" width="200" headerText="LastName">

                  <af:outputText value="#{node.bindings.LastName.inputValue}" id="ot3"/>

                </af:column>

                <af:column id="c4" width="100" headerText="Salary">

                  <af:outputText value="#{node.bindings.Salary.inputValue}" id="ot4"/>

                </af:column>

                <af:column id="c5" width="100" headerText="Job History IDs">

                  <af:selectOneChoice value="#{node.bindings.JobId.inputValue}" label="#{node.bindings.JobId.label}" 

                            shortDesc="#{node.bindings.JobId.hints.tooltip}" id="soc2">

                    <f:selectItems value="#{node.bindings.JobId.items}" id="si2"/>

                  </af:selectOneChoice>

                </af:column>

                <f:facet name="pathStamp">

                  <af:outputText value="#{node}" id="ot998"/>

                </f:facet>

              </af:treeTable>

            </af:dialog>

          </af:popup>

        </af:form>

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

    User, tell us your exact JDev version, please!

    I don't see a mockup and so I don't see the selectOneChoice you are talking about. It's really hard to 'see' something from page code.

    From the data model, it will not work. A selectOneChoice will show the data represented in the row. So, if there is data for the attribute, the SOC will shoe the selected value. If no data is set for the attribute the SOC will show nothing (or empty). Showing the first value, in this case, doesn't make sense as it would mean that you have selected a value.


    Timo

  • dvohra21
    dvohra21 Member Posts: 14,618 Gold Crown

    As Timo indicated selecting first value is like selecting a value. May be what is needed is add a unselectedLabel label.

    unselectedLabel The label for the option that represents a value of null, meaning nothing is selected. If unselectedLabel is not set and if the component does not have a selected value, then an option with an empty string as the label and value is rendered as the first option in the choice box (if there isn't an empty option already defined). Once an option has been successfully selected, and if unselectedLabel is not set, then the empty option will not be rendered.

  • User_8YH96
    User_8YH96 Member Posts: 9 Green Ribbon


    Here are some screenshots that may help explain.

    In the example, you select a department from the dropdown, and then the employees button opens a popup containing a list of employee data on a treetable for that department.

    Under Employee ID 101, there are job history IDs in SOC dropdowns shown in child rows. Both children have two choices in their SOCs, and so should default to no selection or null.

    Under Employee Id 102 , there is one child with job history SOC of IT_PROG. This SOC only has one choice in the dropdown, and in this case I would want it to default to IT_PROG.

  • User_8YH96
    User_8YH96 Member Posts: 9 Green Ribbon
    edited Jun 7, 2022 4:52PM

    I have tried experimenting with the unselectedLabel property a little bit and haven't found much success in getting consistent behavior with it in the treeTable structure.

    The LOV for Job History SOC dropdowns are set to have 'Include "No Selection" Item' as 'Blank Item (First of List)'

  • dvohra21
    dvohra21 Member Posts: 14,618 Gold Crown

    I have tried experimenting with the unselectedLabel property a little bit and haven't found much success in getting consistent behavior with it in the treeTable structure.

    Not consistent, but does it generate the expected table for at least one row?

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

    User, my answer still stands.

    Regardless of what you try to do, with the given data model you will never get your result. A LOV only shows a value when the value is set to the storage behind it. As you use a tree table the storage for 'JobHistoryId' only exists in the JOB_HISTORY table and not in the EMPLOYEE table. The EMPLOYEE table only has a JOB_ID column that is set to the current job of the employee and a LOV would show the currently selected job or nothing if no job is set for the employee.

    So, to get what you want in your real data model, you have to check if only one item exists for your LOV and if yes, select it to the attribute value of the LOV.

    If you made changes to the data model for your test case, you should tell us about them.


    Timo