2

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. :)

Community
  • 1
  • 1
matsa
  • 346
  • 5
  • 16

1 Answers1

1

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))" />
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • I'm not sure if the fragment comes to my rescue. Here's an example SVG: ` ` When '''#a''' is appended to the svg url, this causes the browser to trigger the conditional style. I can't see how the fragment attribute can help. – matsa Mar 18 '15 at 09:01
  • It appends the fragment to the generated URL (like as how `` works). Just tryout the current snapshot with ``. – BalusC Mar 18 '15 at 09:07
  • It works perfectly! Thanks a bunch, BalusC. Any idea on when 2.1 is to be finalized? – matsa Mar 19 '15 at 07:53
  • You're welcome. Hopefully end this month or early April. – BalusC Mar 19 '15 at 07:57