Tuesday, July 26, 2011

CSS Opacity not working in IE

Many of the times CSS Opacity of filter property is working fine in Firefox but not working in Internet Explorer.
After doing lot of search, test and trial i found that nested style of css opacity never works, opacity property of parent is automatically inherited in IE, thought it can work in Firefox/Mozilla. To solve this problem, I made the div for which css opacity property is to be applied as  parent most tag. I copied the code to top of the file.
After doing this stuff, now its working very fine in almost all browser.

So remember: css opacity property never work in nested tag, it overrides by parent opacity, child div automatically inherit parent's  opacity property. So to make it workable, take out this div/tag from its parent & make this div/tag as separate tag or parent of all tag. You can just move this tag to top of the page.

Friday, July 15, 2011

Sorting an ArrayList that contains pojo class

Sorting of ArrayList containing our own Class/Objects in java, Sorting ArrayList that contains customizes java class/objects in java . How to sort Arraylist that contains our own class in java?
Here is the example of sorting  a list that contains java pojo class.
In below example, we have Employee class with attribute id, first name & last name.
We have another class that actually use the sort() method of Collections which has to implement Comparator() to sort pojo with its field.

Here is the Employee Class
public class Employee 
{
    int id;
    String firstName;
    String lastName;
    
    public Employee(int id,String firstName,String lastName)
    {
        this.id=id;
        this.firstName=firstName;
        this.lastName=lastName;
    }
    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }
    public String getFirstName() {
        return firstName;
    }
    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }
    public String getLastName() {
        return lastName;
    }
    public void setLastName(String lastName) {
        this.lastName = lastName;
    }
}

Here is actual class that sort the list which contains Employee objects
 
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;


public class SortEmployeeList
{
    public static void main(String[] args) 
    {
        Employee emp1 = new Employee(1,"Dipen","Khadka");
        Employee emp2 = new Employee(2,"John","Rotela");
        Employee emp3 = new Employee(3,"Shark","Anderson");
        Employee emp4 = new Employee(4,"Suman","Bhatt");
        
        List<Employee> employeeList = new ArrayList<Employee>();
        employeeList.add(emp1);
        employeeList.add(emp2);
        employeeList.add(emp3);
        employeeList.add(emp4);
        
        //sort by First name
        Collections.sort(employeeList, new Comparator() {
            @Override
            public int compare(Object obj1, Object obj2) {
                Employee emp1 = (Employee)obj1;
                Employee emp2 = (Employee)obj2;
                return emp1.getFirstName().compareToIgnoreCase(emp2.getFirstName());
            }
        });
        //Now the employeeList is sorted based on first name
        
        
        //sort by Last name
        Collections.sort(employeeList, new Comparator() {
            @Override
            public int compare(Object obj1, Object obj2) {
                Employee emp1 = (Employee)obj1;
                Employee emp2 = (Employee)obj2;
                return emp1.getLastName().compareToIgnoreCase(emp2.getLastName());
            }
        });
        //Now the employeeList is sorted based on last name
    }
} 

Thursday, July 7, 2011

Skip or Excluding/Disabling jsp Validation in Eclipse

Many of the times Validation of jsp in each and every changes irritate and time consuming for developer.

To Skip or Excluding/Disabling jsp Validation in Eclipse, we can disable validation process as below:


Go to Preferences -> Validation Find the Validator you wish to change and select settings (not all of the validators have settings).


You can also exclude specific folder from validation in eclipse, you have to follow following steps to excluse folder validation:


  1. Right click project
  2. Select properties
  3. Select validation
  4. Check Enable Project specific settings
  5. Click XMl Validator settings
  6. Select Exclude Gruop
  7. Click Add rule
  8. Select Folder or File name
  9. Click Next
  10. Select files or folder which are not validated.
  11. Click Finish
  12. Click OK
  13. Click OK

Thanks.

project facet Java version 6.0 is not supported problem in eclipse IDE

The problem we can face is due to lower version of java being specified in your facet settings.
We get this problem when we try to run Web application/project in eclipse IDE  and try to run in apache tomcat server.

The solution of this problem is:
Goto project properties -> Select Project Facets -> Check the Java version, if it is other than java 5.0 then click on Add/Remove Project Facets. 
A new pop-up will open select "Facets Project" from the configurations dropdown.
Now you will see a Project Facet named "Java". select the checkbox and change the version to 5.0 and click finish.
Clean build your workspace. 



Now It should work.
Thanks.