XPiNC browser url format – and why my demo failed at IBMConnect (part 2)

So this is article is to expand a little on the post I shared on Friday about my demo failure at IBMConnect. I will demonstrate why the problem occurred and what you can do about it. ALL thanks go to Simon Reid who pointed me at the reason once I had found the fix.

The Problem

I had a demonstration http://demo.xomino.com database which shows how some jQuery plugins can be used in XPages. The links within the menu “were” constructed as follows:

isExternal:=@If(@Right(Link; "http")!=""; @True; @False);

theLink:="<a href=\""+@If(isExternal; Link; "/"+@WebDbName+Link)+"\">"+LinkTitle+"</a>";

"<p>" + theLink+"</p>"+@NewLine

The point of this was to open up a link to an external site correctly and point a link to this database appropriately. The use of “/”+@WebDbName is to ensure that the database would still work when it was download and put on someone else’s server.

Works like a charm in the web
FAILED in XPinc

The Reason

As Simon Stated in his reply to my previous post – the XPiNC browser adds a /xsp/ to the front of the url.

To prove this I created a very simple link in an XPage:

<a href="javascript: alert(location.href)>Click Me</a>

And when I clicked the link in the XPiNC browser I got this…

XSPnooooo

And look at that “/xsp/xomino/jQinX.nsf” – there it is the xsp added to the URL

that is NOT what @WebDBName returns (/xomino/jQinX.nsf) and that is the root cause of the fail.

The Solution

There are a number of solutions and it really depends on what works for you – the fact that you are reading this you know about the issue and you need to work out which solution is best for you – here are some options if you need XPiNC support:

  1. Don’t user @WebDbName to get the database path – plain and simple.
  2. If you are able to – compute the links to the other XPages using the link control. I personally despise the link control because it is limiting and does not slot well into jQuery plugins – but it is an option.

The following code creates a link to the LongPress demo page – this works in XPiNC and on the Web

	<xp:link escape="true" text="Long Press Link" id="link2" value="/xLongPress.xsp" title="Long Press Link"></xp:link>

The link created looks like this in XPiNC

	<a id="view:_id1:_id2:_id52:link2" href="/xsp/xomino%5CjQinX.nsf/xLongPress.xsp" class="xspLink" title="Long Press Link">Long Press Link</a>

And looks like this in a browser

	<a id="view:_id1:_id2:_id52:link2" href="/xomino/jQinX.nsf/xLongPress.xsp" class="xspLink" title="Long Press Link">Long Press Link</a><br>

Unfortunately I want my links in documents in a view so that I can look them up – so I can’t use the xp:link

Here are some other options

  1. Use links which are not relative to the databasePath on the server. In my case I changed the menu links to be relative to each other “xPageSlide.xsp” rather than /xomino/jQinX.nsf/xPageSlide.xsp
  2. Use jQuery or dojo to do some form of XPiNC detection and manipulate the links after they have been sent to the page. You could do this by detecting if /xsp/ was the start of your location.path variable and adding it to all the link you cared about – this is dangerous and risky – not favorite which is also why I have no example.

 

Conclusion

The XPiNC browser adds /xsp/ to the front of all URLs – be aware of it

The solution depends on your needs – but for normal links to other XPages use the xp:link control which will do the link figuring out on it’s own

If I had not presented this and FAILED at IBMConnect I would not have had the conversation about it – and would not have learned something very important like this – AWESOME!

 

General Comment

How you deal with failure says a lot about your personality – if it drives you to be better then good for you.

This failure is a learning experience which was handled on stage by laughter, and I hope by this blog post as a learning experience for all 🙂

 

Advertisements

IBM Connect13 Demos

Based on my presentation at IBM Connect 13 Jan 27-31st 2013 I have published my examples to my normal demo database. From there you can also download the sample database which contains working examples of all the code used.

http://demo.xomino.com/

Here is the final presentation on SlideShare

I will be updating this post with more information regarding the World’s largest XPage project shortly.

Thanks to all those who attended the sessions – it was a pleasure to interact and learn from all of you 🙂

