1 Reply Latest reply on Nov 17, 2012 7:36 AM by Cvele_new_account

    getting selected value from lov?

      Hi Everyone,

      i have 2lovs on selecting value from first lov the second lov gets filtered and didn't select anything from second lov. On clicking on submit button im getting the selected values from 2 lovs and printingit on the page.
      As i didnt select anything from second lov i should get null but im getting first value in the list.
      my code is:

      BindingContainer bindings2 = getBindings();
      DCIteratorBinding dcitorg2=(DCIteratorBinding)bindings2.get("BatchNoVO1Iterator") ;
      ViewObject vBatch=dcitorg2.getViewObject();
      batchNo= vBatch.getCurrentRow().getAttribute(0).toString();
      batchId= vBatch.getCurrentRow().getAttribute(3).toString();
      System.out.println("batch number:"+batchNo+"and batch id:"+batchId);
      else {
      System.out.println("Batch VO is null &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&");

      BindingContainer bindings3 = getBindings();
      DCIteratorBinding dcitorg3=(DCIteratorBinding)bindings3.get("StatusLovVO1Iterator") ;
      ViewObject vBatch3=dcitorg3.getViewObject();
      String OperNum= vBatch3.getCurrentRow().getAttribute(1).toString(); // this value is getting printed but i need null if  i dont select any value.
      System.out.println("Status selected is :"+OperNum);
      System.out.println("Operation Queue VO is null &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&");

      How to handle this?
      Plz help me to get out of this.

        • 1. Re: getting selected value from lov?

          1. Put this method in the your ViewRowImpl base class:
              public void resetAttributesAppliedByLOV(String listBindingName){
                  List attrsAppliedByLOV = getAttributesAppliedByLOV(listBindingName); 
              } // of resetAttributesNotSetsByLOV() method
               * @param listBindingName - the 'Uses' atribute value of <listOfValues> from the pageDef
               * @return the complete list of attrbutes applied by LOV (one on which it is LOV attached + set of 'List Return Values' attributes)
              public List getAttributesAppliedByLOV(String listBindingName){
                          List result  = new ArrayList();
                          ListBindingDef lbd = getViewDef().findListBindingDef(listBindingName);
                          if (lbd != null) {
                              List<String> lovAttrNames = Arrays.asList(lbd.getAttrNames());
                              String[] derivedAttrsNames = lbd.getDerivedAttrNames(); 
                              if (derivedAttrsNames != null) {
                                  List<String> lovListReturnValuesAttrs = Arrays.asList(derivedAttrsNames); 
                          return result;
              private void resetAttributes(List attrList){
                  Iterator it = attrList.iterator();
                  while (it.hasNext()){
                      String attrName = (String)it.next();
                      }catch(ReadOnlyAttrException roe) {
                          log.warn("**resetAttributes() ReadOnlyAttrException: " + roe.getMessage());
                  }// of while
          - Next, put this method in the Row Client interface, and add them to the your pageDef as <methodAction>

          Suppose in your pageDef, you have also
              <listOfValues StaticList="false"
                            Uses="YOUR_LOV" id="..."/>
          The NamedData NDValue for your method action should be YOUR_LOV

          2. Finally, make valueChangeListener for master LOV, in which you should execute your methodAction from pageDef you previously added, AND reset value for SECOND lov UI components, something like this:
              public void firstLOV_VCL(ValueChangeEvent e){
                  executeOperationBinding("resetAttributesAppliedByLOV"); // get a point...
          Let me know what happens
          1 person found this helpful