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

Posted by Shay Shmeltzer on Oracle Blogs See other posts from Oracle Blogs or by Shay Shmeltzer
Published on Mon, 19 Nov 2012 17:58:55 +0000 Indexed on 2012/11/19 23:14 UTC
Read the original article Hit count: 255

Filed under:

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[] {});
        }
    }


© Oracle Blogs or respective owner

Related posts about /Oracle/JDeveloper