Friday, July 20, 2012

Create MultiLine ToolTip Jquery

Use The Code (Method-1)
------------------------------------------
<script type="text/javascript" src="../../ui/jquery.ui.tooltip.js"></script>

<script type="text/javascript">
    $(function() {   
        $('#h1t').tooltip();
    });
</script>

<h1 id="h1t" title="NewLine1<br>NewLine2"> asdf </h1>

Use The Code (Method-2)
------------------------------------------

$('#yourElement').tooltip({
track: true,
delay: 0,
showURL: false,
showBody: " - ",
fade: 250
});
<a title="New Line - New Line - New Line - New Linet" id="yourElement" href="http://yogesmprajapati.bogspot.com">mPower Blog</a>

Wednesday, April 25, 2012

Create MDB (Access Database File) using Java

Required Jar (Click to Download)

Steps
  • Add all Jar file to your java project
  • use folllowing code
package net.yogesh.test;

import com.healthmarketscience.jackcess.ColumnBuilder;
import com.healthmarketscience.jackcess.Database;
import com.healthmarketscience.jackcess.Table;
import com.healthmarketscience.jackcess.TableBuilder;
import java.io.File;
import java.io.IOException;
import java.sql.SQLException;
import java.sql.Types;

/**
 *
 * @author yogesh.mpower
 */
public class java2mdb {

    private static Database createDatabase(String databaseName) throws IOException {
        return Database.create(new File(databaseName));
    }

    private static TableBuilder createTable(String tableName) {
        return new TableBuilder(tableName);
    }

    public static void addColumn(Database database, TableBuilder tableName, String columnName, Types sqlType) throws SQLException, IOException {
        tableName.addColumn(new ColumnBuilder(columnName).setSQLType(Types.INTEGER).toColumn()).toTable(database);
    }

    public static void createDB() throws IOException, SQLException {
        String databaseName = "D:/employeedb.mdb"; // Creating an MS Access database
        Database database = createDatabase(databaseName);

        String tableName = "EmployeeDetail"; // Creating table
        Table table = createTable(tableName)
                .addColumn(new ColumnBuilder("Emp_Id").setSQLType(Types.INTEGER).toColumn())
                .addColumn(new ColumnBuilder("Emp_Name").setSQLType(Types.VARCHAR).toColumn())
                .toTable(database);

        table.addRow(1, "yogesh");//Inserting values into the table
        table.addRow(2, "abc");
        table.addRow(3, "pqr");
    }

    public static void main(String[] args) throws IOException, SQLException {
        java2mdb.createDB();
    }
}
  

Output 

file created at path D:/employeedb.mdb
with data

 






 

Sunday, April 22, 2012

Create Pascal's Triangle in One Loop using Java.

Create Pascal's Triangle in One Loop.

What the Algorithm is ?????



Code for this in java


package net.yogesh.test;

import java.util.ArrayList;
import java.util.List;

public class pascal3 {

    public static void main(String[] args) {

        int noOfRows = 10;
        int counter = 1;
        List<Integer> list = new ArrayList<Integer>();
        list.add(1);
       
        list = itMe(list, counter,noOfRows);
    }

    public static List<Integer> itMe(List<Integer> list, int counter,int noOfRows) {
        System.out.println(list);
       
        List<Integer> tempList = new ArrayList<Integer>();

        tempList.add(1);
        for (int i = 1; i < list.size(); i++) {
            tempList.add(list.get(i) + list.get(i-1));
        }
        tempList.add(1);
       
        if(counter != noOfRows)
            itMe(tempList, ++counter,noOfRows);
       
        return tempList;
    }
}

Output

[1]
[1, 1]
[1, 2, 1]
[1, 3, 3, 1]
[1, 4, 6, 4, 1]
[1, 5, 10, 10, 5, 1]
[1, 6, 15, 20, 15, 6, 1]
[1, 7, 21, 35, 35, 21, 7, 1]
[1, 8, 28, 56, 70, 56, 28, 8, 1]
[1, 9, 36, 84, 126, 126, 84, 36, 9, 1]

Thursday, April 19, 2012

Google Maps : Create Marker and Draw Line Runtime

in this demo user can add a marker by simply click on map

and line is automatically draw by map between marker

