Thursday, November 29, 2012

Spring bean threadsafety

Recently working on multi-thread safety issues, and read a interesting article regarding spring bean and thread safe. Please be aware one more thing, spring singleton is not a true singleton, is one instance per application context. So it is possible there are multiple instances inside JVM.

Tuesday, November 20, 2012

Four questions for every solution

1. What is the problem 2. What is the solution 3. Solution Matrix for Advantage and disadvantage. 4. What is the best solution

Monday, November 19, 2012

Java deadLock

Below it is the link of a blog regarding java dead Lock, it is very useful.

Tuesday, October 9, 2012

Java Interview questions Link

Today I read one article regarding interview questions, it is basic but useful. I might use for future interview for Java developers. link is below.

Tuesday, June 26, 2012

Manager vs Leader

Today I read a article and below statement is very interesting. Managers do things right, and leaders do the right thing. Then a manager who has a leadership will do the right things right. It reminds me a concept which a Chinese guy "Sun Tzu" said 2000 years ago in "The Art of War": a Strategist is making sure they are doing the right thing, and a Tactician is making sure the army is doing the thing right.

Tuesday, May 8, 2012

Pagination Solution

In the last couple of days, I had some discussions with some developers regarding how to implement Pagination, below are the notes. 1. Client side solution, good for small result (10-500), static data. Initial load is slow, but switch is fast. 2. Application server solution, good for medium result set (500- 1000), and relative static data. Initial load is slow. and switch is little slow. 3. Database solution, good for Large result set ( > 10000) and dynamic data. Initial load is faster than the other two, but switch pages are much slower depends on QUERY. If the query is complicated and expensive, then solution 3 will have big overhead. By the way, from scalability point of view, database solution is much more expensive as it will need query db multiple times and resources are also expensive (hard to scale).

Monday, March 5, 2012

JSF ajax exception handler solution

Recently I had some issues with JSF ajax exception handling, Primefaces 3.2 will fix it, so I am still waiting.

Below are the resources might helpful:

Friday, February 24, 2012

Best Pratctices for Successfully Project

Some thoughts regarding running IT project successfully.
1. Major stakeholder involvement, and communication with development team. If the development team, especially primary designers(BA and Architect) can communicate with the major stakeholder regularly, then it will the DEv team to align the direction. In a project while ago, Dev team had been working on development for about 6 months based on the requirements BA collected and signed by users about 9 months ago, there is no communication between major stakeholder and development team during that time period, later that project was shut down as requirements are out of date. This is also a big issue for Waterfall.
2. IT project and business requirement design are professional jobs, need specific skills and technical knowledge. Many times we see in a project,

JSF Validation

1. Customize error message.

You can only have one validatorMessage. So if you have multiple validators, please use custom validators.

2. For default validator, if you want customrize message, you can do this too.

put this into resources bundle.
javax.faces.validator.LongRangeValidator.MAXIMUM={1}: Value is greater than allowable maximum of ''{0}''

3. How to specify field name in validator.

private void checkDate(Date date, UIComponent uiComponent, Locale locale) {
if(isDateInRange(date) == false) {
ResourceBundle rb = ResourceBundle.getBundle("messages", locale);
String messageText = getFieldLabel(uiComponent) +" " + rb.getString(getErrorKey());

throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR,
messageText, messageText));

protected String getFieldLabel(UIComponent uiComponent) {
String fieldLabel = (String) uiComponent.getAttributes().get("fieldLabel");

if(fieldLabel == null) {
fieldLabel = "Date" ;

return fieldLabel;

Check this link for details.

Tuesday, February 21, 2012

Thursday, February 16, 2012

HTML5 video

Thursday, February 9, 2012

What are required for Leadership

Good leader requires two things.
1. Version
2. Smart Followers

A good leader is a person who has a version and also group of skilled and smart people which follow him, and help him to achieve his versions.

A leader without a version is just a manager. A good manager does not need a version, but people skills, and can be a good follower.

A expert or specialist can help leaders to achieve something, but not necessary need either version or people skills.

In some cases, a good leader may not have people skills, and still having many followers, also still can be attractive to smart experts and specialists, like Steven Jobs. But he need a clear version.

In my opinion, Version is the most important factor to be a good leader. As clear and good version will attractive more smart people to follow.

JSF Managed Bean

Today I made some changes JSF managed beans using annotation instead of XML. Below it is the example.

@ManagedBean(name="themeSwitcherBean") -- Declare it as managed bean
public class MyThemeSwitcherBean {

@ManagedProperty(value = "#{userAccountService}") -- How to reference spring bean or other managed bean.
UserAccountService userAccountService;

Tuesday, January 10, 2012

Eclipse errors and solutions

1. javax.el.PropertyNotFoundException: /index.xhtml @12,39 value="#{}": Target Unreachable, identifier 'user' resolved to null

reason: it could not load jsf bean.

Solution: a. check project-->properties --> build --> source code, if it is checked.
b. removed the tomcat server.
c. mvn eclipse:eclipse
d. add resources

Friday, January 6, 2012

How to deal with Warning: This page calls for XML namespace declared with prefix p but no taglibrary exists for that namespace.

Yesterday I did a example using PRISMFACE, JSF2, and I got below error:

Warning: This page calls for XML namespace declared with prefix p but no taglibrary exists for that namespace.

After I copied primeface jar into lib directory, everything is working. So wired.

I think this might be a Maven issue.