Pages

Monday, 23 March 2015

Configuring parameters in REST Data Control wizard

REST Data Control is a cool feature introduced recently in JDeveloper which enables you to consume JAX-RS RESTful services in ADF apps. By configuring the various operations in the data control wizard, a tree like structure gets created for you, which can then be dragged and dropped to the page.

Usecase:
This blogpost talks about configuring parameters - Query/Path parameters in the REST Data Control wizard.

Pre-requisites:
JDeveloper 12.1.3.0.0

Steps:
Let us assume that we have a REST service exposed at root URL:
http://<hostname>:<port>/REST-Service-Project1-context-root/resources/empInfo
with a structure as below:

@Path("empInfo)
public class EmployeeService
{
    :
    :
    @GET
    @Produces("application/xml")
    public Employees getEmpList() {
        :
    }

    @GET
    @Produces("application/xml")
    @Path("byID/{id}")
    public Employees getEmployeesByID(@PathParam("id") int id) {
        :
    }
   
    @GET
    @Produces("application/xml")
    @Path("managerList")
    public Employees getOnlyManagers(@QueryParam("isManager") String isManager) {
        :
    }
}

Invoke the REST Data control wizard, and create a connection(I prefer creating a connection till http://<host>:<port>, and configuring the rest of the URI in the next step, although that is purely a matter of choice). After this, you will come to the pane where you define resource URLs. The below snapshot tells you how you provide path param and query param URLs. In case of path param, you need to provide the path parameter with ##. For query params, provide the URL until the query param (excluding the parameter).




In the next step, select the resource method which requires a query param and add the query parameter by clicking the plus icon and providing a valid default value for it. Similarly, select the resource method which requires path param. The URL paramaters section will show up the parameter. Provide a valid default value.




Now, your URL connection should go through and data control must get created successfully.
The same steps can be used when using REST Data Controls with ADF Mobile.

No comments:

Post a Comment