SlideShare a Scribd company logo
Utilising the data attribute
adding client side behaviour in Oracle APEX
Agenda
● Introducing the data attribute
● Introducing jQuery
● Changing Page-items into HTML items
● Record sorting
● Deleting records from a report
● Putting it all together
Who am I ?
● Independent Consultant since 2012
● smart4apex founding member (2010)
● Oracle since 2002 (Oracle 8i)
● PL/SQL, Apex, HTML(5), CSS(3), JavaScript, XML, XSLT
● Special interest in UI
● Trainer at skillbuilders.com
RIMA on Oracle Forums
@rhjmartens
richardmartens.blogspot.nl
Introducing the data attribute
● Problem: how to unambiguously identify elements in a page
● Your HTML will have lots of hooks you can try to catch:
● ID’s
● $(‘#yourid’).whateverfunction();
● classes
● $(‘.yourclass’).anotherfunction();
● DOM traversal
● $(‘#aclass’).parents(‘tr’).children(‘td a[href~=“a-record-id”]’).whatever();
Introducing the data attribute
● The data-* global attributes form a class of attributes called custom data attributes, that
allow proprietary information to be exchanged between the HTML and
its DOM representation by scripts.
(https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/data-*)
● HTML Attributes can be selected by:
$(‘[data-attribute=“1234”]’)
or
$(‘[data-attribute]’)
● And they can be simply added by using the “Custom Attributes” attribute
Introducing jQuery
● “jQuery is a fast, small, and feature-rich JavaScript library. It makes things like HTML
document traversal and manipulation, event handling, animation, and Ajax much simpler
with an easy-to-use API that works across a multitude of browsers. With a combination of
versatility and extensibility, jQuery has changed the way that millions of people write
JavaScript.”
(http://jquery.com/)
● Key functionality:
● element selection (incl. DOM traversal)
● event handling
● AJAX
● Included in APEX by default !!
Introducing jQuery
● Element selection through the use of CSS selectors:
● .class has class
● #static-id has static ID
● [attribute] has attribute
● [attribute=‘value’] has attribute with value
● [attribute~=‘value’] word contains
● [attribute^=‘value’] begins with
● [attribute$=‘value’] ends in
● [attribute*=‘value’] substring contains
● [attribute*=‘value’ i] substring contains (case insensitive)
Changing page-items to HTML5
● Oracle only supports 4 HTML5 types:
● Text, Email, Phone Number and URL
● HTML5 offers a lot more:
● color, date, datetime-local, month, number, range, search, time, week
● Not all of them all supported by all browsers.
● Run DA on pageload:
● $('input[data-html5-type]').each( function() {
$(this).attr( 'type’
, $(this).attr('data-html5-type')
);
});
● Change your item into regular tekst item
● Add attribute: data-html5-type and set it to the type you need
● For date fields don’t forget to set the format to “YYYY-MM-DD”
Changing page-items to HTML5
● of course we need a bit of javascript:
● $('input[data-html5-type]').each( function() {
$(this).attr( 'type’
, $(this).attr('data-html5-type'));
});
● We can include this in an “onload” DA
The rowclick plugin I
● Available on apex.world
● Add data attributes to regions (classic or interactive reports)
● data-rowclick=“LINK”
points to the header in which your browser can find the link
● data-rowclick-event=“click”
defines to what event the plugin needs to listen
● data-rowclick-exclude=“HEADER,STATIC-ID”
defines the header(s) on which the plugin schould not listen
The rowclick plugin II
● What does the plugin actually do?
● Looks for all div’s that have a data-rowclick attribut
● Looks for TR’s that have TD’s that are not excluded by
data-rowclick-exclude
● All those TD’s get a click event function
● This functions will then execute on “click”
● It will look for a TD in the same row that has the defined header and searches for the
first anchor. This anchor is then “executed”
● It’s actually not a rowclick, but a table-cell-click.
Record Sorting
● using jQuery “sortable”
● Sortable is not enabled by default
● More info on:
https://goo.gl/kKvrnW
Record Sorting
● Create classic report
● the SQL should include an “order by” clause
● All “important” regions should have a static ID
● Use the static ID to select your region:
● // initiate sortability
$('#p10-emp').on('apexafterrefresh', function() {
setSortable('#p10-emp’
, 'table.t-Report-report tbody'
, 'data-empno'
, 'EMPNO'
, 'AJAX_SORT_EMP');
});
setSortable(....);
Record Sorting
● And we need a function to handle everything..
● a Handler function
● Let’s watch this in APEX
function setSortable(pRegion, pSelector, pAttrName, pHeader, pServerProcess) { // add some CSS to make user aware
of sortability $(pRegion + ' ' + pSelector).css('cursor', 'pointer'); // add data-empno attribute $(pRegion +
' ' + pSelector + ' td[headers="' + pHeader + '"]').each( function() { $(this).parent('tr').attr(pAttrName,
$(this).text() ); } ); $(pRegion + ' ' + pSelector).sortable({ helper: function(e, ui) {
ui.children().each(function() { $(this).width($(this).width()); }); return ui;
}, stop: function( event, ui ) { // var employees will hold empno's colon deparated var
employees = []; // walk through all items that have data-empno attribute $('[' + pAttrName +
']').each( function(){ employees.push ( $(this).attr(pAttrName) ); } );
apex.server.process ( pServerProcess, { f01: employees }, {dataType:"text",
success: function( pData ) { $(pRegion).trigger('apexrefresh'); } });
//$(ui.item).find('[data-empno]').attr('data-empno') } }); $(pRegion).on('apexafterrefresh', function() {
setSortable(pRegion, pSelector, pAttrName, pHeader, pServerProcess); });
Deleting records from a report
● Again: regular report IR, CR
● Add column with delete icon:
● <i data-delete-id="#EMPNO#" class="fa fa-trash-o"></i>
● Add Event handler:
● are you sure?
● save the value in a hidden item
● execute some pl/sql code (hidden item goes in, gets reset to null and is sent out)
● alert that the records has been deleted
● refresh the report
Requirements
● We must send a letter to an emp
● We must be able to choose from predefined alineas
● We must be able to change the order of which those alineas appear on the letter
● We must be able to change the alinea’s texts without modifying the original predefined
text
● We only need to send one letter per emp
APEX out of the box
● We could use an interactive grid for this!
● Let’s see how that looks
Let’s hack the user interface
Questions ?
A small plug for another great conference

More Related Content

What's hot

React redux
React reduxReact redux
React redux
Michel Perez
 
Redux as a state container
Redux as a state containerRedux as a state container
Redux as a state container
Tahin Rahman
 
React JS and Redux
React JS and ReduxReact JS and Redux
React JS and Redux
Glib Kechyn
 
JavaScript / Web Engineering / Web Development / html + css + js/presentation
JavaScript / Web Engineering / Web Development / html + css + js/presentationJavaScript / Web Engineering / Web Development / html + css + js/presentation
JavaScript / Web Engineering / Web Development / html + css + js/presentation
M Sajid R
 
React&redux
React&reduxReact&redux
React&redux
Blank Chen
 
Building complex User Interfaces with Sitecore and React
Building complex User Interfaces with Sitecore and ReactBuilding complex User Interfaces with Sitecore and React
Building complex User Interfaces with Sitecore and React
Jonne Kats
 
React и redux
React и reduxReact и redux
Redux training
Redux trainingRedux training
Redux training
dasersoft
 
Introduction to react and redux
Introduction to react and reduxIntroduction to react and redux
Introduction to react and redux
Cuong Ho
 
React, Redux, ES2015 by Max Petruck
React, Redux, ES2015   by Max PetruckReact, Redux, ES2015   by Max Petruck
React, Redux, ES2015 by Max Petruck
Maksym Petruk
 
React & Redux
React & ReduxReact & Redux
React & Redux
Federico Bond
 
React & redux
React & reduxReact & redux
React & redux
Cédric Hartland
 
jQuery Beginner
jQuery BeginnerjQuery Beginner
jQuery Beginner
kumar gaurav
 
JavaScript client API for Google Apps Script API primer
JavaScript client API for Google Apps Script API primerJavaScript client API for Google Apps Script API primer
JavaScript client API for Google Apps Script API primer
Bruce McPherson
 
iOS Beginners Lesson 4
iOS Beginners Lesson 4iOS Beginners Lesson 4
iOS Beginners Lesson 4
Calvin Cheng
 
How to separate frontend from a highload python project with no problems - Py...
How to separate frontend from a highload python project with no problems - Py...How to separate frontend from a highload python project with no problems - Py...
How to separate frontend from a highload python project with no problems - Py...
Oleksandr Tarasenko
 
JavaScript - Chapter 9 - TypeConversion and Regular Expressions
 JavaScript - Chapter 9 - TypeConversion and Regular Expressions  JavaScript - Chapter 9 - TypeConversion and Regular Expressions
JavaScript - Chapter 9 - TypeConversion and Regular Expressions
WebStackAcademy
 
Goa tutorial
Goa tutorialGoa tutorial
Goa tutorial
Bruce McPherson
 
Introduction to Redux
Introduction to ReduxIntroduction to Redux
Introduction to Redux
Ignacio Martín
 

What's hot (20)

React redux
React reduxReact redux
React redux
 
Redux as a state container
Redux as a state containerRedux as a state container
Redux as a state container
 
React JS and Redux
React JS and ReduxReact JS and Redux
React JS and Redux
 
JavaScript / Web Engineering / Web Development / html + css + js/presentation
JavaScript / Web Engineering / Web Development / html + css + js/presentationJavaScript / Web Engineering / Web Development / html + css + js/presentation
JavaScript / Web Engineering / Web Development / html + css + js/presentation
 
React&redux
React&reduxReact&redux
React&redux
 
Building complex User Interfaces with Sitecore and React
Building complex User Interfaces with Sitecore and ReactBuilding complex User Interfaces with Sitecore and React
Building complex User Interfaces with Sitecore and React
 
React и redux
React и reduxReact и redux
React и redux
 
Redux training
Redux trainingRedux training
Redux training
 
Introduction to react and redux
Introduction to react and reduxIntroduction to react and redux
Introduction to react and redux
 
Jquery library
Jquery libraryJquery library
Jquery library
 
React, Redux, ES2015 by Max Petruck
React, Redux, ES2015   by Max PetruckReact, Redux, ES2015   by Max Petruck
React, Redux, ES2015 by Max Petruck
 
React & Redux
React & ReduxReact & Redux
React & Redux
 
React & redux
React & reduxReact & redux
React & redux
 
jQuery Beginner
jQuery BeginnerjQuery Beginner
jQuery Beginner
 
JavaScript client API for Google Apps Script API primer
JavaScript client API for Google Apps Script API primerJavaScript client API for Google Apps Script API primer
JavaScript client API for Google Apps Script API primer
 
iOS Beginners Lesson 4
iOS Beginners Lesson 4iOS Beginners Lesson 4
iOS Beginners Lesson 4
 
How to separate frontend from a highload python project with no problems - Py...
How to separate frontend from a highload python project with no problems - Py...How to separate frontend from a highload python project with no problems - Py...
How to separate frontend from a highload python project with no problems - Py...
 
JavaScript - Chapter 9 - TypeConversion and Regular Expressions
 JavaScript - Chapter 9 - TypeConversion and Regular Expressions  JavaScript - Chapter 9 - TypeConversion and Regular Expressions
JavaScript - Chapter 9 - TypeConversion and Regular Expressions
 
Goa tutorial
Goa tutorialGoa tutorial
Goa tutorial
 
Introduction to Redux
Introduction to ReduxIntroduction to Redux
Introduction to Redux
 

Similar to Utilising the data attribute

UNIT 1 (7).pptx
UNIT 1 (7).pptxUNIT 1 (7).pptx
UNIT 1 (7).pptx
DrDhivyaaCRAssistant
 
Design Summit - UI Roadmap - Dan Clarizio, Martin Povolny
Design Summit - UI Roadmap - Dan Clarizio, Martin PovolnyDesign Summit - UI Roadmap - Dan Clarizio, Martin Povolny
Design Summit - UI Roadmap - Dan Clarizio, Martin Povolny
ManageIQ
 
Google apps script
Google apps scriptGoogle apps script
Google apps script
Simon Su
 
Spring data requery
Spring data requerySpring data requery
Spring data requery
Sunghyouk Bae
 
the next web now
the next web nowthe next web now
the next web nowzulin Gu
 
Protractor framework – how to make stable e2e tests for Angular applications
Protractor framework – how to make stable e2e tests for Angular applicationsProtractor framework – how to make stable e2e tests for Angular applications
Protractor framework – how to make stable e2e tests for Angular applications
Ludmila Nesvitiy
 
Modern frontend development with VueJs
Modern frontend development with VueJsModern frontend development with VueJs
Modern frontend development with VueJs
Tudor Barbu
 
SharePoint and jQuery Essentials
SharePoint and jQuery EssentialsSharePoint and jQuery Essentials
SharePoint and jQuery Essentials
Mark Rackley
 
Structured web programming
Structured web programmingStructured web programming
Structured web programmingahfast
 
SharePoint Cincy 2012 - jQuery essentials
SharePoint Cincy 2012 - jQuery essentialsSharePoint Cincy 2012 - jQuery essentials
SharePoint Cincy 2012 - jQuery essentialsMark Rackley
 
Understanding backbonejs
Understanding backbonejsUnderstanding backbonejs
Understanding backbonejs
Nick Lee
 
Wt unit 2 ppts client side technology
Wt unit 2 ppts client side technologyWt unit 2 ppts client side technology
Wt unit 2 ppts client side technology
PUNE VIDYARTHI GRIHA'S COLLEGE OF ENGINEERING, NASHIK
 
Taming that client side mess with Backbone.js
Taming that client side mess with Backbone.jsTaming that client side mess with Backbone.js
Taming that client side mess with Backbone.jsJarod Ferguson
 
Secrets of JavaScript Libraries
Secrets of JavaScript LibrariesSecrets of JavaScript Libraries
Secrets of JavaScript Libraries
jeresig
 
#NewMeetup Performance
#NewMeetup Performance#NewMeetup Performance
#NewMeetup PerformanceJustin Cataldo
 
AngularJS Workshop
AngularJS WorkshopAngularJS Workshop
AngularJS Workshop
Gianluca Cacace
 
Slickdemo
SlickdemoSlickdemo
Slickdemo
Knoldus Inc.
 

Similar to Utilising the data attribute (20)

UNIT 1 (7).pptx
UNIT 1 (7).pptxUNIT 1 (7).pptx
UNIT 1 (7).pptx
 
Design Summit - UI Roadmap - Dan Clarizio, Martin Povolny
Design Summit - UI Roadmap - Dan Clarizio, Martin PovolnyDesign Summit - UI Roadmap - Dan Clarizio, Martin Povolny
Design Summit - UI Roadmap - Dan Clarizio, Martin Povolny
 
Google apps script
Google apps scriptGoogle apps script
Google apps script
 
Spring data requery
Spring data requerySpring data requery
Spring data requery
 
the next web now
the next web nowthe next web now
the next web now
 
Protractor framework – how to make stable e2e tests for Angular applications
Protractor framework – how to make stable e2e tests for Angular applicationsProtractor framework – how to make stable e2e tests for Angular applications
Protractor framework – how to make stable e2e tests for Angular applications
 
Modern frontend development with VueJs
Modern frontend development with VueJsModern frontend development with VueJs
Modern frontend development with VueJs
 
SharePoint and jQuery Essentials
SharePoint and jQuery EssentialsSharePoint and jQuery Essentials
SharePoint and jQuery Essentials
 
Jquery 4
Jquery 4Jquery 4
Jquery 4
 
Jquery fundamentals
Jquery fundamentalsJquery fundamentals
Jquery fundamentals
 
Structured web programming
Structured web programmingStructured web programming
Structured web programming
 
SharePoint Cincy 2012 - jQuery essentials
SharePoint Cincy 2012 - jQuery essentialsSharePoint Cincy 2012 - jQuery essentials
SharePoint Cincy 2012 - jQuery essentials
 
Understanding backbonejs
Understanding backbonejsUnderstanding backbonejs
Understanding backbonejs
 
Wt unit 2 ppts client side technology
Wt unit 2 ppts client side technologyWt unit 2 ppts client side technology
Wt unit 2 ppts client side technology
 
Wt unit 2 ppts client sied technology
Wt unit 2 ppts client sied technologyWt unit 2 ppts client sied technology
Wt unit 2 ppts client sied technology
 
Taming that client side mess with Backbone.js
Taming that client side mess with Backbone.jsTaming that client side mess with Backbone.js
Taming that client side mess with Backbone.js
 
Secrets of JavaScript Libraries
Secrets of JavaScript LibrariesSecrets of JavaScript Libraries
Secrets of JavaScript Libraries
 
#NewMeetup Performance
#NewMeetup Performance#NewMeetup Performance
#NewMeetup Performance
 
AngularJS Workshop
AngularJS WorkshopAngularJS Workshop
AngularJS Workshop
 
Slickdemo
SlickdemoSlickdemo
Slickdemo
 

Recently uploaded

Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Globus
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Mind IT Systems
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Globus
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
AMB-Review
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
Boni García
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
Cyanic lab
 
Launch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in MinutesLaunch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in Minutes
Roshan Dwivedi
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Globus
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Globus
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
NYGGS Automation Suite
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Globus
 
Pro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp BookPro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp Book
abdulrafaychaudhry
 
Top 7 Unique WhatsApp API Benefits | Saudi Arabia
Top 7 Unique WhatsApp API Benefits | Saudi ArabiaTop 7 Unique WhatsApp API Benefits | Saudi Arabia
Top 7 Unique WhatsApp API Benefits | Saudi Arabia
Yara Milbes
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
Globus
 
Enterprise Software Development with No Code Solutions.pptx
Enterprise Software Development with No Code Solutions.pptxEnterprise Software Development with No Code Solutions.pptx
Enterprise Software Development with No Code Solutions.pptx
QuickwayInfoSystems3
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
XfilesPro
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
takuyayamamoto1800
 

Recently uploaded (20)

Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 
APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)APIs for Browser Automation (MoT Meetup 2024)
APIs for Browser Automation (MoT Meetup 2024)
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
 
Launch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in MinutesLaunch Your Streaming Platforms in Minutes
Launch Your Streaming Platforms in Minutes
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
 
Pro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp BookPro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp Book
 
Top 7 Unique WhatsApp API Benefits | Saudi Arabia
Top 7 Unique WhatsApp API Benefits | Saudi ArabiaTop 7 Unique WhatsApp API Benefits | Saudi Arabia
Top 7 Unique WhatsApp API Benefits | Saudi Arabia
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
 
Enterprise Software Development with No Code Solutions.pptx
Enterprise Software Development with No Code Solutions.pptxEnterprise Software Development with No Code Solutions.pptx
Enterprise Software Development with No Code Solutions.pptx
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
 

Utilising the data attribute

  • 1. Utilising the data attribute adding client side behaviour in Oracle APEX
  • 2. Agenda ● Introducing the data attribute ● Introducing jQuery ● Changing Page-items into HTML items ● Record sorting ● Deleting records from a report ● Putting it all together
  • 3. Who am I ? ● Independent Consultant since 2012 ● smart4apex founding member (2010) ● Oracle since 2002 (Oracle 8i) ● PL/SQL, Apex, HTML(5), CSS(3), JavaScript, XML, XSLT ● Special interest in UI ● Trainer at skillbuilders.com RIMA on Oracle Forums @rhjmartens richardmartens.blogspot.nl
  • 4. Introducing the data attribute ● Problem: how to unambiguously identify elements in a page ● Your HTML will have lots of hooks you can try to catch: ● ID’s ● $(‘#yourid’).whateverfunction(); ● classes ● $(‘.yourclass’).anotherfunction(); ● DOM traversal ● $(‘#aclass’).parents(‘tr’).children(‘td a[href~=“a-record-id”]’).whatever();
  • 5. Introducing the data attribute ● The data-* global attributes form a class of attributes called custom data attributes, that allow proprietary information to be exchanged between the HTML and its DOM representation by scripts. (https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/data-*) ● HTML Attributes can be selected by: $(‘[data-attribute=“1234”]’) or $(‘[data-attribute]’) ● And they can be simply added by using the “Custom Attributes” attribute
  • 6. Introducing jQuery ● “jQuery is a fast, small, and feature-rich JavaScript library. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers. With a combination of versatility and extensibility, jQuery has changed the way that millions of people write JavaScript.” (http://jquery.com/) ● Key functionality: ● element selection (incl. DOM traversal) ● event handling ● AJAX ● Included in APEX by default !!
  • 7. Introducing jQuery ● Element selection through the use of CSS selectors: ● .class has class ● #static-id has static ID ● [attribute] has attribute ● [attribute=‘value’] has attribute with value ● [attribute~=‘value’] word contains ● [attribute^=‘value’] begins with ● [attribute$=‘value’] ends in ● [attribute*=‘value’] substring contains ● [attribute*=‘value’ i] substring contains (case insensitive)
  • 8. Changing page-items to HTML5 ● Oracle only supports 4 HTML5 types: ● Text, Email, Phone Number and URL ● HTML5 offers a lot more: ● color, date, datetime-local, month, number, range, search, time, week ● Not all of them all supported by all browsers. ● Run DA on pageload: ● $('input[data-html5-type]').each( function() { $(this).attr( 'type’ , $(this).attr('data-html5-type') ); }); ● Change your item into regular tekst item ● Add attribute: data-html5-type and set it to the type you need ● For date fields don’t forget to set the format to “YYYY-MM-DD”
  • 9. Changing page-items to HTML5 ● of course we need a bit of javascript: ● $('input[data-html5-type]').each( function() { $(this).attr( 'type’ , $(this).attr('data-html5-type')); }); ● We can include this in an “onload” DA
  • 10. The rowclick plugin I ● Available on apex.world ● Add data attributes to regions (classic or interactive reports) ● data-rowclick=“LINK” points to the header in which your browser can find the link ● data-rowclick-event=“click” defines to what event the plugin needs to listen ● data-rowclick-exclude=“HEADER,STATIC-ID” defines the header(s) on which the plugin schould not listen
  • 11. The rowclick plugin II ● What does the plugin actually do? ● Looks for all div’s that have a data-rowclick attribut ● Looks for TR’s that have TD’s that are not excluded by data-rowclick-exclude ● All those TD’s get a click event function ● This functions will then execute on “click” ● It will look for a TD in the same row that has the defined header and searches for the first anchor. This anchor is then “executed” ● It’s actually not a rowclick, but a table-cell-click.
  • 12. Record Sorting ● using jQuery “sortable” ● Sortable is not enabled by default ● More info on: https://goo.gl/kKvrnW
  • 13. Record Sorting ● Create classic report ● the SQL should include an “order by” clause ● All “important” regions should have a static ID ● Use the static ID to select your region: ● // initiate sortability $('#p10-emp').on('apexafterrefresh', function() { setSortable('#p10-emp’ , 'table.t-Report-report tbody' , 'data-empno' , 'EMPNO' , 'AJAX_SORT_EMP'); }); setSortable(....);
  • 14. Record Sorting ● And we need a function to handle everything.. ● a Handler function ● Let’s watch this in APEX function setSortable(pRegion, pSelector, pAttrName, pHeader, pServerProcess) { // add some CSS to make user aware of sortability $(pRegion + ' ' + pSelector).css('cursor', 'pointer'); // add data-empno attribute $(pRegion + ' ' + pSelector + ' td[headers="' + pHeader + '"]').each( function() { $(this).parent('tr').attr(pAttrName, $(this).text() ); } ); $(pRegion + ' ' + pSelector).sortable({ helper: function(e, ui) { ui.children().each(function() { $(this).width($(this).width()); }); return ui; }, stop: function( event, ui ) { // var employees will hold empno's colon deparated var employees = []; // walk through all items that have data-empno attribute $('[' + pAttrName + ']').each( function(){ employees.push ( $(this).attr(pAttrName) ); } ); apex.server.process ( pServerProcess, { f01: employees }, {dataType:"text", success: function( pData ) { $(pRegion).trigger('apexrefresh'); } }); //$(ui.item).find('[data-empno]').attr('data-empno') } }); $(pRegion).on('apexafterrefresh', function() { setSortable(pRegion, pSelector, pAttrName, pHeader, pServerProcess); });
  • 15. Deleting records from a report ● Again: regular report IR, CR ● Add column with delete icon: ● <i data-delete-id="#EMPNO#" class="fa fa-trash-o"></i> ● Add Event handler: ● are you sure? ● save the value in a hidden item ● execute some pl/sql code (hidden item goes in, gets reset to null and is sent out) ● alert that the records has been deleted ● refresh the report
  • 16. Requirements ● We must send a letter to an emp ● We must be able to choose from predefined alineas ● We must be able to change the order of which those alineas appear on the letter ● We must be able to change the alinea’s texts without modifying the original predefined text ● We only need to send one letter per emp
  • 17. APEX out of the box ● We could use an interactive grid for this! ● Let’s see how that looks
  • 18. Let’s hack the user interface
  • 20. A small plug for another great conference