Пример #1
0
  private void encodeSeverityMessages(
      FacesContext facesContext,
      UIComponent component,
      UIMessages uiMessages,
      Severity severity,
      List<FacesMessage> messages)
      throws IOException {
    ResponseWriter writer = facesContext.getResponseWriter();

    String alertSeverityClass = "";

    if (FacesMessage.SEVERITY_INFO.equals(severity)) {
      alertSeverityClass = "alert-info";
    } else if (FacesMessage.SEVERITY_WARN.equals(severity)) {
      alertSeverityClass = ""; // Default alert is a warning
    } else if (FacesMessage.SEVERITY_ERROR.equals(severity)) {
      alertSeverityClass = "alert-error";
    } else if (FacesMessage.SEVERITY_FATAL.equals(severity)) {
      alertSeverityClass = "alert-error";
    }

    writer.startElement("div", null);
    writer.writeAttribute("class", "alert " + alertSeverityClass, "alert " + alertSeverityClass);
    writer.startElement("a", component);
    writer.writeAttribute("class", "close", "class");
    writer.writeAttribute("data-dismiss", "alert", "data-dismiss");
    writer.writeAttribute("href", "#", "href");
    writer.write("&times;");
    writer.endElement("a");

    writer.startElement("ul", null);

    for (FacesMessage msg : messages) {
      String summary = msg.getSummary() != null ? msg.getSummary() : "";
      String detail = msg.getDetail() != null ? msg.getDetail() : summary;

      writer.startElement("li", component);

      if (uiMessages.isShowSummary()) {
        writer.startElement("strong", component);
        writer.writeText(summary, component, null);
        writer.endElement("strong");
      }

      if (uiMessages.isShowDetail()) {
        writer.writeText(" " + detail, null);
      }

      writer.endElement("li");
      msg.rendered();
    }
    writer.endElement("ul");
    writer.endElement("div");
  }
Пример #2
0
  private void log4j(FacesMessage message, final StringBuilder msgBuilder) {

    final Severity severity = message.getSeverity();
    if (FacesMessage.SEVERITY_INFO.equals(severity)) {
      log.info(msgBuilder.toString());
    } else if (FacesMessage.SEVERITY_WARN.equals(severity)) {
      log.warn(msgBuilder.toString());
    } else if (FacesMessage.SEVERITY_ERROR.equals(severity)) {
      log.error(msgBuilder.toString());
    } else if (FacesMessage.SEVERITY_FATAL.equals(severity)) {
      //			log.fatal(message.getSummary());
      log.error(msgBuilder.toString());
    }
  }
  private List<FacesMessage> convertToFacesMsgs(List<BridgeMessage> list) {
    List<FacesMessage> facesMsgs = new ArrayList<FacesMessage>(list.size());

    for (BridgeMessage msg : list) {
      FacesMessage facesMsg = new FacesMessage(msg.summary, msg.detail);

      if (msg.rendered) {
        facesMsg.rendered();
      }

      int ordinal = msg.severityOrdinal;
      if (ordinal == FacesMessage.SEVERITY_INFO.getOrdinal()) {
        facesMsg.setSeverity(FacesMessage.SEVERITY_INFO);
      } else if (ordinal == FacesMessage.SEVERITY_WARN.getOrdinal()) {
        facesMsg.setSeverity(FacesMessage.SEVERITY_WARN);
      } else if (ordinal == FacesMessage.SEVERITY_ERROR.getOrdinal()) {
        facesMsg.setSeverity(FacesMessage.SEVERITY_ERROR);
      } else if (ordinal == FacesMessage.SEVERITY_FATAL.getOrdinal()) {
        facesMsg.setSeverity(FacesMessage.SEVERITY_FATAL);
      }
      facesMsgs.add(facesMsg);
    }
    return facesMsgs;
  }
