This discussion is archived
1 2 3 4 Previous Next 55 Replies Latest reply: Dec 18, 2012 1:52 AM by adf009 Go to original post RSS
  • 15. Re: cascading lov using bean not passing selected parameter value
    user404 Pro
    Currently Being Moderated
    This is the best example I could find :
    http://adfdevelopers.blogspot.be/2009/06/how-to-implement-drop-down-list-in-adf.html
    This is of course just for one list. In de constructor of the bean you need to push the data into the first list.

    Then add a second list (for you second selectonechoice) and generate the getters and setters.
    Add a listener (like said before) on the first selectonechoice which fills the data into the second List and voila.
  • 16. Re: cascading lov using bean not passing selected parameter value
    adf009 Explorer
    Currently Being Moderated
    ok this is what i have done
    public class OrgDetails {
        private RichSelectOneChoice orgType;
        private String orgSubtype;
        private List orgCat1;
        private RichSelectOneChoice orgCat;
        public OrgDetails() {
                   SubType = new ArrayList();
            SelectItem sub = new SelectItem();
            SubType.add(sub);
            sub = new SelectItem();
            orgCat1 = new ArrayList();
           // orgCat = new RichSelectOneChoice();
            SelectItem type = new SelectItem(orgType);
            orgCat1.add(type);
    }
           public void setOrgCat(RichSelectOneChoice orgCat) {
            this.orgCat = orgCat;
        }
    
        public RichSelectOneChoice getOrgCat() {
            return orgCat;
        }
        public void setSubType(List type) {  
            this.SubType = type; 
            }
        public List getSub() {
            return SubType; 
            }
        private ResPerson resPerson;
    
        public void setResPerson(ResPerson resPerson) {
            this.resPerson = resPerson;
        }
        public void listener(AttributeChangeEvent attributeChangeEvent) {
            // Add event code here...
           
          
            AdfFacesContext.getCurrentInstance().addPartialTarget(orgCat);   
           
            refereshpage();
        }
       public void setOrgCat(RichSelectOneChoice orgCat) {
           this.orgCat = orgCat;
       }
    
       public RichSelectOneChoice getOrgCat() {
           return orgCat;
       }
    }
    
    FIRST lov
    <af:selectOneChoice
                                            label="#{bindings.LutOrganisationtypesView1.label}"
                                            required="true"
                                            shortDesc="#{bindings.LutOrganisationtypesView1.hints.tooltip}"
                                            id="soc2" simple="true"
                                            autoSubmit="true"
                                            immediate="true"
                                            rendered="true" attributeChangeListener="#{pageFlowScope.orgDetailsBean.listener}"
                                                                      binding="#{pageFlowScope.orgDetailsBean.orgCat}">
                    
                         <af:forEach items="#{bindings.LutOrganisationtypesView1.iteratorBinding.allRowsInRange}"
                                      var="row">
                            <af:selectItem id="tiltco2" label="#{row.description}"
                                           value="#{row.organisationtypecode}"/>
                          </af:forEach>                 
                        </af:selectOneChoice>
    
    second LOV
    <af:selectOneChoice
                                            label="#{bindings.OrgSubTypeViewVO1.label}"
                                            required="#{bindings.OrgSubTypeViewVO1.hints.mandatory}"
                                            shortDesc="#{bindings.OrgSubTypeViewVO1.hints.tooltip}"
                                            id="soc1" simple="true"
                                            partialTriggers="soc2"
                                            binding="#{pageFlowScope.orgDetailsBean.orgType}">
                                             <af:forEach items="#{bindings.OrgSubTypeViewVO1.iteratorBinding.allRowsInRange}"
                                      var="row">
                            <af:selectItem id="tilto2" label="#{row.Orgsubtypename}"
                                           value="#{row.orgsubtypecode}"/>
                          </af:forEach> 
                          <f:selectItems value="#{pageFlowScope.orgDetailsBean.orgType}"
                                         id="si1"/>
                        </af:selectOneChoice>
    the second lov is empty,even if i make selection form first lov.the first LOV i can make selection

    Edited by: adf0994 on 2012/11/09 2:02 PM

    Edited by: adf0994 on 2012/11/09 2:38 PM

    Edited by: adf0994 on 2012/11/09 3:41 PM

    Edited by: adf0994 on 2012/11/10 10:08 AM
  • 17. Re: cascading lov using bean not passing selected parameter value
    user404 Pro
    Currently Being Moderated
    I made a blog entry specially for you. Including an project example!
    http://adf4beginners.blogspot.be/2012/11/cascading-select-one-choice-using-bean.html
  • 18. Re: cascading lov using bean not passing selected parameter value
    adf009 Explorer
    Currently Being Moderated
    ok thanks let me go and implement your sample will give you feed back monday
  • 19. Re: cascading lov using bean not passing selected parameter value
    adf009 Explorer
    Currently Being Moderated
    hi is there a way i can do this without hard coded the value,access this variable from view using a bean
  • 20. Re: cascading lov using bean not passing selected parameter value
    user404 Pro
    Currently Being Moderated
    It's getting confussing again.
    First you to populate the SOC's with data from a bean, now you want to get it from a view.

    1) Or you put the data in a List using the iterator you use in the view
    2) Or you drag the on you page and let it > Single selection > Select One Choice.
  • 21. Re: cascading lov using bean not passing selected parameter value
    adf009 Explorer
    Currently Being Moderated
    hi i use the following code to pass values using iterator instead of hardcoded values
    public class TestBean {
        
        private List<OrgTypeBean> OrgTypeList;
        private List<OrgSubType> OrgSubList;
        private OrgTypeBean  selectOrgType = new OrgTypeBean ();
       
     
        
        public TestBean() {
                   OrgTypeList = new ArrayList<OrgTypeBean>();
            OrgSubList = new ArrayList<OrgSubType>();
            
            
            BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry();
            BindingContainer bindings2 = BindingContext.getCurrent().getCurrentBindingsEntry();
            //access the name of the iterator the table is bound to. 
            DCIteratorBinding dciter = (DCIteratorBinding) bindings.get("LutOrgsubtypesView1Iterator");
            DCIteratorBinding dciter2 = (DCIteratorBinding) bindings.get("LutOrganisationtypesView1Iterator");
            
            Row newRow =  dciter.getCurrentRow();
            Row newrow2 = dciter2.getCurrentRow();
        
            
            //String OrganisationTypecode = (String)currentRow.getAttribute("Organisationtypecode");
            String OrganisationTypecode = (String)newRow.getAttribute("Organisationtypecode");
            String OrgSubtype = (String)newRow.getAttribute("Orgsubtypename");
            String subtypecode = (String)newRow.getAttribute("Orgsubtypecode");  
            String description = (String)newrow2.getAttribute("Description");
            
            
            
            OrgTypeList.add(new OrgTypeBean(OrganisationTypecode ,description ));
            OrgSubList.add(new OrgSubType(subtypecode,OrgSubtype));
                 
             
        }
    
        public List<SelectItem> getOrgType()
           { 
              List<SelectItem> OrgTypeSelectItems = new ArrayList<SelectItem>();
              for (OrgTypeBean orgtype: OrgTypeList) 
              { 
                //SelectItem constructor (value, label)
                SelectItem item = new SelectItem(orgtype, orgtype.getDescrtion());
                OrgTypeSelectItems.add(item); 
             } 
              return OrgTypeSelectItems; 
            }
        
        public List<SelectItem> getSubTypeSelectedItem()
           { 
              List<SelectItem> subtypeSelectItems = new ArrayList<SelectItem>();
              if(selectOrgType != null)
              {
                  for (OrgSubType subtype:OrgSubList) 
                  { 
                    if(subtype.getsubOrgType() ==  selectOrgType.getOrgType())
                       // if(subtype.getsubOrgType().equal(selectOrgType.getOrgType())) == 0
    
                    {  
                       //SelectItem constructor (value, label)
                       //SelectItem item = new SelectItem(emp, emp.getFirstname() +" "+ emp.getLastname());
                       //SelectItem item = new SelectItem(subtype,subtype.getsubOrgType() + " "+ subtype.getOrgsubtypename());
                       SelectItem item = new SelectItem(subtype,subtype.getOrgsubtypename());
                       subtypeSelectItems.add(item); 
                    }
                  } 
              }
              return subtypeSelectItems; 
            }
        
        public void orgtypeChangedListener(ValueChangeEvent valueChangeEvent) {
           // selectOrgType = (OrgTypeBean)valueChangeEvent.getNewValue();
            //String tes
        OrgTypeBean   test = (OrgTypeBean)valueChangeEvent.getNewValue();
       
            System.out.println(test.getOrgType() ); 
            
            
            selectOrgType.setOrgType(test.getOrgType());
         
          
            System.out.println(valueChangeEvent.getOldValue());
           
              
        }
        
    }
    am only geting one value in first LOV

    Edited by: adf0994 on 2012/11/13 11:30 AM
  • 22. Re: cascading lov using bean not passing selected parameter value
    user404 Pro
    Currently Being Moderated
    You have a null pointer exception on line 58 of your TestBean.
    Propably in your constructor. If you can tell us what line 58 exactly is, mayby we can help.
  • 23. Re: cascading lov using bean not passing selected parameter value
    adf009 Explorer
    Currently Being Moderated
    i fix that error now am only showing one value in first lov and second LOV IS NOT IN LIST of value showing all value in one string,am also dispalying two same value in first LOV
    public class TestBean {
        
        private List<OrgTypeBean> OrgTypeList;
        private List<OrgSubType> OrgSubList;
        private OrgTypeBean  selectOrgType = new OrgTypeBean ();
       // private OrgTypeBean  selectOrgType;
     
        
        public TestBean() {
            OrgTypeList = new ArrayList<OrgTypeBean>();
            OrgSubList = new ArrayList<OrgSubType>();
            
            
            BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry();
            BindingContainer bindings2 = BindingContext.getCurrent().getCurrentBindingsEntry();
            //access the name of the iterator the table is bound to. 
            DCIteratorBinding dciter = (DCIteratorBinding) bindings.get("LutOrgsubtypesView1Iterator");
            DCIteratorBinding dciter2 = (DCIteratorBinding) bindings.get("LutOrganisationtypesView1Iterator");
            List<SelectItem> selectItems = new ArrayList<SelectItem>();
            
            Row newRow =  dciter.getCurrentRow();
            Row newrow2 = dciter2.getCurrentRow();
         //   Row newRow1 = rsi2.createRow();
            
            //String test3 = selectItems.add(new SelectItem(newRow.getAttribute.
            //String OrganisationTypecode = (String)currentRow.getAttribute("Organisationtypecode");
            String OrganisationTypecode = (String)newRow.getAttribute("Organisationtypecode");
            String OrgSubtype = (String)newRow.getAttribute("Orgsubtypename");
            String subtypecode = (String)newRow.getAttribute("Orgsubtypecode");  
            String description = (String)newrow2.getAttribute("Description");
            String  orgtype = (String)newRow.getAttribute("Organisationtypecode");
            
            
            
                  OrgTypeList.add(new OrgTypeBean(orgtype ,description ));
            OrgTypeList.add(new OrgTypeBean(OrganisationTypecode ,description ));
            OrgSubList.add(new OrgSubType(orgtype,OrgSubtype,subtypecode));
            
    
            
            
           
            
          
        }
        public  List<SelectItem> OrgType(){
            List<SelectItem> SelectItem = new ArrayList<SelectItem>();
          BindingContext bc = BindingContext.getCurrent();
          DCBindingContainer binding =
              (DCBindingContainer)bc.getCurrentBindingsEntry();
          DCIteratorBinding iter = binding.findIteratorBinding("LutOrganisationtypesView1Iterator");
          
          List<SelectItem> selectItems = new ArrayList<SelectItem>();
          for (Row r : iter.getAllRowsInRange()){
              selectItems.add(new SelectItem(r.getAttribute("Orgsubtypecode"), //as value
                                             (String)r.getAttribute("Description")));  //as display 
          }
          return selectItems;
        }
        public  List<SelectItem> Subtype(){
          
          BindingContext bc = BindingContext.getCurrent();
          DCBindingContainer binding =
              (DCBindingContainer)bc.getCurrentBindingsEntry();
          DCIteratorBinding iter = binding.findIteratorBinding("LutOrgsubtypesView1Iterator");
          
          List<SelectItem> selectItems = new ArrayList<SelectItem>();
          for (Row r : iter.getAllRowsInRange()){
              selectItems.add(new SelectItem(r.getAttribute("Organisationtypecode"), //as value
                                             (String)r.getAttribute("Orgsubtypename")));  //as display 
          }
          return selectItems;
        }
        public List<SelectItem> getOrgType()
           { 
              List<SelectItem> OrgTypeSelectItems = new ArrayList<SelectItem>();
              for (OrgTypeBean orgtype: OrgTypeList) 
              { 
                //SelectItem constructor (value, label)
                SelectItem item = new SelectItem(orgtype, orgtype.getDescrtion());
                OrgTypeSelectItems.add(item); 
             } 
              return OrgTypeSelectItems; 
            }
        
        public List<SelectItem> getSubTypeSelectedItem()
           { 
              List<SelectItem> subtypeSelectItems = new ArrayList<SelectItem>();
              if(selectOrgType != null)
              {
                  for (OrgSubType subtype:OrgSubList) 
                  { 
                    if(subtype.getsubOrgType() ==  selectOrgType.getOrgType())
                       // if(subtype.getsubOrgType().equal(selectOrgType.getOrgType())) == 0
    
                    {  
                       //SelectItem constructor (value, label)
                       //SelectItem item = new SelectItem(emp, emp.getFirstname() +" "+ emp.getLastname());
                       //SelectItem item = new SelectItem(subtype,subtype.getsubOrgType() + " "+ subtype.getOrgsubtypename());
                       SelectItem item = new SelectItem(subtype,subtype.getOrgsubtypename());
                       subtypeSelectItems.add(item); 
                    }
                  } 
              }
              return subtypeSelectItems; 
            }
        
        public void orgtypeChangedListener(ValueChangeEvent valueChangeEvent) {
           // selectOrgType = (OrgTypeBean)valueChangeEvent.getNewValue();
            //String tes
        OrgTypeBean   test = (OrgTypeBean)valueChangeEvent.getNewValue();
       // String test = (String)valueChangeEvent.getNewValue();
            System.out.println(test.getOrgType() ); 
            //selectOrgType.setOrgType(test);
            
            selectOrgType.setOrgType(test.getOrgType());
         
          
            System.out.println(valueChangeEvent.getOldValue());
           
              
        }
        
    }
    Edited by: adf0994 on 2012/11/13 11:54 AM

    Edited by: adf0994 on 2012/11/13 12:08 PM
  • 24. Re: cascading lov using bean not passing selected parameter value
    user404 Pro
    Currently Being Moderated
    Of course.
    You never use the methods OrgType() and Subtype() so the lists will only contain 1 value (the one from your constructor).
  • 25. Re: cascading lov using bean not passing selected parameter value
    adf009 Explorer
    Currently Being Moderated
    i like to know how will i pass the two method,and able to display value in list values,or is there other way i can do it
            OrgTypeList.add(new OrgTypeBean(otypecode ,Description ));
            OrgSubList.add(new OrgSubType(otypecode,oType,subtype ));
    how will i pass this two method
        public  List<SelectItem> OrgType(){
            List<SelectItem> SelectItem = new ArrayList<SelectItem>();
          BindingContext bc = BindingContext.getCurrent();
          DCBindingContainer binding =
              (DCBindingContainer)bc.getCurrentBindingsEntry();
          DCIteratorBinding iter = binding.findIteratorBinding("LutOrganisationtypesView1Iterator");
          
          List<SelectItem> selectItems = new ArrayList<SelectItem>();
          for (Row r : iter.getAllRowsInRange()){
              selectItems.add(new SelectItem(r.getAttribute("Orgsubtypecode"), //as value
                                             (String)r.getAttribute("Description")));  //as display 
          }
          return selectItems;
        }
        public  List<SelectItem> Subtype(){
          
          BindingContext bc = BindingContext.getCurrent();
          DCBindingContainer binding =
              (DCBindingContainer)bc.getCurrentBindingsEntry();
          DCIteratorBinding iter = binding.findIteratorBinding("LutOrgsubtypesView1Iterator");
          
          List<SelectItem> selectItems = new ArrayList<SelectItem>();
          for (Row r : iter.getAllRowsInRange()){
              selectItems.add(new SelectItem(r.getAttribute("Organisationtypecode"), //as value
                                             (String)r.getAttribute("Orgsubtypename")));  //as display 
          }
          return selectItems;
        }
    Edited by: adf0994 on 2012/11/13 12:32 PM

    Edited by: adf0994 on 2012/11/13 12:33 PM

    Edited by: adf0994 on 2012/11/13 12:37 PM

    Edited by: adf0994 on 2012/11/13 12:44 PM
  • 26. Re: cascading lov using bean not passing selected parameter value
    user404 Pro
    Currently Being Moderated
    http://adf4beginners.blogspot.be/2012/11/cascading-select-one-choice-using-bean.html
    Just change the way how I set/get the data to your business logic.
  • 27. Re: cascading lov using bean not passing selected parameter value
    adf009 Explorer
    Currently Being Moderated
    am not able to go to that link is block in my net work can you paste hear
  • 28. Re: cascading lov using bean not passing selected parameter value
    user404 Pro
    Currently Being Moderated
    Application download location :
    https://www.dropbox.com/sh/x0x5f4qlh6ua0sb/ymmvKcP6Sn
    Check out the bean and the index page.
  • 29. Re: cascading lov using bean not passing selected parameter value
    adf009 Explorer
    Currently Being Moderated
    the code is still have hard coded values i what to use iterator, i can do that,i what to access values from iterator not hard coded values
    i what this method to take value from iterator not hard coded values
        public TestBean() {
            
            OrgTypeList = new ArrayList<OrgTypeBean>();
            OrgSubList = new ArrayList<OrgSubType>();
           // OrgType();
            //Subtype();
                   
            String oType = null;
            String otypecode = null;
            String Description = null;
            String subtype = null;
            BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry();
            BindingContainer bindings2 = BindingContext.getCurrent().getCurrentBindingsEntry();
            //access the name of the iterator the table is bound to. 
            DCIteratorBinding dciter = (DCIteratorBinding) bindings.get("LutOrgsubtypesView1Iterator");
            DCIteratorBinding dciter2 = (DCIteratorBinding) bindings.get("LutOrganisationtypesView1Iterator");
            List<SelectItem> selectItems = new ArrayList<SelectItem>();
            
            for (Row r1 : dciter.getAllRowsInRange()){
                selectItems.add(new SelectItem(r1.getAttribute("Organisationtypecode"), //as value
                                               (String)r1.getAttribute("Orgsubtypename")));  //as display 
                 oType  = (String)r1.getAttribute("Orgsubtypename");
                 otypecode = (String)r1.getAttribute("Organisationtypecode");
                 subtype = (String)r1.getAttribute("Orgsubtypecode");
            }
            for (Row r : dciter2.getAllRowsInRange()){
                selectItems.add(new SelectItem(r.getAttribute("Organisationtypecode"), //as value
                                               (String)r.getAttribute("Description")));  //as display 
                                               Description= (String)r.getAttribute("Description");
    
            OrgTypeList.add(new OrgTypeBean(otypecode ,Description ));
            OrgSubList.add(new OrgSubType(otypecode,oType,subtype ));
            }
    Edited by: adf0994 on 2012/11/13 1:06 PM

    Edited by: adf0994 on 2012/11/13 1:14 PM

    Edited by: adf0994 on 2012/11/13 1:14 PM

    Edited by: adf0994 on 2012/11/13 1:16 PM

Legend

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