Please disable your adblock and script blockers to view this page

Search this blog

Showing posts with label Current. Show all posts
Showing posts with label Current. Show all posts

Tuesday 7 July 2015

Create shortcut of page on a button click in Oracle ADF using JShortcut library (For windows)

This post is about a small trick to create shortcut file from ADF application
Actually this type of requirement doesn't come in picture when you are working in web application , for web application bookmarks replaces desktop shortcut
Still if you want to do this then you can follow approach mentioned in this post

Creating shortcut programmatically requires access of operating system but you need not to worry about that
There is a java library to do this for you - JShortcut
Download jar files from here..

1. Now first step is to create a fusion web application and add this jar to viewController project

2. Create a page (independent runnable like jspx or jsf not fragments) and drop a button in that
3. Create a managed bean to handle button's action
    Here we will make use of JShellLink class of this library

See what docs says about this -

Provide access to shortcuts (shell links) from Java. The native library (jshortcut.dll) is loaded when JShellLink is first loaded. By default, JShellLink first looks for the native library in the PATH, using System.loadLibrary. If the native library is not found in the PATH, JShellLink then looks through each directory in the CLASSPATH (as determined by the value of the system property java.class.path). If an entry in the CLASSPATH is a jar file, then JShellLink looks for the native library in the directory containing that jar file. The application can override this behavior and force JShellLink to look for the native library in a specific directory by setting the system property JSHORTCUT_HOME to point to that directory. This property must be set before the JShellLink class is loaded. This makes it possible to use this library from a self-extracting jar file. 

4. Get the url of current page
 How to get url of current page in ADF Application?
 (See button action listener code for this )
5. Check code written in managed bean-

import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;

import javax.servlet.http.HttpServletRequest;

import net.jimmc.jshortcut.JShellLink;

import oracle.adf.controller.ControllerContext;

    JShellLink link;
    String filePath;

    /**Button action listener to create shortcurt of current page on desktop
     * @param actionEvent
    public void createSortcutonDpAction(ActionEvent actionEvent) {
        try {
            //Get url of current ViewPort
            String viewId = ControllerContext.getInstance().getCurrentViewPort().getViewId();
            String viewUrl = ControllerContext.getInstance().getGlobalViewActivityURL(viewId);

            //Get Server Name and Port
            FacesContext fctx = FacesContext.getCurrentInstance();
            HttpServletRequest hsrequest = (HttpServletRequest) fctx.getExternalContext().getRequest();

            String serverName = hsrequest.getServerName();
            int serverPort = hsrequest.getServerPort();

            String runnableUrl = "http://" + serverName + ":" + serverPort + viewUrl;

            //Create Object of shortcurt link
            link = new JShellLink();
            filePath = JShellLink.getDirectory("") + runnableUrl;
            //Set Where you want to create shortcut
            //Set shortcut file name
            link.setName("Programmatically Created Shortcut");
            //Use ico file to use as shortcut icon

        } catch (Exception ex) {


6.  All done :) , run and check application
Click on button and check on desktop

Same code can be used to create shortcut from pure java application
Cheers :) Happy Learning

Friday 6 December 2013

Show current Date and Time on Page in Oracle ADF (refresh Date/time Programmatically)

Hello All,
in this tutorial i am going to explain that how to show current date and time on your ADF application page
Follow Steps-
  • Create a fusion web application and a page in it (i have used .jspx page)
  • Now drag an output text from component palette and drop it on page

  • Now select the output text and go to its property inspector then select value from Expression Builder as shown in image
  • Now in Expression Builder ,create a Managed Bean of type java.util.Date and assign its value to output text

  •  Now run your page and see current date is there
  • Now to format Date and Time , drag and drop af:convertDateTime  under output text from component palette

  •  Select convertDateTime and go to property inspector and change its pattern and run your page

  •  Now you have done basic configuration for Date/Time, if you want to refresh time (second and minute part) on page periodically then drop a poll component in page and create a poll listener in managed bean
  • Now write this simple code in your managed bean to invoke poll listener

  •     /**Binding of Output text*/
        private RichOutputText dateBind;
        public void setDateBind(RichOutputText dateBind) {
            this.dateBind = dateBind;
        public RichOutputText getDateBind() {
            return dateBind;
        /**Poll Listener Method ,handles Poll Event
         * @param pollEvent
        public void refreshTime(PollEvent pollEvent) {

    And don't forget to set clientComponent property of outputText to true
  • Now Run your application , see in this video clip how your page get refreshed... Cheers ..!

Cheers :) Happy Learning