3 Replies Latest reply: Apr 27, 2013 2:54 PM by ramandeep singh - oracle RSS

    dependant lov second lov is in a bean

    Tshifhiwa
      hi i have a situation where i what to have cascanding lov but the problem is the second lov is pulling data from the oid using a bean,i what to pull the second lov based on the first lov selection which is geting data from the database
      my first lov is
      <af:selectOneChoice value="#{bindings.Branch.inputValue}"
                                    required="#{bindings.Branch.hints.mandatory}"
                                    shortDesc="#{bindings.Branch.hints.tooltip}"
                                    id="soc10">
                  <f:selectItems value="#{bindings.Branch.items}" id="si15"/>
                </af:selectOneChoice>
      
      it list two values
      Deeds and survey
      
      the second lov is
      <af:selectOneChoice id="soc5"
                                    valueChangeListener="#{pageFlowScope.InternalUserBean.InternalType}">
                                    <af:forEach var="item"
                                    items="#{pageFlowScope.InternalUserBean.childRoles}">
                          <af:selectItem value="#{item}" label="#{item}" id="tu7g"/>
                        </af:forEach>
                  <f:selectItems value="" id="si5"/>
                </af:selectOneChoice>
      
      it pull data from OID,using a bean
      if the firs lov selection is Deeds i what to pull this data from OID
          public  String[]  getUserTypesDeeds() {
                String userTypes [] = null;
                                                try{
                          
                              InitialDirContext ctx = null;
                              ctx = getOIDConnection();  
                              Attributes attrs = ctx.getAttributes("cn=");
                              DirContext ctxd =  ctx;
                              AttrLOV  attrLOV = AttrLOV.createAttrLOV("UserTypes", ctxd,"cn=Deeds",attrs) ;
                             // AttrLOV  attrLOV = AttrLOV.createAttrLOV("UserTypes", ctxd,"cn=Deeds, ",attrs) ;                      
                              userTypes = new String[attrLOV.getRealVals().length];
                              userTypes= attrLOV.getRealVals()   ;
                                 ctx.close();
      
                          } catch (Exception e) {
                 
                  e.printStackTrace();
                }
                                                return   userTypes;
            }
      
      if the firs lov selection is Survey i what to pull this data from OID in second lov
          public  String[]  getUserTypesSurvey() {
                String userTypes [] = null;
                                                try{
                          
                              InitialDirContext ctx = null;
                              ctx = getOIDConnection();  
                              Attributes attrs = ctx.getAttributes("cn=SecurityContext");
                              DirContext ctxd =  ctx;
                              AttrLOV  attrLOV = AttrLOV.createAttrLOV("UserTypes", ctxd,"cn=Survey,cn=UserTypes,cn=a",attrs) ;
                             // AttrLOV  attrLOV = AttrLOV.createAttrLOV("UserTypes", ctxd,"cn=Survey",attrs) ;                      
                              userTypes = new String[attrLOV.getRealVals().length];
                              userTypes= attrLOV.getRealVals()   ;
                                 ctx.close();
      
                          } catch (Exception e) {
                 
                  e.printStackTrace();
                }
                                                return   userTypes;
            }
      
      the whole code is
      private String userType;   
      
       public void setUserType(String userType) {
              this.userType = userType;
          }
      
          public String getUserType() {
              return userType;
          }   
      
      
       public String[] InternalType(ValueChangeEvent valueChangeEvent) {
              // Add event code here...
              String userTypes [] = null;
                                              try{
                        
                            InitialDirContext ctx = null;
                            ctx = getOIDConnection();  
                            Attributes attrs = ctx.getAttributes("cn=SecurityContext");
                            DirContext ctxd =  ctx;                 
                            AttrLOV  attrLOV = AttrLOV.createAttrLOV("UserTypes", ctxd,"cn=Deeds) ;
                            AttrLOV  attrLOV1 = AttrLOV.createAttrLOV("UserTypes", ctxd,"cn=Survey) ;                      
                            userTypes = new String[attrLOV.getRealVals().length] ;                     
                            userTypes= attrLOV.getRealVals();
                            ctx.close();
      
                        } catch (Exception e) {
               
                e.printStackTrace();
              }
                                              return   userTypes;
              }
      
            public   String[]   getChildRoles() {
                      
                     int  count = this.getUserTypesDeeds().length  this.getUserTypesSurvey().length;
                     String[] roles = new String[count]  ;
                          for( count = 0; count < this.getUserTypesDeeds().length; count++){
                              String t = (String)this.getUserTypesSurvey()[ count];
                              roles[count] = t ;
                              
                          }
                      for( count = 0; count < this.getUserTypesDeeds().length; count++){
                          String t = (String)this.getUserTypesSurvey()[ count];
                          roles[count] = t ;
                          
                      }
                      
                     
                         
                      return   roles ;
           
                     
                  }
          
          
      anybody to help

      Edited by: adf009 on 2013/04/27 11:01 AM

      Edited by: adf009 on 2013/04/27 11:05 AM
        • 1. Re: dependant lov second lov is in a bean
          ramandeep singh - oracle
          Hi,

          Use valuechangelistener to get the selected item value and then perform the search on oid , retrieve the results and populate the second selectone choice.

          You can also call processupdates to get the selecteditem value

          valueChangeEvent.getComponent().processUpdates(FacesContext.getCurrentInstance());

          --
          Regards,
          Ramandeep
          • 2. Re: dependant lov second lov is in a bean
            Tshifhiwa
            hi do u have sample to do that Use valuechangelistener to get the selected item value and then perform the search on oid how to do that
            • 3. Re: dependant lov second lov is in a bean
              ramandeep singh - oracle
              Hi,

              I don't have the sample for your exact requirement but i can tell you the approach.

              Do this get the selected value from select one choice call the method to perform search on OID (Read using OPSS API) after the search is performed populate the second select one choice list and add a partial target to the second select one choice which will cause it to refresh.

              OPSS utility

              Some useful fragment if you need to access other values from the selected row of select one choice.
              >
              //this gives you access to the contents of the select one choice row
              JUCtrlListBinding binding=(JUCtrlListBinding)bindings.getCtrlBinding("yourattrname");
              //typecheck just to be sure that some value is selected.
              if(binding instanceof Row){
              }
              Edited by: Ramandeep Nanda on Apr 28, 2013 1:20 AM