4 Replies Latest reply on Nov 11, 2008 4:46 AM by maxandersen

    Visual Editor: Problem with stylesheet path and multiple vie

    asgeirf

      Hi folks,

      I have a Seam-gen project with the following structure:

      view/stylesheet/theme.css
      view/layout/template.xhtml
      
      view/home.xhtml (uses template.xhtml)
      view/admin/home.xhtml (uses template.xhtml)


      The template references the stylesheet as follows:

      <link rel="stylesheet" type="text/css" href="#{request.contextPath}/stylesheet/theme.css"/>


      This works well at runtime, but not within the Visual Editor, which doesn't pick up the stylesheet. Giving the href a relative location like './stylesheet/theme.css' works well for views within the root 'view' folder, but not for views within sub-folders.

      My current workaround is to add the relative path to the stylesheet within the template.

      <!-- This href enables pages in first-level sub-folders to access the css -->
      <link rel="stylesheet" type="text/css" href="../stylesheet/theme.css"/>
      
      <!-- This href enables root folders to access the css -->
      <link rel="stylesheet" type="text/css" href="./stylesheet/theme.css"/>


      My question is: Is there any way to avoid such a 'hack' to enable the visual editor to view styled pages within sub-folders. Is there any way to e.g. specify the absolute location of the stylesheet/template?

        • 1. Re: Visual Editor: Problem with stylesheet path and multiple
          maxandersen

          if you are using JBT 3 beta you should be able to setup a EL expression for the pages in a specific folder.

          See http://docs.jboss.org/tools/whatsnew/vpe/vpe-news-3.0.0.Alpha1.html for details.

          • 2. Re: Visual Editor: Problem with stylesheet path and multiple
            asgeirf

             

            "max.andersen@jboss.com" wrote:
            if you are using JBT 3 beta you should be able to setup a EL expression for the pages in a specific folder.

            See http://docs.jboss.org/tools/whatsnew/vpe/vpe-news-3.0.0.Alpha1.html for details.


            Great, thanks!

            This seems to work fine for images etc, but I can't get it to work for CSS.

            1) Setting the actual run-time absolute folder (pr project) to my 'view' folder
            2) Setting the el expression (pr project) request.contextPath to empty string (no value)

            <img src="#{request.contextPath}/img/banner.png"/>
            <link rel="stylesheet" type="text/css" href="#{request.contextPath}/stylesheet/theme.css"/>


            (I'm on #jbosstools on IRC if you'd like to help debug this further)


            • 3. Re: Visual Editor: Problem with stylesheet path and multiple
              asgeirf

              Some further observations regarding this issue:

              Observation 1) The visual editor in a clean JBoss Tools install (In my case this build [1] on linux_x86_64) does not pick up the stylesheet of a clean seam-gen project generated by the 'seam create-project' command.

              <a:loadStyle src="/stylesheet/theme.css"/>


              To test this, change the url to '../stylesheet/theme.css' and you will see that the page is rendered with the stylesheet (this relative url naturally only works for layout/template.xhtml and co, change it to e.g. 'stylesheet/theme.css' to see the change in 'home.xhtml')

              Observation 2) Setting the 'Actual Run-time Absolute folder' to $myproject/view in Project-scope does not help resolve the CSS url above.

              Max opened this and related jiras yesterday: https://jira.jboss.org/jira/browse/JBIDE-3059

              However, this issue might not be directly related to EL expressions, as I don't use any in this example, and it still doesn't work...

              [1] http://download.jboss.org/jbosstools/builds/nightly/3.0.0.CR1/200811080256/index.html

              • 4. Re: Visual Editor: Problem with stylesheet path and multiple
                maxandersen

                the problem is that for seam-gen'ed project we don't know the root web content dir.

                I guess we should add a "search upwards until we see a WEB-INF dir...that would be a good default.