14 Replies Latest reply: Mar 4, 2013 10:46 AM by Alejandro Tovar Lanz RSS

    Cascaded LOV issue

    RaghuBGowda
      Hi,

      I have a cascaded LOVs. Ideally it should work like this.

      Select a value from the first combo box LOV and based on the value selected, populate the second LOV and so on.

      When first LOV changes, in the second LOV, the first element should get selected by default. However this is not happening. Instead user is forced to choose an option from the LOV manually.

      Any help in how to select the first element in the LOV automatically?

      Regards,
      Raghu
        • 1. Re: Cascaded LOV issue
          Eric.Noah
          have you ever unselected the < include ''no selection" item >?
          may be you should give more information about what you set.
          • 2. Re: Cascaded LOV issue
            RaghuBGowda
            Hi Eric,

            I have unselected "No Selection". Let me elaborate more on this. Say I have 2 LOVs. 1 CountryLOV 2. StatesLOV.
            When I select a country from CountryLOV, based on this countryID, my StatesLOV gets populated and lists all the states for the countryId selected.

            Use Case:
            Select USA from CountryLOV. The StatesLOV list Alabama, Alaska, Arizona.....so on. Here Alabama is selected by default in the StatesLOV automatically when the page loaded.

            Now if I change my Country selection in the CountryLOV to Australia, the StatesLOV populates Tasmania, SouthAustralia... so on. However the issue is, the StateLOV's default selection in this case is sill Alabama. Whereas it should have been changed to Tasmania.

            Please help.

            Thanks,
            Raghu
            • 3. Re: Cascaded LOV issue
              Cvele_new_account
              Did you adjust partialTriiggers prpperty for the second (dependant) LOV ?
              It should point to the master LOV UI component
              • 4. Re: Cascaded LOV issue
                RaghuBGowda
                Hi Cvele,

                Yes. I have partialTrigger pointing to the master LOV. The lists are coming fine. However as I mentioned earlier, the child LOV still shows the previously selected Item, though that Item is not in its current list.

                Use Case:
                Select USA from CountryLOV. The StatesLOV list Alabama, Alaska, Arizona.....so on. Here Alabama is selected by default in the StatesLOV automatically when the page loaded.

                Now if I change my Country selection in the CountryLOV to Australia, the StatesLOV populates Tasmania, SouthAustralia... so on. But the selection is still Alabama which is not in the list.

                Requirement: When I select an item from masterLOV, I need the childLOV to list the item based on my selection from masterLOV and in addition the first element should be selected by default.

                Regards,
                Raghu
                • 5. Re: Cascaded LOV issue
                  Cvele_new_account
                  And you have autoSubmit="true" for the master LOV, right ?
                  • 6. Re: Cascaded LOV issue
                    RaghuBGowda
                    Hi Cvele,

                    Yes. I have autoSubmit=true.

                    is it possible to load run the childLOV model on valueChangeListener of the masterLOV and set the current row to the first row?

                    Regards,
                    Raghu
                    • 7. Re: Cascaded LOV issue
                      Cvele_new_account
                      Yes, something similar can be done. I know how this should be resolved, just as I do not have time to write you a solution. Maybe a little later ...
                      • 8. Re: Cascaded LOV issue
                        RaghuBGowda
                        Hi Cvele,

                        It would be greate If you can help in this.

                        Thanks,
                        Raghu
                        • 9. Re: Cascaded LOV issue
                          RaghuBGowda
                          Hi Cvele,

                          It would be greati if you can help in this.

                          Thanks,
                          Raghu
                          • 10. Re: Cascaded LOV issue
                            Eric.Noah
                            if you can solve this, can you tell me about it?
                            zhngjan@gmail.com.
                            thanks.

                            Eric.
                            • 11. Re: Cascaded LOV issue
                              RaghuBGowda
                              Hi Cvele,

                              If you know the solution could you please guide me in this? Its pretty urgent :(

                              Regards,
                              Raghu
                              • 12. Re: Cascaded LOV issue
                                Cvele_new_account
                                Basically, in the ViewRowImpl, in the setter method for the attribute on which the LOV is attached, you need to programmatically set "detail LOV attribute", from the LOV ViewAccessor. Unfortunately, I also have a lot of urgent work .. :-(
                                • 13. Re: Cascaded LOV issue
                                  RaghuBGowda
                                  Thanks Cvele. I ll try the suggestion.
                                  • 14. Re: Cascaded LOV issue
                                    Alejandro Tovar Lanz
                                    Hi,

                                    The solution shouldn't be that complicate. Just create a valueChangeListener in your first LOV's component.

                                    You need to update your model in the valueChangeEvent with your new value of yourFirstLOV:
                                        public void countryChanged(ValueChangeEvent valueChangeEvent) {
                                            ADFUtils.setValueToEL("#{bindings.yourFirstLOV.inputValue}",valueChangeEvent.getNewValue());
                                            ADFUtils.setValueToEL("#{bindings.yourSecondLOV.inputValue}",0);
                                        }
                                       
                                    The value for LOV are actually the indexes on the list of the element.

                                    If you are no using ADFUtils here is the implementation of that method:
                                        public static 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);
                                        }   
                                    Try this and post your results. Then only bad thing I can see from this is that if your name's bindings ever change (for example, change from yourSecondLOV to yourSecondLOV2) then you will have to update the java code.

                                    Regards

                                    Sorry, I had to edit because I made a mistake, now you should be able to try and post your results

                                    Edited by: Alejandro T. Lanz on Mar 4, 2013 8:41 AM