ADF Mobile Code Corner

Similar documents
ADF Code Corner How-to launch a popup upon rendering of a page fragment in a region using JSF 2. Abstract: twitter.

ADF Code Corner How-to declaratively build a master-detail behavior with DVT components. Abstract: twitter.com/adfcodecorner

ADF Mobile Code Corner

ADF Code Corner How-to enforce LOV Query Filtering. Abstract: twitter.com/adfcodecorner

ADF Code Corner How-to further filter detail queries based on a condition in the parent view using ADF BC. Abstract: twitter.

ADF Mobile Code Corner

ADF Code Corner. 90. Filtering ADF bound lists. Abstract: twitter.com/adfcodecorner

ADF Code Corner How-to use the af:autosuggestbehavior component tag with ADF bound data sources. Abstract: twitter.

ADF Code Corner How-to bind custom declarative components to ADF. Abstract: twitter.com/adfcodecorner

ADF Code Corner How-to show a glasspane and splash screen for long running queries. Abstract: twitter.com/adfcodecorner

ADF Mobile Code Corner

ADF Code Corner. 97. How-to defer train-stop navigation for custom form validation or other developer interaction. Abstract: twitter.

ADF Code Corner. 70. How-to build dependent list boxes with Web Services Business Services. Abstract: twitter.com/adfcodecorner

ADF Code Corner Implementing auto suggest functionality in ADF Faces. Abstract:

ADF Code Corner. 64. How-to implement a Select Many Shuttle with pre- selected values. Abstract: twitter.com/adfcodecorner

ADF Code Corner How-to restrict the list of values retrieved by a model driven LOV. Abstract: twitter.com/adfcodecorner

ADF Code Corner How to cancel an edit form, undoing changes with ADFm savepoints

ADF Code Corner. 71. How-to integrate Java Applets with Oracle ADF Faces. Abstract: twitter.com/adfcodecorner

1 Copyright 2011, Oracle and/or its affiliates. All rights reserved.

ADF Code Corner. 016-How-to customize the ADF Faces Table Filter. Abstract: twitter.com/adfcodecorner

ADF Region Interaction: External Train Navigation

ADF Code Corner. 65. Active Data Service Sample Twitter Client. Abstract: twitter.com/adfcodecorner

ADF Code Corner. 048-How-to build XML Menu Model based site menus and how to protect them with ADF Security and JAAS. Abstract:

ADF Code Corner How-to use Captcha with ADF Faces and Oracle ADF. Abstract: twitter.com/adfcodecorner

ADF Code Corner How-to build a reusable toolbar with Oracle ADF Declarative Components. Abstract: twitter.com/adfcodecorner

ADF Mobile : Data Services Java Beans. Ma Ping

ADF Code Corner. Oracle JDeveloper OTN Harvest 01 / Abstract: twitter.com/adfcodecorner

How to be a Good Bean

1 Copyright 2011, Oracle and/or its affiliates. All rights reserved.

ADF Code Corner. Oracle JDeveloper OTN Harvest 02 / Abstract: twitter.com/adfcodecorner

Take Your Oracle Forms on the Road Using ADF Mobile. Mia Urman, OraPlayer & Denis Tyrell, Oracle Corporation

ADF Hands-On. Understanding Task Flow Activities / 2011 ADF Internal Enterprise 2.0 Training. Abstract:

Copyright 2012, Oracle and/or its affiliates. All rights reserved.

Oracle Fusion Middleware 11g: Build Applications with ADF Accel

Copyright 2012, Oracle and/or its affiliates. All rights reserved.

Real Life ADF Mobile. 10 things that you don't get from the developer guide

ADF Code Corner. Oracle JDeveloper OTN Harvest 09 / Abstract: twitter.com/adfcodecorner

Visual Web Next Design Concepts. Winston Prakash Feb 12, 2008

Mastering Oracle ADF Task Flows. Frank Nimphius Principal Product Manager Oracle JDeveloper / ADF

Oracle Applications OAF, MSCA, MA and ADF. May 06, 2011

Oracle Fusion Middleware 11g: Build Applications with ADF I

