Follow by Email

Monday, 22 May 2017

Populate select one choice using Web Service Data Control in ADF Application


My previous post was about creating a JAX-WS Web Service from Java Bean and consuming web service and showing data in ADF table. Now In this post, I am going to elaborate about consuming that Web Service in ADF Application and show Employees data in selectOneChoice component


So for this requirement, We need to use Web Service Data Control and from that WSDL we can create ADF Faces components

Let's see how to implement this

  • Create a Fusion Web Application


  • Right click on Model project and Select
    New-- From Gallery-- Business Tier -- Data Controls-- Web Service Data Control


  • Copy WSDL URL of Web Service that we created in the previous blog post and give Name and URL in WSDL creation wizard


  • Click on Next and shuttle method to selected side that you want to consume, Here I have selected getEmpList method


  • Click on Finish, We can see that DataControls.dcx file is generated. This file has list of data controls used in project and necessary information to initialize data control


  • Now create a Java Class in model project to hold selectOneChoice value


  • Java Code of EmpLov Java Class

    public class EmpLov {
        public EmpLov() {
            super();
        }
        //String variable to hold Employees Name
        private String empName;
    
        public void setEmpName(String empName) {
            this.empName = empName;
        }
    
        public String getEmpName() {
            return empName;
        }
    }
    

  • Right Click on Java Class and select Create Data Control


  • Now you can see it appears under Data Control


  • Drop empName on page as select one choice and configure it
 Click on Add button to select List Data Source and select Web Service


 Set List Attribute and Display Attribute and click on Ok button


All Done :) Now run and check application

Cheers :) Happy Learning

2 comments :

  1. Thank you for this post,

    Actually we have opposite scenario and we need your advice
    we need lov on some request attributes

    For example:
    On request service method we have (long variable1)
    On ui we need lov for this variable1 the user select one choice description from database then the value sent to variable1 as value of this description

    how we can handle this since we have many variables on all services as best practice??

    ReplyDelete
    Replies
    1. But why you want to apply Lov on Service attribute ?
      I don't think this is practical, WebServices are used to get you data and you can use that data to apply lov on some attribute

      Ashish

      Delete