SilverStream
Application Server 3.5

com.sssw.rt.form
Class PvHelperGeneral

java.lang.Object
 |
 +--com.sssw.rt.form.PvHelperGeneral
All Implemented Interfaces:
AgiInvokeBusinessObject

public class PvHelperGeneral
extends Object
implements AgiInvokeBusinessObject

The PvHelperGeneral class provides general purpose helper methods for Java-based forms. SilverStream creates an instance of PvHelperGeneral for every form control created. The instance variable is called agGeneral.


Constructor Summary
PvHelperGeneral()
           
 
Method Summary
 void beginWaitCursor()
          Turns on the wait cursor.
 void endWaitCursor()
          Turns off the wait cursor.
 String[] getArguments()
          Returns any application-specific arguments that a user includes on the command line when starting a form with SilverJRunner.
 URL getDatabaseURL()
          Returns an URL pointing to the database that contains the form.
 int getEnvironment()
          Returns information about the environment in which the form is running.
 Image getIconImage()
          Gets the icon image of the form's frame, if possible.
 AgrServerSession getServerSession()
          Gets the server session associated with this form.
 String getTitle()
          Obtains the title of the form's containing window, if possible.
 Object invokeAgent(String agentSpec)
          Deprecated. use PvHelperGeneral.invokeBusinessObject(String)
 Object invokeAgent(String agentSpec, Object param)
          Deprecated. use PvHelperGeneral.invokeBusinessObject(String, Serializable)
 Serializable invokeBusinessObject(String agentSpec)
          Invokes the named business object.
 Serializable invokeBusinessObject(String agentSpec, Serializable param)
          Invokes the named business object.
 void setIconImage(Image icon)
          Sets the icon image of the form's frame, if possible.
 void setTitle(String title)
          Sets the title of the form's window, if possible.
 void showConsole(boolean show)
          Shows or hides the Java console, which displays printouts and exceptions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PvHelperGeneral

public PvHelperGeneral()
Method Detail

getEnvironment

public int getEnvironment()
Returns information about the environment in which the form is running.
Usage:

The return value is one of these values:
ENV_BROWSER - the form is running in a browser.
ENV_APPLICATION - the form is running in SilverJRunner.
ENV_DESIGNER - the form is running in test mode in the SilverStream Form Designer.

Example:
 	switch (agGeneral.getEnvironment())
 	{
 		case agGeneral.ENV_BROWSER:
 			//do something
 			break;
 		case agGeneral.ENV_APPLICATION:
 			//do something else
 			break;
 		case agGeneral.ENV_DESIGNER:
 			//do something different
 			break;
 	}
 

getArguments

public String[] getArguments()
Returns any application-specific arguments that a user includes on the command line when starting a form with SilverJRunner. (This consists of all arguments specified after the form name, except those beginning with -ss_.)
Returns:
a String array containing the application arguments passed to the form by SilverJRunner. Returns null if not running in SilverJRunner.
Example:
Suppose a user enters the following command to start SilverJRunner and load the form named myform:
  SilverJRunner -ss_proxy=myproxy myserver mydb myform -s aaa bbb
 

This passes these application arguments to the form:

  -s aaa bbb
 

To access them, code the following in an appropriate form event (such as formActivate):

  String[] passedArgs;
  passedArgs = agGeneral.getArguments();
 

invokeBusinessObject

public Serializable invokeBusinessObject(String agentSpec)
                                  throws Exception
Invokes the named business object.
Specified by:
invokeBusinessObject in interface AgiInvokeBusinessObject
Parameters:
agentSpec - the name of the business object to invoke
Returns:
The result returned by the business object. The writer of the business object sets this by calling setResult() on the AgoInvokedEvent object passed to the invoked event
Throws:
Throws - any exception thrown by the buiness object
Usage:

The business object spec. can be:

  • The fully qualified classname of an invokable business object in the current database, or
  • database:classname for a business object in another database on the same server.

You cannot specify the ip address of the server or the full server name.

The invokeBusinessObject() method returns a result that the writer of the business object sets by calling setResult() on the AgoInvokedEvent object passed to the invoked event.

Example:
 	Object retVal = agGeneral.invokeBusinessObject("mypackage.mysubpkg.MyBusObj");
 

This example uses invokeBusinessObject and invokes an object in another database.

 
    try
    {
 
    agGeneral.invokeBusinessObject("WineDemo2:com.silverdemo.dso.general.Invoked");
    }
    catch (Exception __exx)
    {
    agDialog.displayError(__exx);
    }
 

invokeBusinessObject

