Sunday, March 2, 2014

ADF Mobile - Reading custom properties from adf-config.xml

Take a scenario where you have integrated the push notification feature into mobile application and application needs to be shipped to client, to work push notification feature you need Sender ID for both Android and iOS and client want's to use their own Sender Id.

Next question will be where can we store the custom Sender Id in the application so that the client can edit. Credit goes to Srini Indla(Oracle), I have extracted the idea based on one of his forum reply and below is one of the way.

Custom values can be stored in add-config.xml file under <adf:adf-properties-child> tag, add-config.xml is used to configure application-level settings, including the Configuration Service parameters and read more on ADF Mobile Configuration Service Usage. The advantage of storing the properties and accessing it via the adf-confg.xml is that the values can be accessible using the EL expression at run time.

Below is a sample adf-confif.xml with custom properties:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<adf-config xmlns="http://xmlns.oracle.com/adf/config" xmlns:config="http://xmlns.oracle.com/bc4j/configuration"
            xmlns:adf="http://xmlns.oracle.com/adf/config/properties">
  <adf-adfm-config xmlns="http://xmlns.oracle.com/adfm/config">
    <defaults changeEventPolicy="ppr" useBindVarsForViewCriteriaLiterals="true"/>
    <startup>
      <amconfig-overrides>
        <config:Database jbo.locking.mode="optimistic"/>
      </amconfig-overrides>
    </startup>
  </adf-adfm-config>
  <adf:adf-properties-child xmlns="http://xmlns.oracle.com/adf/config/properties">
    <adf-property name="adfAppUID" value="MobileAdfConfig-1564"/>
    <adf-property name="username" value="Weblogic"/>
    <adf-property name="password" value="Weblogic1"/>
  </adf:adf-properties-child>
</adf-config>
In Amx page you can access the above custom defined properties using EL expression.
For ex:  "#{applicationScope.configuration.username}"

Below is the sample code to access custom properties from adf-config.xml in managed bean.
ValueExpression userNameVe =
            AdfmfJavaUtilities.getValueExpression("#{applicationScope.configuration.username}", String.class);
String userName = (String)userNameVe.getValue(AdfmfJavaUtilities.getAdfELContext());

ValueExpression passwordVe =
            AdfmfJavaUtilities.getValueExpression("#{applicationScope.configuration.password}", String.class);
String password = (String)passwordVe.getValue(AdfmfJavaUtilities.getAdfELContext());

23 comments:

  1. Could you set the property on the fly as well?. For instance, from a value returned from a REST service?

    ReplyDelete
  2. There is a great blog about Oracle ADF and thanks for sharing about Oracle ADF information. We are providing online training classes OracleADFonlinetraining

    ReplyDelete
  3. Avail the best assistance for QuickBooks on Quickbooks Phone Number1 877-948-5867.

    ReplyDelete
  4. Small business owners benefit from the accounting software as it helps business owners to track all the processes of accounting. QuickBooks is one of the best accounting software Quickbooks Phone Number.

    ReplyDelete
  5. Obtain pocket-friendly technical support service for QuickBooks at Quickbooks Phone Number 1833-244-5865

    ReplyDelete
  6. Let us take the pleasure to serve you, trust our team at Quickbooks Phone Number 1 855-377-7767 will surely help you get out of every technical glitch you are facing or going to face in the future.
    Quickbooks Phone Number

    ReplyDelete
  7. Avail curbing solutions for QuickBooks at quickbooks phone number Quickbooks Phone Number 1 316-600-2287

    ReplyDelete
  8. Really so amazing picture thanks for sharing .if you have anu problem with quickbooks software then please contact at

    QuickBooks Customer Service

    ReplyDelete
  9. QuickBooks is a user-friendly accounting software which helps you to manage and run your accounts smoothly with more impact to your business. But, there are rare times when our customers struggle with persistent bugs & errors, namely QuickBooks Error 15215.
    quickbooks customer service (866)-822-4745

    ReplyDelete
  10. QuickBooks Error 15215 is usually triggered by a conflict with another application running in the background when you attempt to download and install a payroll update.
    quickboks customer service(855) 742-7868.

    ReplyDelete
  11. There are many ways to resolve QuickBooks Error 15215 and get your affairs back running on our software like - rebooting the system or running QuickBooks as a Windows Administrator. However, you can contact our team at
    Quickbooks Phone Number (877) 762-1118

    ReplyDelete
  12. QuickBooks is financial accounting software may occur these errors while using it just call at ours team at

    quickbooks customer service

    ReplyDelete
  13. Qb error PS077 happens due to downloading payroll application,But no issue we have a blog that will help you to fix the issue of QuickBooks error PS077 . You can call on 855-738-0359

    ReplyDelete