ilog.webui.dhtml

Class IlxWController

  • java.lang.Object
    • javax.servlet.GenericServlet
      • javax.servlet.http.HttpServlet
        • ilog.webui.dhtml.IlxWController
  • All Implemented Interfaces:
    ilog.webui.dhtml.IlxWConstants, java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig
    Direct Known Subclasses:
    IlxWDefaultController


    public abstract class IlxWController
    extends javax.servlet.http.HttpServlet
    implements ilog.webui.dhtml.IlxWConstants
    The controller servlet for the web components. This servlet manages communication between the client side and the server side of the Web Components.

    When creating a Web Application using the web components, you must provide a controller servlet and give its path in the ilog.webui.dhtml.controller_path context parameter. You will typically provide this information in the WEB-INF/web.xml deployment descriptor of your Web Application (see Servlet 2.2 Specification for more details on Web Applications and deployment descriptors). The controller you provide must be a subclass of IlxWController, namely either the IlxWDefaultController class or your own subclass.
    Here is an example of a controller servlet subclass:

       public class MyController extends IlxWController {
         public void handleError(HttpRequest req,
                                 HttpResponse resp,
                                 IlxWControllerError error,
                                 String updateRequest) {
           resp.sendError(HttpResponse.SC_INTERNAL_SERVER_ERROR,
                          error.getMessage());
         }
       }
       
    ... and typically, you reference this servlet in your WEB-INF/web.xml file as follows:
       ...
       <context-param>
         <param-name>ilog.webui.dhtml.controller_path</param-name>
         <param-value>/servlet/myservlets.MyController</param-value>
       </context-param>
       <servlet>
         <servlet-name>MyController</servlet-name>
         <servlet-class>myservlets.MyController</servlet-class>
       </servlet>
       <servlet-mapping>
         <servlet-name>MyController</servlet-name>
         <url-pattern>/servlet/myservlets.MyController</url-pattern>
       </servlet-mapping>
       ...
       

    To understand how communication between the client side and the server side of a web component is managed, let's have a look at a scenario of a user interaction. Suppose a user performs an action on a Web browser, for instance, clicks on a link of the Syntactic Editor. When this action is performed, a JavaScript proxy method is called. This method first registers the data representing the modification applied to the component in a queue stored in the JavaScript environment of the client. We call this queue the modified component queue. Next time a request is sent to the controller servlet, the data of the modified component queue will be added to the request and the server-side ,component object will be updated accordingly. In this way, components are synchronized between their client side and their server side.

    The major issue on the client side is whether to redisplay the HTML page or not. The JavaScript proxy applies modifications to the HTML page by evaluating the user action. There are three possible conditions that may arise:

    • No need to redisplay page (for example, a text field was edited);
    • Redisplay page by client: the JavaScript proxy can carry this out locally;
    • Redisplay page by server: the JavaScript proxy sends a request to the
    • server.
    When a modification of the component state is placed in the queue, the JavaScript proxy method evaluates the modification. If the component needs to be redisplayed through the server, the JavaScript proxy sends a request to the controller servlet. The send requests may be sent to the server via two different ways, depending on the web browser:
    • On Internet Explorer 5 or later, the data is sent and received via an XMLHttpRequest ActiveX object. This allows us to implement a smart redisplaying mechanism, because only the modified parts of the component
    • need to be redisplayed.
    • On other web browsers, for example Netscape 3.x and 4.x, the data is sent via a form with _self as the target. After processing the modified component queue, the controller servlet forwards the request to the servlet or JSP page that displayed the component which triggered the action.

    In this class, the service() method handles all requests regardless of their type. Overriding doGet, doPost, doPut, etc. has no effect.

    See Also:
    IlxWComponent, IlxWPort, IlxWManager, Serialized Form
    • Constructor Summary

      Constructors 
      Constructor and Description
      IlxWController() 
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      protected abstract void handleError(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, IlxWControllerError error, java.lang.String requestPath)
      Handles the errors thrown by the service method of this servlet.
      protected void service(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
      Redefines HttpServlet.service().
      • Methods inherited from class javax.servlet.http.HttpServlet

        doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service
      • Methods inherited from class javax.servlet.GenericServlet

        destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, init, log, log
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • IlxWController

        public IlxWController()
    • Method Detail

      • service

        protected void service(javax.servlet.http.HttpServletRequest req,
                   javax.servlet.http.HttpServletResponse resp)
                        throws javax.servlet.ServletException,
                               java.io.IOException
        Redefines HttpServlet.service(). You should not have to redefine this method.
        Overrides:
        service in class javax.servlet.http.HttpServlet
        Throws:
        javax.servlet.ServletException
        java.io.IOException
      • handleError

        protected abstract void handleError(javax.servlet.http.HttpServletRequest request,
                       javax.servlet.http.HttpServletResponse response,
                       IlxWControllerError error,
                       java.lang.String requestPath)
                                     throws java.io.IOException,
                                            javax.servlet.ServletException
        Handles the errors thrown by the service method of this servlet.
        Throws:
        java.io.IOException
        javax.servlet.ServletException
        Parameters:
        error - The controller error object.
        request - The current request.
        response - The current response.
        requestPath - The path of the request that has been called just before the servlet controller.

© Copyright IBM Corp. 1987, 2015