Friday, September 18, 2009

Changing the Landing page after Login in Lotus Connections 2.5

As I described in an earlier post, how to modify the Homepage link of the navigation bar in order to display the "My page" instead of the update page, I describe in this post how to modify the Homepage redirection after logging in to Connections. We make use of the WASReqURL cookie that is set to remember the URL to a protected resource when there is no User session active. WAS redirects to the Login page and remembers the previously called URL in the WASReqURL. Via a small JavaScript on the login page, we modify this cookie to point to the My Page url. The login page is defined in dboard.war/auth/login.jsp. Add the following snippet to the head scripts of the file.


function setRedirectCookie(){
var cookieName = "WASReqURL";
var requestURL = getCookie(cookieName);
if(requestURL.substr(requestURL.length - 9) == "homepage/") {
  requestURL += "web/widgets";
}
setCookie(cookieName, requestURL, null, "/");
}


The getCookie() and setCookie() methods are copied from the example on w3schools. Note, that the setCookie() method uses a fourth parameter, which is the path that is simply appended after the expires parameter. The setRedirectCookie() method retrieves the WASReqURL and checks if it ends with "homepage/" - which is the Updates page. If thats the case, the "web/widgets" is appended, pointing to the My Page.

10 comments:

GreatJava said...

seems easier to just mod the web.xml to have web/widgets as the default welcome page. Deployment the same as changing a jsp and so is dealing with the patches.

Thomas101 said...

This did not work for me with the pilot install. However, your other post about changing the header to land on the widgets page worked.

s said...

It dosen't WOrk

G.Muecke said...

Never tested it with the pilot install. I had this running on a standard deployment. Did you check the actual contents of the cookies? And did you implement the get/setCookie methods as described?
@s: It does.

s said...

Thank you for your answer and help, i tested it with a standard install, i implement the two methods set and get cookies. i put alert in the code and i got this result :

requestURL.substr(requestURL.length - 9) ===> homepage/ : ok

requestURL =====> http://connections.company.com/homepage/web/widgets :ok

But after Login i got this result:

Error 404: SRVE0190E: File not found: /auth/http://connections.company.com/homepage/web/widgets

and in the url :
https://connections.company.com/homepage/auth/http%3A//company.company.com/homepage/web/widgets

G.Muecke said...

that's interessint, seems you are assembling a wrong url in the cookie, your script appends the new request url to the current one (which ends with auth/)... did you use the version of w3schools and added a fourth - the path - parameter to it as I've written?

s said...

Yes I did and this is my script (yours) :

function setCookie(c_name,value,expiredays,path)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toUTCString())+
( ( path ) ? ";path=" + path : "" );
}

function getCookie(c_name)
{
if (document.cookie.length>0)
{
c_start=document.cookie.indexOf(c_name + "=");
if (c_start!=-1)
{
c_start=c_start + c_name.length+1;
c_end=document.cookie.indexOf(";",c_start);
if (c_end==-1) c_end=document.cookie.length;
return unescape(document.cookie.substring(c_start,c_end));
}
}
return "";
}

function setRedirectCookie(){
var cookieName = "WASReqURL";
var requestURL = getCookie(cookieName);

if(requestURL.substr(requestURL.length - 9) == "homepage/")
alert("requestURL.substr(requestURL.length - 9)" + requestURL.substr(requestURL.length - 9));
{
requestURL += "web/widgets";
alert("requestURL" + requestURL);
}
setCookie(cookieName, requestURL, null, "/");
}

setRedirectCookie();

G.Muecke said...

If I remember correctly, I append the path parameter unconditionally ( only ";path=" + path ) but that shouldn't be the cause.
Seems the cookie value is not replaced but the new string appended instead.
You should try the firebug plugin for firefox, you can debug you JS code and validate the content of the cookies during execution.
Also try to clear all cookies in the browser and navigate to connections/homepage, maybe there is still an old cookie value set.

s said...

it doesn't work, the last chance is to remove "/auth" from the URL after login and then it will work

best landing page design said...

WOW..It seems to be very easy way of changing landing page. Let me try. I quite excited about it. I hope that it will work great for me.