Thursday, July 14, 2011

Ajax Browser support

No comments:
Ajax Browser support
Ajax supports all kind of browsers with small conflicts.
Older browsers like Internet Explorer 5.0 6.0 didn't support xmlHttpRequest directly so instead they are using ActiveXObject which is implemented in Explorer 5.0 and 6.0.

Latest Browsers like Firefox, Opera, Chrome, Safari and IE 8 implemented the xmlHttpRequest to support Ajax.


Note:
  At first website must satisfy a Compatible view in all kind of browsers. If you use ajax in your web Application then you have to use two kind of codes for compatibility. 


Older Browsers like IE5.0 and IE6.0
xmlhttp = new ActiveXObject("Microsoft.XMLHttpRequest");


For Latest Browsers
xmlhttp = new XMLHttpRequest();

So using the above code creates an object for all kind of browsers. No more compatible issue in using Ajax. 

Code for Checking Browser Compatibility
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
} 

--
Thank you.


http://ajaxtutorialonline.blogspot.com/2010/06/ajax-browser-support.html



Read More

Sunday, July 10, 2011

String to Date format by str_to_date()

No comments:

String to Date format by str_to_date()

Converting string data to date format by using str_to_date() function to insert to mysql table 

Storing string data in mysql table date field by converting to date format by str_to_date function 

We know we have to use particular format for date & time field before storing to mysql date field. So if a user entered data is to be stored in a table then we have to change the format by using different string functions and convert them to acceptable date format. You can read this tutorial to know how the string functions are used to format the user entered data to mysql table. 

By using the function str_to_date() we can convert the string data to mysql required format of date field. This function requires the string data and the format in which it is available.

str_to_date(string_data, format)

If the format is not supported by the string data given then the output will be NULL. For any illegal date or time string value also the output will be NULL. 

Now let us try with some examples of this str_to_date function and its outputs.

SELECT STR_TO_DATE('12/15/2008', '%m/%d/%Y');

Output of above query is 2008-12-15

Same way here are some examples and the outputs of str_to_date function for your understanding 

STR_TO_DATE('Dec/15/2008', '%M/%d/%Y'); => 2008-12-15
STR_TO_DATE('31/Jan/2008', '%d/%M/%Y'); => 2008-01-31
STR_TO_DATE( '31/Jan/2008 23:52', '%d/%M/%Y %H:%i' ) => 2008-01-31 23:52:00

Try with some illegal date

STR_TO_DATE( '32/Apr/2008', '%d/%M/%Y' ) => NULL


--
Thank you.

http://www.plus2net.com/sql_tutorial/str_to_date.php



Read More

Thursday, June 30, 2011

struts2+Spring workflow

No comments:

struts2+Spring workflow

1. An initial request goes to the Servlet container (such as Jetty or Resin) which is passed through a standard filter chain.

2. the required FilterDispatcher is called, which in turn consults the ActionMapper to determine if the request should invoke an action.


3. The ActionMapper interface provides a mapping between HTTP requests and action invocation requests and vice-versa.

When given an HttpServletRequest, the ActionMapper may return null if no action invocation request matches, or it may return an ActionMapping that describes an action invocation for the framework to try.

If the ActionMapper determines that an Action should be invoked, the FilterDispatcher delegates control to theActionProxy.

4. The ActionProxy consults the framework Configuration Files manager (initialized from the struts.xml file).

5. the ActionProxy creates an ActionInvocation, which is responsible for the command pattern implementation. This includes invoking any Interceptors (the before clause) in advance of invoking the Action itself.

6. Once the Action returns, the ActionInvocation is responsible for looking up the proper result associated with the Action result code mapped in struts.xml.

7. The result is then executed, which often (but not always, as is the case for Action Chaining) involves a template written in JSP or FreeMarker to be rendered.


8. While rendering, the templates can use the Struts Tags provided by the framework.

9. All objects in this architecture (Actions, Results, Interceptors, and so forth) are created by anObjectFactory.

This ObjectFactory is pluggable. We can provide our own ObjectFactory
A popular ObjectFactory implementation uses Spring as provided by the Spring Plugin.

Normally, in struts.xml you specify the class for each Action. When using the default SpringObjectFactory, the framework will ask Spring to create the Action and wire up dependencies as specified by the default auto-wire behavior.


10. Interceptors are executed again (in reverse order, calling the after clause).


11. Finally, the response returns through the filters configured in the web.xml.


N.B:
don't know how to setup simple struts2 project? see simple setup
Read More

How to import NetBeans project into Eclipse

No comments:

How to import NetBeans project into Eclipse

