Monday, October 6, 2008

Blogger: Resolve Common Error while placing ads in a blogger

This article is little off-beat. However this is definitely useful for those who are newbie in the blogging world. Recently I have tried to display ad inside the article. For that I have made some changes in the template. After entering the ad code when try to save the template I have encountered different errors.
  1. Open quote is expected for attribute "{1}" associated with an element type <elementType> : Check the template code and look for (say height). This will be something like height = 5. Now blogger will complaint the above error. The solution is simple just put 5 within single quote like height = '5'.
  2. The reference to entity "<entity>" must end with the ';' delimiter. : Check the template code and look for (say ad_size). Usually this kind of error is found when we use & inside a url (say http: // example.com?a=1&ad_size=3). Now "&" has to be replaced with "&amp;" to get rid of the problem.

Note: These problem errors are reference to blogger.com

Similar kinds of problem might occur because less than and greater than sign.

<>

> should be replaced with &gt;

"" should be replaced with &quot;

Regards

Monu

Saturday, October 4, 2008

JSF: Avoid both Pagination and vertical scrolling at the same time

I have seen many applications (including one of my own application) use page pagination and vertical scrolling at the same time. This is a bad design at any curcumstances. Pagination is commonly used where application needs to display a huge chunk of data rows. It enhances page response and processing time. However sometime a page may have lot of other UI components which may allow a smaller portion of page area to display data row (may be atmost 10 rows). In such cases web designer go for vertical scrolling. Eventually this will force developer to think about implementing fixed header data column in a table.
From my perception, even though you are able to display only few rows of data in a table at one time; do NOT go for vertical scrolling. This will reduce page usability. If user agrees to have say 20 rows in a page they might agree for 10 rows if convinced properly.
JSF allows two types of pagination.
  1. UI Pagination only: This is pagination in the UI only. No need to do any kind of code in the server. Just need to use pagination component in the web page using tooling.
  2. Both UI and Server side Pagination: This is pagination both in the UI and in the server. You need to take care of previous, next and current set of rows that need to be displayed.

Very shortly I will explain these pagination technics with example along with vertical scrolling and fixed header problem.

Regards

Monu

Thursday, October 2, 2008

EGL: Extract URL details

This article helps Enterprise Generation Language (EGL) programmers to get the details about the server, port number and url type. Given below is a piece of dirty code (DONT COPY)
1) Create a Java Class like below:
package explore.your.thought.process
public class URLDetails {
public String getServer(String url) {
String replacedStr = getURLType(url);
String server = "";
String urlWithOutHTTP = url.replaceAll(replacedStr, "");
String[] strArr = urlWithOutHTTP.split("[:]");
if (strArr.length > 0)
server = strArr[0];
return server;
}
public String getServerPort(String url) {
String replacedStr = getURLType(url);
String serverPort = "";
String urlWithOutHTTP = url.replaceFirst(replacedStr, "");
String[] strArr = urlWithOutHTTP.split("[:]");
if (strArr.length > 1) {
String[] strArr1 = strArr[1].split("[/]");
if (strArr1.length > 0) {
serverPort = strArr1[0];
}
}
return serverPort;
}
public String getURLType(String url) {
String urlType = "";
if (url.indexOf("https://") != -1)
urlType = "https://";
else if (url.indexOf("http://") != -1)
urlType = "http://";
return urlType;
}
}
2) create an EGL External Type:

ExternalType URLDetails type JavaObject
{JavaName = "URLDetails", PackageName = "explore.your.thought.process"}
Function getServer(url String in) returns (String) ;
function getServerPort(url String in) returns (String);
Function getURLType(url String in) returns (String);
End
Regards
Monu

Wednesday, October 1, 2008

EGL: Converting string to int

Enterprise Generation Language (EGL) is coming up great. It has provided a good many number of API's. However sometime we need to rely on Java api to do some small task. For example converting string to int or any other datatype conversion. There is nothing great in converting string to int in EGL. We just need to do something like below:
resultInt int = JavaLib.invoke("java.lang.Integer", "parseInt", "12345");
if we print resultInt obviously the result would be "12345". So far so good. Now try to change the string to "9999999999" and execute the program again. Output will be something like
For input string: "9999999999" and the execution will stop by then. What is the reason for this behavior? This is because we are NOT handling exception. Try below snippet:
try
resultInt int = JavaLib.invoke("java.lang.Integer", "parseInt", "12345");
onException (e AnyException)
//assign some value as per business
resultInt = -1;
end
Regards
Monu