OpenNTF.org - XPages Wiki

My Links (Not logged in)
User Name Password
Hosted by Prominic.NET

   Project: XPages Wiki (Managed by Steve Castledine, Niklas Heidloff)
Actions:


Response
Subject
Created 03/12/2009 02:00 PM by Bo M Nilsson.
Modified03/12/2009 02:01 PM by Bo M Nilsson.
Body

I'm having the same problem with 0.02

It's as if it's missing out on the database name. Looking at xpWikiStyle.js I find this condition
if(renderForXSP){
tlink="editpage.xsp?action=newDocument&subject="+t;
im="<img src=\"plus.gif\" />";
}
else{
tlink="../editpage.xsp?action=newDocument&amp;subject="+t;
im="<img src=\"../plus.gif\" />";
}

Can it be that this is where the path to the image goes wrong? The path to plus.gif is http://server.com/database.nsf/plus.gif but the ../ makes it http://server.com/plus.gif if you open the database from http://server.com/database.nsf

If you instead open from for example http://server.com/database.nsf/dx/Welcome it seem to work. It is then opened from the "(Main Content View)" so having the boolean renderForXSP false then is ofc right.

Since the starting page of the whole project is home.xsp shouldnt the renderForXSP boolean be true then when the application starts? I tried changing it but it had no effect. I guess there's alot of things I dont understand yet :-)

I have not been successful in finding a proper solution so I did a little ugly hack to get the images working.

First I added an onload function to the home.xsp page (which is really the only place the problem exists)

I did this by editing the source of home.xsp adding the following code after the resources (<xp:this.resources> element)

<script language="Javascript">
XSP.addOnLoad(function () {fixImages();});
</script>

This executes whatever code is in fixImages() so this is what fixImages looks like:

function fixImages()
{
var imageTags = document.getElementsByTagName("img");
var imageTagsCount = imageTags.length;

for (var it = 0; it < imageTagsCount; it ++)
{
var imgSrc = imageTags[it].getAttribute("src");

if((imgSrc.indexOf("database.nsf/") == -1) && (imgSrc.indexOf("domjava/xsp") == -1))
{
if((imgSrc.indexOf("http://serverdomain/")) != -1)
imgSrc = imgSrc.substring(22,imgSrc.length);
else if ((imgSrc.indexOf("../")) != -1)
imgSrc = imgSrc.substring(3,imgSrc.length);

var newImgSrc = "http://serverdomain/database.nsf/" + imgSrc;

imageTags[it].setAttribute("src", newImgSrc);
}
}
}

Be aware that IE 7 browser treats the src attribute abit different than firefox and the rest

So first I grab all the image elements on the page then grab the "src" attribute of them.
I then check if the database name is already present (since in my case that is what's missing for non-working images)
I also check so that I'm not altering images that have different (and absolute) references, aka they dont have domejava/xsp
in the source path.
Then I need to check if the domain name is preset, which it is in IE (but not in non-evil-browsers) and cut it away,
then I check if ../ is present (this is for the tiny icons at external links and such) and cut that away as well.
Then I add the absolute path (not just the database name) and the trimmed src path to the images. I need to add the
domain for IE cuz it didnt seem to work with just a relative path, then I set src attribute..

Pretty ugly solution, but it works and I didnt have to dig into the workings of the wiki.

Links are not working either (on home.xsp) so I'm gonna have to do the same thing for the href attribute of the a elements.



Feedback

Show details for Missing Icons on Wiki main page ( on 02/25/2009 03:02:40 PM )Missing Icons on Wiki main page ( on 02/25/2009 03:02:40 PM )
Check out other projects
Switch to project: