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,,

Master Detail iterations using tree component by managed bean

Requirement – Making sort of master detail iteration by selecting tree node and refresh another table in same page.

Solutions- This application is based on default HR schema. Using country view we are making an tree. When we select any of county node in tree, all location respective to countries will display to right side.Note- we don’t have any view link between both VO.

Drag drop countries VO as tree.

We have a view criteria in locationVO and we drag drop locationVO on to the page as table.
On country tree we have selecionListener , which return selected the current row of tree.Code is as below –

    public void selectionListener(SelectionEvent selectionEvent) {
        // Add event code here...
        //##{bindings.checklistStructureVO1.treeModel.makeCurrent}
        invokeMethodExpression("#{bindings.CountriesView1_1.treeModel.makeCurrent}", Object.class, SelectionEvent.class, selectionEvent);
        
        RichTree tree = (RichTree)selectionEvent.getSource();
           TreeModel model = (TreeModel)tree.getValue();      
           //get selected nodes
           RowKeySet rowKeySet = selectionEvent.getAddedSet();
        Iterator rksIterator = rowKeySet.iterator();
        //Validating for single select only. Need to check for multiselect
        while (rksIterator.hasNext()) {
            List key = (List)rksIterator.next();
            JUCtrlHierBinding treeBinding = null;
            CollectionModel collectionModel = (CollectionModel)tree.getValue();
            treeBinding = (JUCtrlHierBinding)collectionModel.getWrappedData();            
            JUCtrlHierNodeBinding nodeBinding = null;
            nodeBinding = treeBinding.findNodeByKeyPath(key);
            Row rw = nodeBinding.getRow();
      
            String country = (String)rw.getAttribute("CountryId");
           
            Map pageFlowScope = ADFContext.getCurrent().getPageFlowScope();
             pageFlowScope.put("countryId", country);
             
            BindingContainer bindings = getBindings();
        
         OperationBinding ob1 = bindings.getOperationBinding("executeSearchVo");
     
           ob1.getParamsMap().put("country", country);
       
           Object result = ob1.execute();
        
           if (!ob1.getErrors().isEmpty()){
              List errorList = ob1.getErrors();
               System.out.println("ERROR IN VC EXECUTION");
            //g Capture and handle Error
          }   
        
        AdfFacesContext.getCurrentInstance().addPartialTarget(this.getPbBinding());
    }
}

In the above method we are calling a custom appModuleImpl method and passing parameter to viewCriteria to location VO.We are also doing PPR programmaticly.

custom method of executing view Criteria –

    public void executeSearchVo(String country) {
        System.out.println("hello ob1"+ country);
    ViewObjectImpl traineeVO = this.getLocationsView1(); //relaventVO
    traineeVO.setApplyViewCriteriaName("LocationsViewCriteria");
    traineeVO.setNamedWhereClauseParam("country", country); //bindVariable name and pass value

     //criteriaName

    traineeVO.executeQuery(); //executeVO with Criteria

    }

That’s it. Now when you run the application it will look like as below –

You can download the sample application in below link.

TreeIteration

you are done. Happy coding with Vinay Kumar in Techartifact.

JDeveloper/ADF 12c is here….

Oracle released a new version of JDeveloper 12c. It is available for download now.
Many features are added in the new version.Few of them are listed below –


Java EE 6 Support –
JDeveloper wizards and editors have been updated to work with Java EE 6 specifications, including EJB 3.1, Servlet 3.0, CDI, JPA 2.0, EL 2.2, and more.

HTML5, MathML and CSS3 Support – Updated editors for working with latest HTML5 and CSS3 content.

EJB 3.1 Support – JDeveloper provides support for new EJB 3.1 features including:
— Singleton Session Bean
— Simplified No Interface Client View
— Asynchronous Session Bean Invocations

New Component: Timeline – is an interactive data visualization that allows users to view events in chronological order and easily navigate forwards and backwards within a defined time range.for example , we have in facebook.


Support for offline databases-
This feature enables the user to work with offline databases. The user can create new offline database objects based on existing objects in a database


Web Service Data Control Enhancements-

— Support for all REST operations
— Create a Web Service Data control from RESTful service URL

Oracle Public Cloud– Connect to, browse, and upload database objects to your Database Cloud Service in Oracle Public Cloud.

Read in detail –Jdeveloper 12c features

In future , i will blog about new features in details….

Happy coding in Jdeveloper 12c with Vinay 😉