2
votes

Follow-up to How to embed SVG graphics properly in JSF application using OmniFaces

I'm using the OmniFaces 2.1 snapshot in order to output SVG files from byte[] arrays. I need to suffix #a on SVG URL's in order to activate a CSS style inside the SVG.

Example img:

<img src="/web/javax.faces.resource/ApplicationBean_getImageById_svg.xhtml?ln=omnifaces.graphic&amp;v=0&amp;p=106.1%23a">

As you can see, my #a is appended at the right side of the URL as %23a.

If this had been a regular URL it would be

<img src="106.1.svg#a" />

It would then pick the CSS style and, in my case, paint the background of this sign yellow.

I'm really hoping BalusC comes to my rescue here. Heh. :)

1

1 Answers

1
votes

As per this commit, the <o:graphicImage> got a new fragment attribute. This should enable you to pass SVG view modes via URL fragment identifier. It's available in today's 2.1 SNAPSHOT.

E.g.

<o:graphicImage value="#{bean.svg(imageId)}" 
    type="svg" fragment="svgView(viewBox(0,200,1000,1000))" />