8 Replies Latest reply: Oct 9, 2012 10:50 AM by 918581 RSS

    How to get the row selected in af:inputComboBoxListOfValues

    918581
      Hi,

      Am using jdev 11.1.1.2.1.

      Am using af:inputComboBoxListOfValues component , i have made the component based on the " department id" and the display value is " department name".

      In the value change listener i want to get the selected department id but currently am getting only the department name.(using valueChangeEvent.getNewValue().toString())

      So is there any way to get the entire row and get the "department id" using that ??

      Please help.


      Thanks,
      Hari
        • 1. Re: How to get the row selected in af:inputComboBoxListOfValues
          Timo Hahn
          Try
              public void StatusChangedListener(ValueChangeEvent valueChangeEvent)
              {
                  BindingContext lBindingContext = BindingContext.getCurrent();
                  BindingContainer lBindingContainer = lBindingContext.getCurrentBindingsEntry();
                  JUCtrlListBinding list = (JUCtrlListBinding) lBindingContainer.get("YOURCOMBOBOX");
                  int newindex = (Integer) valueChangeEvent.getNewValue();
                  Object row = list.getDisplayData();  // get the list elements
                  Row lFromList = (Row)list.getValueFromList(newindex);
                  Object lAttribute = lFromList.getAttribute("ID");
                  // work with the ID
              }
          Code is not tested...

          Timo
          • 2. Re: How to get the row selected in af:inputComboBoxListOfValues
            Arunkumar Ramamoorthy-Oracle
            Hari,

            Looks like your List attribute and display attribute both pointing to Department name.

            Check out this blog : https://blogs.oracle.com/adf/entry/getting_selected_value_from_selectonechoice

            -Arun
            • 3. Re: How to get the row selected in af:inputComboBoxListOfValues
              918581
              Hi Timo,

              The above app roach works fine , if we pass the newindex properly.

              But valueChangeEvent.getNewValue() is giving me the selected names instead of its index(like 1,2,3....)

              Please suggest me wat can be done... if i get the index , am done with it.

              Thanks,
              hari

              Edited by: Hari on Oct 9, 2012 12:42 AM
              • 4. Re: How to get the row selected in af:inputComboBoxListOfValues
                918581
                Hi Arun,

                The above link works for select one choice but i want for inputcombobox LOV, I tried but it is giving me null.

                Thanks,
                Hari
                • 5. Re: How to get the row selected in af:inputComboBoxListOfValues
                  Timo Hahn
                  Then try
                  public void StatusChangedListener(ValueChangeEvent valueChangeEvent)
                      {
                          BindingContext lBindingContext = BindingContext.getCurrent();
                          BindingContainer lBindingContainer = lBindingContext.getCurrentBindingsEntry();
                          JUCtrlListBinding list = (JUCtrlListBinding) lBindingContainer.get("YOURCOMBOBOX");
                          int newindex = list.getSelectedIndex();
                          Object row = list.getDisplayData();  // get the list elements
                          Row lFromList = (Row)list.getValueFromList(newindex);
                          Object lAttribute = lFromList.getAttribute("ID");
                          // work with the ID
                      }
                  Timo
                  • 6. Re: How to get the row selected in af:inputComboBoxListOfValues
                    918581
                    Hi Timo,

                    Here is my pagedef file of LOV.


                    <listOfValues StaticList="false" IterBinding="AppointmentEditVO1Iterator"
                    Uses="LOV_LeadName" id="LeadName" />

                    and here is the java code

                    BindingContext lBindingContext = BindingContext.getCurrent();
                    BindingContainer lBindingContainer = lBindingContext.getCurrentBindingsEntry();
                    JUCtrlListBinding list = (JUCtrlListBinding) lBindingContainer.get("LeadName");
                    int newindex = list.getSelectedIndex();
                    System.out.println("newindex"+newindex);
                    Object row = list.getDisplayData(); // get the list elements
                    Row lFromList = (Row)list.getValueFromList(newindex);

                    but am getting the newIndex as -1 always.

                    Please help whats going wrong here.

                    Thanks,
                    Hari

                    Edited by: Hari on Oct 9, 2012 2:36 AM
                    • 7. Re: How to get the row selected in af:inputComboBoxListOfValues
                      Timo Hahn
                      Sorry for the confusion, needed to check it out:
                      this code should work:
                          public void nameValueCangeListener(ValueChangeEvent valueChangeEvent) {
                              FacesContext contxt = FacesContext.getCurrentInstance();
                              valueChangeEvent.getComponent().processUpdates(contxt); // after this the new row is selected!
                              BindingContext lBindingContext = BindingContext.getCurrent();
                              BindingContainer lBindingContainer = lBindingContext.getCurrentBindingsEntry();
                              JUCtrlListBinding list = (JUCtrlListBinding) lBindingContainer.get("YOUR_LIST_BINDING_NAME"); 
                              Row lFromList = (Row)list.getCurrentRow();
                              Object lAttribute = lFromList.getAttribute("YOUR_ATTRIBUTE_YUO_WANT_TO_GET");
                          }
                      Timo
                      • 8. Re: How to get the row selected in af:inputComboBoxListOfValues
                        918581
                        Thanks Timo, Its perfect.

                        Thanks,
                        Hari