Пример #4
0
  private void encodeLoadingInfo(
      FacesContext facesContext,
      UIComponent component,
      UIMessages uiMessages,
      Severity severity,
      List<FacesMessage> messages)
      throws IOException {
    ResponseWriter writer = facesContext.getResponseWriter();

    if (FacesMessage.SEVERITY_WARN.equals(severity)) {
      writer.append("<div class=\"modal fade\" id=\"idAlertaServer\">");
    } else if (FacesMessage.SEVERITY_INFO.equals(severity)) {
      writer.append("<div class=\"modal fade\" id=\"idInfoServer\">");
    } else if (FacesMessage.SEVERITY_ERROR.equals(severity)) {
      writer.append("<div class=\"modal fade\" id=\"idErrorServer\">");
    }
    writer.append("<div class=\"modal-dialog modal-sm\" >");
    if (FacesMessage.SEVERITY_WARN.equals(severity)) {
      writer.append("<div class=\"modal-content\" style=\" background: #FCF8E3\">");
    } else if (FacesMessage.SEVERITY_INFO.equals(severity)) {
      writer.append("<div class=\"modal-content\" style=\" background: #D9EDF7\">");
    } else if (FacesMessage.SEVERITY_ERROR.equals(severity)) {
      writer.append("<div class=\"modal-content\" style=\" background: #F2DEDE\">");
    }
    writer.append("<div class=\"modal-header\" style=\"padding: 5px;\">");
    writer.append(
        "<button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-label=\"Close\"><span style=\"color: black; font-size: large\" ></span></button>");
    writer.append("<h4 style=\"color: #8A6D3B\"><b>" + messages.get(0).getDetail() + "</b></h4>");
    writer.append("</div>");
    writer.append("<div style=\"background: white;box-sizing: border-box;\" >");
    writer.append("<div class=\"modal-body\" style=\"padding: 7px;\">");
    if (FacesMessage.SEVERITY_WARN.equals(severity)) {
      writer.append(
          "<table style=\"width: 100%\"><tr><td style=\"padding-right: 8px\"><img style=\"width: 30px\" src=\"../../bootstrap/img/warning.png\" /></td><td><div style=\"font-size: 1.2em\" class=\"text-resalt-comun\"><b>"
              + messages.get(0).getSummary()
              + "</b></div></td></tr></table>");
    } else if (FacesMessage.SEVERITY_INFO.equals(severity)) {
      writer.append(
          "<table style=\"width: 100%\"><tr><td style=\"padding-right: 8px\"><img style=\"width: 30px\" src=\"../../bootstrap/img/info.png\" /></td><td><div style=\"font-size: 1.2em\" class=\"text-resalt-comun\"><b>"
              + messages.get(0).getSummary()
              + "</b></div></td></tr></table>");
    } else if (FacesMessage.SEVERITY_ERROR.equals(severity)) {
      writer.append(
          "<table style=\"width: 100%\"><tr><td style=\"padding-right: 8px\"><img style=\"width: 30px\" src=\"../../bootstrap/img/info.png\" /></td><td><div style=\"font-size: 1.2em\" class=\"text-resalt-comun\"><b>"
              + messages.get(0).getSummary()
              + "</b></div></td></tr></table>");
    }

    writer.append("</div></div></div></div></div>");

    if (FacesMessage.SEVERITY_WARN.equals(severity)) {
      writer.append(
          "<script>\n"
              + "            function alertarServer() {\n"
              + "                $(\"#idAlertaServer\").modal('show');\n "
              + "}"
              + "alertarServer();"
              + "            </script>");
    } else if (FacesMessage.SEVERITY_INFO.equals(severity)) {
      writer.append(
          "<script>\n"
              + "            function informarServer() {\n"
              + "                $(\"#idInfoServer\").modal('show');\n "
              + "}"
              + "informarServer();"
              + "            </script>");
    } else if (FacesMessage.SEVERITY_ERROR.equals(severity)) {
      writer.append(
          "<script>\n"
              + "            function errorServer() {\n"
              + "                $(\"#idErrorServer\").modal('show');\n "
              + "}"
              + "errorServer();"
              + "            </script>");
    }
  }