Monday, December 12, 2011

Using Velocity in Domino

We are using velocity framework to solve our task with html templates and when we started to work with velocity we faced up with problem below
java.util.MissingResourceException: Can't find resource for bundle java.util.PropertyResourceBundle, key member_access_not_allowed at
java.util.MissingResourceException.(MissingResourceException.java:50) at 
java.util.ResourceBundle.getObject(ResourceBundle.java:400) at 
java.util.ResourceBundle.getString(ResourceBundle.java:421) at 
lotus.notes.JavaString.getFormattedString(Unknown Source) at 
lotus.notes.AgentSecurityManager.checkMemberAccess(Unknown Source) at 
java.lang.Class.checkMemberAccess(Class.java:112) at 
java.lang.Class.getDeclaredMethods(Class.java:675) at 
org.apache.velocity.util.introspection.ClassMap.populateMethodCacheWith(ClassMap.java:167)
We have found the issue in velocity's source (well it is an issue only for Domino).
org.apache.velocity.util.introspection.ClassMap.populateMethodCacheWith(MethodCache, Class)
that line we have to change to get only Public methods but not all declared as it requires more access then Domino gives by default (we are not able to to get all private methods into Domino for security reason), so we just changed getDeclaredMethods to getMethods and problem has gone.

Tuesday, November 01, 2011

Solution for Lotus Domino to the trailing slash problem

2 months ago I've posted article about solution which can solve our problem in Domino with last trailing slash in URL. As I mentioned in my previous post, Domino does not care about url with/without last trailing slash, both way would work for Domino. Well, some of you maybe even find this feature useful because it gives less problems, however what if we talk about SEO (Search Engine Optimisation)?

There is actually article from google about to slash or not to slash, where they explain that they handle similar URL with and without last trailing slash as 2 different URL, they also propose ways how to solve this. If you ask what is bad here, answer is quite simple: just image that each URL has it's power/score for google. In case if we have only 1 possible URL for our page all score go to it, otherwise we will split them (high score will go to URL which is more often used by people in web).

Now about solution we implemented on our website. We used DSAPI to solve it as it does not do affect speed so much as different solutions. If you want to read more deeply about technical staff, you may want to read this article: solution to the trailing slash problem.

Yes it works like it should, no impact to page load's speed which was "very-very" important to us. And I heared google start to love us a bit more after that.

Related topics
DSAPI for Domino
Rewriting URL in Domino using DSAPI
Replacement for DSAPI in Java/XPages

Saturday, October 08, 2011

JavaScript: use power of console

console.log() - is pretty nice way to display debug information without interrupting user's actions. But do you know that 'console object' has lot of other useful methods? In this article I will try to show another important method in console object.


1. power of output
most common case for using console object is:
console.log("hello word")
but here few more ways how we can use it
console.log("string1", "string2", 1, 2, {proper1:"val1", proper2: 5});
console.log("Do you know that word %s same for all language except english %s. %d < %d", "ananas", "pineapple", 1, 2);
There are few another kind of log (works same as log but has different status)
console.debug(), console.info(), console.warn(), console.error()


console.group() and console.groupEnd() allow you to format very nice output with categories, it is very usefull when you have tons of data in log so you can easy control what is related to etc.
console.group("Food")
console.group("Fruit")
console.log("Apple")
console.groupEnd("Fruit")
console.group("Vegetables")
console.log("Potato")
console.groupEnd("Vegetables")
console.groupEnd("Food")
2. power of time
just put console.time()/console.timeEnd() before/after code where you want to measure time .
Aslo there are profile methods console.profile() and console.profileEnd() which allow to see "stack".


3. power of inspection
I guess most of us often want to see specific properties in HTML fragment, for such tasks we can use console.dir(object) or console.dirxml(element)


Some usefull articles about logging: Firebug about logging and Joe Hewitts about console

Tuesday, September 20, 2011

Page-layout rel = «next | prev»

Along with the attribute rel = «canonical» to specify a 'search robot' to duplicate content, it is now possible to use the HTML reference value rel = "next" and rel = "prev" to indicate the position of the current page with neighbors in the navigation box. F.x. you have article splitted on 10 pages and you use next/prev buttons in order to move from one page to another. If you want to be sure that most of 'score' from 'google spider' will go to main page red="next"/"prev" is the very good options.

Here is more details about our example


Now about rel="next" and rel="prev"
www.example.com/article?id=123page=1
<link rel="next" href="http://www.example.com/article?id=123&page=2" />
www.example.com/article?id=123page=2
<link rel="next" href="http://www.example.com/article?id=123&page=3" />
<link rel="prev" href="http://www.example.com/article?id=123&page=1" />
www.example.com/article?id=123page=3
<link rel="next" href="http://www.example.com/article?id=123&page=4" />
<link rel="prev" href="http://www.example.com/article?id=123&page=2" />www.example.com/article?id=123page=10
<link rel="prev" href="http://www.example.com/article?id=123&page=9" />


Few notes:

  • First page should have only rel=«next». 
  • All pages between 1-st and last usually should have both only rel=«next» and rel="prev".
  • Last page should have olny rel=«prev». 
  • Allowed to use the value rel=«previous» as an alternative to rel=”prev”. Not sure if it has sence :) 
  • In case if you fail with that Google will continue to index your content with own heuristic logic.