Marky talks twice at IBM Connect – The World’s Largest XPage Project and jQuery

This year is my second “connect-o-sphere” event and it will be a wholly different experience than the last one. I am speaking in two session, both about XPages, both as part of the best practices track. I am very excited to have the opportunity to speak at the world’s foremost conference on IBM Notes (*still in shock*).

The first session is with my boss Andrew Barickman and we will be sharing some lessons learned from the world’s largest XPage project.
“The world’s largest?” – yeah the world’s largest! (well ok at least outside of IBM internally). The point of this session is to share some of the lessons we have learned so that you don’t have to when you have an 18 month long, 10 person effort to work on!! We will discuss:

  • in a team environment on the same database
  • highlight some significant XPiNC performance enhancements which we worked with IBM on and they have  implemented in the next release IBM Notes Domino 9
  • demonstrate how we went from a notes client only application to a web based XPages application, managing  aspects of the user interface to provde a better user experience which still seemed “familiar”

The XPages Blast session is going on at the same time – which is a COOL session, but this is the repeat of the XPages Blast session on Monday at 11am – so go to THAT XPages Blast first and then come and see us – you know you want to 🙂

My second session will be on my favorite subject – jQuery.
This is a beginners introduction to how you can include jQuery successfully in your XPage applications. It will include a brief introduction to how jQuery works, best practices for adding it to your XPage applications and demonstrations of how  jQuery plugins can significantly improve your XPages and how to most effectively use them. I will be demonstrating new plugins which I have not blogged about and highlighting a couple of old ones.

This session is not just for beginners though – even advanced XPage developers can benefit from understanding what is available in jQuery World and arguably there is a plugin which you could have used in an XPages project somewhere at some time.

Gurupalooza
I will also be onstage for Gurupalooza immediately following my jQuery talk on Thursday morning. Yes that’s right, I am speaking in the room right-next-door-to and right-before-the Gurupalooza session on Thursday.

So the way I look at it is this….it is Thursday morning, you’ve not had enough sleep all week and you want to go to Gurupalooza – so why go to a session in the Dolphin and then rush over to the Swan for Gurupalooza, when you can come and see my session and then crawl into the room next door – makes perfect sense to me 🙂

I look forward to meeting as many of you as humanly possible at Connect, don’t forget to come and say hi and ask questions after my sessions.

Marky

Here are my two sessions:

Lessons Learned from the World’s Largest XPage Project


Session ID : BP211
Track : Track 07: Best Practices

Presented by : Mark Roden, Andrew Barickman
Date : 01/29/2013
Time : 08:15 AM – 09:15 AM
Location : SW 1-2
Level : **

Description :
Working on the world’s largest XPages implementation has its challenges. Modernizing an IBM Notes client application used in over 105 countries by over 100,000 users teaches you a lot! In this session, we’ll share some of the challenges and our appropach to overcoming them. We’ll demonstrate a new XPinC performance feature in the upcoming Social Edition being added as a result of our work with IBM. We’ll also demonstrate best practices in user interaction, share lessons learned on team development using a single .nsf file — and much more. Come and find out more about how you can save time, money and avoid end-user frustration as we share our experiences – and open the covers of the largest XPages project in the world. Sample DB provided!

and 

jQuery: The World’s Most Popular JavaScript Library Comes to XPages


Session ID : BP103
Track : Track 07: Best Practices

Presented by : Mark Roden
Date : 01/31/2013
Time : 08:30 AM – 09:30 AM
Location : SW 3-4
Level : *

Description :
Whether you want to add some serious eye candy to your XPages Applications or just want to do more with less code, jQuery, the world’s most popular JavaScript framework can help you. Come to this session and find out how you can use some of the thousands of jQuery plugins, in harmony with Dojo, within your XPages applications to create a better experience not only for your users, but for you as a developer. In this session, we’ll look at how jQuery works, how to add it to your XPages, and how a complete JavaScript beginner can take advantage of its power. We’ll demonstrate many working examples — and a sample database will be provided.