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


Comments:

Dear
can we simply use set property listener on the update button to copy each value to it's appropriate update field? if yes which one you think is faster ??
Thanks

Posted by Jaber Taslaq on November 20, 2012 at 01:27 AM PST #

Jaber, depending on the scenario a setPorpertyListener might work. If you'll try it in this case you'll see that you might run into problems while copying into key fields.

Posted by Shay on November 20, 2012 at 11:39 AM PST #

Hi Shay,
Is there a way to download source code for above demo ?

Posted by guest on January 08, 2013 at 12:26 PM PST #

guest, I don't have the code packaged - but if you just follow the video everything should work. If it doesn't post your issue on the OTN ADF Forum.

Posted by shay shmeltzer on January 08, 2013 at 04:59 PM PST #

Hi,
It would be nice to see an application that uses ADF Business Components through web service interface, AND List of values...

Posted by guest on January 09, 2013 at 05:35 AM PST #

Hello Shay
After executing the datacontrol method, How can I get the return value?

Posted by guest on May 13, 2013 at 11:50 PM PDT #

guest - check out the sample here to see how to invoke a WS programmatically - https://blogs.oracle.com/mobile/entry/web_services_example_part_2

Posted by Shay on May 14, 2013 at 12:56 PM PDT #

Hi Shay,
I had used your article and the video to successfully update the data through adfbc webservices. When I try to add a selectonechoice to the update field, it throws me an error back saying "The selected target attribute has read-only access.Please select an updateable attribute". Is there a workaround to handle this kind of update scenario.

Thanks

Posted by guest on August 27, 2013 at 09:22 AM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed
About

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

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