Probably somebody did a blog post about it but I haven't found it yet.
The Problem
If you didn't modify your Universal theme, by default, success and validation messages appear in the top right corner of a page and you have to close them manually or they disappear when you refresh/submit your page.
It can be confusing when you are on a page with Interactive Grid and you change something repeatedly and successfully - it seems like nothing happened. So let's see how to hide them...
The Solution
It can be done by using theme hooks under apex.message namespace.
How To
If you want that all your client-side messages are hidden after 3 seconds you should call this code:
apex.message.setThemeHooks({ beforeShow: function(pMsgType, pElement$){ setTimeout(function() { $('.t-Body-alert .t-Alert').fadeOut('slow'); }, 3000); } });
Where the second parameter in setTimeout function (with value 3000) is a number of milliseconds. In my case, it's 3 seconds.
If you want to hide only success or error/validation messages you can use pMsgType variable. For example:
apex.message.setThemeHooks({ beforeShow: function(pMsgType, pElement$){ if (pMsgType==apex.message.TYPE.SUCCESS){ setTimeout(function() { $('.t-Body-alert .t-Alert').fadeOut('slow'); }, 3000); } } });
For error/validation messages pMsgType parameter equals error.
To apply this code for all pages in application put this in Page Load dynamic action on the global page (page 0) or in your custom JS file (preferred).
The demo is available here.
The demo is available here.
Enjoy!
Tested on APEX 5.1.1.00.08
Hi
ReplyDeleteI did exactly the same on a page with editable report and no theme changes...Apex 5.2 but it doesn't work.
I wonder why
Hi!
DeleteAPEX 5.2? That doesn't exists. Do you mean 18.2?
Br,
Marko
Sorry Marko i meant Apex 5.1
DeleteIt should work. Where did you put this code? Is there any JS error in console window?
DeleteHi
Deletewhere to put this code?
Kind Regards
Read the last sentence:
Delete"To apply this code for all pages in application put this in Page Load dynamic action on global page (page 0) or in your custom JS file (preferred)."
Thank you! It worked for me.
ReplyDeleteFernando
My success messages don't go away. I tried both first code for all messages, and second one for either success or error. The errors go away but not the success messages. What am I missing ?
ReplyDeleteIt's hard to figure it out like this. What's your version of APEX? Can you make an example on apex.oracle.com so I can see the code?
DeleteThis comment has been removed by the author.
DeleteHey Alice,
DeleteMaybe you were solving the same problem as me - this one article is only about client-side validations which apears like any checks or saving messages.
As you are submiting page and your message came in URL, this will not help you. But try this one article, that helped me: http://lschilde.blogspot.com/2017/06/apex-universal-theme-auto-hide-success.html
Now I am using combination of both codes:
apex.jQuery(document).ready(function () {
var opt = {
autoDismiss: true,
duration: 2000 // Optional. Default value is 3000
}
// this only applys configuration when base page has a process success message ready to display
apex.theme42.configureSuccessMessages(opt);
if (apex.theme42.configureSuccessMessages.options === undefined) {
apex.theme42.configureSuccessMessages.options = opt;
}
});
apex.message.setThemeHooks({
beforeShow: function(pMsgType, pElement$){
if (pMsgType=='success'){
setTimeout(function() {
$('.t-Alert').fadeOut('slow');
}, 2000);
}
}
});
Hope it will help you too :)
Hi Vladimir,
Deletedid you take a look at UT JavaScript API:
https://apex.oracle.com/pls/apex/f?p=42:6201:
There's apex.theme42.util.configAPEXMsgs that can be used for hiding messages.
Btw. apex.theme42.configureSuccessMessages is deprecated and it will be removed in a future release.
Hi Vladimir: We migrated to APEX 19.1 and the code provided by Marko worked like a charm. Thanks so much for reviewing my quest and providing an alternate solution.
DeleteAlice
.t-Alert isn't very specific, and hides any alert regions on the page.
ReplyDeleteWould .t-Alert--success be more appropriate?
True! Maybe, better way (if you use alert regions) would be to use selector $('.t-Body-alert .t-Alert')
DeleteOr use apex.message.hidePageSuccess(); to avoid selectors, though sans fade.
ReplyDeleteapex.message.hidePageSuccess by default hides only success messages, but it can be overridden with beforeHide callback to do the both.
Delete...but probably the best way to do it is to use UT JS API https://apex.oracle.com/pls/apex/f?p=42:6201
DeleteThat was a better option. The setThemeHooks doesn't work for &success_msg coming from branched pages.
DeleteThis comment has been removed by a blog administrator.
ReplyDelete