You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by "ir. ing. Jan Dockx" <ja...@mac.com> on 2005/08/17 00:03:06 UTC

Folder images in tree2

I have the following in my jspx file for an x:tree2 (using the nightly  
build d.d. 15/8).

           <x:tree2 value="#{handler.treeModel}" var="node"  
varNodeToggler="t" showRootNode="false">

             <f:facet name="be.peopleware.ehims.olts.Speciality">
               <h:panelGroup>
                 <f:facet name="expand">
                   <h:graphicImage  
value="/img/org/apache/myfaces/custom/tree2/yellow-folder-open.png"  
rendered="#{t.nodeExpanded}" />
                 </f:facet>
                 <f:facet name="collapse">
                   <h:graphicImage  
value="/img/org/apache/myfaces/custom/tree2/yellow-folder-closed.png"  
rendered="#{!t.nodeExpanded}" />
                 </f:facet>
                 <h:outputText value="#{node.wrapped.instance.name}"  
styleClass="node" />
               </h:panelGroup>
             </f:facet>

         </x:tree2>

This shows the folder images on first load. The trouble is the open or  
closed folders don't show after a JavaScript action.
The reason is that the url's passed to the JavaScript function are  
exactly what we typed into the value of the graphicImage, and are not  
interpreted context relative.

onclick="treeNavClick('org.apache.myfaces.tree.TOGGLE_SPAN:_id18:0:0',  
't2_id28',  
'/OLTS/faces/myFacesExtensionResource/tree2.HtmlTreeRenderer/11235566/ 
images/nav-plus-line-middle.gif',  
'/OLTS/faces/myFacesExtensionResource/tree2.HtmlTreeRenderer/11235566/ 
images/nav-minus-line-middle.gif', '_id2:_id18:0:0:t2_id29',  
'/img/org/apache/myfaces/custom/tree2/yellow-folder-open.png',  
'/img/org/apache/myfaces/custom/tree2/yellow-folder-closed.png',  
'_id18', '0:0');"

They should be translated somewhere from  
"/img/org/apache/myfaces/custom/tree2/yellow-folder-closed.png" to  
"/CONTEXT_NAME/img/org/apache/myfaces/custom/tree2/yellow-folder- 
closed.png", and that doesn't seem to happen.
As you can see, it does happen for the image1 and image2 arguments, but  
not for the expandImg and collapseImg.

It seems that in the example it only happens to work because a relative  
path is used, and the images folder happens to be next to the jsp file.  
The would mean in my case that I would have to use  
"../../../../../../img/org/apache/myfaces/custom/tree2/yellow-folder- 
closed.png", which is pretty way out there and unstable, obviously.  
Indeed, this does work though.

What am I missing? A call to  
facesContext.getApplication().getViewHandler().getResourceURL(facesConte 
xt, [expand][collapse]ImgSrc); would do the trick in the JavaScript  
rendering (line 523 and 525 of the current head,  
org.apache.myfaces.custom.tree2.HtmlTreeRenderer#encodeNavigation(FacesC 
ontext, ResponseWriter, HtmlTree)).


Met vriendelijke groeten,

Jan Dockx

PeopleWare NV - Head Office
Cdt.Weynsstraat 85
B-2660 Hoboken
Tel: +32 3 448.33.38
Fax: +32 3 448.32.66

PeopleWare NV - Branch Office Geel
Kleinhoefstraat 5
B-2440 Geel
Tel: +32 14 57.00.90
Fax: +32 14 58.13.25

http://www.peopleware.be/
http://www.mobileware.be/

Re: Folder images in tree2

Posted by Sean Schofield <se...@gmail.com>.
Sorry I misunderstood.  Problem has been fixed.  You can thank Mathias
Werlitz for the fix.

sean

