duminică, 8 februarie 2015

Embed a SVG image provided as byte[]/InputStream using OmniFaces 2.1

This post is based on the following question from StackOverflow. Based on the BalusC answer, you can find on GitHub a complete example, named OmniFacesSVGs.

You can see how to:

- Display a SVG image provided as byte[] via a managed bean (the image is stored for keeping the things simple in the /resources folder, but you can use any other folder accessible to your server-side code).
- Display a SVG image provided as byte[] via a Servlet (the image is stored as a string in a Servlet).
- Use fragment attribute to trigger SVG view modes (beware of browser support).

Note The type="svg" is mandatory when dataURI="false" (default)!
Note Do not understand that the byte[]/InputStream must be fetched from a folder or a Servlet! Obviously, it can be provided by any service.

The SVGs used in this example are from here.

Niciun comentariu:

Trimiteți un comentariu