This discussion is archived
0 Replies Latest reply: Jun 18, 2013 1:10 PM by user302148 RSS

JScriptWindowPJC

user302148 Newbie
Currently Being Moderated

Hi,

 

I get the following error when i try to use JScriptWindowPJC, even I have re-compiled the codes and re-created the jar file. Your help will be greatly appreciated.

 

netscape.javascript.JSException: Failure to evaluate openWindowURL("http://otn.oracle.com/products/forms")

at sun.plugin.javascript.ocx.JSObject.eval(Unknown Source)

at oracle.forms.samples.JScriptWindowPJC.setProperty(JScriptWindowPJC.java:181)

 

[code]

package oracle.forms.samples;

/**
*  Oracle Forms JavaBean that calls a Javascript in the Applet HTML page to open
*  a Browser Window that remains under the control of Oracle Forms. The Javascript
*  can be added as a parameter value of HTMLbeforeForm in the formsweb.cfg file. The
*  HTMLbeforeForm can either be added in the default area of the formsweb.cfg file,
*  which makes it available for all applications, or in the application specific
*  configuration, which makes it available only for this application. The Javascript
*  looks as follows:
*  <code>

*  &lt;script&gt;
*  var windowHandle;
*
* function openWindowURL(URLString){
* if (windowHandle == null || windowHandle.closed){
*    windowHandle = window.open(URLString,"OracleFormsServicesSubWindow","location=false,toolbar=false,resizable,scrollbars");
*  }
*  else {
*   windowHandle.close();
*   windowHandle= window.open(URLString,"OracleFormsServicesSubWindow","location=false,toolbar=false,resizable,scrollbars");
*  }
*  windowHandle.focus();
* }
*
* function closeWindow(){
* if (windowHandle && !windowHandle.closed){
*  windowHandle.close();
*  }
* else{
* }
*}
* &lt;/script&gt;
*  </code>

*  This JavaBean is required for all MS IE versions running on MS XP SP2, because
*  this is where Microsoft started to secure their browser to prevent some Javascript
*  calls.

*  This bean only works with InternetExplorer, for Netscape and Mozilla use the
*  web.show_document('Javascript:...','_self'); built-in call.

*  For you to decide which browser your client is on, I added a method that allows you
*  to get this information so you can handle different browser versions in Forms.

*  @author Frank Nimphius
*  @version May 2005
*/

 

import netscape.javascript.*;
import oracle.forms.handler.IHandler;
import oracle.forms.ui.VBean;
import java.applet.Applet;
import oracle.forms.properties.ID;

public class JScriptWindowPJC extends VBean
{

  /**
   * set_custom_property('beanblock.beanarea',1,'OPEN_WINDOW','<URL absolut or relative>');
   */
  public static final ID pOpenWindow                 = ID.registerProperty("OPEN_WINDOW");
  /**
   * set_custom_property('beanblock.beanarea',1,'CLOSE_WINDOW','');
   */
  public static final ID pCloseWindow                = ID.registerProperty("CLOSE_WINDOW");
  /**
   * get_custom_property('beanblock.beanarea',1,'BROWSER_VERSION');
   */
  public static final ID pBrowserVersion             = ID.registerProperty("BROWSER_VERSION");
 
  /**
   * set_custom_property('beanblock.beanarea',1,'LOG_OUTPUT','true');
   * set_custom_property('beanblock.beanarea',1,'LOG_OUTPUT','false');
   */
  public static final ID pLogOutput             = ID.registerProperty("LOG_OUTPUT");

  /* JSObject variables */
  JSObject m_window=null;
  JSObject m_document=null;

  Applet m_applet;

  /*Forms settings*/
  IHandler m_handler;

  /*Browser type */
  boolean isMSIE= false;
 
  boolean logOutput=false;
 
  public JScriptWindowPJC()
  {
  }
 
  /**
   * Implementation of IView interface init is called when the bean is first
   * instanciated we use this to obtain information such as the browser type
   * and to call the Javascript
   * @see oracle.forms.ui.IView
   */

  public final void init (IHandler handler)
  {
    try
    {
      super.init(handler);
      m_handler = handler;
      // get the forms applet handler
      m_applet = m_handler.getApplet();

      /*
       * For this bean to work, you need to add the following parameters to the
       * Forms Applet HTML template
       *
       * In the <embed> section:
       *
       * browser="Netscape"
       *
       * In the <object ..> section
       *
       * <PARAM NAME="browser"       VALUE="IE">
       */
      if ((m_applet.getParameter("BROWSER")).toUpperCase().indexOf("INTERNETEXPLORER")>-1){
          isMSIE=true;
          log("The Browser used is Internet Explorer");
      }
      else
      {
          log("The Browser used is Netscape or other");
          isMSIE=false;
      }
     
      if(isMSIE){
        // get a handle to the applet window
        m_window = JSObject.getWindow(m_applet);   
        JSObject navigator = (JSObject) m_window.getMember("navigator");

        // For the Javascript we need a handle to the document
        m_document = (JSObject) m_window.getMember("document");
      }
      else
      {
        log("Use web.show_document() for Netscape and Mozilla");
      }
    }
    catch (Exception e)
    {
      System.out.println("Error Initialising JScriptWindow Bean");
      System.out.println(e.toString());
      System.out.println("Stack Trace\n-----------------------");
      e.printStackTrace();
    }
  }
 
 
  private void log (String s)
  {
    if (logOutput) System.out.println(s);
  }

  public Object getProperty(ID p0)
  {
    if (p0 == pBrowserVersion)
    {
      String s;
      s= isMSIE?"IE":"Netscape or Mozilla";
      return s;
    }
    return super.getProperty(p0);
  }

  public boolean setProperty(ID p0, Object p1)
  {
    if (p0 == pOpenWindow && isMSIE)
    {
      if(p1 != null && ((String)p1).length()>0)
      {
        log("OPEN_WINDOW called with URL "+(String)p1);
        m_window.eval("openWindowURL(\""+(String)p1+"\")");
        return true;
      }
      else
      {
        log ("No valid URL string provided in call to OPEN_WINDOW");
        return true;
      }
    }
    else if (p0==pCloseWindow & isMSIE)
    {
      log("CLOSE WINDOW called");
      m_window.eval("closeWindow()");
      return true;
    }
    else if(p0==pLogOutput)
    {
      if (p1 != null && ("true".equalsIgnoreCase((String)p1)))
      {
        logOutput= true;
      }
      else
      {
        logOutput= false;
        return true;
      }
    }
    return super.setProperty(p0, p1);
  }

}

[/code]

Thanks

RM