public void renderContentEnd(
      Appendable writer, Map<String, Object> context, ModelScreenWidget.Content content)
      throws IOException {
    String expandedContentId = content.getContentId(context);
    String editMode = "Edit";
    String editRequest = content.getEditRequest(context);
    String enableEditName = content.getEnableEditName(context);
    String enableEditValue = (String) context.get(enableEditName);
    String urlString = "";
    if (editRequest != null && editRequest.toUpperCase().indexOf("IMAGE") > 0) {
      editMode += " Image";
    }

    if (UtilValidate.isNotEmpty(editRequest) && "true".equals(enableEditValue)) {
      HttpServletResponse response = (HttpServletResponse) context.get("response");
      HttpServletRequest request = (HttpServletRequest) context.get("request");
      if (request != null && response != null) {
        if (editRequest.indexOf("?") < 0) editRequest += "?";
        else editRequest += "&amp;";
        editRequest += "contentId=" + expandedContentId;
        ServletContext ctx = (ServletContext) request.getAttribute("servletContext");
        RequestHandler rh = (RequestHandler) ctx.getAttribute("_REQUEST_HANDLER_");
        urlString = rh.makeLink(request, response, editRequest, false, false, false);
      }

      Map<String, Object> parameters = FastMap.newInstance();
      parameters.put("urlString", urlString);
      parameters.put("editMode", editMode);
      parameters.put("editContainerStyle", content.getEditContainerStyle(context));
      parameters.put("editRequest", editRequest);
      parameters.put("enableEditValue", enableEditValue);
      executeMacro(writer, "renderContentEnd", parameters);
    }
  }
Ejemplo n.º 2
0
 // Made this a separate method so it can be externalized and reused.
 private Map<String, Object> createImageParameters(Map<String, Object> context, Image image) {
   Map<String, Object> parameters = new HashMap<String, Object>();
   parameters.put("id", image.getId(context));
   parameters.put("style", image.getStyle(context));
   parameters.put("width", image.getWidth(context));
   parameters.put("height", image.getHeight(context));
   parameters.put("border", image.getBorder(context));
   String src = image.getSrc(context);
   if (UtilValidate.isNotEmpty(src) && request != null && response != null) {
     String urlMode = image.getUrlMode();
     if ("ofbiz".equalsIgnoreCase(urlMode)) {
       boolean fullPath = false;
       boolean secure = false;
       boolean encode = false;
       ServletContext ctx = (ServletContext) request.getAttribute("servletContext");
       RequestHandler rh = (RequestHandler) ctx.getAttribute("_REQUEST_HANDLER_");
       src = rh.makeLink(request, response, src, fullPath, secure, encode);
     } else if ("content".equalsIgnoreCase(urlMode)) {
       StringBuilder newURL = new StringBuilder();
       ContentUrlTag.appendContentPrefix(request, newURL);
       newURL.append(src);
       src = newURL.toString();
     }
   }
   parameters.put("src", src);
   return parameters;
 }
