Browsing "Older Posts"

Browsing Category "APEX examples"

Interactive Grid - Column stretching

Von Tobias Arnhold → 12.19.2018
Since APEX 18.1 you can define the stretch behavior per column.

You can choose between 3 different options:

Use Report Setting
The column will use the Stretch Report Setting set by the End User to define if the column should stretch or not.
In APEX 18.1 you have a new option to let the end user decide if the columns should be stretched or not.
This option effects all columns by default.

Never
The column will not stretch and always just use the width specified. This is useful for columns with short content like Yes/No or Numbers.
This option will over rule "Use Report Setting" and is really good for link columns or as the documentation says: short content columns.

Always
The column will always stretch, irrespective of the Stretch Report Setting set by the End User.


Results can look slightly different:


Imho: Small enhancement with huge impact.

APEX client side error messages - apex.message.showErrors

Von Tobias Arnhold → 10.25.2018
Since APEX 5.1 we have the ability to create client side messages without the requirement to use a plugin or custom code to create nice looking client side messages.

For that requirement the APEX team created the apex.message library.

This library provides the same look and feel as if you would create a message out of your Page Designer > Validation Area.



In this example I will tell you something about a more advanced way to use the client side error messages.

As the documentation says this is the default way to create a client side error message:

/* General page error message */
apex.message.showErrors([
{
type: "error",
location: "page",
message: "Page error has occurred!",
unsafe: false
}
]);
  /* Item error message */ apex.message.showErrors([
{
type: "error",
location: [ "page", "inline" ],
pageItem: "P1_ITEM",
message: "Value is required!",
unsafe: false
}
]);

Example for a page error message:




In my example I want to check more then one item. For that I created an array including all item names I wanted to check. Within a "FOR" loop I run through every item and created an error message if the value was NULL. If no error occurred I run another custom dynamic action.

apex.message.clearErrors();

var chkErr = 0;
var arr = [
   'P1_STRASSE', 
   'P1_HAUS_NR',
   'P1_PLZ', 
   'P1_ORT', 
   'P1_ITEM_XYZ'
];

for (var i in arr) {
  if ($v(arr[i]).length == 0) {
    apex.message.showErrors([
      {
        type: apex.message.TYPE.ERROR,
        location: ["inline"],
        pageItem: arr[i],
        message: "Value is required!",
        unsafe: false
      }
    ]);
    chkErr = 1;
  } 
}

if ( chkErr == 0 ) { 
  /* Custom dynamic action call when no error occurred */
  apex.event.trigger(document, 'customDA', [{customAttribute:'1'}]); 
}
You want to know more? Check out the documentation and this series of blog posts by Martin D'Souza:
https://www.talkapex.com/2018/03/custom-apex-notification-messages/
https://www.talkapex.com/2018/03/how-to-save-page-data-but-show-errors-in-apex/

#nextGENTrip18 a Twitter story

Von Tobias Arnhold → 8.27.2018
I would like to give you a feeling about our #NextGEN community activities by showing you a collection of tweets at the latest event which we participated:

The #ApexDay2018 in Stockholm at the SWEOUG

We have been 12 IT enthusiast from different places and different life circumstances.
 - 6 women and 6 men
 - 5 students and 5 employees and 2 freelancer
 - 9 Oracle specialists and 7 of them working primary with APEX


Goal

Get everyone further engaged in #NextGEN activities and inspire new IT enthusiasts to join our community/activities/events.

Follow DOAG #NextGEN

Website: https://www.doag.org/de/nextgen/nextgen/
Twitter: https://twitter.com/doagnextgen
Instagram: https://www.instagram.com/doagnextgen

The Twitter story




























5 reasons why 








You came this far... That can only mean that you want to join us.
We have a Slack channel where we organize new events and help each other on different topics. Especially APEX newcomer get a lot of support. Slack channel communication is in German. If you want to join then just write us an email: nextgen@doag.org