<Insert Picture Here> WebCenter Interaction Essentials: Advanced Multi-Channel UI Customizations with Adaptive Layouts Session #904

ADF Code Corner. Oracle JDeveloper OTN Harvest 10 / Abstract: twitter.com/adfcodecorner

Customizing Oracle Identity Governance: Populating Request Attributes

Copyright 2014, Oracle and/or its affiliates. All rights reserved.

1Z0-441

Rich Web UI made simple Building Data Dashboards without Code

Oracle Fusion Middleware 11g: Build Applications with ADF I

6 The MVC model. Main concepts to be covered. Pattern structure. Using design patterns. Design pattern: Observer. Observers

Release Notes1.1 Skelta BPM.NET 2009 March 2010 Release <Version > Date: 20 th May, 2010

Lesson 5 Introduction to Cascading Style Sheets

Getting Started Guide

Oracle Developer Day

JAVABEANS CLASS TO BE A COMPONENT WHAT MAKES A DETAILED VIEW. Tomas Cerny, Software Engineering, FEE, CTU in Prague,

Copyright 2012, Oracle and/or its affiliates. All rights reserved.

ADF OAF Who Cares? You Do! Oracle Applications Framework / Application Development Framework - Which way do I go?

Oracle Exam 1z0-441 Oracle Mobile Development 2015 Essentials Version: 6.0 [ Total Questions: 85 ]

An Oracle White Paper June Guidelines for Creating Task Flows to Be Used in Oracle Composer-Enabled Pages

How-to Build Card Layout Responses from Custom Components

Preferential Resource Delivery Via Web Proxy or Web Browser

Oracle Application Development Framework Overview

Overview. Principal Product Manager Oracle JDeveloper & Oracle ADF

Chapter 1 GETTING STARTED. SYS-ED/ Computer Education Techniques, Inc.

Creating a Model-based Builder

SwingML Tutorial. Introduction. Setup. Execution Environment. Last Modified: 7/10/ :22:37 PM

Oracle Developer Day

Developing Cross Device Mobile Applications

Getting Started: Log on or Create Account

Oracle Fusion Middleware

FILE UPLOAD IN ORACLE ADF MOBILE

Oracle 1Z Oracle WebCenter 11g Essentials.

Oracle ADF 11g: New Declarative Validation, List of Values, and Search Features. Steve Muench Consulting Product Manager Oracle ADF Development Team

Developing Applications with Java EE 6 on WebLogic Server 12c

Build a Mobile App in 60 Minutes with MAF

Functional. Pattern Embeding Regions inside PopUp Windows

Strategies for Running Oracle Forms from Mobile Devices and Tablets.

Kentico CMS Web Parts

Copyright 2012, Oracle and/or its affiliates. All rights reserved.

1Z0-430

Oracle Mobile Application Framework

Index LICENSED PRODUCT NOT FOR RESALE

NetAdvantage for jquery SR Release Notes

Designing Forms in Access

Achieving the Perfect Layout with ADF Faces RC

Creating your first JavaServer Faces Web application

JSF Tags. This tutorial will cover a number of useful JSF tags. For a complete listing of available JSF tags consult the Oracle documentation at:

End User s Guide Release 5.0

SPARK. User Manual Ver ITLAQ Technologies

Illustration 1: The Data Page builder inputs specifying the model variable, page and mode

Oracle Middleware 12c: Build Rich Client Applications with ADF Ed 1 LVC

<Insert Picture Here> Oracle Application Framework (OAF): Architecture, Personalization, and Extensibility in Oracle E-Business Suite Release 12

Oracle Forms Modernization Through Automated Migration. A Technical Overview

Mobilize Your Users Now with Oracle Mobile Application Framework (MAF)

Integrating Facebook. Contents

IT6503 WEB PROGRAMMING. Unit-I

ArtfulBits Web Part

Java EE 6: Develop Web Applications with JSF

Oracle EXAM - 1Z Java EE 6 Enterprise JavaBeans Developer Certified Expert Exam. Buy Full Product.

NetBeans 6.5.1, GlassFish v 2.1, Web Space Server 10 Patient Lookup Portlet with a Google Map, Route and Directions