On 8/18/05, ir. ing. Jan Dockx <ja...@mac.com> wrote:
> The problem is not in h:graphicImage. That works as described. The
> problem is in tree2 code:
> 
> orrg.apache.myfaces.custom.tree2.HtmlTreeRenderer#encodeNavigation(Faces
> Context, ResponseWriter, HtmlTree)) in line 523 and 525 of the current
> head. Where h:graphicImage does push the URL through
> facesContext.getApplication().getViewHandler().getResourceURL(...),
> tree2 does not. Easily fixed.
> 
> >>
> >>
> >> A call to
> >> facesContext.getApplication().getViewHandler().getResourceURL(facesCon
> >> te
> >> xt, [expand][collapse]ImgSrc); would do the trick in the JavaScript
> >> rendering (line 523 and 525 of the current head,
> >> org.apache.myfaces.custom.tree2.HtmlTreeRenderer#encodeNavigation(Face
> >> sC
> >> ontext, ResponseWriter, HtmlTree)).
> 
> On 18 Aug 2005, at 16:48, Sean Schofield wrote:
> 
> > This has always been the case with <h:graphicImage>.  Was this somehow
> > working differently in an earlier version of tree2?  I doubt it.
> >
> > sean
> >
> > On 8/16/05, ir. ing. Jan Dockx <ja...@mac.com> wrote:
> >> I have the following in my jspx file for an x:tree2 (using the nightly
> >> build d.d. 15/8).
> >>
> >>           <x:tree2 value="#{handler.treeModel}" var="node"
> >> varNodeToggler="t" showRootNode="false">
> >>
> >>             <f:facet name="be.peopleware.ehims.olts.Speciality">
> >>               <h:panelGroup>
> >>                 <f:facet name="expand">
> >>                   <h:graphicImage
> >> value="/img/org/apache/myfaces/custom/tree2/yellow-folder-open.png"
> >> rendered="#{t.nodeExpanded}" />
> >>                 </f:facet>
> >>                 <f:facet name="collapse">
> >>                   <h:graphicImage
> >> value="/img/org/apache/myfaces/custom/tree2/yellow-folder-closed.png"
> >> rendered="#{!t.nodeExpanded}" />
> >>                 </f:facet>
> >>                 <h:outputText value="#{node.wrapped.instance.name}"
> >> styleClass="node" />
> >>               </h:panelGroup>
> >>             </f:facet>
> >>
> >>         </x:tree2>
> >>
> >> This shows the folder images on first load. The trouble is the open or
> >> closed folders don't show after a JavaScript action.
> >> The reason is that the url's passed to the JavaScript function are
> >> exactly what we typed into the value of the graphicImage, and are not
> >> interpreted context relative.
> >>
> >> onclick="treeNavClick('org.apache.myfaces.tree.TOGGLE_SPAN:_id18:0:0',
> >> 't2_id28',
> >> '/OLTS/faces/myFacesExtensionResource/tree2.HtmlTreeRenderer/11235566/
> >> images/nav-plus-line-middle.gif',
> >> '/OLTS/faces/myFacesExtensionResource/tree2.HtmlTreeRenderer/11235566/
> >> images/nav-minus-line-middle.gif', '_id2:_id18:0:0:t2_id29',
> >> '/img/org/apache/myfaces/custom/tree2/yellow-folder-open.png',
> >> '/img/org/apache/myfaces/custom/tree2/yellow-folder-closed.png',
> >> '_id18', '0:0');"
> >>
> >> They should be translated somewhere from
> >> "/img/org/apache/myfaces/custom/tree2/yellow-folder-closed.png" to
> >> "/CONTEXT_NAME/img/org/apache/myfaces/custom/tree2/yellow-folder-
> >> closed.png", and that doesn't seem to happen.
> >> As you can see, it does happen for the image1 and image2 arguments,
> >> but
> >> not for the expandImg and collapseImg.
> >>
> >> It seems that in the example it only happens to work because a
> >> relative
> >> path is used, and the images folder happens to be next to the jsp
> >> file.
> >> The would mean in my case that I would have to use
> >> "../../../../../../img/org/apache/myfaces/custom/tree2/yellow-folder-
> >> closed.png", which is pretty way out there and unstable, obviously.
> >> Indeed, this does work though.
> >>
> >> What am I missing? A call to
> >> facesContext.getApplication().getViewHandler().getResourceURL(facesCon
> >> te
> >> xt, [expand][collapse]ImgSrc); would do the trick in the JavaScript
> >> rendering (line 523 and 525 of the current head,
> >> org.apache.myfaces.custom.tree2.HtmlTreeRenderer#encodeNavigation(Face
> >> sC
> >> ontext, ResponseWriter, HtmlTree)).
> >>
> >>
> >> Met vriendelijke groeten,
> >>
> >> Jan Dockx
> >>
> >> PeopleWare NV - Head Office
> >> Cdt.Weynsstraat 85
> >> B-2660 Hoboken
> >> Tel: +32 3 448.33.38
> >> Fax: +32 3 448.32.66
> >>
> >> PeopleWare NV - Branch Office Geel
> >> Kleinhoefstraat 5
> >> B-2440 Geel
> >> Tel: +32 14 57.00.90
> >> Fax: +32 14 58.13.25
> >>
> >> http://www.peopleware.be/
> >> http://www.mobileware.be/
> >>
> >>
> >
> >
> Met vriendelijke groeten,
> 
> Jan Dockx
> 
> PeopleWare NV - Head Office
> Cdt.Weynsstraat 85
> B-2660 Hoboken
> Tel: +32 3 448.33.38
> Fax: +32 3 448.32.66
> 
> PeopleWare NV - Branch Office Geel
> Kleinhoefstraat 5
> B-2440 Geel
> Tel: +32 14 57.00.90
> Fax: +32 14 58.13.25
> 
> http://www.peopleware.be/
> http://www.mobileware.be/
> 
> 
>

