22 October 2010

Fix Lov that does not return Secondary Attr values when Primary Value is the same

...or Different Secondary attrs cannot be selected for the same primary attr

Scenario

Let's say that we have a VO based on entity that has t least attrs:
  1. AttrPK1 which is  PK
  2. AttrPK2 also a PK
  3. AtrrsDesc is a required description
The 1st attr "AttrK1" we have an LOV that returns all 3 attrs


The following scenarion breaks it:

  •  raise LOV 
  • select a different row that has the same AttrPK1  but differnetAttrPK2  and press ok
  • then LOV does not return the AttrPK2 and Desc based on the different row cos AttrPK1 that the Lov is on did not change and it thinks that there no changes



Solution

In order to fix this we change AttrPK1 Lov 

page
     
                                            popupTitle="Lov title"
                                            value="#{bindings.AttrPK1.inputValue}"
                                            label="#{bindings.AttrPK1.hints.label}"
                                            model="#{bindings.AttrPK1.listOfValuesModel}"
                                            required="#{bindings.AttrPK1.hints.mandatory}"
                                            shortDesc="#{bindings.AttrPK1.hints.tooltip}"
                                            simple="true" autoSubmit="true"
                                            launchPopupListener="#{backing.attrPK1_LaunchListener}">
                       
                      

backing
   public void attrPK1_LaunchListener(LaunchPopupEvent launchPopupEvent) {
        //Always trigger the value change event.
        triggerValueChange(this.getAttrPK1());
    }

    /**
     * Triggers a change in the specified control's value.
     * The change is triggered even if there is not an actual change by the user.
     * Useful in cases where we always want the component to call its value change listener.
     */
    private void triggerValueChange(UIXValue cntrl) {   
        //trigger only when the control already has a value
        if (cntrl.getValue() != null) {
            //put a dummy value just to trigger value change
            cntrl.setValue(" ");
        }
    }

Note: In application module it wotks ok


Special Thanx to: Evgenia Maniati

No comments:

Post a Comment

You might also like:

Related Posts Plugin for WordPress, Blogger...