also marker is Draggable.

Demo image



Code


<!--
     Created By : Yogesh Prajapati
           Date : 03 April 2011
-->

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
    <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
        <title> Search Demo </title>
        <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAzr2EBOXUKnm_jVnk0OJI7xSosDVG8KKPE1-m51RBrvYughuyMxQ-i1QfUnH94QxWIa6N4U6MouMmBA" type="text/javascript"></script>
      

        <script type="text/javascript">
            var map;
            var secondLastMarker = null
            var lastMarker = null;
           
            function initialize() {
               
                if (GBrowserIsCompatible()) {
                   
                    map = new GMap2(document.getElementById("map_canvas"));
                    map.setCenter(new GLatLng(23.450, 72.483), 11);
                    map.addControl(new GSmallMapControl());
                   
                    GEvent.addListener(map, "click", function(overlay, latLng) {
                        var marker = new GMarker(latLng,{draggable: true});
                        map.addOverlay(marker);
                        if(lastMarker == null){
                            lastMarker = latLng;
                        }else if(secondLastMarker == null){
                            secondLastMarker = lastMarker;
                            lastMarker = latLng;
                            drawLine(map,secondLastMarker,lastMarker);
                        }else{
                            secondLastMarker = lastMarker;
                            lastMarker = latLng;
                            drawLine(map,secondLastMarker,lastMarker);
                        }
                       });
                }
            }
           
            function drawLine(map,firstPoint,LastPoint){
                var polyline = new GPolyline([secondLastMarker,lastMarker
                                              ], "#ff0000", 5);
                    map.addOverlay(polyline);
            }
                       
        </script>
    </head>

    <body onload="initialize()" onunload="GUnload()" style="background-color:aliceblue">
           <div id="map_canvas" style="width: 100%; height: 550px;"></div>
        Demo Created By : <b>Yogesh Prajapati</b><br/>
    </body>

</html>

Note:

Line is just polyLine if you want to draw path between them than you need to do something different
this is just for demo purpose.

Create your own mini google map Search Engine

First of all see the example



in this demo  google api is used for Map and searching
Markers and search box is placed custom.

this is just a standalone HTML code you can copy and paste to your favourite writer
and save as html.

for doing such a thing use following code

<!--
     Created By : Yogesh Prajapati
           Date : 28 March 2011
