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.IlxWConstantsThe 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_pathcontext parameter. You will typically provide this information in theWEB-INF/web.xmldeployment 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 ofIlxWController, namely either theIlxWDefaultControllerclass 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 yourWEB-INF/web.xmlfile 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.
- On Internet Explorer 5 or later, the data is sent and received via
an
XMLHttpRequestActiveX 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
_selfas 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. OverridingdoGet,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 voidhandleError(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, IlxWControllerError error, java.lang.String requestPath)Handles the errors thrown by theservicemethod of this servlet.protected voidservice(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)RedefinesHttpServlet.service().-
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service
-
-
-
-
Method Detail
-
service
protected void service(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp) throws javax.servlet.ServletException, java.io.IOExceptionRedefinesHttpServlet.service(). You should not have to redefine this method.- Overrides:
servicein classjavax.servlet.http.HttpServlet- Throws:
javax.servlet.ServletExceptionjava.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.ServletExceptionHandles the errors thrown by theservicemethod of this servlet.- Throws:
java.io.IOExceptionjavax.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.
-
-