Ejemplo n.º 3
0
  protected void viewHandlerRender(
      String typeToUse, HttpServletRequest request, HttpServletResponse response)
      throws ServletException {
    ServletContext context = (ServletContext) request.getAttribute("servletContext");
    RequestHandler requestHandler = (RequestHandler) context.getAttribute("_REQUEST_HANDLER_");

    // see if the type is defined in the controller.xml file
    try {
      if (Debug.verboseOn())
        Debug.logVerbose("Rendering view [" + content + "] of type [" + typeToUse + "]", module);
      ViewHandler vh = requestHandler.getViewFactory().getViewHandler(typeToUse);
      // use the default content-type and encoding for the ViewHandler -- may want to change this.
      vh.render(name, content, info, null, null, request, response);
    } catch (ViewHandlerException e) {
      throw new ServletException(e.getNonNestedMessage(), e.getNested());
    }
  }
  public void renderImage(
      Appendable writer, Map<String, Object> context, ModelScreenWidget.Image image)
      throws IOException {
    if (image == null) return;
    String src = image.getSrc(context);

    String urlMode = image.getUrlMode();
    boolean fullPath = false;
    boolean secure = false;
    boolean encode = false;
    HttpServletResponse response = (HttpServletResponse) context.get("response");
    HttpServletRequest request = (HttpServletRequest) context.get("request");
    String urlString = "";
    if (urlMode != null && urlMode.equalsIgnoreCase("intra-app")) {
      if (request != null && response != null) {
        ServletContext ctx = (ServletContext) request.getAttribute("servletContext");
        RequestHandler rh = (RequestHandler) ctx.getAttribute("_REQUEST_HANDLER_");
        urlString = rh.makeLink(request, response, src, fullPath, secure, encode);
      } else {
        urlString = src;
      }
    } else if (urlMode != null && urlMode.equalsIgnoreCase("content")) {
      if (request != null && response != null) {
        StringBuilder newURL = new StringBuilder();
        ContentUrlTag.appendContentPrefix(request, newURL);
        newURL.append(src);
        urlString = newURL.toString();
      }
    } else {
      urlString = src;
    }
    Map<String, Object> parameters = FastMap.newInstance();
    parameters.put("src", src);
    parameters.put("id", image.getId(context));
    parameters.put("style", image.getStyle(context));
    parameters.put("wid", image.getWidth(context));
    parameters.put("hgt", image.getHeight(context));
    parameters.put("border", image.getBorder(context));
    parameters.put("alt", image.getAlt(context));
    parameters.put("urlString", urlString);
    executeMacro(writer, "renderImage", parameters);
  }
  public void renderContentFrame(
      Appendable writer, Map<String, Object> context, ModelScreenWidget.Content content)
      throws IOException {
    String dataResourceId = content.getDataResourceId(context);
    String urlString = "/ViewSimpleContent?dataResourceId=" + dataResourceId;
    String fullUrlString = "";
    HttpServletRequest request = (HttpServletRequest) context.get("request");
    HttpServletResponse response = (HttpServletResponse) context.get("response");
    if (request != null && response != null) {
      ServletContext ctx = (ServletContext) request.getAttribute("servletContext");
      RequestHandler rh = (RequestHandler) ctx.getAttribute("_REQUEST_HANDLER_");
      fullUrlString = rh.makeLink(request, response, urlString, true, false, false);
    }

    Map<String, Object> parameters = FastMap.newInstance();
    parameters.put("fullUrl", fullUrlString);
    parameters.put("width", content.getWidth());
    parameters.put("height", content.getHeight());
    parameters.put("border", content.getBorder());
    executeMacro(writer, "renderContentFrame", parameters);
  }
Ejemplo n.º 6
0
 public static String determineAutoLinkType(
     String linkType, String target, String targetType, HttpServletRequest request) {
   if ("auto".equals(linkType)) {
     if ("intra-app".equals(targetType)) {
       String requestUri =
           (target.indexOf('?') > -1) ? target.substring(0, target.indexOf('?')) : target;
       ServletContext servletContext = request.getSession().getServletContext();
       RequestHandler rh = (RequestHandler) servletContext.getAttribute("_REQUEST_HANDLER_");
       ConfigXMLReader.RequestMap requestMap =
           rh.getControllerConfig().getRequestMapMap().get(requestUri);
       if (requestMap != null && requestMap.event != null) {
         return "hidden-form";
       } else {
         return "anchor";
       }
     } else {
       return "anchor";
     }
   } else {
     return linkType;
   }
 }
 public void renderContainerBegin(
     Appendable writer, Map<String, Object> context, ModelScreenWidget.Container container)
     throws IOException {
   String containerId = container.getId(context);
   String autoUpdateTarget = container.getAutoUpdateTargetExdr(context);
   HttpServletRequest request = (HttpServletRequest) context.get("request");
   String autoUpdateLink = "";
   if (UtilValidate.isNotEmpty(autoUpdateTarget) && UtilHttp.isJavaScriptEnabled(request)) {
     if (UtilValidate.isEmpty(containerId)) {
       containerId = getNextElementId();
     }
     HttpServletResponse response = (HttpServletResponse) context.get("response");
     ServletContext ctx = (ServletContext) request.getAttribute("servletContext");
     RequestHandler rh = (RequestHandler) ctx.getAttribute("_REQUEST_HANDLER_");
     autoUpdateLink = rh.makeLink(request, response, autoUpdateTarget);
   }
   Map<String, Object> parameters = FastMap.newInstance();
   parameters.put("id", containerId);
   parameters.put("style", container.getStyle(context));
   parameters.put("autoUpdateLink", autoUpdateLink);
   parameters.put("autoUpdateInterval", container.getAutoUpdateInterval());
   executeMacro(writer, "renderContainerBegin", parameters);
 }