-->

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
    <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
        <title> Search Demo </title>
        <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAzr2EBOXUKnm_jVnk0OJI7xSosDVG8KKPE1-m51RBrvYughuyMxQ-i1QfUnH94QxWIa6N4U6MouMmBA"
        type="text/javascript"></script>

        <script type="text/javascript">
            var map;
            function initialize() {
               
                if (GBrowserIsCompatible()) {


                    function doGenerateMarkerHtmlCallback(marker,html,result) {
                        html.innerHTML+="<b>Result Coordinates: "+result.lat+","+result.lng+"</b><br>";
                        html.innerHTML+="<b>Marker Location: "+marker.getLatLng().toUrlValue()+"</b>";
                        return html;
                    }


                    var options = {
                        resultList : document.getElementById('results'),
                        onMarkersSetCallback : function(markers) {
                            fillTable(markers);
                        },
                        onGenerateMarkerHtmlCallback:doGenerateMarkerHtmlCallback
                        //onGenerateMarkerHtmlCallback : function(marker, div, result) {div.innerHTML = result.title + "<br/>"; return div; }
                    };

                    map = new GMap2(document.getElementById("map_canvas"), {googleBarOptions: options});
                    map.setCenter(new GLatLng(23.450, 72.483), 8);
                    map.addControl(new GSmallMapControl());
                    map.enableGoogleBar();

                    var myLayer = new GLayer("com.google.webcams");
                    map.addOverlay(myLayer);

                }
            }

            function deleteAllRows()
            {
                for(var i = document.getElementById("tblResult").rows.length; i > 0;i--)
                {
                    document.getElementById("tblResult").deleteRow(i -1);
                }
            }
           
            function setCenterOnMap(lat,lng){
                map.setCenter(new GLatLng(lat,lng), 15);
            }

            function fillTable(markers){
                deleteAllRows();
                var table = document.getElementById('tblResult');
               
                var counter=65;
               
                for(i=0;i<markers.length;i++){
                    var row = table.insertRow(i);
                    var cell0 = row.insertCell(0);
                    var  newImage = "url(http://www.google.com/mapfiles/marker" + String.fromCharCode(counter) + ".png)";
                    cell0.style.backgroundImage = newImage;
                    cell0.style.backgroundRepeat="no-repeat";
                    cell0.style.width="18px";
                    cell0.style.height="35px";
                    cell0.align="center";
                    cell0.vAlign="top";
                    counter++;
                   
                    var cell1 = row.insertCell(1);
                    cell1.innerHTML = "<a href=javascript:void() onClick=javascript:setCenterOnMap(" + markers[i].marker.getPoint().lat() + "," + markers[i].marker.getPoint().lng() + ")>"  + markers[i].result.title + "</a>";
                    cell1.vAlign="top";

                    //alert(markers[i].marker.getPoint().lat() + " - " + markers[i].marker.getPoint().lng());
                }
            }
           
        </script>
    </head>

    <body onload="initialize()" onunload="GUnload()" style="background-color:aliceblue">
        <table border="0" width="100%" >
            <tr>
                <td style="width: 250px;" align="center" style="vertical-align: top">
                    <div id="results" style="visibility: collapse;height: 0px"></div>
                    <table border="0" width="100%" style="height: 450px">
                        <tr>
                            <td style="height: 10px">

                                <table border="0" width="100%">
                                    <tr>
                                        <td align="right" style="width: 65px">
                                            <img src="http://www.google.com/mapfiles/marker.png"/>
                                        </td>
                                        <td>
                                            &nbsp;&nbsp;Search Results
                                        </td>
                                    </tr>
                                </table>
                                <table border="0">
                                    <tr>
                                        <td>
                                            <img src="myLine.png" width="210px" height="1px" style="vertical-align: top"/>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                        <tr>
                            <td style="vertical-align: top">
                                <table id="tblResult" border="0" width="100%" cellspacing="5" >
                                </table>
                            </td>
                        </tr>
                    </table>
                </td>
                <td>
                    <div id="map_canvas" style="width: 100%; height: 550px;"></div>
                </td>
            </tr>
           
            <tr>
                <td align="right" colspan=2>
                    Demo Created By : <b>Yogesh Prajapati</b><br/>
                </td>
            </tr>
        </table>

    </body>

</html>

for any help related to Map contact.....

Monday, February 20, 2012

Quartz Scheduler

OverView : Quartz is a full-featured, open source job scheduling service that can be integrated with, or used along side virtually any Java EE or Java SE application - from the smallest stand-alone application to the largest e-commerce system. Quartz can be used to create simple or complex schedules for executing tens, hundreds, or even tens-of-thousands of jobs; jobs whose tasks are defined as standard Java components that are programmed to fulfill the requirements of your application. The Quartz Scheduler includes many enterprise-class features, such as JTA transactions and clustering

Needed Jar :
  • quartz-all-2.1.3
  • log4j-1.2.16
  • slf4j-log4j12-1.6.1
Smaple Code:

demo.java(main Class)
-------------------------

package test;

import org.quartz.JobBuilder;
import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.SimpleScheduleBuilder;
import org.quartz.Trigger;
import org.quartz.TriggerBuilder;
import org.quartz.impl.StdSchedulerFactory;

public class demo {

    public static void main(String[] args) throws SchedulerException {
        try{
        Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();
      
        scheduler.start();
      
         // define the job and tie it to our HelloJob class
        JobDetail job = JobBuilder.newJob(HelloJob.class).withIdentity("job1", "group1")
        .build();
      
        // Trigger the job to run now, and then every 5 seconds
          Trigger trigger = TriggerBuilder.newTrigger()
          .withIdentity("myTestTrigger", "myTestgroup")
          .startNow()
          .withSchedule(SimpleScheduleBuilder.simpleSchedule()
                          .withIntervalInSeconds(5)
                          .repeatForever())          
          .build();
        
        // Tell quartz to schedule the job using our trigger
          scheduler.scheduleJob(job, trigger);

      
        //scheduler.shutdown();
        }catch(Exception e){
            e.printStackTrace();
        }
        System.out.println("Complete mPower");
    }

}

