Decision Center API

ilog.webui.dhtml.components
Class IlxWActionHolder

java.lang.Object
  extended by ilog.webui.dhtml.IlxWContainer
      extended by ilog.webui.dhtml.IlxWComponent
          extended by ilog.webui.dhtml.components.IlxWActionHolder
All Implemented Interfaces:
ilog.webui.dhtml.IlxWConstants, ilog.webui.dhtml.IlxWCSSModelProvider, ilog.webui.dhtml.IlxWDependencyProvider, ilog.webui.dhtml.IlxWJSObject, Serializable

public class IlxWActionHolder
extends IlxWComponent

An action holder is a hidden component that holds an action (IlxWAction) that can be triggered by the program. This means that once printed, it has no graphical representation on the web browser.

Action holders provide the user with a way to perform some actions on the web server and be sure that the modified component queue has been flushed to the server before the action is performed.

The getJSPerformCall(IlxWPort, java.lang.String []) method generates a JavaScript instruction which can be executed at any time on the client HTML page. This instruction triggers the action associated with the action holder.

Although the action holder is a hidden component, it must be printed to a port via its print method, otherwise the instruction generated by getJSPerformCall will not be valid.

Furthermore, the current page may not be completely loaded when the user tries to trigger the action. To test whether the page is completely loaded or not, use the getJSIsAvailable(ilog.webui.dhtml.IlxWPort) method. This method returns a JavaScript boolean expression which tells whether the page is complete or not.

Suppose you want to write an HTML link which, when clicked, triggers the action associated with an action holder. Here is an example that uses both the getJSIsAvailable and getJSPerformCall methods:

   ...
   IlxWActionHolder ah = new IlxWActionHolder(myAction);
   ah.print(port);
   ...
   String isAvailable = ah.getJSIsAvailable(port);
   String perform = ah.getJSPerformCall(port);
   String code = "if ("+isAvailable+") { "+perform+" }";
   out.print("<a href=\"javascript:void(0)\" onclick=\"+code+\">");
   out.print("Click Me");
   out.print("</a>");
   ...
 

See Also:
IlxWAction, IlxWController, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class ilog.webui.dhtml.IlxWComponent
IlxWComponent.DynamicStyleMap
 
Field Summary
 
Fields inherited from class ilog.webui.dhtml.IlxWContainer
listenerList
 
Constructor Summary
IlxWActionHolder()
          Constructs a new action holder.
IlxWActionHolder(IlxWAction action)
          Constructs a new action holder with the given action.
 
Method Summary
protected  void doPrint(IlxWPort port)
           
 IlxWAction getAction()
          Gets the action held by this action holder.
 String getJSIsAvailable(IlxWPort port)
          Generates a JavaScript instruction whose evaluation will be a Boolean telling whether the page where this action holder has been printed is completely loaded or not.
 String getJSPerformCall(IlxWPort port)
          Calls the action with no argument.
 String getJSPerformCall(IlxWPort port, String arg)
          Calls the action with one argument.
 String getJSPerformCall(IlxWPort port, String[] args)
          Generates a JavaScript instruction whose evaluation performs a call to the action associated with this action holder.
 String getJSPerformCall(IlxWPort port, String arg1, String arg2)
          Calls the action with two arguments.
 String getJSPerformCall(IlxWPort port, String arg1, String arg2, String arg3)
          Calls the action with three arguments.
 void notifyDependencies(IlxWPort port)
           
protected  void printComponent(IlxWPort port)
          Prints the HTML code that will display the graphical representation of this component.
 void setAction(IlxWAction action)
          Sets the action held by this action holder.
 
Methods inherited from class ilog.webui.dhtml.IlxWComponent
addPropertyChangeListener, addPropertyChangeListener, detach, firePropertyChange, firePropertyChange, getName, getRealHtmlTagName, getStyle, invalidate, isInvalidated, print, removePropertyChangeListener, removePropertyChangeListener, setName, validate
 