Ejemplo n.º 8
0
  private String getLocationURI(HttpServletRequest request) {
    StringBuilder uri = new StringBuilder();
    uri.append(request.getScheme());
    uri.append("://");
    uri.append(request.getServerName());
    if (request.getServerPort() != 80 && request.getServerPort() != 443) {
      uri.append(":");
      uri.append(request.getServerPort());
    }
    uri.append(request.getContextPath());
    uri.append(request.getServletPath());

    String reqInfo = RequestHandler.getRequestUri(request.getPathInfo());
    if (!reqInfo.startsWith("/")) {
      reqInfo = "/" + reqInfo;
    }

    uri.append(reqInfo);
    return uri.toString();
  }
Ejemplo n.º 9
0
  /**
   * @see org.ofbiz.webapp.event.EventHandler#invoke(ConfigXMLReader.Event,
   *     ConfigXMLReader.RequestMap, javax.servlet.http.HttpServletRequest,
   *     javax.servlet.http.HttpServletResponse)
   */
  public String invoke(
      Event event, RequestMap requestMap, HttpServletRequest request, HttpServletResponse response)
      throws EventHandlerException {
    LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
    GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator");

    // first check for WSDL request
    String wsdlReq = request.getParameter("wsdl");
    if (wsdlReq == null) {
      wsdlReq = request.getParameter("WSDL");
    }
    if (wsdlReq != null) {
      String serviceName = RequestHandler.getOverrideViewUri(request.getPathInfo());
      DispatchContext dctx = dispatcher.getDispatchContext();
      String locationUri = this.getLocationURI(request);

      if (serviceName != null) {
        Document wsdl = null;
        try {
          wsdl = dctx.getWSDL(serviceName, locationUri);
        } catch (GenericServiceException e) {
          serviceName = null;
        } catch (WSDLException e) {
          sendError(response, "Unable to obtain WSDL", serviceName);
          throw new EventHandlerException("Unable to obtain WSDL", e);
        }

        if (wsdl != null) {
          try {
            OutputStream os = response.getOutputStream();
            response.setContentType("text/xml");
            UtilXml.writeXmlDocument(os, wsdl);
            response.flushBuffer();
          } catch (IOException e) {
            throw new EventHandlerException(e);
          }
          return null;
        } else {
          sendError(response, "Unable to obtain WSDL", serviceName);
          throw new EventHandlerException("Unable to obtain WSDL");
        }
      }

      if (serviceName == null) {
        try {
          Writer writer = response.getWriter();
          StringBuilder sb = new StringBuilder();
          sb.append("<html><head><title>OFBiz SOAP/1.1 Services</title></head>");
          sb.append("<body>No such service.").append("<p>Services:<ul>");

          for (String scvName : dctx.getAllServiceNames()) {
            ModelService model = dctx.getModelService(scvName);
            if (model.export) {
              sb.append("<li><a href=\"")
                  .append(locationUri)
                  .append("/")
                  .append(model.name)
                  .append("?wsdl\">");
              sb.append(model.name).append("</a></li>");
            }
          }
          sb.append("</ul></p></body></html>");

          writer.write(sb.toString());
          writer.flush();
          return null;
        } catch (Exception e) {
          sendError(response, "Unable to obtain WSDL", null);
          throw new EventHandlerException("Unable to obtain WSDL");
        }
      }
    }

    // not a wsdl request; invoke the service
    response.setContentType("text/xml");

    // request envelope
    SOAPEnvelope reqEnv = null;

    // get the service name and parameters
    try {
      XMLStreamReader xmlReader = StAXUtils.createXMLStreamReader(request.getInputStream());
      StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(xmlReader);
      reqEnv = (SOAPEnvelope) builder.getDocumentElement();

      // log the request message
      if (Debug.verboseOn()) {
        try {
          Debug.logInfo("Request Message:\n" + reqEnv + "\n", module);
        } catch (Throwable t) {
        }
      }
    } catch (Exception e) {
      sendError(response, "Problem processing the service", null);
      throw new EventHandlerException("Cannot get the envelope", e);
    }

    Debug.logVerbose("[Processing]: SOAP Event", module);

    String serviceName = null;
    try {
      SOAPBody reqBody = reqEnv.getBody();
      validateSOAPBody(reqBody);
      OMElement serviceElement = reqBody.getFirstElement();
      serviceName = serviceElement.getLocalName();
      Map<String, Object> parameters =
          UtilGenerics.cast(SoapSerializer.deserialize(serviceElement.toString(), delegator));
      try {
        // verify the service is exported for remote execution and invoke it
        ModelService model = dispatcher.getDispatchContext().getModelService(serviceName);

        if (model == null) {
          sendError(response, "Problem processing the service", serviceName);
          Debug.logError("Could not find Service [" + serviceName + "].", module);
          return null;
        }

        if (!model.export) {
          sendError(response, "Problem processing the service", serviceName);
          Debug.logError(
              "Trying to call Service [" + serviceName + "] that is not exported.", module);
          return null;
        }

        Map<String, Object> serviceResults = dispatcher.runSync(serviceName, parameters);
        Debug.logVerbose("[EventHandler] : Service invoked", module);

        createAndSendSOAPResponse(serviceResults, serviceName, response);

      } catch (GenericServiceException e) {
        if (UtilProperties.getPropertyAsBoolean("service", "secureSoapAnswer", true)) {
          sendError(
              response, "Problem processing the service, check your parameters.", serviceName);
        } else {
          if (e.getMessageList() == null) {
            sendError(response, e.getMessage(), serviceName);
          } else {
            sendError(response, e.getMessageList(), serviceName);
          }
          Debug.logError(e, module);
          return null;
        }
      }
    } catch (Exception e) {
      sendError(response, e.getMessage(), serviceName);
      Debug.logError(e, module);
      return null;
    }

    return null;
  }