netbeansFew days ago, when I faced some issues with NetBeans IDE, I switched to Eclips. Now the problem was my work. Placing java files from one place to another seems easy. But preparing configuration file is really time-consuming. And as usual I avoid manual work. SO let's see what I did to import NetBeans workspace into Eclipse without wasting time
1


  1. There is a dist folder inside NetBeans workspace, containing a .war file. Import this war file into Eclipse. For this;
    1. Open eclips IDE > Go to File Menu => Import => War
  2. Above step will make package structure in Eclipse workspace similar to NetBeans. It'll also prepare configuration file. Now you need to place source files only. For this
    1. Go to src folder inside NetBeans folder => Copy all contents => Place them to src folder inside NetBeans folder.
    2. Right click on Project name in right side panel of Eclipse IDE => Refresh

Your Eclipse workspace is prepared. If above trick doesn't work for you refer another way;

2


OVERVIEW OF THE PROCESS

  1. Lets say you already have a NetBeans project created called MyProjectand located at <PATH>\MyProject
  2. open NetBeans and change the project settings
  3. create a ZIP file of the <PATH>\MyProject\MyProject.zip
  4. create a new folder <PATH>\NEW (or your choice), this is where we are going to create the Eclipse Project
  5. open Eclipse create a new project and import the ZIP file
  6. create a new folder <PATH>\NEW\MyProject\dist(necessary forNetBeans)
  7. Now you can DECIDE when to work with Eclipse or NetBeans

DETAILED PROCESS

  1. Let's say you already have a NetBeans project created called MyProjectand located at <PATH>\MyProject
  2. open NetBeans
    • open MyProject
    • Right click MyProject and select Clean Project (this deletes thebuild/classed and dist folders)
    • open the file project.properties located in the folder<PATH>\MyProject\nbproject
    • change the build.dir to bin
    • change the build.classed.dir to ${build.dir}
    • save and close the file

close NetBeans

  1. create a ZIP file of the <PATH>\MyProject\MyProject.zip that will contain this folders:
    • nbproject
    • src
    • Any other folder or file that is located at <PATH>\MyProject
  2. create a new folder <PATH>\NEW (or your choice), this is where we are going to create the Eclipse Project
  3. open Eclipse
    • go to Window, Open Perspective, Java
    • go to File, New, Project, Java Project
    • click NEXT
    • type MyProject
    • select Create project at external location
    • type <PATH>\NEW\MyProject (this folder will be created by ECLIPSE)
    • select Create separate source and output folders
    • click NEXT
    • click FINISH
    • Right click on MyProject (at the Package Explorer)
    • select IMPORT
    • select ZIP file (usually the last option on the list)
    • click NEXT
    • BROWSE and look for the <PATH>\MyProject\MyProject.zip created onSTEP 3
    • click FINISH

close Eclipse

  1. create a new folder <PATH>\NEW\MyProject\dist(necessary forNetBeans)
  2. Now you can DECIDE when to work with Eclipse or NetBeans



Read More

Choosing a date time picker UI – jQuery

No comments:

Choosing a date time picker UI – jQuery

by VEERA on JUNE 19, 2011

in WEB

I had a requirement to add an input control for users to select date time range. User will be selecting two values – start time and end time. For both the values, the date is same. Only the time differs. For example, the values could be 6/19/2011 10:30 to 6/19/2011 11:30.

I am using jQuery UI library for my web-app. So, I started searching for a date time picker widget with an option to choose a time range. The built-indatepicker does not have the ability to choose a time. But thanks to Trent, there's a plug-in I found to add timepicker to jQuery datepicker. With that, I came up with the design which initially looked like this:

datetime picker ui - jquery

The control functioned as I expected. I deployed the app with this UI and tried it for a week to find out if there's an usability issue. And, yes! There was some difficulties I found while using this date time picker.

  1. It was too many clicks – one to choose a date, one to choose a hour and one to choose the minutes. Additionally, there's a second input date too for which I had to repeat these clicks again – so a total of six clicks just to enter two input values. Not good!
  2. On the time picker slider, the hour and minute slides are disconnected. Means, you need to separately choose these two. I found this a lot more confusing. Also, while in a hurry, this confusion will lead to dissatisfaction with my application. Again, not good.

So, I decided to come up with some other way to enter the start time and end time. After googling a while and self brainstorming, I decided to go with a single date control and single time control. Hence, my current UI looks like this:

date time picker - improved ui - jQuery

Now it is a lot more simplified – just a textbox and a slider. And, the number of clicks user has to make is just three (compare it with the six of previous approach). It looks more elegant and fit too on my form.

So, now a question to you – which datetime picker UI would you prefer?First one or the second one?


--
Thank to http://veerasundar.com/




Read More