コード例 #1
0
  protected MessageContext getMessageContext() {

    MessageContextFactory messageContextFactory =
        (MessageContextFactory) FactoryExtensionFinder.getFactory(MessageContextFactory.class);

    return messageContextFactory.getMessageContext();
  }
コード例 #2
0
  protected void encodePreview(
      FacesContext facesContext, ResponseWriter responseWriter, InputFile inputFile)
      throws IOException {

    // Delegate writing of the entire <input type="file"...> ... </input> element to the delegate
    // renderer.
    DelegationResponseWriter delegationResponseWriter =
        new InputFileDelegationResponseWriter(responseWriter, inputFile.isAuto());
    super.encodeMarkupEnd(facesContext, inputFile, delegationResponseWriter);

    // Format the preview-table.html template and write it to the response.
    Locale locale = facesContext.getViewRoot().getLocale();
    String clientId = inputFile.getClientId(facesContext);
    responseWriter.startElement("div", inputFile);
    responseWriter.startElement("table", inputFile);
    responseWriter.writeAttribute("id", clientId + "_table", null);
    responseWriter.writeAttribute("class", "table table-bordered", null);
    responseWriter.startElement("thead", inputFile);
    responseWriter.writeAttribute("class", "table-columns", null);
    responseWriter.startElement("tr", inputFile);
    responseWriter.startElement("th", inputFile);

    MessageContextFactory messageContextFactory =
        (MessageContextFactory) FactoryExtensionFinder.getFactory(MessageContextFactory.class);
    MessageContext messageContext = messageContextFactory.getMessageContext();
    String i18nFileName = messageContext.getMessage(locale, "file-name");
    responseWriter.writeText(i18nFileName, null);
    responseWriter.endElement("th");
    responseWriter.startElement("th", inputFile);

    String i18nFileType = messageContext.getMessage(locale, "file-type");
    responseWriter.writeText(i18nFileType, null);
    responseWriter.endElement("th");
    responseWriter.startElement("th", inputFile);

    String i18nFileSize = messageContext.getMessage(locale, "file-size");
    responseWriter.writeText(i18nFileSize, null);
    responseWriter.endElement("th");
    responseWriter.endElement("tr");
    responseWriter.endElement("thead");
    responseWriter.startElement("tfoot", inputFile);
    responseWriter.startElement("tr", inputFile);
    responseWriter.startElement("td", inputFile);
    responseWriter.writeAttribute("colspan", "3", null);

    String i18nNoFilesSelected = messageContext.getMessage(locale, "no-files-selected");
    responseWriter.writeText(i18nNoFilesSelected, null);
    responseWriter.endElement("td");
    responseWriter.endElement("tr");
    responseWriter.endElement("tfoot");
    responseWriter.startElement("tbody", inputFile);
    responseWriter.startElement("tr", inputFile);
    responseWriter.endElement("tr");
    responseWriter.endElement("tbody");
    responseWriter.endElement("table");
    responseWriter.endElement("div");
  }
コード例 #3
0
  protected void encodeProgress(
      FacesContext facesContext,
      ResponseWriter responseWriter,
      UIComponent uiComponent,
      String clientId)
      throws IOException {

    Locale locale = facesContext.getViewRoot().getLocale();
    responseWriter.startElement("div", uiComponent);
    responseWriter.writeAttribute("id", clientId + "_selectFilesBox", null);
    responseWriter.writeAttribute("class", "select-files-box", null);
    responseWriter.endElement("div");
    responseWriter.startElement("div", uiComponent);
    responseWriter.writeAttribute("id", clientId + "_uploadFilesBox", null);
    responseWriter.writeAttribute("class", "upload-files-box", null);
    responseWriter.startElement("button", uiComponent);
    responseWriter.writeAttribute("id", clientId + "_uploadFilesButton", null);
    responseWriter.writeAttribute("class", "alloy-button", null);

    MessageContextFactory messageContextFactory =
        (MessageContextFactory) FactoryExtensionFinder.getFactory(MessageContextFactory.class);
    MessageContext messageContext = messageContextFactory.getMessageContext();
    String i18nUploadFiles = messageContext.getMessage(locale, "upload-files");
    responseWriter.writeText(i18nUploadFiles, null);
    responseWriter.endElement("button");
    responseWriter.endElement("div");
    responseWriter.startElement("div", uiComponent);
    responseWriter.startElement("table", uiComponent);
    responseWriter.writeAttribute("id", clientId + "_table", null);
    responseWriter.writeAttribute("class", "table table-bordered", null);
    responseWriter.startElement("thead", uiComponent);
    responseWriter.writeAttribute("class", "table-columns", null);
    responseWriter.startElement("tr", uiComponent);
    responseWriter.startElement("th", uiComponent);

    String i18nFileName = messageContext.getMessage(locale, "file-name");
    responseWriter.writeText(i18nFileName, null);
    responseWriter.endElement("th");
    responseWriter.startElement("th", uiComponent);

    String i18nFileType = messageContext.getMessage(locale, "file-type");
    responseWriter.writeText(i18nFileType, null);
    responseWriter.endElement("th");
    responseWriter.startElement("th", uiComponent);

    String i18nFileSize = messageContext.getMessage(locale, "file-size");
    responseWriter.writeText(i18nFileSize, null);
    responseWriter.endElement("th");
    responseWriter.startElement("th", uiComponent);

    String i18nProgress = messageContext.getMessage(locale, "progress");
    responseWriter.writeText(i18nProgress, null);
    responseWriter.endElement("th");
    responseWriter.endElement("tr");
    responseWriter.endElement("thead");
    responseWriter.startElement("tfoot", uiComponent);
    responseWriter.startElement("tr", uiComponent);
    responseWriter.startElement("td", uiComponent);
    responseWriter.writeAttribute("colspan", "4", null);

    String i18nNoFilesSelected = messageContext.getMessage(locale, "no-files-selected");
    responseWriter.writeText(i18nNoFilesSelected, null);
    responseWriter.endElement("td");
    responseWriter.endElement("tr");
    responseWriter.endElement("tfoot");
    responseWriter.startElement("tbody", uiComponent);
    responseWriter.startElement("tr", uiComponent);
    responseWriter.endElement("tr");
    responseWriter.endElement("tbody");
    responseWriter.endElement("table");
    responseWriter.endElement("div");
  }