Monday, March 11, 2013

Get ADF Mobile Form values in managed bean using Accessor Iterator

Scenario is how to get the ADF Mobile form values in managed bean programmatically. Accessor Iterator can be used with AdfmfJavaUtilities.getValueExpression() method to get values.  getValueExpression method is for expressions that refer to values, this method should perform syntactic validation of the expression.

Below is one of the way to access from values, here is the code below.
ValueExpression ve =
            AdfmfJavaUtilities.getValueExpression("#{bindings.editEmployeeIterator.currentRow.dataProvider}",
                                                  Object.class);
        Object obj = ve.getValue(AdfmfJavaUtilities.getAdfELContext());
        Employee empRes = new Employee(); 
        if (obj instanceof ConcreteJavaBeanObject) {
            ConcreteJavaBeanObject cjbo = (ConcreteJavaBeanObject)obj;
            empRes = (Employee)cjbo.getInstance();
        }
        System.out.println(empRes.getId());
        System.out.println(empRes.getEmail());
        System.out.println(empRes.getFirstName());
        System.out.println(empRes.getLastName());
You can download the sample workspace from here. Application screen looks like below when it deployed and run on Android Device/Emulator. In first screen Employee list will be displayed, Next click on Add button to navigate for Employee form and looks like below.


Click on the Save button, check the employee form values by enabling debugger mode as shown below. You can check on how to Debugging ADF Mobile Apps on Android.


3 comments:

  1. Hi,
    What if my datacontrol returns an object instead of a List like your example? what EL should I write?
    thanks

    ReplyDelete
  2. Hi Deepak,

    One of the webservice input object is a collection (complex type - repeatable) with itemnumber and quantity , I have created a form with textbox to enter itemnumber and quantity.

    Added the command button for create, delete, first, last, next, previous that are shown under that collection.

    But on click of 'create' the values are not getting appended to the iterator, instead it is getting overwritten.

    Kindly help.

    ReplyDelete

  3. Thanks your blog is awesome.
    mobile recharge online
    Videocon Telecom, the next-generation GSM mobile service network is the telecom arm of the $10 billion Videocon Group. The company has partnered with global technology leaders to create a robust infrastructure featuring future ready mobile technologies. Powered by the most advanced GSM-EDGE network, Videocon Telecom aims to redefine the Indian mobile telecommunications industry by leveraging a combination of the parent company’s strong brand recall and retail reach with a spirit of innovation and customer centricity. Videocon endeavours to transform the life of every Indian consumer by changing the very paradigm of the way he or she communicates.

    ReplyDelete