Friday, June 08, 2007

Category View Builder - Expand All (Portlet Factory)

Things have been so crazy the pass month. Been spending so much time picking up new skill but at the same time have to rush for the project. So I have been neglecting my post here. Almost coming to the completion of my project. Phase 1 anyway. Portlet Factory does give a good impression during these learning period.

I start to build a sample application using db2 as datastore. After playing around, I understand better the concept of separating data access & UI front end. This can be easily be done by creating separate model for service provider and consumer. For the first model, I prepare the SQL statements and the service provider & service operation builder. Then for the UI front end, service consumer builder is used. That way, the back end provider can be changed without changing the UI model. Of course the data schema have to be same.

I won't go into the detail of how that is done. The Portlet Factory samples covers a lot of those. I have gotten used to having categorized view from Lotus Domino/Notes. Thankfully, Portlet Factory provides category view builder. It is just a simple as selecting your table and specifying which column need to be categorized.



My only problem is getting it to expand all during load. Thanks to mtr on the forum, I have some idea on how to get it done. I use view & form builder to display the categorized view. So instead of setting the "View & Form" builder as main, create an "Action List" builder as the main. First I user the DataService to set the result for the table. Then I use the Category View function to expandAll. At last display the view page.



Hope the will help those looking for a expand all during load. The more I use Portlet Factory, the more I find it as a user friendly tool. Quite a lot of things can be done without going down into coding. That is a very good news for beginner.

Monday, May 14, 2007

Firefox can't establish a connection to the server

I have just change a new notebook. After a day of transferring data onto it, I started to use it. Everything seems to work fine until I was browsing on Firefox. A few sites I get the error "Firefox can't establish a connection to the server at websitename.com". I search through the web & forum but did not managed to get a solution. My proxy setting seems to be alright. I can go to those sites using IE and they is not an IE only sites. At the end of the day I gave up. I have a look at it again the next day and found the culprit. I have set the proxy for http but not for other protocol. So a simple checked on "Use this proxy server for all protocols" solved the problem. Come to think of it, the sites that I had problem accessing are https site which use SSL. How could I miss that? Sad to hear that a person (from a forum) gave up using Firefox because couldn't get this tiny issue fixed. Hope this help those who face the same problem out there.

Wednesday, April 25, 2007

AirAsia

Thanks to AirAsia, my recent trip to Langkawi just cost below RM 100 (USD 30) for two way flight (Kuala Lumpur - Langkawi), including airport tax, fuel surcharge and travel insurance. Last year I managed to get free ticket to Cambodia on AirAsia (just have to pay for tax and fuel surcharge). AirAsia motto "now everyone can fly" stay true, providing budget traveler like me with affordable flights. If you are in or coming to ASEAN countries, do check out AirAsia for budget flights.

AirAsia

This is not a promotion for them (maybe yes in a way) and I'm not affiliated to them. Just sharing information for good flight deal. But bear in mind, it's a budget airline. Always hear of delay. My experience was delay for around 1/2 - 1 hours, so still acceptable. Once the plane was early and we arrive early too. Food is served seperately. I tried Nasi Lemak (local Malaysia food) and it does taste good although serve cold. On newer planes (Airbus), the seat space was good. But on the older planes, they are quite cramp. But for a 1 to 2 hours flight, it is bearable.

Check out some of the pictures I took in Langkawi here.

Visit Malaysia 2007

Thursday, April 19, 2007

Websphere Portlet Factory

Just installed Websphere Portlet Factory (WPF) and test it out a bit. My previous experience of developing portlet is using Websphere Studio Application Developer (WSAD), now called Rational Application Developer (RAD). Definitely WPF is much simpler to get started with, for developing portlets than WSAD.

I manage to built a simple portlet to display a Domino application view and document in a few minutes. Basically a few builders in a portlet factory model would do the job. But this just create the WPF provided standard view and display all the fields in the document. It would take more work to customized to the way we may want it to be. But still so far, no Java coding yet. Good new ya.

Will spend more time learning up WPF. Definitely it is much easier to learn than building portlet in WSAD. This hold true especially for those who are still going to learn Java :) Let just see how far we can built portlet application using WPF without JAVA codings. Will update my findings soon.

Tuesday, April 10, 2007

Websphere Portal iFrame portlet on IE 7

