Monday Nov 19, 2012

ADF Mobile - Update through Web Service (with ADF Business Components)

In my previous blog entry I went over the basics of exposing ADF Business Components through service interfaces, and developing a simple ADF Mobile application that access and fetches data from those services.

In this entry we'll dive a bit deeper  and address an update scenario through these web service interfaces.

You can see the full demo video at the end of the post.

In the first steps I show how to add an explicit method execution to fetch a specific record we want to update on the second page of a flow.

For an update you'll be invoking a service method and passing the record you want to update as a parameter. As in many other Web services scenarios, we need to provide a complete object of specific type to the method. The ADF Web service data control helps you here by offering an object of this type that you can drag and drop into your page.

The next step is to make sure to fill that object with the values you want to update. In the demo we do this through  coding in a backing bean that shows how to use the AdfmfJavaUtilities utility. The code gets the value from one field, gets a pointer to the parallel update field, and then copy from one to the other.

At the end of the bean we manually execute the call to the update method on the Web service.

Here is the demo:


Here is the code used in the backing bean in the demo above.

package a.mobile;

import oracle.adfmf.amx.event.ActionEvent;
import javax.el.MethodExpression;
import javax.el.ValueExpression;

import oracle.adfmf.amx.event.ActionEvent;
import oracle.adfmf.framework.api.AdfmfJavaUtilities;
import oracle.adfmf.framework.model.AdfELContext;
public class backing {
    public backing() {
    }

    public void copyAndUpdate(ActionEvent actionEvent) {
        // Add event code here...
        AdfELContext adfELContext = AdfmfJavaUtilities.getAdfELContext();
        ValueExpression ve = AdfmfJavaUtilities.getValueExpression("#{bindings.DepartmentName.inputValue}", String.class);
        ValueExpression ve3 =
            AdfmfJavaUtilities.getValueExpression("#{bindings.DepartmentName1.inputValue}", String.class);
        ve3.setValue(adfELContext, ve.getValue(adfELContext));
        ve = AdfmfJavaUtilities.getValueExpression("#{bindings.DepartmentId.inputValue}", int.class);
        ve3 = AdfmfJavaUtilities.getValueExpression("#{bindings.DepartmentId1.inputValue}", int.class);
        ve3.setValue(adfELContext, ve.getValue(adfELContext));
        ve = AdfmfJavaUtilities.getValueExpression("#{bindings.ManagerId.inputValue}", int.class);
        ve3 = AdfmfJavaUtilities.getValueExpression("#{bindings.ManagerId1.inputValue}", int.class);
        ve3.setValue(adfELContext, ve.getValue(adfELContext));
        ve = AdfmfJavaUtilities.getValueExpression("#{bindings.LocationId.inputValue}", int.class);
        ve3 = AdfmfJavaUtilities.getValueExpression("#{bindings.LocationId1.inputValue}", int.class);
        ve3.setValue(adfELContext, ve.getValue(adfELContext));
        MethodExpression me = AdfmfJavaUtilities.getMethodExpression("#{bindings.updateDepartmentsView1.execute}", Object.class, new Class[] {});
        me.invoke(adfELContext, new Object[] {});
        }
    }


About

me
I'm a Director of Product Management for the Oracle Java Development Tools.
Follow me:
Search

Archives
« November 2012 »
SunMonTueWedThuFriSat
    
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
20
21
22
23
24
25
26
27
28
29
30
 
       
Today