HelloJob .java(JobClass)
-------------------------

package test;

import java.util.Date;

import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

public class HelloJob implements Job {

    public HelloJob() {
    }

    public void execute(JobExecutionContext context)
      throws JobExecutionException
    {
      System.err.println("Hello!  mPower Job is executing. Time : " + new Date());
    }
  }

Output:
--------------


 u can see job is exectuting after 5 sec. continuously...
 

Tuesday, January 31, 2012

IOC container of the Spring 3 framework.



Spring IoC
In this section we will learn Spring IoC with the help of many articles and ready to test example code. In this section we are exploring IOC container of the Spring 3 framework. The IOC container is the main component of the Spring framework. It provides the main IoC container and AOP framework. The core container of the Spring Framework provides important functionality including dependency injection and bean lifecycle management.
The core container is responsible for providing  essential functionality to the Spring framework. The BeanFactory is the primary component of the core container. The BeanFactory is an implementation of the Factory pattern. The core container of the Spring Framework provides Dependency Injection and Inversion of Control (IOC) functionalities.
Modules of Core Container:
Following are the modules of the Spring Core Container:
  1. Beans
  2. Core
  3. Context
  4. Expression Language
IoC
The IoC or Inversion of Control is the core features of the Spring Framework. Developers uses the IoC container to manage the beans and its dependency in the application. Thus simplifies the implementation of business logic in the application. The IoC is very important and it's very necessary to fully understand.
What is IoC?
The Inversion of Control is the process by which application defines the dependency and these dependencies are then satisfied in runtime by the Spring Framework. The IoC is also known as Dependency Injection(DI).
I the application dependencies are satisfied through:
  1. Constructor Injection
    Here the IoC container injects the dependency through the constuctor.
     
  2. Setter Injection
    The setter injection is done through the setters (setter method).
     
  3. Interface Injection
    The spring does not provide direct Interface Injection functionality.
In this section we will be presenting the examples of Spring Core module.

Saturday, January 28, 2012

Jar Required for Spring (Basic)


 For Typical Application

  • spring-asm-3.0.2.RELEASE
  • spring-beans-3.0.2.RELEASE
  • spring-context-support-3.0.2.RELEASE
  • spring-core-3.0.2.RELEASE
  • spring-context-3.0.2.RELEASE
  • spring-expression-3.0.2.RELEASE
  • spring-web-3.0.2.RELEASE
  For Using AOP, ORM, TAGLIB, JMS,STRUTS, JDBC etc...

  • cglib-2.2
  • commons-logging-1.1
  • jstl
  • spring-aop-3.0.2.RELEASE
  • spring-aspects-3.0.2.RELEASE
  • spring-instrument-3.0.2.RELEASE
  • spring-instrument-tomcat-3.0.2.RELEASE
  • spring-jdbc-3.0.2.RELEASE
  • spring-jms-3.0.2.RELEASE
  • spring-orm-3.0.2.RELEASE
  • spring-oxm-3.0.2.RELEASE
  • spring-struts-3.0.2.RELEASE
  • spring-test-3.0.2.RELEASE
  • spring-tx-3.0.2.RELEASE
  • spring-webmvc-3.0.2.RELEASE
  • spring-webmvc-portlet-3.0.2.RELEASE
  • standard
  For Include External Resource Such as CSS,JS,IMAGES,ICON etc...
  • org.springframework.js-2.0.2.RELEASE

    Friday, January 6, 2012

    Always Leave Office On Time.......

    Always Leave Office On Time
    Why ?

    1. Work is never ending process. You can never finish the work.

    2. Interest of a client is not more important than your family.

    3. If you fail in life your boss or client will not be the person to offer a helping hand but your
    family and friends will do.

    4. Life does not mean coming to office, going home and sleeping. There is more to a life. You
    need time to socialize, entertainment, exercise and relaxation. Don't make your life meaningless.

    5. A person who sits in office till late is not a hardworking person. He just don't know how to
    manage work within the stipulated time.

    6. You did not study hard and struggle just to have a meaningless life.

    Have a balance life. We work to live , not live to work.. :)

    Disqus for yogi's talk

    comments powered by Disqus