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