Set APEX application name for Dev, Test and Prod environment in the same database

Von Tobias Arnhold → 7.18.2018
In case you have a small application where development, test and maybe also production environment are on the same database and your applications in this environment distinguish only by the application IDs. To setup a custom application name based on the ID you could do like this:


We assume our application name is "Training room app" defined in the "Shared Components" > "User Interface Attributes"


To differentiate the environments I add a dynamic action "Page Load" on Page 0.
This dynamic action is executing custom Javascript code:

if ('&APP_ID.' == '200') {
  $('.t-Header-logo').find('span').html('Training room app - <b style="color:#008A34">Test Environment</b>');
}
else if ('&APP_ID.' == '300') {
  $('.t-Header-logo').find('span').html('Training room app - <b style="color:#9366a5">Development Environment</b>');
}


The code is changing the name of the logo area.

 

Copy and Paste to clipboard

Von Tobias Arnhold → 7.17.2018
Well I had the requirement to copy the content of a textarea into the clipboard. There are two ways to do that:

1. Build a dynamic action with custom Javascript code:
Copy Text to Clipboard

Code example - with dynamic action on "Click" and "Execute Javascript Code":
/* Select the text field */
$('#P1_APEX_ITEM').select();

/* Copy the text inside the text field */
document.execCommand("copy");



2. Use an APEX plugin:
Copy to Clipboard (v1.1) - build by Dick Dral



Icons made by Vitaly Gorbachev from www.flaticon.com is licensed by CC 3.0 BY

Enable save button on form change

Von Tobias Arnhold → 6.28.2018
Today I had the requirement that the save button should stay disabled until a form item changed.

After digging around I found a quite easy solution which worked well until now.

Save Button
Static ID: saveBtn
Custom Attributes: disabled

Dynamic Action
Event: Page Load
Execute Javascript Code:
$('#wwvFlowForm').on('input change', function() {
    $('#saveBtn').attr('disabled', false);
});



Simple but effective.

Working with the APEX tree

Von Tobias Arnhold → 6.27.2018
Out of a coincidence I haven't used the APEX tree region for years. Now I got the task to create a customizable tree in my application. Since APEX 5 there is a new tree type called "APEX tree" which supports some really cool functions.

Anyway I had to look around to find out what the APEX tree is actually capable of. First of all start with the APEX "Sample Trees" application which you find in the packaged application area.



Morten Braten took that example and described the features really well:
https://ora-00001.blogspot.com/2016/01/working-with-the-apex-5-treeview.html

John Snyders from the APEX team also created 2 blogposts about the "APEX tree":
APEX 5.0 Converting to the new APEX Tree
Add Checkbox Selection to APEX Tree Region

And as he mentioned there is a Javascript library behind it "libraries/apex/widget.treeView.js." which is documented since APEX 18.1 or at least I think it is. Anyway here is a link which I also have to further investigate:
JS Doc: Widget: treeView

German users can read this document provided by MT AG:
http://files.xmasman.de/20160216_MeetupNRW_TillAlbert_WiePflanzeIchEinenBaumApex.pdf

Check inside your APEX application if debug mode is enabled

Von Tobias Arnhold → 6.08.2018
Sounds like a simple task but whenever I have the requirement to add a region and make it conditional to check if APEX is running in debug mode. I always search for half an hour finding the right solution.

Search example on Google: "Oracle APEX check debug mode conditional PL/SQL"
Trying this or 30 different other ways it always ends up with the wrong results.

But it is so easy - Conditional PL/SQL Expression:
APEX_APPLICATION.G_DEBUG

G_DEBUG returns true or false!
The documentation is a bit imprecise because it says 'Yes' or 'No'.

Anyway it is all well documented in the APEX documentation
> APEX_APPLICATION > Global Variables:
https://docs.oracle.com/database/apex-18.1/AEAPI/Global-Variables.htm#AEAPI29544