Example #1
0
  @Override
  public void encodeEnd(FacesContext context) throws IOException {
    // call create here so that we'll have a valid chart
    createITextObject(context);

    if (imageData != null) {
      ResponseWriter response = context.getResponseWriter();
      response.startElement("img", null);
      GraphicImageStore store = GraphicImageStore.instance();
      String key = store.put(new ImageWrapper(imageData, Type.IMAGE_JPEG));
      String url =
          context.getExternalContext().getRequestContextPath()
              + GraphicImageResource.GRAPHIC_IMAGE_RESOURCE_PATH
              + "/"
              + key
              + Type.IMAGE_JPEG.getExtension();

      response.writeAttribute("src", url, null);

      response.writeAttribute("height", getHeight(), null);
      response.writeAttribute("width", getWidth(), null);

      response.endElement("img");
    }

    super.encodeEnd(context);
  }