public Serializable invokeBusinessObject(String agentSpec,
                                         Serializable param)
                                  throws Exception
Invokes the named business object.
Specified by:
invokeBusinessObject in interface AgiInvokeBusinessObject
Parameters:
agentSpec - the name of the business object to invoke.
param - any Serializable parameter you want to pass to the business object
Returns:
The result returned by the business object. The writer of the business object sets this by calling setResult() on the AgoInvokedEvent object passed to the invoked event
Throws:
throws - any exception thrown by the buiness object
Usage:

The business object spec. can be:

  • The fully qualified classname of an invokable business object in the current database, or
  • database:classname for a business object in another database.

You cannot specify the ip address of the server or the full server name.

The invokeBusinessObject() method returns a result that the writer of the business object sets by calling setResult() on the AgoInvokedEvent object passed to the invoked event.

Example:
 	Object retVal = agGeneral.invokeBusinessObject("mypackage.mysubpkg.MyBusObj",
 		CustID.getIntegerValue());
 

invokeAgent

public Object invokeAgent(String agentSpec)
                   throws AgoUnrecoverableSystemException,
                          IOException
Deprecated. use PvHelperGeneral.invokeBusinessObject(String)

Invoke the named agent.
Parameters:
agentSpec - This can be:
  • The name of an URL invokable agent in the current database
  • Database:agent for an agent in another database, or
  • A full URL to an agent.

invokeAgent

public Object invokeAgent(String agentSpec,
                          Object param)
                   throws AgoUnrecoverableSystemException,
                          IOException
Deprecated. use PvHelperGeneral.invokeBusinessObject(String, Serializable)

Invoke the named agent.
Parameters:
agentSpec - This can be:
  • The name of an URL-invokable agent in the current database
  • Database:agent for an agent in another database, or
  • A full URL to an agent.
params - a set of parameters to pass to the agent.

beginWaitCursor

public void beginWaitCursor()
Turns on the wait cursor.
Usage:

Calls to beginWaitCursor() can be nested. That is, if you call beginWaitCursor() twice and then call endWaitCursor() once, the wait cursor will still be displayed.

Example:
 	agGeneral.beginWaitCursor();
 
See Also:
PvHelperGeneral.endWaitCursor()

endWaitCursor

public void endWaitCursor()
Turns off the wait cursor.
Example:
 	agGeneral.endWaitCursor();
 
See Also:
PvHelperGeneral.beginWaitCursor()

getDatabaseURL

public URL getDatabaseURL()
Returns an URL pointing to the database that contains the form.
Usage:

The database URL ends with a trailing slash and might look something like this: http://MyServer/MyDatabase/

Example:
  java.net.URL myURL;
  myURL = agGeneral.getDatabaseURL
 

setTitle

public void setTitle(String title)
Sets the title of the form's window, if possible.
Parameters:
title - the title to set for the window
Usage:

The title can only be set if the form is displayed in a dialog or frame, or if it is being run as a SilverJRunner application.

See Also:
PvHelperGeneral.getTitle()

getTitle

public String getTitle()
Obtains the title of the form's containing window, if possible.
Usage:

The getTitle() method returns a title only if the form is being displayed in a dialog or frame, or if it is being run as an application (SilverJRunner).

See Also:
PvHelperGeneral.setTitle(String)

setIconImage

public void setIconImage(Image icon)
Sets the icon image of the form's frame, if possible.
Usage:

The setIconImage() method should be called from the formActivate event (not from the formLoaded event), since it requires that the form already have been added to its containing frame.

This method can be used only if the form is being displayed in a dialog or frame, or if it is being run as an application (SilverJRunner).

Example:
 	agGeneral.setIconImage(getImage("myIcon.gif");
 
See Also:
PvHelperGeneral.getIconImage()

getIconImage

public Image getIconImage()
Gets the icon image of the form's frame, if possible.
Usage:

The getIconImage() method should be called from the formActivate event (not from the formLoaded event), since it requires that the form already have been added to its containing frame.

This method can be used only if the form is being displayed in a dialog or frame, or if it is being run as an application (SilverJRunner).

Example:
 	Image currentIcon;
 	currentIcon = agGeneral.getIconImage();
 
See Also:
PvHelperGeneral.setIconImage(Image)

showConsole

public void showConsole(boolean show)
Shows or hides the Java console, which displays printouts and exceptions.
Parameters:
show - if true, the console is shown; if false, the console is hidden

getServerSession

public AgrServerSession getServerSession()
Gets the server session associated with this form. This is the object used to connect to the server.

SilverStream
Application Server 3.5