Example #1
0
  @SuppressWarnings({"rawtypes", "unchecked"})
  protected void setupWebXML() {
    WebResourcesFacet web = this.project.getFacet(WebResourcesFacet.class);
    ServletFacet servlet = this.project.getFacet(ServletFacet.class);
    WebAppCommonDescriptor servletConfig = (WebAppCommonDescriptor) servlet.getConfig();
    Node root = ((NodeDescriptor) servletConfig).getRootNode();
    removeConflictingErrorPages(root);

    // (prefer /faces/error.xhtml)

    List<String> webPaths = getAccessStrategy().getWebPaths(web.getWebResource(ERROR_XHTML));
    String errorLocation = webPaths.size() > 1 ? webPaths.get(1) : "/faces/error.xhtml";
    createErrorPageEntry(servletConfig, errorLocation, "404");
    createErrorPageEntry(servletConfig, errorLocation, "500");

    // Use the server timezone since we accept dates in that timezone, and it makes sense to display
    // them in the
    // same
    boolean found = false;
    List<ParamValueCommonType<?>> allContextParam = servletConfig.getAllContextParam();
    for (ParamValueCommonType<?> contextParam : allContextParam) {
      if (contextParam
          .getParamName()
          .equals("javax.faces.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE")) {
        found = true;
      }
    }
    if (!found) {
      servletConfig
          .createContextParam()
          .paramName("javax.faces.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE")
          .paramValue("true");
    }
    servlet.saveConfig(servletConfig);
  }
Example #2
0
 @SuppressWarnings({"rawtypes", "unchecked"})
 private void createErrorPageEntry(
     WebAppCommonDescriptor servletConfig, String errorLocation, String errorCode) {
   List<ErrorPageCommonType> allErrorPage = servletConfig.getAllErrorPage();
   for (ErrorPageCommonType errorPageType : allErrorPage) {
     if (errorPageType.getErrorCode().equalsIgnoreCase(errorCode)) {
       return;
     }
   }
   servletConfig.createErrorPage().errorCode(errorCode).location(errorLocation);
 }