Monday 6 September 2010

Lotus Connections 2.5 - Linking from the Person Card - Don't use JavaScript in your URLs

Following on from my earlier post, I've hit a roadblock in my plan to create a link from the Lotus Connections Person Card which opens in a new, rather than in the same, window.

As I'd mentioned, I was using the sloc:serviceReference stanza in LotusConnections-config.xml to create the link, using the code: -

<sloc:serviceReference serviceName="googleService"
  href="http://www.google.com"   enabled="true"
  ssl_href="http://www.google.com"   ssl_enabled="false"
  person_card_service_url_pattern="/search?hl=en&amp;q={email}&amp;btnG=Google+Search"
  person_card_service_name_js_eval="'Google Me'"/>

which works OK, but causes the Google page to open in the same window as Connections.

Therefore, I thought I'd be a smartypants, and replace the href= tag with something that I know works in "pure" HTML: -

<a href="javascript:void(window.open('http://www.google.com','width=300','height=300'))">Google Me</a>

giving me: -

<sloc:serviceReference serviceName="googleService"
  href="http://www.google.com"   enabled="true"
  ssl_href="http://www.google.com"   ssl_enabled="false"
  person_card_service_url_pattern="/search?hl=en&amp;q={email}&amp;btnG=Google+Search"
  person_card_service_name_js_eval="'Google Me'"/

Well, that was a great idea .... until I started Profiles, at which point I saw: -

9/6/10 15:55:11:687 BST] 00000051 VenturaConfig E com.ibm.ventura.internal.config.VenturaConfigurationProviderImpl getServiceURL CLFRO2006E: com.ibm.ventura.internal.config.VenturaConfigurationProviderImpl href attribute in googleService service element cannot be used to construct a proper URL
                                 java.net.MalformedURLException: unknown protocol: javascript
        at java.net.URL.<init>(URL.java:609)
        at java.net.URL.<init>(URL.java:499)
        at java.net.URL.<init>(URL.java:448)

in the SystemOut.log file.

Looking at the exception: -

java.net.MalformedURLException: unknown protocol: javascript

this actually makes sense, as Connections is taking the contents of the href= tag, and using it to create a Java object of type java.net.URL which, as per the Javadoc

<snip>
Parameters:
protocol - the name of the protocol to use.
host - the name of the host.
port - the port number on the host.
file - the file on the host
Throws:
MalformedURLException - if an unknown protocol is specified.
</snip>

doesn't expect to see stuff other than a "real" URL encoded within it.

So, I'll have to search elsewhere - not sure where but .... watch this space ....


5 comments:

Mr Sutton said...

It's probably overkill for what you're trying to achieve, but you can register custom URL protocol handlers in for the java.net.URL class. You could register a javascript: handler and then the URL would be considered valid and avoid the MalformedURLException.

I did say it was overkill though... :)

Dave Hay said...

Cheers, Adrian, will look into that, much obliged

Daniele Vistalli said...

It can be done but you need to change the approach.

Instead of using XML configuration you can use the javascript personcard API as explained in here:

http://publib.boulder.ibm.com/infocenter/ltscnnct/v2r0/topic/com.ibm.lc_2.0_IC/t_admin_profiles_extend_biz_card_js.html

In this way the service is added at runtime by your code. (if you use the xml interface LC is just doing the same on your behalf).

Using the javascript api you should be able to push as "javascript:..." url as the service URL.

You could do even more but IBM is not documenting the semantic tag service API very well.

Try it

Hint: you can put your initialization code in a JS file referenced by the header and registering it by binding it to the onload event.

Dave Hay said...

Ciao Daniele, thanks for the advice, however, I'm still looking at the same issue - as far as I can tell, the JavaScript API still creates a URL object, based upon my reading of the Information Centre: -


location The location and url_pattern are combined into one URL before the link is displayed.


http://tinyurl.com/35b26e5

I'll keep trying, and report back ...

Dave Hay said...

@Daniele, interestingly, the js_eval parameter is quite interesting - I've achieved my objective BUT I have the new window opening as soon as the user clicks on "Click here to view business card" :-)

I'm guessing that the js_eval parameter is designed to drive the popup of the card itself :-)

Visual Studio Code - Wow 🙀

Why did I not know that I can merely hit [cmd] [p]  to bring up a search box allowing me to search my project e.g. a repo cloned from GitHub...