ilog.webui.dhtml.components

Class IlxWActionHolder

  • All Implemented Interfaces:
    ilog.webui.dhtml.IlxWConstants, ilog.webui.dhtml.IlxWCSSModelProvider, ilog.webui.dhtml.IlxWDependencyProvider, ilog.webui.dhtml.IlxWJSObject, java.io.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
    • 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 java.io.IOException
        Overrides:
        doPrint in class IlxWComponent
        Throws:
        java.io.IOException
      • getJSIsAvailable

        public java.lang.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 java.lang.String getJSPerformCall(IlxWPort port,
                                        java.lang.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 java.lang.String getJSPerformCall(IlxWPort port,
                                        java.lang.String arg1,
                                        java.lang.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 java.lang.String getJSPerformCall(IlxWPort port,
                                        java.lang.String arg1,
                                        java.lang.String arg2,
                                        java.lang.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

© Copyright IBM Corp. 1987, 2017