Re: Folder images in tree2

Posted by "ir. ing. Jan Dockx" <ja...@mac.com>.
The problem is not in h:graphicImage. That works as described. The  
problem is in tree2 code:

orrg.apache.myfaces.custom.tree2.HtmlTreeRenderer#encodeNavigation(Faces 
Context, ResponseWriter, HtmlTree)) in line 523 and 525 of the current  
head. Where h:graphicImage does push the URL through   
facesContext.getApplication().getViewHandler().getResourceURL(...),  
tree2 does not. Easily fixed.

>>
>>
>> A call to
>> facesContext.getApplication().getViewHandler().getResourceURL(facesCon 
>> te
>> xt, [expand][collapse]ImgSrc); would do the trick in the JavaScript
>> rendering (line 523 and 525 of the current head,
>> org.apache.myfaces.custom.tree2.HtmlTreeRenderer#encodeNavigation(Face 
>> sC
>> ontext, ResponseWriter, HtmlTree)).

On 18 Aug 2005, at 16:48, Sean Schofield wrote:

> This has always been the case with <h:graphicImage>.  Was this somehow
> working differently in an earlier version of tree2?  I doubt it.
>
> sean
>
> On 8/16/05, ir. ing. Jan Dockx <ja...@mac.com> wrote:
>> I have the following in my jspx file for an x:tree2 (using the nightly
>> build d.d. 15/8).
>>
>>           <x:tree2 value="#{handler.treeModel}" var="node"
>> varNodeToggler="t" showRootNode="false">
>>
>>             <f:facet name="be.peopleware.ehims.olts.Speciality">
>>               <h:panelGroup>
>>                 <f:facet name="expand">
>>                   <h:graphicImage
>> value="/img/org/apache/myfaces/custom/tree2/yellow-folder-open.png"
>> rendered="#{t.nodeExpanded}" />
>>                 </f:facet>
>>                 <f:facet name="collapse">
>>                   <h:graphicImage
>> value="/img/org/apache/myfaces/custom/tree2/yellow-folder-closed.png"
>> rendered="#{!t.nodeExpanded}" />
>>                 </f:facet>
>>                 <h:outputText value="#{node.wrapped.instance.name}"
>> styleClass="node" />
>>               </h:panelGroup>
>>             </f:facet>
>>
>>         </x:tree2>
>>
>> This shows the folder images on first load. The trouble is the open or
>> closed folders don't show after a JavaScript action.
>> The reason is that the url's passed to the JavaScript function are
>> exactly what we typed into the value of the graphicImage, and are not
>> interpreted context relative.
>>
>> onclick="treeNavClick('org.apache.myfaces.tree.TOGGLE_SPAN:_id18:0:0',
>> 't2_id28',
>> '/OLTS/faces/myFacesExtensionResource/tree2.HtmlTreeRenderer/11235566/
>> images/nav-plus-line-middle.gif',
>> '/OLTS/faces/myFacesExtensionResource/tree2.HtmlTreeRenderer/11235566/
>> images/nav-minus-line-middle.gif', '_id2:_id18:0:0:t2_id29',
>> '/img/org/apache/myfaces/custom/tree2/yellow-folder-open.png',
>> '/img/org/apache/myfaces/custom/tree2/yellow-folder-closed.png',
>> '_id18', '0:0');"
>>
>> They should be translated somewhere from
>> "/img/org/apache/myfaces/custom/tree2/yellow-folder-closed.png" to
>> "/CONTEXT_NAME/img/org/apache/myfaces/custom/tree2/yellow-folder-
>> closed.png", and that doesn't seem to happen.
>> As you can see, it does happen for the image1 and image2 arguments,  
>> but
>> not for the expandImg and collapseImg.
>>
>> It seems that in the example it only happens to work because a  
>> relative
>> path is used, and the images folder happens to be next to the jsp  
>> file.
>> The would mean in my case that I would have to use
>> "../../../../../../img/org/apache/myfaces/custom/tree2/yellow-folder-
>> closed.png", which is pretty way out there and unstable, obviously.
>> Indeed, this does work though.
>>
>> What am I missing? A call to
>> facesContext.getApplication().getViewHandler().getResourceURL(facesCon 
>> te
>> xt, [expand][collapse]ImgSrc); would do the trick in the JavaScript
>> rendering (line 523 and 525 of the current head,
>> org.apache.myfaces.custom.tree2.HtmlTreeRenderer#encodeNavigation(Face 
>> sC
>> ontext, ResponseWriter, HtmlTree)).
>>
>>
>> Met vriendelijke groeten,
>>
>> Jan Dockx
>>
>> PeopleWare NV - Head Office
>> Cdt.Weynsstraat 85
>> B-2660 Hoboken
>> Tel: +32 3 448.33.38
>> Fax: +32 3 448.32.66
>>
>> PeopleWare NV - Branch Office Geel
>> Kleinhoefstraat 5
>> B-2440 Geel
>> Tel: +32 14 57.00.90
>> Fax: +32 14 58.13.25
>>
>> http://www.peopleware.be/
>> http://www.mobileware.be/
>>
>>
>
>
Met vriendelijke groeten,

