Sunday 15 May 2011

Real “ToolTip” for OAF GUI Elements

My goal is very simple. I want when my mouse hover over some element to display a simple tooltip that shows some message and disappear after mouse is moved away. However there is no such thing in OAF. Oracle built something that is called Tip  Message. It is a message that appears bellow/near specific GUI element and doesn’t disappear.

The solution is very simple.

For example you, have a textfield element called “PrinterName” . Get a reference to this object and attach a java script command by using onMouseOver  event.

public void processRequest(OAPageContext pageContext, OAWebBean webBean)
 {
   super.processRequest(pageContext, webBean);
  
 
   OAMessageTextInputBean msgPrinterName2 = (OAMessageTextInputBean)pageContext.getPageLayoutBean().findChildRecursive("PrinterName");
   if (msgPrinterName2!=null)
      msgPrinterName2.setOnMouseOver("this.title='This is my tooltip';");

2 comments:

  1. This works perfectly for single line tool tip. Could you please provide your inputs on what and how to do for multi line tool tip

    ReplyDelete
  2. I didn't work with OAF for at least 8–9 years and no longer have access to the development platform. I didn't try to implement the multi-line tooltip, so what I am about to write is not tested. According to StackOverflow, all you need to do is add a character to the tooltip text. 
    https://stackoverflow.com/questions/3340802/add-line-break-within-tooltips

    ReplyDelete