1 Reply Latest reply on Aug 7, 2009 6:20 AM by Nik Eizwan Nik Sufian

    Problems with TreeNode: URL Context Paths for Images

    Nik Eizwan Nik Sufian Newbie

      I am having some difficulty understanding and using URL context paths, specifically for attributes in RichFaces Trees.

      In my understanding, RichFaces automatically resolves relatives paths, adding the full context path to it. Therefore, "/skin/images" becomes "<current module/application>/skin/images". This seems to happen whenever a forward slash is found in a value.

      However, my project consists of an EAR file with many WAR and JAR files, each one built by BuildMagic from different modules. And I already have a module built with context-root="/skin", used throughout the project.

      The thing is, if the path is hardcoded in my JSP in normal HTML, it is resolved correctly. But when I use "/skin/" in RichFaces components (I'm using attribute 'icon' and 'iconleaf' in<rich:treeNode>), whether hardcoded or with value expressions to a bean, the paths are resolved.

      <rich:treeNode type="node" id="node" icon="/skin//node_icon.gif" />
      <rich:treeNode type="leaf" id="leaf" iconLeaf="#{item.iconLeaf}" />

      The two workarounds I have are to create a servlet and to use that in the URL path (am not successful with this one so far), or to force the path to be taken literally, using a backslash. The second one is a horrible workaround, but it actually works:

      <rich:treeNode type="node" id="node" icon="\/skin//workflow_1.gif" />
      <rich:treeNode type="leaf" id="leaf" iconLeaf="#{item.iconLeaf}" />
      <and in the bean:>
      iconLeaf = \\skin//std_icon.gif;

      Can someone shed some light on this please? Either on whether this path-resolving behaviour can be configured, or if there's a better way to do it other than the methods above? Any help will be very much appreciated. Many thanks in advance...

      More info of my project setup:
      JBoss version: jboss-eap-4.3.0.GA_CP04
      RichFaces version: 3.3.1
      JSF implementation: Mojarra Sun, v1.2MR2
      Browser: Internet Explorer 6-8
      Also using OpenFaces; may be relevant via ViewHandler usage

        • 1. Re: Problems with TreeNode: URL Context Paths for Images
          Nik Eizwan Nik Sufian Newbie

          My apologies if the message was too lengthy. To summarise:


          1. <rich:treeNode iconLeaf="/skin/images/leaf.gif" />
          Iconleaf becomes, in HTML,
          < tr >< td >< imgsrc="/myproject/mymodule/skin/images/leaf.gif" / >< /td >< /tr >
          Can the above behaviour be disabled, so that /skin stays as /skin?

          2. If not, is there any better way of working around it, other than using a servlet to serve the path, or the hack below?
          <rich:treeNode iconLeaf="\/skin/images/leaf.gif" />


          If any more info/requirements is needed, I'll be happy to provide them.
          Many thanks for any help...