Jan Dockx

PeopleWare NV - Head Office
Cdt.Weynsstraat 85
B-2660 Hoboken
Tel: +32 3 448.33.38
Fax: +32 3 448.32.66

PeopleWare NV - Branch Office Geel
Kleinhoefstraat 5
B-2440 Geel
Tel: +32 14 57.00.90
Fax: +32 14 58.13.25

http://www.peopleware.be/
http://www.mobileware.be/

Re: Folder images in tree2

Posted by Sean Schofield <se...@gmail.com>.
This has always been the case with <h:graphicImage>.  Was this somehow
working differently in an earlier version of tree2?  I doubt it.

sean

On 8/16/05, ir. ing. Jan Dockx <ja...@mac.com> wrote:
> I have the following in my jspx file for an x:tree2 (using the nightly
> build d.d. 15/8).
> 
>           <x:tree2 value="#{handler.treeModel}" var="node"
> varNodeToggler="t" showRootNode="false">
> 
>             <f:facet name="be.peopleware.ehims.olts.Speciality">
>               <h:panelGroup>
>                 <f:facet name="expand">
>                   <h:graphicImage
> value="/img/org/apache/myfaces/custom/tree2/yellow-folder-open.png"
> rendered="#{t.nodeExpanded}" />
>                 </f:facet>
>                 <f:facet name="collapse">
>                   <h:graphicImage
> value="/img/org/apache/myfaces/custom/tree2/yellow-folder-closed.png"
> rendered="#{!t.nodeExpanded}" />
>                 </f:facet>
>                 <h:outputText value="#{node.wrapped.instance.name}"
> styleClass="node" />
>               </h:panelGroup>
>             </f:facet>
> 
>         </x:tree2>
> 
> This shows the folder images on first load. The trouble is the open or
> closed folders don't show after a JavaScript action.
> The reason is that the url's passed to the JavaScript function are
> exactly what we typed into the value of the graphicImage, and are not
> interpreted context relative.
> 
> onclick="treeNavClick('org.apache.myfaces.tree.TOGGLE_SPAN:_id18:0:0',
> 't2_id28',
> '/OLTS/faces/myFacesExtensionResource/tree2.HtmlTreeRenderer/11235566/
> images/nav-plus-line-middle.gif',
> '/OLTS/faces/myFacesExtensionResource/tree2.HtmlTreeRenderer/11235566/
> images/nav-minus-line-middle.gif', '_id2:_id18:0:0:t2_id29',
> '/img/org/apache/myfaces/custom/tree2/yellow-folder-open.png',
> '/img/org/apache/myfaces/custom/tree2/yellow-folder-closed.png',
> '_id18', '0:0');"
> 
> They should be translated somewhere from
> "/img/org/apache/myfaces/custom/tree2/yellow-folder-closed.png" to
> "/CONTEXT_NAME/img/org/apache/myfaces/custom/tree2/yellow-folder-
> closed.png", and that doesn't seem to happen.
> As you can see, it does happen for the image1 and image2 arguments, but
> not for the expandImg and collapseImg.
> 
> It seems that in the example it only happens to work because a relative
> path is used, and the images folder happens to be next to the jsp file.
> The would mean in my case that I would have to use
> "../../../../../../img/org/apache/myfaces/custom/tree2/yellow-folder-
> closed.png", which is pretty way out there and unstable, obviously.
> Indeed, this does work though.
> 
> What am I missing? A call to
> facesContext.getApplication().getViewHandler().getResourceURL(facesConte
> xt, [expand][collapse]ImgSrc); would do the trick in the JavaScript
> rendering (line 523 and 525 of the current head,
> org.apache.myfaces.custom.tree2.HtmlTreeRenderer#encodeNavigation(FacesC
> ontext, ResponseWriter, HtmlTree)).
> 
> 
> Met vriendelijke groeten,
> 
> Jan Dockx
> 
> PeopleWare NV - Head Office
> Cdt.Weynsstraat 85
> B-2660 Hoboken
> Tel: +32 3 448.33.38
> Fax: +32 3 448.32.66
> 
> PeopleWare NV - Branch Office Geel
> Kleinhoefstraat 5
> B-2440 Geel
> Tel: +32 14 57.00.90
> Fax: +32 14 58.13.25
> 
> http://www.peopleware.be/
> http://www.mobileware.be/
> 
>