Tuesday, February 24, 2009

Axis Dynamic Proxy Binding Tutorial

So you are accessing a SOAP Web Service that is being improved recently by their owners. They did not break previous functionality but they are returning an extra complex type member. Your code broke and the client you developed using WSDL2Java and static stubs does not work any longer.

The solution for this problem is called "Custom Serialization" and I have written a tutorial, result of my recent struggle with the issue. You can access it from here.

Thursday, February 12, 2009

Javascript ( JQuery ) Pagination

In every other WEB project you face you need pagination. I need to have this snippet at hand and so I have decided to post it here. I use JQuery and it is assumed I have a div#id=pagination nested into a div#id=content

function loadPagination(action, p, r, t){
var maxDirectPageLinks = 10;
var totalPages = t/r;
if(Math.floor(totalPages) != totalPages){
totalPages = Math.floor(totalPages) + 1;
}

$("#pagination").remove();
var start = 1;
var end = maxDirectPageLinks;

if(totalPages > 1){
if (maxDirectPageLinks < totalPages) {
if(p - maxDirectPageLinks/2 > 0 && p + maxDirectPageLinks/2 < totalPages) {
var start = p - maxDirectPageLinks/2 + 1;
var end = p + maxDirectPageLinks/2;
}else if(p - maxDirectPageLinks/2 < 0) {
var start = 1;
var end = maxDirectPageLinks;
}else if(p + maxDirectPageLinks/2 > totalPages) {
var start = totalPages - maxDirectPageLinks + 1;
var end = totalPages;
}
}else {
end = totalPages;
}
$("#content").append("
");
//$("#pagination").append("page " + p + " from " + totalPages + " pages for " + action + " (records per page/totalrecords=" + r + "/" + t);
if(p > 1){
$("#pagination").append("" + "Previous" + " ");
}
for(var i = start; i <= end; i++) {
if(i == p) {
$("#pagination").append(i + " ");
}else{
$("#pagination").append("" + i + " ");
}

}
if(p < totalPages){
$("#pagination").append("" + "Next" + " ");
}
$("#pagination").append("(" + totalPages + " total pages)")
}
}

Wednesday, February 04, 2009

IPhone SDK 2.2.1 with 2x faster Javascript

I was surprised when I finished deploying my application in an Ad Hoc IPod Touch device after seeing it was running faster than in my develoment IPhone.

The application makes heavy use of the WebKit and I was experiencing 5-6 seconds delay between heavy Views (6K JSON data) when deployed to the IPhone but it went down to 3-4 when I deployed into the IPod Touch. Considering sqlite takes around 2 seconds in either case we are definitely getting a 2x Javascript performance increase (faster JavaScript execution).

The reason for the boost? A new 2.2.1 version in the Ipod Touch (I have 2.2 in the Iphone).

Followers