Pages

Friday, 6 November 2015

React-Native DrawerLayoutAndroid - How to Open the Menu on Click of an Menu Icon

Recently had a chance to develop an app using the react native. On of my requirement for the app was a hamburgur menu. While the DrawerLayoutAndroid available does the job, to a great extend, had a requirement to open the menu on click of the Home Menu/Hamburgur menu.

This turned out to be quite a challenge. The document did not provide any means to open the drawer. On digging deeper into the code, noticed one method within the DrawerLayoutAndroid.android.js called openDrawer. This looked to be promising but the challenge was this was withing the Component, but react provides a nice feature called ref which is a callback function that is executed after render returning an instance of the rendered component. By using this i was able to access the openDrawer method and open the menu as required.

The below code snippet will explain this better:
var MenuDrawerLayout = React.createClass({
    navigationView : function(){
        return (
             <View style={{flex: 1,alignItems: 'center'}}>
                <Text style={{margin: 10, fontSize: 15, textAlign: 'right'}}>Hello</Text>
                <Text style={{margin: 10, fontSize: 15, textAlign: 'right'}}>World!</Text>
              </View>
               );
    },
    drawerInstance : {instance : {openDrawer : function(){}}},
    initInstance : function(instance){
        console.log(instance);
        this.drawerInstance.instance = instance;
    },
    onMenuClick : function(event){
        //callback function called when menu is clicked. This
       console.log(this.drawerInstance.instance);
    this.drawerInstance.instance.openDrawer();
    },
    render:function(){
        return(<DrawerLayoutAndroid
            drawerWidth={dimension.width-56}
            drawerPosition={DrawerLayoutAndroid.positions.Left}
            ref={this.initInstance}
            renderNavigationView={this.navigationView}>
               <View style={styles.container} >
                    <View style={[styles.body]}>
                        <Header onMenuClick={this.onMenuClick}></Header>
                        <Dashboard.DashboardBody />
                    </View>
               </View>
        </DrawerLayoutAndroid>);
    }
})



Thursday, 5 November 2015

Creating ADFBC REST services - A new feature in Oracle JDeveloper 12.2.1

With the release of JDeveloper 12.2.1, a number of new features have come in. One particular feature w.r.t web services that has been introduced in this release is the ability to create RESTful services using ADF business components. In this blog, I will take you through the steps to expose ADFBC components as REST services.

Steps:
Create a new ADF fusion application.



Call the application ‘EmployeeDescribe’.


On the Model project, invoke the ‘Business Components From Tables’ wizard.


Connect to the DB in which you created the tables. I have used EMPLOYEES table from HR schema in my case. In Step 1 of the wizard, query and toggle the EMPLOYEES table to the RHS as shown.


In step 2, toggle EmployeesView to the RHS as shown. In Step 4, ensure ‘Add to Application Module’ is ticked. Click Finish to close the wizard.


To create the ADFBC REST service, open the AppModule by double clicking on it. Navigate to Web Service -> REST and click the plus icon. In the resulting dialog, click on the link provided.


It will take you to the adf-config.xml page. Navigate to 'Release versions' tab and create a new version.


Come back to the REST tab under App module and click the plus icon. Click Yes in the resulting dialog. Doing so will configure your application for REST services and add a new project to it.

Next, provide a name, say emp for the resource. This will expose the employee object with endpoint as emp.


Next, run the RESTWebService project. A URL gets generated in the console. Copy that to the browser and replace the last part with version/resourcename. So, the final URL may look something as below:
http://127.0.0.1:7101/EmployeeDescribe-RESTWebService-context-root/rest/rel1/emp

In the browser, a description of the emp resource is shown.
You can get the complete description of the service, by using a URL such as:

http://127.0.0.1:7101/EmployeeDescribe-RESTWebService-context-root/rest/rel1/describe


In this case, you will be able to see details about what resources the REST service exposes, the attributes that are present, their type, methods exposed etc. This is the basically a description of the REST service.
You have now successfully exposed your ADF business components as a REST service!!!