12 Replies Latest reply: Dec 16, 2012 10:32 AM by Timo Hahn RSS

    LOV returning null value

    Tshifhiwa
      hi i have following LOV,which is geting value using a bean ,my problem is when i make selection i can see the value but when i check in my bean if the value i been selected i get null,am in jdeveloper 11.1.1.6.0
      my bean is
      public class Details {
       private String category;
      
          public void setCategory(String  category) {
              this.category = category;
              System.out.println("category " +category );
          }
          
          public String getCategory() {
              System.out.println("categorytest2 " +category );
              return category;
             
          }
      }
      and my lov is
      <af:selectOneChoice
                                              label="#{bindings.LutOrganisationtypesView1.label}"
                                              required="#{bindings.LutOrganisationtypesView1.hints.mandatory}"
                                              shortDesc="#{bindings.LutOrganisationtypesView1.hints.tooltip}"
                                              id="soc2"
                                              simple="true"
                                              value="#{pageFlowScope.orgDetailsBean.category}"
                                              autoSubmit="true">
                                              
                                            <af:forEach items="#{bindings.LutOrganisationtypesView1.iteratorBinding.allRowsInRange}"
                                        var="row">
                              <af:selectItem id="tiltcosBB2" label="#{row.description}"
                                             value="#{row.organisationtypecode}"/>
                            </af:forEach>      
                                          </af:selectOneChoice>
      i get this print out
      categorytest2 null
      categorytest2 null
      categorytest2 null
      categorytest2 null
      categorytest2 null
      categorytest2 null
      categorytest2 null
      categorytest2 null

      Edited by: adf0994 on 2012/12/13 1:39 PM

      Edited by: adf0994 on 2012/12/13 1:40 PM
        • 1. Re: LOV returning null value
          user404
          There are many solutions available on google regarding this 'problem'.
          https://blogs.oracle.com/adf/entry/getting_selected_value_from_selectonechoice
          • 2. Re: LOV returning null value
            Tshifhiwa
            i did this but still geting null value
            <af:selectOneChoice
                                                    label="#{bindings.LutOrganisationtypesView1.label}"
                                                    required="#{bindings.LutOrganisationtypesView1.hints.mandatory}"
                                                    shortDesc="#{bindings.LutOrganisationtypesView1.hints.tooltip}"
                                                    id="soc2"
                                                    simple="true"
                                                    value="#{pageFlowScope.orgDetailsBean.category}"
                                                    autoSubmit="true">
                                                    
                                                  <af:forEach items="#{bindings.LutOrganisationtypesView1.iteratorBinding.allRowsInRange}"
                                              var="row">
                                    <af:selectItem id="tiltcosBB2" label="#{row.description}"
                                                   value="#{pageFlowScope.orgDetailsBean.category}"/>
                                  </af:forEach>      
                                                </af:selectOneChoice>
            printout
            categorytest2 null
            categorytest2 null
            categorytest2 null
            categorytest2 null
            categorytest2 null
            categorytest2 null
            categorytest2 null
            categorytest2 null
            categorytest2 null
            • 3. Re: LOV returning null value
              Timo Hahn
              I don't know what's so complicated about this?
              I setup up a test case in minutes and it's working OK for me. Somehow your configuration isn't right. From your printouts I see that the setter of the bean is never called. All printouts of start with 'categorytest2' which is the getter. It sure will return null if it's never get a value via the setter!

              Add
              <af:outputText value="sel: #{pageFlowScope.orgDetailsBean.category}" id="ot1" partialTriggers="soc2"/>
              to your page and the that it changed when you select an other value in your lov. Next thing to check is that you have declared the pageFlowScope bean correclty in the bounded task flow definition file (e.g. adfc-config.xml). There you should find something like
                <managed-bean id="__4">
                  <managed-bean-name id="__3">orgDetailsBean</managed-bean-name>
                  <managed-bean-class id="__1">de.hahn.blog.xxyyzz.view.beans.Details</managed-bean-class>
                  <managed-bean-scope id="__2">pageFlow</managed-bean-scope>
                </managed-bean>
              Timo
              • 4. Re: LOV returning null value
                Tshifhiwa
                hi i change my lov to this
                    public void setCategory(String  cAtegory) {
                        System.out.println("categoryselected " +category);
                        this.category = cAtegory;
                        System.out.println("category " +cAtegory );
                    }
                    
                    public String getCategory() {
                        System.out.println("categorytest2 " +category );
                        return category;
                       
                    }
                
                <af:selectOneChoice
                                                        label="#{bindings.LutOrganisationtypesView1.label}"
                                                        required="#{bindings.LutOrganisationtypesView1.hints.mandatory}"
                                                        shortDesc="#{bindings.LutOrganisationtypesView1.hints.tooltip}"
                                                        id="soc2"
                                                        simple="true"
                                                        autoSubmit="true"
                                                        value="#{pageFlowScope.orgDetailsBean.category}"
                                                        valueChangeListener="#{pageFlowScope.orgDetailsBean.valueChanged}">
                                                       
                                                      <af:forEach items="#{bindings.LutOrganisationtypesView1.iteratorBinding.allRowsInRange}"
                                                  var="row">
                                        <af:selectItem id="tiltcosBB2" label="#{row.description}"
                                                       value="#{row.organisationtypecode}"/>
                                      </af:forEach>      
                                                    </af:selectOneChoice>
                
                
                    public void valueChanged(ValueChangeEvent valueChangeEvent) {
                        this.setValueToEL("#{pageFlowScope.orgDetailsBean.category}", valueChangeEvent.getNewValue()); //Updates the model
                        System.out.println("\n******** Selected Value: "+resolveExpression("#{row.organisationtypecode}"));
                        System.out.println("\n******** Display Value: "+resolveExpression("#{row.description} ne ' ' ? #{pageFlowScope.orgDetailsBean.category} : ''}"));
                    }
                      
                    public Object resolveExpression(String el) {      
                        FacesContext facesContext = FacesContext.getCurrentInstance();
                        ELContext elContext = facesContext.getELContext();
                        ExpressionFactory expressionFactory =  facesContext.getApplication().getExpressionFactory();        
                        ValueExpression valueExp = expressionFactory.createValueExpression(elContext,el,Object.class);
                        return valueExp.getValue(elContext);
                    }
                
                    public void setValueToEL(String el, Object val) {
                        FacesContext facesContext = FacesContext.getCurrentInstance();
                        ELContext elContext = facesContext.getELContext();
                        ExpressionFactory expressionFactory =   facesContext.getApplication().getExpressionFactory();
                        ValueExpression exp = expressionFactory.createValueExpression(elContext, el, Object.class);
                        exp.setValue(elContext, val);
                    }      
                    
                am geting this printout 
                categorytest2 null
                categorytest2 null
                categorytest2 null
                categoryselected null
                category PRIV 
                categorytest2 PRIV 
                
                ******** Selected Value: PRIV 
                categorytest2 PRIV 
                categorytest2 PRIV 
                
                ******** Display Value: PRIV  ne ' ' ? PRIV  : ''}
                categorytest2 PRIV 
                categorytest2 PRIV 
                categorytest2 PRIV 
                categorytest2 PRIV 
                categorytest2 PRIV 
                categorytest2 PRIV 
                categorytest2 PRIV
                
                and your output is showing code based on lov selection
                configuration IS ok

                Edited by: adf0994 on 2012/12/13 4:05 PM
                • 5. Re: LOV returning null value
                  Timo Hahn
                  adf0994,
                  I'm sorry to say that I don't understand what you are doing.

                  Why do you make everything more complicated?
                  Why don't you (as I did) setup a new sample project which only analyses the problem?

                  It took me 5 minutes to get my sample up and running, without writing any java code beside the bean you use to store the selected value.

                  If you'll like I make the sample available for you to analyse it in more detail. Sample need the HR schema as my LOV is set up on hte regions table.

                  Timo
                  • 6. Re: LOV returning null value
                    Tshifhiwa
                    timo am trying to check if am geting the VALUE when i do selection in my LOV,
                    i have re-create a problem where can i upload it ,which only anylise the problem

                    Edited by: adf0994 on 2012/12/13 5:12 PM
                    • 7. Re: LOV returning null value
                      Timo Hahn
                      You can upload your sample to any file hoster which is accessible for erverybody and hope that someone have a look at it. Don't forget to include a detailed description how to reproduce the problem.

                      Timo
                      • 8. Re: LOV returning null value
                        Tshifhiwa
                        hi i have upload the file in file hosting the link is BELOW,is there anybody can help me
                        http://www.filehosting.org/file/details/402997/LovCascanding.zip

                        Edited by: adf0994 on 2012/12/14 10:19 AM

                        Edited by: adf0994 on 2012/12/14 5:20 PM

                        Edited by: adf0994 on 2012/12/15 2:32 AM
                        • 9. Re: LOV returning null value
                          SrinivasJilla
                          Hi,

                          To download file it asks for email. Can you please upload where it doesn't ask for email/registration.

                          Thanks,
                          Srini
                          • 10. Re: LOV returning null value
                            Tshifhiwa
                            ok i upload it hear there is no email needed i just what to disable inputtext when making selection if lov selection = govt
                            http://www.filedropper.com/lovcascanding

                            Edited by: adf0994 on 2012/12/16 12:06 PM
                            • 11. Re: LOV returning null value
                              Subramanian Meyyappan
                              hi dude,

                              from the top to down of your of post your saying am getting null value from getter method which you had, while choosing lov.
                              i had a question '?'. what is the usecase? or else trying to re-produce anything?

                              this is to Timo,
                              first fall, i would like to thank doing here a great job. being long time am not here on forums.
                              • 12. Re: LOV returning null value
                                Timo Hahn
                                See the answer to your other thread {thread:id=2475331}

                                Timo