Ejemplo n.º 10
0
  protected void renderScreenletPaginateMenu(
      Appendable writer, Map<String, Object> context, ModelScreenWidget.Form form)
      throws IOException {
    HttpServletResponse response = (HttpServletResponse) context.get("response");
    HttpServletRequest request = (HttpServletRequest) context.get("request");
    ModelForm modelForm = form.getModelForm(context);
    modelForm.runFormActions(context);
    modelForm.preparePager(context);
    String targetService = modelForm.getPaginateTarget(context);
    if (targetService == null) {
      targetService = "${targetService}";
    }

    // get the parametrized pagination index and size fields
    int paginatorNumber = WidgetWorker.getPaginatorNumber(context);
    String viewIndexParam = modelForm.getMultiPaginateIndexField(context);
    String viewSizeParam = modelForm.getMultiPaginateSizeField(context);

    int viewIndex = modelForm.getViewIndex(context);
    int viewSize = modelForm.getViewSize(context);
    int listSize = modelForm.getListSize(context);

    int highIndex = modelForm.getHighIndex(context);
    int actualPageSize = modelForm.getActualPageSize(context);

    // if this is all there seems to be (if listSize < 0, then size is unknown)
    if (actualPageSize >= listSize && listSize >= 0) return;

    // needed for the "Page" and "rows" labels
    Map<String, String> uiLabelMap = UtilGenerics.cast(context.get("uiLabelMap"));
    String ofLabel = "";
    if (uiLabelMap == null) {
      Debug.logWarning("Could not find uiLabelMap in context", module);
    } else {
      ofLabel = uiLabelMap.get("CommonOf");
      ofLabel = ofLabel.toLowerCase();
    }

    // for legacy support, the viewSizeParam is VIEW_SIZE and viewIndexParam is VIEW_INDEX when the
    // fields are "viewSize" and "viewIndex"
    if (viewIndexParam.equals("viewIndex" + "_" + paginatorNumber))
      viewIndexParam = "VIEW_INDEX" + "_" + paginatorNumber;
    if (viewSizeParam.equals("viewSize" + "_" + paginatorNumber))
      viewSizeParam = "VIEW_SIZE" + "_" + paginatorNumber;

    ServletContext ctx = (ServletContext) request.getAttribute("servletContext");
    RequestHandler rh = (RequestHandler) ctx.getAttribute("_REQUEST_HANDLER_");

    Map<String, Object> inputFields = UtilGenerics.toMap(context.get("requestParameters"));
    // strip out any multi form fields if the form is of type multi
    if (modelForm.getType().equals("multi")) {
      inputFields = UtilHttp.removeMultiFormParameters(inputFields);
    }
    String queryString = UtilHttp.urlEncodeArgs(inputFields);
    // strip legacy viewIndex/viewSize params from the query string
    queryString = UtilHttp.stripViewParamsFromQueryString(queryString, "" + paginatorNumber);
    // strip parametrized index/size params from the query string
    HashSet<String> paramNames = new HashSet<String>();
    paramNames.add(viewIndexParam);
    paramNames.add(viewSizeParam);
    queryString = UtilHttp.stripNamedParamsFromQueryString(queryString, paramNames);

    String anchor = "";
    String paginateAnchor = modelForm.getPaginateTargetAnchor();
    if (paginateAnchor != null) anchor = "#" + paginateAnchor;

    // preparing the link text, so that later in the code we can reuse this and just add the
    // viewIndex
    String prepLinkText = "";
    prepLinkText = targetService;
    if (prepLinkText.indexOf("?") < 0) {
      prepLinkText += "?";
    } else if (!prepLinkText.endsWith("?")) {
      prepLinkText += "&amp;";
    }
    if (!UtilValidate.isEmpty(queryString) && !queryString.equals("null")) {
      prepLinkText += queryString + "&amp;";
    }
    prepLinkText += viewSizeParam + "=" + viewSize + "&amp;" + viewIndexParam + "=";

    String linkText;

    // The current screenlet title bar navigation syling requires rendering
    // these links in reverse order
    // Last button
    String lastLinkUrl = "";
    if (highIndex < listSize) {
      int page = (listSize / viewSize);
      linkText = prepLinkText + page + anchor;
      lastLinkUrl = rh.makeLink(request, response, linkText);
    }
    String nextLinkUrl = "";
    if (highIndex < listSize) {
      linkText = prepLinkText + (viewIndex + 1) + anchor;
      // - make the link
      nextLinkUrl = rh.makeLink(request, response, linkText);
    }
    String previousLinkUrl = "";
    if (viewIndex > 0) {
      linkText = prepLinkText + (viewIndex - 1) + anchor;
      previousLinkUrl = rh.makeLink(request, response, linkText);
    }
    String firstLinkUrl = "";
    if (viewIndex > 0) {
      linkText = prepLinkText + 0 + anchor;
      firstLinkUrl = rh.makeLink(request, response, linkText);
    }

    Map<String, Object> parameters = FastMap.newInstance();
    parameters.put("lowIndex", modelForm.getLowIndex(context));
    parameters.put("actualPageSize", actualPageSize);
    parameters.put("ofLabel", ofLabel);
    parameters.put("listSize", listSize);
    parameters.put("paginateLastStyle", modelForm.getPaginateLastStyle());
    parameters.put("lastLinkUrl", lastLinkUrl);
    parameters.put("paginateLastLabel", modelForm.getPaginateLastLabel(context));
    parameters.put("paginateNextStyle", modelForm.getPaginateNextStyle());
    parameters.put("nextLinkUrl", nextLinkUrl);
    parameters.put("paginateNextLabel", modelForm.getPaginateNextLabel(context));
    parameters.put("paginatePreviousStyle", modelForm.getPaginatePreviousStyle());
    parameters.put("paginatePreviousLabel", modelForm.getPaginatePreviousLabel(context));
    parameters.put("previousLinkUrl", previousLinkUrl);
    parameters.put("paginateFirstStyle", modelForm.getPaginateFirstStyle());
    parameters.put("paginateFirstLabel", modelForm.getPaginateFirstLabel(context));
    parameters.put("firstLinkUrl", firstLinkUrl);
    executeMacro(writer, "renderScreenletPaginateMenu", parameters);
  }