I was testing an Websphere Portal v6.0 iFrame portlet. It was working on IE 6.0 and Firefox. But on IE 7, I get the error message below.

The portlet cannot be displayed because your browser does not support iframes.

My first impression was that IE7 support for iframe was disable. So I check the IE settings and it seems alright. After some searching around, I found the problem is not with IE7. It's a known issue but can be easily solved. Go to the Portal Administration -> Portal Settings -> Supported Clients. The list of supported client is listed there. IE 7 is missing. Just "Add new client" and filled up the information as per MSIE 6.0. Only the information below needs to be changed

User Agent:
.*MSIE 7.0.*

Version:
7.0

It would be much easier if we could make a copy of the IE 6.0 client setting and make the necessary changes only. Any portlet guru who can modify the Supported Client setting portlets to have additional copy function?

Looking forward to play around more with Portal Server.

Tuesday, April 03, 2007

Document Navigation From View - HTTP_Referer

On Lotus client, when opening a document from a view, normally will be open on a new tab. Thus closing it may bring you back to the view.

On web, people try to avoid opening a new window. When opening a document from a view, users will expect to go back to the view that they come from. Users can access the same document from different views. Thus application have to be built to handle this.

One way to do this is passing the view name through the anchor link when opening the doc from the view. A simple way is to look through the view table DOM anchor and append the required query strings. I usually put the a div tag ("viewtable") around the embedded view in the $$ViewTemplate. This code below will look through the anchor link and append in the view name.

var anchor =
document.getElementById("viewtable").getElementsByTagName("a");
for(var i=0; i<=anchor.length; i++){
if(anchor[i] !== undefined){
anchor[i].href = anchor[i].href + "&view=" +
document.getElementById("viewname").value;}
}

This is a simple solution but when you have a large view, you have to take into consideration of the script performance. There should be a simpler way to do this. I just thought of using CGI values.

So I tried using HTTP_Referer. It returns the url of where you come from, thus it can be used to retrieve the view name. I store the view name in a hidden field for easy reference. The formula below can be used in the field to retrieve the view name from the HTTP_Referer. If it cannot find the view name in the HTTP_Referer, it will put in a default view name.

a:=@Left(@Right(HTTP_Referer; ".nsf/"); "?OpenView");
@If(a=""; "vMyAction"; a)

The "Close" button in the document can use the field to navigate back to the view.
When going from read to edit mode, the referer will be the read mode thus losing the view name info. A simple way around this is to pass the view name along in the URL when opening the document in edit mode or going back to read mode. It can easily be retrieve using @UrlQueryString.

There are many ways to do the document navigation from the view. You can use the methods above, cookies, etc. If you know a better or simpler way to do it, feel free to drop in your comments.

Add to del.icio.us

Tuesday, March 20, 2007

Javascript String Performance

Followup previous article on innerHTML performance, I now take a look at what is the better way to built the HTML string for the innerHTML.

I use 2 for loop to built a table with 1000 rows and 5 columns. 4 different ways of building the string is tested. The test is done on Firefox 2.

1) str += ...
2) str = str + ...
3) str = str.concat(... , ...)
4) str.push(... , ...)

Below is the javascript sample for the 4th test cases

function init(){
console.time("String")
var newStr = new Array("<table>");
for(var i=0; i<1000; i++){
newStr.push("<tr>");
for (var j=0; j<5; j++){
newStr.push("<td>row ", i, " col ", j, "</td>");
}
newStr.push("</tr>");
}
newStr.push("</table>");
document.getElementById("content").innerHTML = newStr.join("");
console.timeEnd("String");
}

I did sample of 20 time and get the average result.







Test TypeAverage Time (ms)
1str += ...317.5
2str = str + ...285.4
3str = str.concat(... , ...)287.2
4str.push(... , ...)298.4


The results is quite close. The 1st Case is the slowest among all. The other 3 time is almost silimar considering their performance variation is about the same. Thus for most case (small functions), either way should be fine. But to squeeze every ms out, try using case 2-4.

The only thing to avoid is building the string like the example below.
newStr = newStr + "row ";
newStr = newStr + i;
newStr = newStr + " col ";
newStr = newStr + j;
newStr = newStr + "";

Use this instead:
newStr = newStr + "row " + i + " col " + j + "";

Any String that can be build in one line, should be done so.

Add to del.icio.us