This discussion is archived
1 2 Previous Next 17 Replies Latest reply: Jul 31, 2013 5:36 AM by vinaykumar2 Go to original post RSS
  • 15. Re: adding new option in selectonechoice
    Timo Hahn Oracle ACE
    Currently Being Moderated

    I made a test case with out use case:

    here is the code from the page. mySeletion1 is an Integer variable in the binding layer.

                            <af:panelGroupLayout id="pgl2">

                                <af:selectOneChoice label="Label 1" id="soc1" value="#{bindings.mySeletion1.inputValue}" autoSubmit="true">

                                    <f:selectItems value="#{viewScope.SelectOneBean.valueList}" id="si1"/>

                                </af:selectOneChoice>

                                <af:outputText value="Selected Value: #{bindings.mySeletion1.inputValue}" id="ot2" partialTriggers="soc1"/>

                            </af:panelGroupLayout>

    here is the bean code

        List<SelectItem> valueList = null;

     

     

        public List<SelectItem> getValueList() {

            if (valueList == null || valueList.size() == 0) {

                valueList = getYourValueListFromServiceByRunningQuery();

            }

     

     

            return valueList;

        }

     

     

        private List<SelectItem> getYourValueListFromServiceByRunningQuery()

     

     

        {

            valueList = new ArrayList<SelectItem>();

            List valueListFromBinding = new ArrayList();

            BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry();

            // Get a attribute value of the current row of iterator

            DCIteratorBinding iterBind = (DCIteratorBinding) bindings.get("DepartmentsIterator");

            iterBind.executeQuery();

     

     

     

     

            RowSetIterator rowIter = iterBind.getRowSetIterator();

            Integer count = 0;

            while (rowIter.hasNext()) {

                count++;

                SelectItem selItNew = new SelectItem();

                Row row = rowIter.next();

                String nameValue = (String) row.getAttribute("DepartmentName");

                System.out.println("configGrp name: " + nameValue);

                selItNew.setLabel(nameValue);

                selItNew.setValue(count);

                valueList.add(selItNew);

            }

     

     

            SelectItem selIt = new SelectItem();

            selIt.setLabel("ALL");

            count++;

            selIt.setValue(count);

            valueList.add(selIt);

     

     

            return valueList;

        }

    As I don't have your data I use the departments VO to get the names for the select items.

     

    Timo

  • 16. Re: adding new option in selectonechoice
    webcentercontentnewbie Newbie
    Currently Being Moderated

    thanks it wkred....

  • 17. Re: adding new option in selectonechoice
    vinaykumar2 Expert
    Currently Being Moderated

    see this af:selectonechoice not getting updated | They point the finger at me.. again!

     

     

    it will help u. Set value as integer.if u need the value of selectonechoice. when u set value in selectitem, u can also put value and label in hashmap, and using valuchangelistener u can get the integer value and pass into hashmap and get value of selectonechoice...

1 2 Previous Next

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points