Sunday, January 11, 2009

EGL: Performance Optimization

There are many factors which directly or indirectly affects the performance of EGL/Java Web Application. Performance tunning can be done at various ends. Mainly Application Level, Database Level and Server Level.

A few thoughts mentioned below:

Application level:
1) If you are displaying huge chunk of data in the UI (say more than 25 rows in a page) then programmatic pagination is must. That is segregate the resultset into different pages (may be 20-25 rows per page). And load data for each page on demand.
2) Give a look at the UI components for the page you are getting less performance and see if it can be simplified with lesser components. I know it is not easy and advisable to redesign at the point when delivery date is close.
3) You can use "Ajax" whenever and wherever possible. It will definitely increase the performance.
4) If you are using session variable make sure you remove it once it is done. DONOT wait till user logoff.
A topic of debate:
1) Hand written java code by professional is always better than generated java code. Hand written java code can always be fined tunned and pin-point using optimization tools like Optimizeit etc.
2) Now million dollar question (or may be some cents) is why jsf is defaulted to session scope and why not defaulted to request scope? How it is removed from the session on page transition? How and when the memory is reclaimed by JVM? As we all know we cannot force JVM to garbage collected.
Server Level:
It is one of the several important steps that needs to be performed in order to get maximum output. It is NOT very difficult and scary to make changes to server setting then sticking onto the default setting. Refer below links to get an insite of it http://www.ibm.com/developerworks/websphere/library/techarticles/0602_lurie/0602_lurie.html
http://whitepapers.techrepublic.com.com/abstract.aspx?docid=325396
http://rifers.org/blogs/gbevin/2005/4/21/get_rid_of_outofmemoryerror

Database Level:
This is under discussion and will be posted shortly.

Debate and discussions are always wel-come.

Regards
Monu

Thursday, January 8, 2009

JSF: Displaying "Loading....Please Wait!" message during ajax call

AJAX is becoming a specification in present day web application. Web 2 already infected and spread all across internet application. Web 3 is knocking at the doop step. more...

A very common requirement in ajax based web page is to convey the user that some server-side process is going on and the page/portion of the page is reloading. The best way to do this is displaying a suitable message like "Loading.....Please Wait!". Java Server Faces (JSF) is very impressive in implementing AJAX behavior in a page. It has provided well abstracted and easy to implement steps. Now coming back to message displaying use case; it requires just 4 additional changes:
  1. Download a ajax activity image and store in images folder under WebContent folder. You can refer to this site to generate a gif image http://www.ajaxload.info/
  2. Copy the below code anywhere in the page. Preferrably immediately after <body>
    <div id="loading"><p>Loading... Please wait!</p><img src="${pageContext.request.contextPath}/images/activity.gif" /></div>
  3. Add two javascript function as mentioned below:

    <script language="JavaScript">function startProgressBar(){ document.all.loading.style.visibility="visible";}function stopProgressBar(){ document.all.loading.style.visibility="hidden";}</script>
  4. Change the ajax tag in your jsf page
    <hx:ajaxRefreshRequest target="ajaxGroup" onstart="startProgressBar()" oncomplete="stopProgressBar()" id="ajaxRefreshRequest1"></hx:ajaxRefreshRequest>

Regards

Monu

Wednesday, November 19, 2008

EGL: Customize error message.

In EGL/JSF there is an api called Syslib.setError("errorMsg"). This api display the error message in the UI provided there is an error component available in the page. You can put that error component by dragging onto the page from enhanced faces component . So far so good.
Now if you want to display multiple message with a break in each line. For example you want to display following messages:
Warning: you have not entered street name.
Form has been saved.
Now if you want to display these lines in the same fashion as above you can not do that using setError function. It will display both the statement in the same line. Also if you want to set different colors for warning and success message you can not do.
Now how to accomplish this requirement. JSF provide one component called outputText. You can drag this component from Enhanced Faces component list. Then create a string variable in the JSF Handler and assign the variable as below:
multipleMsg String = "Warning: you have not entered street name
Form has been saved";
After that bind this multipleMsg variable to the outputText component in the jsp. Similarly you can also add color on to these texts.
Is not it cool
Regards
Monu

Sunday, November 16, 2008

Defect Fixing: Be careful of bug fixing side effect

Defect Fixing ! Hmm one of the terrible thing to developers life. This is the biggest challenge a developer can have during developement. A small defect can make months long hard work bitter. So developers be careful of that and vows yourself to find remedy to tackle this and make your developement life easy. From my experience I have list down some points which might help minimizing defect counts.
  1. Prevention is better than cure: I think this is the single most important statement that minimize all problems. So what prevention should we take? How this statment is applicable to software development? Well the answer is straight forward follow best practices and coding standard.
  2. Bug fixing side effect: Most deadly defects are the result of defect fixing. Some features remain untested after fixing a defect in some other feature assuming that the former is already tested before. That is why automation of test cases are highly desirable. Make sure irrespective of severity of the defect you run the entire test cases only again before delivery of code.
  3. Time line: Make sure you keep enough time for testing your application.

Regards

Monu

myLot

myLot User Profile

Wednesday, November 5, 2008

EGL: Edit page details while printing web page

What you do when you want to print a web page? Answer is obvious; use window.print() event. What you do when you want to print a web page which requires formatting like removing some text, page break, modifying some content etc. just before sending to printer? Answer could be you will create one more page and make the changes required for printing with window.print() event on page load function. Then forward to this page on clicking print button. Is there any other better solution? Remember the original page could be the result of lot of business which need to take care even when you are forwarding to other page taking up printing responsibility.
Well in that case I would prefer to advise you to use javascript and css. This approach is not only fast but also easy and accurate.
Now how to do that. Well answer is right below:


  1. Surround the portion with a div in the jsp page you want to print . Donot think about the changes now.

  2. Call a javascript function say printPage(divPrintId). divPrintId is the id of the div.

  3. Retrieve the entire text within the div as str=document.getElementById(divPrintId).innerHTML

  4. Now do the business changes on the innerHTML text.

  5. For page break you can create a javascript inside printPage javascript like below:
    newwin.document.write('pageBreakDetails();\n')
    newwin.document.write('function pageBreakDetails(){\n')
    newwin.document.write('var details = document.getElementById("form1:tableId").style.pageBreakBefore="always";\n ')
    newwin.document.write('}\n')

Let me know if someone finds any difficulty implementing this


Regards


Monu

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