Ejemplo n.º 11
0
  public static void buildHyperlinkUrl(
      Appendable externalWriter,
      String target,
      String targetType,
      Map<String, String> parameterMap,
      String prefix,
      boolean fullPath,
      boolean secure,
      boolean encode,
      HttpServletRequest request,
      HttpServletResponse response,
      Map<String, Object> context)
      throws IOException {

    // We may get an encoded request like:
    // &#47;projectmgr&#47;control&#47;EditTaskContents&#63;workEffortId&#61;10003
    // Try to reducing a possibly encoded string down to its simplest form:
    // /projectmgr/control/EditTaskContents?workEffortId=10003
    // This step make sure the following appending externalLoginKey operation to work correctly
    String localRequestName = StringEscapeUtils.unescapeHtml(target);

    localRequestName = UtilHttp.encodeAmpersands(localRequestName);
    Appendable localWriter = new StringWriter();

    if ("intra-app".equals(targetType)) {
      if (request != null && response != null) {
        ServletContext servletContext = request.getSession().getServletContext();
        RequestHandler rh = (RequestHandler) servletContext.getAttribute("_REQUEST_HANDLER_");
        externalWriter.append(
            rh.makeLink(request, response, "/" + localRequestName, fullPath, secure, encode));
      } else if (prefix != null) {
        externalWriter.append(prefix);
        externalWriter.append(localRequestName);
      } else {
        externalWriter.append(localRequestName);
      }
    } else if ("inter-app".equals(targetType)) {
      String fullTarget = localRequestName;
      localWriter.append(fullTarget);
      String externalLoginKey = (String) request.getAttribute("externalLoginKey");
      if (UtilValidate.isNotEmpty(externalLoginKey)) {
        if (fullTarget.indexOf('?') == -1) {
          localWriter.append('?');
        } else {
          localWriter.append("&amp;");
        }
        localWriter.append("externalLoginKey=");
        localWriter.append(externalLoginKey);
      }
    } else if ("content".equals(targetType)) {
      appendContentUrl(localWriter, localRequestName, request);
    } else if ("plain".equals(targetType)) {
      localWriter.append(localRequestName);
    } else {
      localWriter.append(localRequestName);
    }

    if (UtilValidate.isNotEmpty(parameterMap)) {
      String localUrl = localWriter.toString();
      externalWriter.append(localUrl);
      boolean needsAmp = true;
      if (localUrl.indexOf('?') == -1) {
        externalWriter.append('?');
        needsAmp = false;
      }

      for (Map.Entry<String, String> parameter : parameterMap.entrySet()) {
        String parameterValue = null;
        if (parameter.getValue() instanceof String) {
          parameterValue = parameter.getValue();
        } else {
          Object parameterObject = parameter.getValue();

          // skip null values
          if (parameterObject == null) continue;

          if (parameterObject instanceof String[]) {
            // it's probably a String[], just get the first value
            String[] parameterArray = (String[]) parameterObject;
            parameterValue = parameterArray[0];
            Debug.logInfo(
                "Found String array value for parameter ["
                    + parameter.getKey()
                    + "], using first value: "
                    + parameterValue,
                module);
          } else {
            // not a String, and not a String[], just use toString
            parameterValue = parameterObject.toString();
          }
        }

        if (needsAmp) {
          externalWriter.append("&amp;");
        } else {
          needsAmp = true;
        }
        externalWriter.append(parameter.getKey());
        externalWriter.append('=');
        StringUtil.SimpleEncoder simpleEncoder =
            (StringUtil.SimpleEncoder) context.get("simpleEncoder");
        if (simpleEncoder != null && parameterValue != null) {
          externalWriter.append(
              simpleEncoder.encode(
                  URLEncoder.encode(parameterValue, Charset.forName("UTF-8").displayName())));
        } else {
          externalWriter.append(parameterValue);
        }
      }
    } else {
      externalWriter.append(localWriter.toString());
    }
  }