Methods inherited from class ilog.webui.dhtml.IlxWContainer
add, add, getAttribute, getAttributeNames, getComponent, getComponentCount, getComponentNamed, getComponents, getManager, getParent, getUserAgentRules, indexOf, isAncestorOf, remove, remove, removeAll, removeAttribute, setAttribute, setAuthorRules, setFinalizer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IlxWActionHolder

public IlxWActionHolder()
Constructs a new action holder. By default, the associated action will be null.


IlxWActionHolder

public IlxWActionHolder(IlxWAction action)
Constructs a new action holder with the given action.

Method Detail

setAction

public void setAction(IlxWAction action)
Sets the action held by this action holder.

Parameters:
action - The action to be performed.

getAction

public IlxWAction getAction()
Gets the action held by this action holder.

Returns:
The action performed by the holder.

doPrint

protected void doPrint(IlxWPort port)
                throws IOException
Overrides:
doPrint in class IlxWComponent
Throws:
IOException

printComponent

protected void printComponent(IlxWPort port)
                       throws IOException
Description copied from class: IlxWComponent
Prints the HTML code that will display the graphical representation of this component. This method is called by the IlxWComponent.print(ilog.webui.dhtml.IlxWPort) method.

Specified by:
printComponent in class IlxWComponent
Throws:
IOException
Parameters:
port - The port on which the component will be printed.
See Also:
IlxWComponent.print(ilog.webui.dhtml.IlxWPort)

getJSIsAvailable

public String getJSIsAvailable(IlxWPort port)
Generates a JavaScript instruction whose evaluation will be a Boolean telling whether the page where this action holder has been printed is completely loaded or not. If the page is not completely loaded, calling the JavaScript code generated by getJSPerformCall may throw a JavaScript error. It is strongly recommended to test this instruction before trying to perform the action associated with the action holder.

Parameters:
port - The port where the returned JavaScript expression will be printed.
Returns:
The JavaScript Boolean expression telling whether the page is completely loaded.

getJSPerformCall

public String getJSPerformCall(IlxWPort port,
                               String[] args)
Generates a JavaScript instruction whose evaluation performs a call to the action associated with this action holder.

If the page is not completely loaded, calling the JavaScript code generated by getJSPerformCall may throw a JavaScript error. It is strongly recommended to test whether the page is completely loaded or not via the getJSIsAvailable(ilog.webui.dhtml.IlxWPort) method before executing the code returned by this method.

Parameters:
args - The JavaScript arguments to pass to the call. You will get those arguments back in the IlxWAction.perform method of the associated action.
port - The port where the returned JavaScript instruction will be printed.
Returns:
The JavaScript instruction that calls the action.
See Also:
getJSIsAvailable(ilog.webui.dhtml.IlxWPort), getJSPerformCall(ilog.webui.dhtml.IlxWPort, java.lang.String[])

getJSPerformCall

public String getJSPerformCall(IlxWPort port)
Calls the action with no argument.

Parameters:
port - The port where the returned JavaScript instruction will be printed.
See Also:
getJSPerformCall(IlxWPort, java.lang.String [] args)

getJSPerformCall

public String getJSPerformCall(IlxWPort port,
                               String arg)
Calls the action with one argument.

Parameters:
port - The port where the returned JavaScript instruction will be printed.
See Also:
getJSPerformCall(IlxWPort, java.lang.String [] args)

getJSPerformCall

public String getJSPerformCall(IlxWPort port,
                               String arg1,
                               String arg2)
Calls the action with two arguments.

Parameters:
port - The port where the returned JavaScript instruction will be printed.
See Also:
getJSPerformCall(IlxWPort, java.lang.String [] args)

getJSPerformCall

public String getJSPerformCall(IlxWPort port,
                               String arg1,
                               String arg2,
                               String arg3)
Calls the action with three arguments.

Parameters:
port - The port where the returned JavaScript instruction will be printed.
See Also:
getJSPerformCall(IlxWPort, java.lang.String [] args)

notifyDependencies

public void notifyDependencies(IlxWPort port)
Specified by:
notifyDependencies in interface ilog.webui.dhtml.IlxWDependencyProvider
Overrides:
notifyDependencies in class IlxWComponent

Decision Center API

© Copyright IBM Corp. 1987, 2013