Showing posts with label Oracle MAF. Show all posts
Showing posts with label Oracle MAF. Show all posts

Saturday, 5 March 2016

Oracle MAF Pull to Refresh component

The new MAF 2.2 Version have various new components one of the them is Refresh component.
Instead of displaying a refresh button to a user, you can use this component to expose the concept of refreshing as a gesture. Use listView inside of this container. When the user drags their finger down anywhere within this container, a determination will be made to see whether any component between the container and the finger is not scrolled to its top. 

For more information about amx:refreshContainer follow oracle doc here

Step1: create a list view as shown below



Step2: surround list view component with amx:refreshContainer


Setp3: provide the required attributes to refresh container component



Output: Pull down the list view



Thanks :) Happy Learning :)





Saturday, 30 May 2015

Display Remote Server Images in OracleMAF

Hi folks in this post i will show you how to display remote server image in Oracle MAF application.
Recently i have got requirement to display the images of remote servers in MAF application.
Generally in ADF web application if we add URL to Source attribute it will display image in page. But same will not work with MAF application.


Now Follow the below steps

Step 1:

I'll take google image here. Using below URL you can access the image
http://www.google.co.in/images/srpr/logo11w.png

Now we will display the same image in Oracle MAF application

Step 2:

Create MAF application and add amx page in maf-feature.xml

Step 3:

Add image tag with URL as shown below

 <amx:image id="i1" source="http://www.google.co.in/images/srpr/logo11w.png" inlineStyle="height:20%; width:30%;"/>

Step 4:

Open maf-application.xml file and go to security tab and add the domian in URL whitelist as shown below


Output:











Thursday, 21 August 2014

MAF: Data Control method returns Custom Type as array

In my previous post i have discussed about the Call Data control method from managed bean which return the Integer/String or and primitive data type.

But if your Data control method returns the Array of Custom data type Like Employees,Department etc. Use below code.

findEmployeesInDept is data control method which returns array of employees.

        pnames = new ArrayList();
        params = new ArrayList();
        ptypes = new ArrayList();
        
        pnames.add("findCriteria");
        params.add("10");
        ptypes.add(String.class);
       
        //end - WS empty params

        List l = new ArrayList();
        try 
        {    
            GenericType result = (GenericType)AdfmfJavaUtilities.invokeDataControlMethod("HRDC", null, "findEmployeesInDept",pnames, params, ptypes);
            if(result!=null)
            {
                for (int i = 0; i < result.getAttributeCount(); i++) 
                {
                    GenericType r = (GenericType)result.getAttribute(i);
                    Employees wd = (Employees)GenericTypeBeanSerializationHelper.fromGenericType(Employees.class, r);
                    l.add(wd);
                }
            }
        } 
        catch (AdfInvocationException e) 
        {
            e.getMessage();
        }

Thanks
Happy Learning.

Sunday, 17 August 2014

invokeContainerJavaScript method call TimeOut after 15 seconds

In Oracle MAF When you call the javascript function which have alter statement, If you don't close the alert box with in 15 sec on runtime then you will get below Java script time out error.

To resolve this issue, handle the exception as given below. Because the java script method which have the alert statement will throw the AdfException if the alert box is not closed with in 15 secs.


        try {
            AdfmfContainerUtilities.invokeContainerJavaScriptFunction("com.psihcm.ihcmMain", "mandatory",
                                                                      new Object[] { msg });

        } catch (AdfException e) {


        }


Call Data Control method from managed bean in MAF

If you have requirement to call the Data Control method from managed bean, Use AdfmfJavaUtilities.invokeDataControlMethod(). Below is complete code




Data Control method name is calculateDays with three argument of String type. In below method "iHCMWSClient" (name of the data control).

        List pnames1 = new ArrayList();
        List params1 = new ArrayList();
        List ptypes1 = new ArrayList();

        pnames1.add("arg0"); //start date
        ptypes1.add(String.class);
        params1.add(TimeShift.convertStringToDate(startDate));

        pnames1.add("arg1"); //endDate
        ptypes1.add(String.class);
        params1.add(TimeShift.convertStringToDate(endDate));

        pnames1.add("arg2"); //personID
        ptypes1.add(String.class);
        params1.add(new AbsenceRequest().getpID());

        System.out.println("%%%%% result" + noOfDays);
        try {
            noOfDays =
                    (String)AdfmfJavaUtilities.invokeDataControlMethod("iHCMWSClient", null, "calculateDays", pnames1, params1, ptypes1);

    System.out.println("%%%%% result" + noOfDays);
     
        } catch (AdfInvocationException e) {
            throw new AdfException("error ", AdfException.ERROR);
        }



Calling Java Script function from java bean class in MAF

Hi

Sometimes you may get requirement to call javascript function from bean class, Use below invokeContainerJavaScriptFunction() to call the Javascript function.

doAlert() is JS function with one argument.

                AdfmfContainerUtilities.invokeContainerJavaScriptFunction("com.ihcmMobile.Absence", "doAlert",
                                                                          new Object[] { " Absence Record Already Exist " });



JS Function:

doAlert = function () {
        var args = arguments;
        var str = ""+ args[0];
        alert(str);  //Absence Record Already Exist  gets printed

    };



Error while deploying MAF app to android - Cannot run program "\sdk\tools\zipalign"

Hi

If you are getting the below error while deploying the application to android. Here is the solution

[11:11:31 AM] Cannot run program "\sdk\tools\zipalign"": CreateProcess error=2, The system cannot find the file specified
[11:11:31 AM] CreateProcess error=2, The system cannot find the file specified

During the deployment jdeveloper creates .apk file using zipalign.exe file. But zipaling.exe is not exist in this location C:\Program Files\Android\sdk\tools\zipalign.

Solution is copy the zipaling.exe from   \build-tools\19.1.0  to \sdk\tools folder.




Getting Started With Oracle MAF

Oracle MAF:


Oracle MAF (Mobile Application Framework) is a hybrid-mobile framework that enables developers to rapidly develop single-source applications and deploy to both the Apple iOS and Google Android platforms. Oracle MAF provides a complete MVC development framework - that leverage Java, HTML5 and JavaScript - with declarative user interface definition, device services integration and built-in security. Oracle MAF maximizes code reuse and results in faster development of compelling mobile applications.




Features and Benefits


  • Develop once, deploy to multiple mobile devices and platforms including iOS and Android
  • Choose your preferred development language Java or JavaScript
  • Leverage Over 80 components for simpler development of richer user interfaces
  • Accelerate development through visual & declarative application development
  • Choose your preferred IDE - Oracle JDeveloper or Eclipse
  • Access native device services, such as phone, SMS, camera, GPS and more
  • Integrate both on-device and browser-based mobile interfaces into the same applications

For More information on Oracle MAF go through the link Oracle MAF