Oracle ACE Graham Smith recently posted a fantastic idea to Idea Labs: Put the cursor in Global Search when clicking Home. In a search-centric experience, this makes a lot of sense. And if you like this idea, you don't have to wait for a future PeopleTools release. We can build it ourselves with Event Mapping and a little JavaScript!
To avoid potential conflicts with accessibility and the PeopleTools-delivered tab order, the following implementation uses a keyboard combination (hotkeys) to activate the search bar. This is akin to Apple's Spotlight. I choose CTRL+SPACE. Several years ago, we recorded a SoundByte showing similar functionality:
Let's implement a slightly different version that specifically targets homepages/landing pages.
Here is what we will need:
- HTML Definition that contains JavaScript to run when the page loads
- Event Mapping App Class to inject our JavaScript
- Related Content Service Definition
- Event Mapping definition to map the App Class into the Landing Page Content Reference
The JavaScript to implement the request is trivial:
document.getElementById('PTSKEYWORD').focus();But we are going to lock this into a key handler, so the full JavaScript looks like this:
document.addEventListener('keydown', function(e) {
if (e.ctrlKey && (e.key === ' ')) {
var el;
el = document.getElementById('PTSKEYWORD');
if(!!el) {
el.focus();
}
}
});I threw that JavaScript into an HTML definition named JSM_GS_LP_FOCUS_JS, and then referenced it from my Event Mapping PeopleCode as follows:
import PT_RCF:ServiceInterface; class PageActivate extends PT_RCF:ServiceInterface method execute(); end-class; method execute /+ Extends/implements PT_RCF:ServiceInterface.execute +/ AddJavaScript(HTML.JSM_GS_LP_FOCUS_JS); end-method;
The remaining tasks are standard Event Mapping:
- Create a Service
- Assign the Service to the Content Reference Fluid Home
- Test
And now you have your Hotkey! Enjoy!
At JSMpros, we teach PeopleTools Tips like this every day! Check out our events page to see what course we are offering next. Prefer to learn at your own pace? Enroll in on-demand training to learn whatever you want, whenever you want, wherever you want.
.jpg)
No comments:
Post a Comment