Get the display value of selectonechoice or LOV in bean – Oracle ADF

I found one approach to get the display value of LOV in managed bean using  ADFUtils.evaluateEl method.

Say if you have a value change listener for an lov,  valueChangeEvent.getNewValue() gives the index of the value. To get the display value of the lov, use below logic  :

public void onDeptNameChange(ValueChangeEvent valueChangeEvent) {

Object deptNameAttribute = ADFUtils.evaluateEL("#{bindings.deptName.items['"+valueChangeEvent.getNewValue().toString()+

"'].label}");

String deptNameStr = deptNameAttribute .toString();  // This should have the selected display value of lov.

}

Say if you want to access the display value of LOV, in any other method, other than valueChange listener, then use below code :

Object deptNameAttribute = ADFUtils.evaluateEL("#{bindings.deptName.items['"+ADFUtils.getBoundAttributeValue("deptId")+"'].label}");

Here deptId is the code of this lov.  Hope this is helpful.

Happy learning with Techartifact……

Dynamic Creation of cascading Lov in oracle ADF or model driven Lov in Oracle ADF.

Requirement – I am working on tricky requirement where i have two child component and one child LOV.How to do that?

Solution- Well if you have working knowledge of cascading LOV in then we pass bind parameter of parent LOV attribute in child LOV View Accessor(VA) . But in this scenario , we have two master LOV. then we will be doing by passing through managed bean, using Application module session .

What i have done.I have used HR schema .

I have 3 view object. one as country table of HR schema.One View object for location table.One view which have all transient attribute and consider to be main view object.

As i found this approach in Jobinesh’s blog- i write a custom method in applicationModuleImpl.java as below –

    public void setLocationIDSessionData(String locId){
          System.out.println("hello 232323&&&"+locId);
        this.getSession().getUserData().put("LocationId", locId);
        
      }

I have getUserData method of applicationModule interface which returns a java.util.Hashtable which may be used to store user specific context that is related to this application session.

Read all other method related to this
http://docs.oracle.com/cd/E12839_01/apirefs.1111/e10653/oracle/jbo/ApplicationModuleHandle.html

Ok, coming back to this requirement – I used a managed bean in backing bean scope where i executed the binding of applicationModuleImpl custom method as below –

    public void executec(String valueChangeEvent) {
    BindingContext bctx = BindingContext.getCurrent();
           BindingContainer bindings = bctx.getCurrentBindingsEntry();
           OperationBinding op =
               (OperationBinding)bindings.getOperationBinding("setLocationIDSessionData");
           op.getParamsMap().put("locId",valueChangeEvent);
           op.execute();
    }

Here we are passing the value of both LOV to locationId to custom applicationModuleImpl method.In both parent LOV , i create valuechangeEvent method , which get the current selected countryId and pass to custom applicationModuleImpl method. that is below –

    public void VC(ValueChangeEvent valueChangeEvent) {
      System.out.println("hello &&&"+valueChangeEvent.getNewValue());
      
       
        executec(valueChangeEvent.getNewValue().toString());
    }

    public void vc2(ValueChangeEvent valueChangeEvent) {
        System.out.println("hello &&&34343"+valueChangeEvent.getNewValue());
        executec(valueChangeEvent.getNewValue().toString());
    }

Now we have final task, we have to set the value of child lov bind parameter in child View Accessor as adf.userSession.userData.LocationId

That’s it.now we will run the jspx , which have all 3 lov.2 parent and one child LOV.
for displaying LOV , we need to click on create button.after click you can see all 3 LOVs.

After selecting county as CH from countryLov1 , we will see different values in location ID.

Now we will select country as IN from countryLov2 , we will see different values in location ID.

You can download the sample application here.

ModelDrivernCascadingLOVs

Happy coding with Vinay kumar in techartifact….

Get the value from SelectOneChoice or LOV not the index in bean -Oracle ADF

Another approach i am sharing with you.Normally we want to get selectOneChoice value and we normally get the index.
We will creating an attribute in the selectOneChoice items and the selected value lable.

                        <af:selectOneChoice value="#{bindings.reportType.inputValue}"
                                          required="#{bindings.reportType.hints.mandatory}"
                                          shortDesc="#{bindings.reportType.hints.tooltip}"
                                          id="soc1" partialTriggers="cb2"
                                          autoSubmit="true"
                                          styleClass="hrt_reporting"
                                          valueChangeListener="#{pageFlowScope.ReportFilterBean.reportTypeVC}"
                                          binding="#{pageFlowScope.ReportFilterBean.reportTypeChoice}">
                        <f:selectItems value="#{bindings.reportType.items}"
                                       id="si2"/>
                        <f:attribute name="rowIndexVal" value="#{bindings.reportType.items[bindings.reportType.inputValue].label}"/>
                      </af:selectOneChoice>

and in the bean you can write as

        valueChangeEvent.getComponent().processUpdates(FacesContext.getCurrentInstance());
        Map map = ((UIComponent)valueChangeEvent.getSource()).getAttributes();
        String reportTypeValue = (String)map.get("rowIndexVal");

that’s it, you are done.

Happy coding with Vinay Kumar in techartifact,,