Ejemplo n.º 12
0
  /**
   * An HTTP WebEvent handler that logs out a userLogin by clearing the session.
   *
   * @param request The HTTP request object for the current request.
   * @param response The HTTP response object for the current request.
   * @return Return a boolean which specifies whether or not the calling request should generate its
   *     own content. This allows an event to override the default content.
   */
  public static String logout(HttpServletRequest request, HttpServletResponse response) {
    // run the before-logout events
    RequestHandler rh = RequestHandler.getRequestHandler(request.getSession().getServletContext());
    rh.runBeforeLogoutEvents(request, response);

    // invalidate the security group list cache
    GenericValue userLogin = (GenericValue) request.getSession().getAttribute("userLogin");

    doBasicLogout(userLogin, request, response);

    Element rootElement = getRootElement(request);

    String result = "error";
    if (rootElement != null) {
      String className =
          UtilXml.childElementValue(
              rootElement,
              "AuthenticationHandler",
              "org.ofbiz.ldap.openldap.OFBizLdapAuthenticationHandler");
      try {
        Class<?> handlerClass = Class.forName(className);
        InterfaceOFBizAuthenticationHandler authenticationHandler =
            (InterfaceOFBizAuthenticationHandler) handlerClass.newInstance();
        result = authenticationHandler.logout(request, response, rootElement);
      } catch (ClassNotFoundException e) {
        Debug.logError(e, "Error calling userLogin service", module);
        Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.getMessage());
        String errMsg =
            UtilProperties.getMessage(
                resourceWebapp,
                "loginevents.following_error_occurred_during_login",
                messageMap,
                UtilHttp.getLocale(request));
        request.setAttribute("_ERROR_MESSAGE_", errMsg);
      } catch (InstantiationException e) {
        Debug.logError(e, "Error calling userLogin service", module);
        Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.getMessage());
        String errMsg =
            UtilProperties.getMessage(
                resourceWebapp,
                "loginevents.following_error_occurred_during_login",
                messageMap,
                UtilHttp.getLocale(request));
        request.setAttribute("_ERROR_MESSAGE_", errMsg);
      } catch (IllegalAccessException e) {
        Debug.logError(e, "Error calling userLogin service", module);
        Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.getMessage());
        String errMsg =
            UtilProperties.getMessage(
                resourceWebapp,
                "loginevents.following_error_occurred_during_login",
                messageMap,
                UtilHttp.getLocale(request));
        request.setAttribute("_ERROR_MESSAGE_", errMsg);
      } catch (Exception e) {
        Debug.logError(e, "Error calling userLogin service", module);
        Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.getMessage());
        String errMsg =
            UtilProperties.getMessage(
                resourceWebapp,
                "loginevents.following_error_occurred_during_login",
                messageMap,
                UtilHttp.getLocale(request));
        request.setAttribute("_ERROR_MESSAGE_", errMsg);
      }
    }

    if (request.getAttribute("_AUTO_LOGIN_LOGOUT_") == null) {
      return autoLoginCheck(request, response);
    }
    return result;
  }
  public void renderNextPrev(Appendable writer, Map<String, Object> context) throws IOException {
    String targetService = this.getPaginateTarget(context);
    if (targetService == null) {
      targetService = "${targetService}";
    }

    Map<String, Object> inputFields = UtilGenerics.checkMap(context.get("requestParameters"));
    Map<String, Object> queryStringMap = UtilGenerics.toMap(context.get("queryStringMap"));
    if (UtilValidate.isNotEmpty(queryStringMap)) {
      inputFields.putAll(queryStringMap);
    }

    String queryString = UtilHttp.urlEncodeArgs(inputFields);
    int paginatorNumber = this.getPaginatorNumber(context);
    queryString = UtilHttp.stripViewParamsFromQueryString(queryString, "" + paginatorNumber);

    if (UtilValidate.isEmpty(targetService)) {
      Debug.logWarning("TargetService is empty.", module);
      return;
    }

    int viewIndex = -1;
    try {
      viewIndex = ((Integer) context.get("viewIndex")).intValue();
    } catch (Exception e) {
      viewIndex = 0;
    }

    int viewSize = -1;
    try {
      viewSize = ((Integer) context.get("viewSize")).intValue();
    } catch (Exception e) {
      viewSize = this.getViewSize();
    }

    int listSize = -1;
    try {
      listSize = this.getListSize();
    } catch (Exception e) {
      listSize = -1;
    }

    /*
    int highIndex = -1;
    try {
        highIndex = modelForm.getHighIndex();
    } catch (Exception e) {
        highIndex = 0;
    }

    int lowIndex = -1;
    try {
        lowIndex = modelForm.getLowIndex();
    } catch (Exception e) {
        lowIndex = 0;
    }
     */

    int lowIndex = viewIndex * viewSize;
    int highIndex = (viewIndex + 1) * viewSize;
    int actualPageSize = this.getActualPageSize();
    // if this is all there seems to be (if listSize < 0, then size is unknown)
    if (actualPageSize >= listSize && listSize > 0) {
      return;
    }

    HttpServletRequest request = (HttpServletRequest) context.get("request");
    HttpServletResponse response = (HttpServletResponse) context.get("response");

    ServletContext ctx = (ServletContext) request.getAttribute("servletContext");
    RequestHandler rh = (RequestHandler) ctx.getAttribute("_REQUEST_HANDLER_");

    writer.append("<table border=\"0\" width=\"100%\" cellpadding=\"2\">\n");
    writer.append("  <tr>\n");
    writer.append("    <td align=\"right\">\n");
    writer.append("      <b>\n");
    if (viewIndex > 0) {
      writer.append(" <a href=\"");
      StringBuilder linkText = new StringBuilder(targetService);
      if (linkText.indexOf("?") < 0) linkText.append("?");
      else linkText.append("&amp;");
      // if (queryString != null && !queryString.equals("null")) linkText += queryString + "&";
      if (UtilValidate.isNotEmpty(queryString)) {
        linkText.append(queryString).append("&amp;");
      }
      linkText
          .append("VIEW_SIZE_" + paginatorNumber + "=")
          .append(viewSize)
          .append("&amp;VIEW_INDEX_" + paginatorNumber + "=")
          .append(viewIndex - 1)
          .append("\"");

      // make the link
      writer.append(rh.makeLink(request, response, linkText.toString(), false, false, false));
      String previous =
          UtilProperties.getMessage(
              "CommonUiLabels", "CommonPrevious", (Locale) context.get("locale"));
      writer.append(" class=\"buttontext\">[").append(previous).append("]</a>\n");
    }
    if (listSize > 0) {
      Map<String, Integer> messageMap =
          UtilMisc.toMap(
              "lowCount",
              Integer.valueOf(lowIndex + 1),
              "highCount",
              Integer.valueOf(lowIndex + actualPageSize),
              "total",
              Integer.valueOf(listSize));
      String commonDisplaying =
          UtilProperties.getMessage(
              "CommonUiLabels", "CommonDisplaying", messageMap, (Locale) context.get("locale"));
      writer.append(" <span class=\"tabletext\">").append(commonDisplaying).append("</span> \n");
    }
    if (highIndex < listSize) {
      writer.append(" <a href=\"");
      StringBuilder linkText = new StringBuilder(targetService);
      if (linkText.indexOf("?") < 0) linkText.append("?");
      else linkText.append("&amp;");
      if (UtilValidate.isNotEmpty(queryString)) {
        linkText.append(queryString).append("&amp;");
      }
      linkText
          .append("VIEW_SIZE_" + paginatorNumber + "=")
          .append(viewSize)
          .append("&amp;VIEW_INDEX_" + paginatorNumber + "=")
          .append(viewIndex + 1)
          .append("\"");

      // make the link
      writer.append(rh.makeLink(request, response, linkText.toString(), false, false, false));
      String next =
          UtilProperties.getMessage("CommonUiLabels", "CommonNext", (Locale) context.get("locale"));
      writer.append(" class=\"buttontext\">[").append(next).append("]</a>\n");
    }
    writer.append("      </b>\n");
    writer.append("    </td>\n");
    writer.append("  </tr>\n");
    writer.append("</table>\n");
  }