Virto SharePoint Forms Designer for Office 365. Installation and User Guide

Transcription:

ADF Mobile Code Corner m03. Abstract: A requirement in software development is to conditionally enable/disable or show/hide UI. Usually, to accomplish this, you dynamically look-up a UI component to change its visibility state. In ADF Mobile v 1.0 however there is no such component look up and the requirement thus needs to be implemented differently. In this article I explain how to dynamically change the component visibility and rendering state from Java. twitter.com/adfcodecorner Author: Frank Nimphius, Oracle Corporation twitter.com/fnimphiu 04-MAR-2013

Oracle ADF Mobile Code Corner is a blog-style series of how-to documents targeting at Oracle ADF Mobile that provide solutions to real world coding problems. ADF Mobile Code Corner is an extended offering to ADF Code Corner Disclaimer: All samples are provided as is with no guarantee for future upgrades or error correction. No support can be given through Oracle customer support. Please post questions or report problems related to the samples in this series on the OTN forum for Oracle JDeveloper: http://forums.oracle.com/forums/forum.jspa?forumid=83 Introduction In ADF Mobile there are two visible states for user interface, visible and rendered. If you set a component's visible state to false, then the component still is rendered but hidden on a page If you set the rendered property to false then a component is not added to a page or view at all. Both however have a similar effect in that users can either see or don't see a UI component. Components that are disabled always render on the screen but cannot be used for data input or invoking an action. In this article I show you how you can dynamically set a component's visible and disabled state from Java. ADF Mobile v 1.0 does not provide a lookup facility to obtain a component handle to directly manipulate the visible and disabled state so that we need to be a bit creative. To unveil the solution upfront: The change in the UI (at least for the hide/unhide) functionality is implemented using CSS on the inlinestyle property. The secret sauce however is the use of the PropertyChangeSupport support added to the class that exposes the method to switch the UI visibility state. The screen shots for this sample, as well as the source code, are taken from a later ADF Code Corner mobile sample How-to send Emails with Attachments". To download the sample code, refer to this sample when it is out. Use Case The images below show a train-style menu for users to navigate between different areas in a long form to compose and send a mail with attachment. Instead of navigating between different views in a task flow, this sample uses show/hide switches to display the information to edit. 2

Pressing the Addressing command button e.g. hides all input fields that are not related to defining the mail addressing (to, cc and bcc) Pressing the command button to compose the mail title and message body simply disables all other UI. Note that if there is a need to switch back to the addressing section, then this can be done without losing data. 3

Another menu option navigates to the image area for users to take a picture with the on-device camera. Similar to the solution explained in this article you can use the same approach to render/not render or enable/disable component. To simplify the task of switching content areas, the related input text fields can be grouped in panelformlayout or panelgrouplayout. Implementation At runtime, ADF mobile user interfaces developed with AMX (ADF Mobile XML) render in HTML and JavaScript, which means that what you see on your mobile display in fact is a web view. So if the task is to show and hide (without removing them from the generated HTML) then CSS will do: display:none; Note that if you want to ensure your mobile displays render fast, you should make sure that a minimum of UI are rendered in a view. Here, using CSS would be sub-optimal because the component HTML is still rendered just hidden. In cases where you need to switch between very long forms, using bounded task flow navigation or changing the rendered property state is more efficient. For small forms, as indicate in this sample, using CSS provides reasonably good performance so let's continue with a look at the amx markup of the UI. <amx:commandbutton id="cb5" text="picture" action="#{viewscope.composemailviewbean.showcaptureimage" > <amx:commandbutton id="cb4" text="message" action="#{viewscope.composemailviewbean.showmailbody"/> The command buttons in the header area of the view invoke a managed bean methods to indicate the area that should be made visible. 4

