/** * This method creates an event vector based on a given request object. * * @param request The HttpRequest object. * @return A Vector containing the events */ private Vector createEventVector(HTTPRequest request) { Vector eventVector = new Vector(); if (request.getQueryValue("mauiEvent") != null) { eventVector = StringUtilities.split(".", request.getQueryValue("mauiEvent")); } return eventVector; }
/** * This method takes care of some special generic Maui events. It should be called before the Maui * application handles the event. * * @param mauiApp Reference to the MauiApplication associated with the events * @param eventVector The same event vector that is passed to the Maui app. * @param paramHash Hashtable of HTTP parameters * @param response The HTTPResponse object which will be sent back to the client */ private void processEvent( MauiApplication mauiApp, Vector eventVector, Hashtable paramHash, HTTPRequest request, HTTPResponse response) { boolean passEventToMauiApp = true; try { if (eventVector != null && !eventVector.isEmpty()) { // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Component events // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - String componentID = (String) eventVector.lastElement(); // If there are parentheses... if (componentID.startsWith("(") && componentID.endsWith(")")) { // ... strip them off! componentID = componentID.substring(1, componentID.length() - 1); } // // Strip off prefix - some wml browsers don't like variables that begin with a digit // if (componentID.startsWith("IDz")) { componentID = componentID.substring(3); } { System.err.println("componentID: " + componentID); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Pass events to Maui application // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Check for a content-type override String contentType = null; { if ((contentType = request.getQueryValue("contentType")) != null) { response.setContentType(contentType); } else { response.setContentType("x-wap.wml"); } } response.setContent(mauiApp.render().getBytes()); } else { response.setContentType("text/vnd.wap.wml"); response.setContent(mauiApp.render().getBytes()); } } catch (Exception e) { response.setContentType(getBaseContentType()); response.setContent((generateExceptionMessage(e)).getBytes()); e.printStackTrace(System.err); } }