1 2 Previous Next 15 Replies Latest reply on Jul 24, 2006 2:46 AM by free1000

    SVG in portlet

    scollins311

      Describe your environment:
      JBoss Portal Version
      2.4.0 CR1

      Did you get Portal from CVS? or download it?
      download

      JBoss AS Version
      4.0.4 GA

      Database Vendor and Version
      enterprise db 8.1

      JDBC Connector and Version
      EnterpriseDB Native Driver, version: EnterpriseDB 8.1.3.12

      OS Platform
      windows xp sp2

      Describe the problem:
      I have a portlet that contains an inline svg image. The rest of the portlet is displayed fine but the svg is ignored by the browser. The tags appear in the source. I can reproduce this in a regular page(not a portlet) by making the file .html instead of .xhtml. This has led me to believe that the portal is returning an .html file (I could be wrong). That would explain why the browser is ignoring the svg content. Is there a way to get the portal to return an xhtml page, or has anyone found a way to get inline svg to work?

      Thanks in advance,
      Shaun

        • 1. Re: SVG in portlet

          Have you tried changing the supported mime-type for the portlet?

          Is the path to your SVG correct?

          • 2. Re: SVG in portlet
            scollins311

            These are the supported types I've added:

            <supports>
             <mime-type>text/html</mime-type>
             <portlet-mode>VIEW</portlet-mode>
             </supports>
             <supports>
             <mime-type>text/xml</mime-type>
             <portlet-mode>VIEW</portlet-mode>
             </supports>
             <supports>
             <mime-type>application/xhtml+xml</mime-type>
             <portlet-mode>VIEW</portlet-mode>
             </supports>
            


            I don't know what you mean with the path to my svg? Do you mean the namespace? The svg code is in the xhtml page. The namespaces I'm using are
            xmlns:xlink="http://www.w3.org/2000/xlink/namespace/"
            xmlns:svg="http://www.w3.org/2000/svg"
            


            Thank you for answering so quickly,
            Shaun

            • 3. Re: SVG in portlet

              Maybe I don't understand SVG that well. Don't you have to link to an SVG file, much like you would with a flash file?

              • 4. Re: SVG in portlet
                scollins311

                You can but you can also do something like this person did.

                http://jwatt.org/svg/demos/xhtml-with-inline-svg.xhtml

                View the source to see what's going on.


                Shaun

                • 5. Re: SVG in portlet
                  free1000

                  Could it be possible that you also have to set content-type in your doView as well?

                  I think if you are serving xhtml to the browser. As xhtml is an instance of an xml document I expect that the content type should be application/xhtml+xml... however I haven't tried this myself yet

                  protected void doView(RenderRequest rRequest, RenderResponse rResponse) throws PortletException, IOException, UnavailableException
                   {
                   rResponse.setContentType("application/xhtml+xml");
                  
                   PortletRequestDispatcher prd = getPortletContext().getRequestDispatcher("View.jsp");
                   prd.include(rRequest, rResponse);
                   }
                  
                  


                  Thanks to this thread I discovered that firefox can natively display SVG inline. Cool.


                  • 6. Re: SVG in portlet
                    scollins311

                    I'm using Seam and JSF, so I don't think that I have a doView. I have tried setting the content type in the seam action that gets called on the page. I did it similar to how supernovasoftware.com did it in this thread: http://www.jboss.com/index.html?module=bb&op=viewtopic&t=82396

                    Except instead of the request I got the response and set the content type that way. Maybe that isn't correct?


                    Shaun

                    • 7. Re: SVG in portlet

                      I'm a bit stuck here. Even the link you sent, shows me a broken resource area. Do I need some SVG plugin in browsers?

                      • 8. Re: SVG in portlet
                        scollins311

                        Yeah, you'll probably need the adobe svg viewer.

                        http://www.adobe.com/svg/viewer/install/main.html


                        Shaun

                        • 9. Re: SVG in portlet
                          free1000

                          Apparently SVG support is now available natively in firefox (no need for the Adobe viewer).

                          • 10. Re: SVG in portlet
                            free1000

                            Ah... I have a theory that the problem is possibly that the content type of the *entire rendered portal page* is text/html

                            To embed svg in any single portlet window the *overall* content type of the portal page needs to be application/xhtml+xml because setting the content type of an individual portlet does not affect the total page.

                            Hence I think we need a way to set the content type for the portal as a whole. Can anyone direct me to where this might be configured/hacked?

                            • 11. Re: SVG in portlet
                              free1000

                              Ah... I have a theory that the problem is possibly that the content type of the *entire rendered portal page* is text/html

                              To embed svg in any single portlet window the *overall* content type of the portal page needs to be application/xhtml+xml because setting the content type of an individual portlet does not affect the total page.

                              Hence I think we need a way to set the content type for the portal as a whole. Can anyone direct me to where this might be configured/hacked?

                              • 12. Re: SVG in portlet
                                scollins311

                                free1000
                                I agree. That is one of the paths I was lurking down before I came here for help. Changing it was just over my head.

                                Shaun

                                • 13. Re: SVG in portlet
                                  free1000

                                  I guess that its safer for the entire portal to default to text/html in case there are portlets which are used which are not xhtml conformant. I'd expect to find the overall content type configurable at a high level, but maybe its something that can be set per page. This might be the most useful as it would mean that one could place non xhtml conformant portlets on other pages.

                                  • 14. Re: SVG in portlet
                                    free1000

                                    Content type for the whole portal can be altered by changing the content type for the index.jsp file which acts as the host for the whole portal layout.

                                    The default file is at

                                    jboss-portal.sar\portal-core.war\layouts\generic\index.jsp

                                    Altering the meta tag in the HTML sends the correct content type to the browser. However this still does not make my inline svg display correctly so some more research is needed.

                                    1 2 Previous Next