The show/hide areas are defined by panelformlayout tags as shown below. <amx:panelformlayout id="pfl1" inlinestyle="#{viewscope.composemailviewbean.showaddressingheader"> <amx:inputtext value=" "/> <amx:inputtext value=" "/> <amx:inputtext value=" "/> </amx:panelformlayout> As shown, the inlinestyle property of the panelformlayout component references the same managed bean that is referenced by the command buttons. This way, in response to a button press action, the UI in a panel form are shown or hidden. All that is missing now is the information of how to tell the UI that they need to refresh. This information is part of the managed bean and uses the PropertyChangeSupport for the setter/getter pair referenced in the inlinestyle property. About PropertyChangeSupport JavaBeans properties become bounded properties when they communicate value changes to interested listeners. The PropertyChangeSupport class implements this change notification in a thread safe manner. The event receiving part implements the PropertyChangeListener interface, which also is implemented by ADF Mobile. To add PropertyChangeSupport to a bean in Oracle JDeveloper, right mouse click into the bean's source code and choose Generate Accessors from the menus as shown in the image above. Select the properties for which you want to generate setter/getter methods and check the Notify listeners when property changes check box (shown in the image below) for JDeveloper to generate all the requires property change notification code. This adds a change notification line onto each setter methods in which listeners are informed about the new and the old value of a property. In addition, methods are added for the mobile framework to register a change listener. 5

The bean code below contains generated property change support to notify the ADF Mobile framework about changes to the different mail areas for the to refresh: import oracle.adfmf.java.beans.propertychangelistener; import oracle.adfmf.java.beans.propertychangesupport; public class ComposeMailViewBean { //default settings for the individual show/hide areas private String showphotobutton = "display:none;"; private String showaddressingheader = ""; private String showmailbodyheader = "display:none;"; private String showcaptureheader = "display:none;"; //The secret sauce that makes it possible to dynamically show/hide //UI in ADF mobile private transient PropertyChangeSupport propertychangesupport = new PropertyChangeSupport(this); public ComposeMailViewBean() { super(); /** * Method to display all fields that are required for editing the * mail to, cc and bcc options. Disables all the other edit options * @return null. The method is called from a command action and * thus needs to return a String */ 6

public String showaddressing() { setshowphotobutton("display:none;"); setshowaddressingheader(""); setshowmailbodyheader("display:none;"); setshowcaptureheader("display:none;"); return null; /** * Method to display all fields that are required for editing the * mail title and message options. Disables all the other edit * options * @return null. The method is called from a command action and thus * needs to return a String */ public String showmailbody() { setshowphotobutton("display:none;"); setshowaddressingheader("display:none;"); //display the mail body and header section setshowmailbodyheader(""); setshowcaptureheader("display:none;"); return null; /** * Method to display all fields and button that are required for * capturing an image using the camera. Disables all the other edit * options * @return null. The method is called from a command action and * thus needs to return a String */ public String showcaptureimage() { //show button to capture photo setshowphotobutton(""); setshowaddressingheader("display:none;"); setshowmailbodyheader("display:none;"); //show photo width and height settings setshowcaptureheader(""); return null; public void setshowaddressingheader(string showaddressingheader) { String oldshowaddressingheader = this.showaddressingheader; this.showaddressingheader = showaddressingheader; propertychangesupport.firepropertychange("showaddressingheader", 7

oldshowaddressingheader, showaddressingheader); /** * Method that returns CSS to display the addressing. * This method is referenced from a panelformlayout component's * inlinestyle property * @return */ public String getshowaddressingheader() { return showaddressingheader; public void addpropertychangelistener(propertychangelistener l) { propertychangesupport.addpropertychangelistener(l); public void removepropertychangelistener(propertychangelistener l) { propertychangesupport.removepropertychangelistener(l); public void setpropertychangesupport(propertychangesupport propertychangesupport) { PropertyChangeSupport oldpropertychangesupport = this.propertychangesupport; this.propertychangesupport = propertychangesupport; propertychangesupport.firepropertychange("propertychangesupport", oldpropertychangesupport, propertychangesupport); public PropertyChangeSupport getpropertychangesupport() { return propertychangesupport; Conclusion In this article I explain how UI in ADF Mobile can be partially refreshed using a JavaBean property and the PropertyChangeSupport class to programmatically and thus dynamically set the inlinestyle property, dispabled or rendered property. The complete source code and sample used in this article become available in a later article "How-to send Emails with Attachments". 8

RELATED DOCOMENTATION 9