Saturday, 20 August 2016

How to Set Multiple data and retrive Using Generic list and Comparator

package com.AddMultiple;
import java.util.*;
/**
 *
 * @author Ananddw
 *
 */
public class Mutiple implements Comparable<Mutiple>{
   
    private String name;
    private String age;
    private String location;
   
   
   
    @Override
    public int compareTo(Mutiple o) {
        return name.compareTo(o.name);
    }
   
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getAge() {
        return age;
    }
    public void setAge(String age) {
        this.age = age;
    }
    public String getLocation() {
        return location;
    }
    public void setLocation(String location) {
        this.location = location;
    }
   
    public static void main(String[]args){
       
        List<Mutiple>list = new ArrayList<Mutiple>();
        for(int i=0;i<3;i++){
           
            Mutiple mutiple =new Mutiple();
            if(i==0){
            mutiple.setName("Anand");
            mutiple.setAge("24");
            mutiple.setLocation("Bangalore");
            }
           
            if(i==1){
            mutiple.setName("Ajeet");
            mutiple.setAge("24");
            mutiple.setLocation("Pune");
            }
            if(i==2){
            mutiple.setName("Antrish");
            mutiple.setAge("24");
            mutiple.setLocation("Chennai");
            }
           
            list.add(mutiple);
           
        }
       
        for(Mutiple mutlist:list){
            System.out.println("==>"+mutlist.getName()+"\t"+mutlist.getAge()+"\t"+mutlist.getLocation());
           
        }
    }
}


++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
O/P
==>Anand    24    Bangalore
==>Ajeet    24    Pune
==>Antrish    24    Chennai

Tuesday, 16 August 2016

How to Get Checked Row Data Using Java Script

                                                                                                                                                                                  <!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<table border="1">
<tr>
<th>Name</th>
<th>Salary</th>
</tr>
<tr>
<td>Ramesh Raman</td>
<td>5000</td>
<td><input type="checkbox" name="lineitemsCheckBox" id="lineitemsCheckBox" value="Anand"/> </td>
</tr>
<tr>
<td>Shabbir Hussein</td>
<td>7000</td>
<td><input type="checkbox" name="lineitemsCheckBox" id="lineitemsCheckBox" value="Ajeet"/> </td>
</tr>

<tr>
<td>Shabbir Hussein</td>
<td>8</td>
<td><input type="checkbox" name="lineitemsCheckBox" id="lineitemsCheckBox" value="Antrish bhai"/> </td>
</tr>
<tr>

<td>Shabbir Hussein</td>
<td>9</td>
<td><input type="checkbox" name="lineitemsCheckBox" id="lineitemsCheckBox" value="Test"/> </td>
</tr>
</table>

<input type="submit" onclick="Run()">

<script type="text/javascript">
function  Run(){
var lineitemscheckbox = document.getElementsByName('lineitemsCheckBox');
for (var i = 0, len = lineitemscheckbox.length; i < len; i++) {
        if (lineitemscheckbox[i].checked) {
            //alert("checked " + lineitemscheckbox[i].value);
            //lineitemskey[i] = lineitemscheckbox[i].value;
            temp = lineitemscheckbox[i].value;
         // alert("===>"+temp);
 }
 }
}
</script>


</body>
</html>  
<%--In Dymanic value you can passit Like
<input type='checkbox' name='lineitemsCheckBox' id='lineitemsCheckBox' value='"+finalMessage+ "'/>
-->

Map class field to map

 import java.lang.reflect.Field; import java.util.HashMap; import java.util.Map; public class AutogeneratedClassMapper {     public static M...