8 Replies Latest reply on May 25, 2007 6:26 AM by Tim Perrett

    Seam Themes based on domain?

    Tim Perrett Newbie

      Hey Guys

      Is there a way that an appication could be configured to use a different theme based on the domain they were visiting? I have no idea if this is possible and would really appreciate your input :)

      Thanks

      Tim

        • 1. Re: Seam Themes based on domain?
          Leo Newbie

          tim,

          take a look on trinidad sample seam-cvs.

          There is a tag on template.xml (<trh:styleSheet />) that can help you .. perhaps changing something there or intersepting some event overriding it.

          rgds
          Leo

          • 2. Re: Seam Themes based on domain?
            Gavin King Master

            It should be very easy to write a seam page action that checks the domain, and calls themeSelector.setTheme(). Map it to the view id "*".

            • 3. Re: Seam Themes based on domain?
              Tim Perrett Newbie

              Ok sounds like the kind of thing I was thinking of! Excellent.

              So basicly, it will get called on every request due to the view id "*" in web.xml (should it be web.xml?)

              Many thanks

              Tim

              • 4. Re: Seam Themes based on domain?
                Gavin King Master

                In pages.xml, of course!

                • 5. Re: Seam Themes based on domain?
                  Tim Perrett Newbie

                  LOL - sorry now that was a silly mistake!!!

                  Cheers

                  Tim

                  PS: i'll do the code and post it back up when its ready :)

                  • 6. Re: Seam Themes based on domain?
                    Tim Perrett Newbie

                    Just thinking aloud - If i needed each theme to use a different XHTML file within seam, as perhaps the HTML was different, is this even possible?

                    How does seam know to look for the view files? I am guessing there is a paramater i could set somwhere to dynamically point it at a different set of files?

                    Cheers, and appologies for these newbie questions!

                    Tim

                    • 7. Re: Seam Themes based on domain?
                      Arjan van Bentem Novice

                       

                      "tim_perrett" wrote:
                      If i needed each theme to use a different XHTML file within seam, as perhaps the HTML was different, is this even possible?

                      Yes. Your theme is basically a property file. It could set any property with any name you like. Often it would just be css and template (which you could also name "stylesheet" and "layout", or whatever you like). For example, assuming sub-folders stylesheet and layout:
                      css stylesheet/my-stylesheet.css
                      template /layout/my-layout.xhtml


                      The properties can be referenced in your views. And when you set up your views to use a template, like
                      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
                       xmlns:s="http://jboss.com/products/seam/taglib"
                       ...
                       template="#{theme.template}">


                      then Seam will use the template you've specified in the property file for your specific theme.

                      A side note: when using subfolders, such as /admin/admin.xhtml for your admin view, then you cannot simply use
                      <link href="#{theme.css}" rel="stylesheet" type="text/css" />

                      For the admin pages, the above would make the browser try to find /admin/stylesheet/my-stylesheet.css instead of /stylesheet/my-stylesheet.css. Instead, use:
                      <link href="#{facesContext.externalContext.requestContextPath}/#{theme.css}"
                       rel="stylesheet" type="text/css" />


                      Good luck,
                      Arjan.

                      • 8. Re: Seam Themes based on domain?
                        Tim Perrett Newbie

                        Ok great, so im guessing i can also use the themes to do it for any templae, not just the layout so i could also do:

                        
                         <s:decorate template="#{theme.some.property}">
                         <ui:define name="label">Zip:</ui:define>
                         #{hotel.zip}
                         </s:decorate>
                        
                        


                        Brilliant!

                        Otherwise, within the seam framework is there the ability to use view helpers? View orientated functionality? This wouldnt really sit in the actions would it?

                        Cheers