<?xml version="1.0" encoding="UTF-8" standalone="no"?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:gd="http://schemas.google.com/g/2005" xmlns:georss="http://www.georss.org/georss" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:thr="http://purl.org/syndication/thread/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-243792444529211508</atom:id><lastBuildDate>Thu, 19 Dec 2024 03:18:08 +0000</lastBuildDate><category>jQuery</category><category>Struts</category><category>Design Pattern</category><category>Twitter</category><category>Web Design</category><category>oracle</category><title>Mohammad Abul Khaer</title><description>I will write here various article about programming, database, web design etc</description><link>http://makhaer.blogspot.com/</link><managingEditor>noreply@blogger.com (Khaer)</managingEditor><generator>Blogger</generator><openSearch:totalResults>9</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><language>en-us</language><itunes:explicit>no</itunes:explicit><copyright>Mohammad Abul Khaer</copyright><itunes:keywords>web,java,jQuery</itunes:keywords><itunes:summary>I'm writing here various programming technologies including web to java.</itunes:summary><itunes:subtitle>I'm writing here various programming technologies including web to java.</itunes:subtitle><itunes:category text="Technology"><itunes:category text="Software How-To"/></itunes:category><itunes:category text="Technology"><itunes:category text="Gadgets"/></itunes:category><itunes:author>Mohammad Abul Khaer</itunes:author><itunes:owner><itunes:email>khaer.mohammad@gmail.com</itunes:email><itunes:name>Mohammad Abul Khaer</itunes:name></itunes:owner><item><guid isPermaLink="false">tag:blogger.com,1999:blog-243792444529211508.post-6899113714483831407</guid><pubDate>Fri, 12 Jul 2013 16:05:00 +0000</pubDate><atom:updated>2013-07-12T09:09:06.101-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Design Pattern</category><title>How decorator pattern works</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div style="text-align: justify;"&gt;
Decorator is a structural pattern that adds additional responsibility to the object at run time. This pattern adds responsibility to a particular object not on the class. As a result different object of same type can have different responsibilities.&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
I would explain a real life example from my experience. I am a biker. Every morning I go to office riding on my bike. When I bought this bike the seller just sold the standard bike to me. They didn't provide any tail light, head light, mud guard and even the kickstand with the bike. Later I added or decorated my bike by adding a tail light, mud guard and with a kickstand. So, functionality of each of this component is different. I added them with my bike and they are responsible for additional functionalities. This can be thought of as a decorator pattern example. Here first I have the bike with standard installation. Then I decorated it with other component.&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
Participants in a decorator pattern are&lt;br /&gt;
&lt;ul style="text-align: left;"&gt;
&lt;li&gt;Component interface&lt;/li&gt;
&lt;li&gt;a Concrete implementation of Component&lt;/li&gt;
&lt;li&gt;An abstract decorator&lt;/li&gt;
&lt;li&gt;One or more concrete decorator that will extend abstract decorator&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
Basic class diagram is as follows. Later I will add the bike example decorator&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;/div&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFmsIf8hwGlycOBD_iU9rMvZG6sLrx-G0afGN70xqD7aHRi3ocrUOa7m6QIEYLZahWLC27gPc-h0i5d5UNAXaL9Yjem1VEmhXth2ws2S1MxzRTWbgNwALhQD99SYAKHkyDRoRRuP7Hf-oS/s405/decorator.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFmsIf8hwGlycOBD_iU9rMvZG6sLrx-G0afGN70xqD7aHRi3ocrUOa7m6QIEYLZahWLC27gPc-h0i5d5UNAXaL9Yjem1VEmhXth2ws2S1MxzRTWbgNwALhQD99SYAKHkyDRoRRuP7Hf-oS/s1600/decorator.jpg" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Figure 1: Decorator pattern&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
Here &lt;b&gt;ConcreteDecorator &lt;/b&gt;is the standard component that has to be decorated. In my example it is my bike.&amp;nbsp;&lt;b&gt;Decorator &lt;/b&gt;abstract class contains a reference of &lt;b&gt;&lt;i&gt;component&lt;/i&gt;. &lt;/b&gt;Each of the concrete decorator adds additional responsibility to the standard object. Now lets dive to the bike example. Participants for this example are&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Bike&lt;/b&gt; as the &lt;b&gt;Component&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;StandardBike&amp;nbsp;&lt;/b&gt;as the &lt;b&gt;ConcreteComponent&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;BikeDecorator &lt;/b&gt;as the abstract &lt;b&gt;Decorator&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;TailLightDecorator &lt;/b&gt;as the &lt;b&gt;ConcreteDecorator&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
So, the diagram for bike example is as follows&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEirnAXGlpvap65wzJOCQKQ-RN-6R6gP9CasCyZDQBLqh39EViNuh4PLh3vZweT68BW4nuEOZaPH5-X73XEKToNrjOjRAecNXtXyicpsur5_NaczIfb4mhHaQv9ytcNaqhVnOceJedOsCG5O/s1600/bike-decorator.jpeg" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEirnAXGlpvap65wzJOCQKQ-RN-6R6gP9CasCyZDQBLqh39EViNuh4PLh3vZweT68BW4nuEOZaPH5-X73XEKToNrjOjRAecNXtXyicpsur5_NaczIfb4mhHaQv9ytcNaqhVnOceJedOsCG5O/s1600/bike-decorator.jpeg" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Figure 2: Diagram of bike decorator&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;br /&gt;
The code for each of the component are given below&lt;br /&gt;
&lt;br /&gt;
Bike interface is as follows&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: java"&gt;public interface Bike {
  public String ride();
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;pre class="brush: java"&gt;public class StandardBike implements Bike{
 @Override
 public String ride(){
  return " This is a standard bike";
 }
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;pre class="brush: java"&gt;public abstract class BikeDecorator implements Bike{

 protected Bike bike;
 
 public BikeDecorator(Bike pBike){
  this.bike = pBike;
 }
 
 @Override
 public String ride(){
  return bike.ride();
 }
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;pre class="brush: java"&gt;public class TailLightDecorator extends BikeDecorator {

 public TailLightDecorator(Bike pBike) {
  super(pBike);
 }

 @Override
 public String ride() {
  return bike.ride() + turnOnLight();
 }

 public String turnOnLight() {
  return " + tail light";
 }
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;pre class="brush: java"&gt;public class MudGuardDecorator extends BikeDecorator {

 public MudGuardDecorator(Bike pBike) {
  super(pBike);
 }

 @Override
 public String ride() {
  return bike.ride() + preventMud();
 }

 public String preventMud() {
  return "+ mud guard";
 }
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;pre class="brush: java"&gt;public class Client {

 public static void main(String [] args){
  MudGuardDecorator md = new MudGuardDecorator(new TailLightDecorator(new StandardBike()));
  System.out.println(md.ride());
 }
 
}
&lt;/pre&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="blogger-post-footer"&gt;Technology never stops.&lt;/div&gt;</description><link>http://makhaer.blogspot.com/2013/07/how-decorator-pattern-works.html</link><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFmsIf8hwGlycOBD_iU9rMvZG6sLrx-G0afGN70xqD7aHRi3ocrUOa7m6QIEYLZahWLC27gPc-h0i5d5UNAXaL9Yjem1VEmhXth2ws2S1MxzRTWbgNwALhQD99SYAKHkyDRoRRuP7Hf-oS/s72-c/decorator.jpg" width="72"/><thr:total>1</thr:total><author>khaer.mohammad@gmail.com (Mohammad Abul Khaer)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-243792444529211508.post-7305870785001964041</guid><pubDate>Tue, 02 Jul 2013 16:32:00 +0000</pubDate><atom:updated>2013-07-02T09:32:01.370-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Twitter</category><title>How to query for tweets using twitter4j</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
Twitter has killed their API 1.0 on June 11, 2013. Now you cannot do a search query without authentication. Twitter4j is an excellent library for java developers to implement twitter things. You can update status, get a timeline, query for tweets using this library. Here I am going to show you how to query using twitter4j library&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: java"&gt;Twitter twitter = new TwitterFactory().getInstance();

        AccessToken accessToken = new AccessToken("You-Access-Token-Key", "Your-Access-Token-Secret-Key");
        twitter.setOAuthConsumer("Your-Consumer-Token-Key", "Your-Consumer-Token-Secret-Key");
        twitter.setOAuthAccessToken(accessToken);

        try {
            Query query = new Query("#Shahbag");
            QueryResult result;
            result = twitter.search(query);
            List&lt;status&gt; tweets = result.getTweets();
            for (Status tweet : tweets) {
                System.out.println("@" + tweet.getUser().getScreenName() + " - " + tweet.getText());
            }
        }
        catch (TwitterException te) {
            te.printStackTrace();
            System.out.println("Failed to search tweets: " + te.getMessage());
        }
&lt;/status&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div class="blogger-post-footer"&gt;Technology never stops.&lt;/div&gt;</description><link>http://makhaer.blogspot.com/2013/06/how-to-query-for-tweets-using-twitter4j.html</link><thr:total>0</thr:total><author>khaer.mohammad@gmail.com (Mohammad Abul Khaer)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-243792444529211508.post-7473619419175705127</guid><pubDate>Mon, 07 Sep 2009 10:15:00 +0000</pubDate><atom:updated>2012-11-17T05:36:16.596-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">oracle</category><title>Oracle Export, Import using sqlplus</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
I will write here about oracle export,import using sqlplus. I assumed that you have basic idea about oracle, sql.&lt;br /&gt;
&lt;br /&gt;
There may situation like follows:-&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;You want to copy some tables from one schema to another schema&lt;/li&gt;
&lt;li&gt;You want to copy a schema into another database&lt;/li&gt;
&lt;li&gt;You want to copy table rows from one schema to another schema&lt;/li&gt;
&lt;/ul&gt;
You can do this using oracle export, import facilities. These two facilities are really powerful to smooth data transfer. Usually I do this using sqlplus command facilities.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt;ExportProcess&lt;/span&gt; :&lt;br /&gt;
At first you need to create dump file. Enter command prompt then type &lt;span style="font-weight: bold;"&gt;exp&lt;/span&gt; in the prompt. It will ask for userid and password of the schema. Suppose your schema is &lt;span style="font-weight: bold;"&gt;ab&lt;/span&gt;&lt;span style="font-weight: bold;"&gt; &lt;/span&gt;and listener name is &lt;span style="font-weight: bold;"&gt;biis &lt;/span&gt;and password is &lt;span style="font-weight: bold;"&gt;ab&lt;/span&gt;. Then type mak@iis and then password makiis.&lt;br /&gt;
&lt;br /&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj2dPjQeq0im0tOruHIPsAez9DRWfEy4NojI8C7zR6mVZtZA01Eu6CFsqah3MTkF4F03ihoAdN9ZsrJxfMD3_2jKRlhLzgpqniH5J52zzmNtLQ-kbQVnb1uQ4bYuGjWmbLNyBMdhZNydcmP/s1600-h/exp.JPG" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"&gt;&lt;img alt="" border="0" id="BLOGGER_PHOTO_ID_5378989723350718562" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj2dPjQeq0im0tOruHIPsAez9DRWfEy4NojI8C7zR6mVZtZA01Eu6CFsqah3MTkF4F03ihoAdN9ZsrJxfMD3_2jKRlhLzgpqniH5J52zzmNtLQ-kbQVnb1uQ4bYuGjWmbLNyBMdhZNydcmP/s400/exp.JPG" style="cursor: pointer; display: block; height: 603px; margin: 0px auto 10px; text-align: center; width: 636px;" /&gt;&lt;/a&gt;&lt;br /&gt;
Then choose the dump file location. You may choose default directory by just entering file name or choose any other location say c:\\ab.dmp. The dump file will be stored in C drive. There are some dump options that is&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;dump full database&lt;/li&gt;
&lt;li&gt;dump a user&lt;/li&gt;
&lt;li&gt;dump tables&lt;/li&gt;
&lt;/ol&gt;
Here we dump all object(tables,grants,constraints,function,procedures,view,materialized view etc) under user &lt;span style="font-weight: bold;"&gt;ab.&lt;/span&gt; sqlplus will ask for U for user, T for tables and E for entire database. Then enter other options such as export grants, export table data, compress extend etc. After entering all the options export will start and if you see a message at the end stating that "Export terminated successfully without warnings" then dump is 100% successful.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt;Import Process:&lt;/span&gt;&lt;br /&gt;
Now you import all objects of &lt;span style="font-weight: bold;"&gt;ab &lt;/span&gt;to another user say &lt;span style="font-weight: bold;"&gt;xyz&lt;/span&gt;. For this purpose&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt; First create the user &lt;span style="font-weight: bold;"&gt;xyz&lt;/span&gt;.&lt;/li&gt;
&lt;li&gt;Then enter in cammand prompt and type &lt;span style="font-weight: bold;"&gt;imp.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;Then type username and password of the user on which you want to import objects.&lt;/li&gt;
&lt;li&gt;Then type location of dump file (c:\\ab.dump)&lt;/li&gt;
&lt;li&gt;Enter dump options&lt;/li&gt;
&lt;/ol&gt;
All objects from &lt;span style="font-weight: bold;"&gt;ab &lt;/span&gt;to &lt;span style="font-weight: bold;"&gt;xyz&lt;/span&gt; will be imported successfully.&lt;br /&gt;
&lt;br /&gt;
&lt;a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhii49OlMiygCUUsqDx3H2F_uiNKoKODkXUhBoxXZGadcz9wGZKp-AdR_Wm42vJwm1AE_rK9HQ3axJ9MPX1lEOzrvc7Tx9yuMqYxlswW_o04-6_GZp1qAzEZfrgNMxdDrmGQ_1CMXf68qEA/s1600-h/imp.JPG" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"&gt;&lt;img alt="" border="0" id="BLOGGER_PHOTO_ID_5379002999840934306" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhii49OlMiygCUUsqDx3H2F_uiNKoKODkXUhBoxXZGadcz9wGZKp-AdR_Wm42vJwm1AE_rK9HQ3axJ9MPX1lEOzrvc7Tx9yuMqYxlswW_o04-6_GZp1qAzEZfrgNMxdDrmGQ_1CMXf68qEA/s400/imp.JPG" style="cursor: pointer; display: block; height: 433px; margin: 0px auto 10px; text-align: center; width: 588px;" /&gt;&lt;/a&gt;&lt;br /&gt;
I accepted the default dump options for import and export.&lt;br /&gt;
&lt;br /&gt;
For any queries plz contact me at khaer_mohammad@yahoo.com&lt;/div&gt;
&lt;div class="blogger-post-footer"&gt;Technology never stops.&lt;/div&gt;</description><link>http://makhaer.blogspot.com/2009/09/oracle-export-import-using-sqlplus.html</link><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" height="72" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj2dPjQeq0im0tOruHIPsAez9DRWfEy4NojI8C7zR6mVZtZA01Eu6CFsqah3MTkF4F03ihoAdN9ZsrJxfMD3_2jKRlhLzgpqniH5J52zzmNtLQ-kbQVnb1uQ4bYuGjWmbLNyBMdhZNydcmP/s72-c/exp.JPG" width="72"/><thr:total>9</thr:total><author>khaer.mohammad@gmail.com (Mohammad Abul Khaer)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-243792444529211508.post-2277072791734226476</guid><pubDate>Thu, 23 Jul 2009 05:54:00 +0000</pubDate><atom:updated>2012-11-17T05:36:42.096-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Struts</category><title>Custom Request Processor in Struts</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div style="text-align: justify;"&gt;
I assume that you know the basics of struts and you are using lower version than that of struts 2.0.&lt;br /&gt;
&lt;br /&gt;
Struts is a powerful MVC framework which can be extended to do some excellent work. There may be situations where you need some regular works at every actions. Such as validating the user, checking his/her roles, log user activities etc. Struts provides a way for that. ActionServlet is the only servlet in Struts. Before redirecting to the programmer's action, ActionServlet creates an object of RequestProcessor. The RequestProcessor class in the Struts distribution provides a default implementation for each of the request-processing steps. That means you can override only the methods that interest you, and use default implementations for rest of the methods. The processPreprocess method in RequestProcessor can be overridden to do some common tasks such as&lt;br /&gt;
&lt;br /&gt;
1. Validating User Session&lt;br /&gt;
2. Validating User Role&lt;br /&gt;
3. Putting Action Form's Data Into User Log Table.&lt;br /&gt;
&lt;br /&gt;
You have to do two things to implement custom request processor in struts.&lt;br /&gt;
1. Configure struts-config.xml. You can configure this way&lt;br /&gt;
&lt;textarea cols="60" readonly="readonly" rows="3"&gt;&lt;controller&gt;&lt;set-property property="processorClass" value="mypackage.MyRequestProcessor"&gt;&lt;/set-property&gt;&lt;/controller&gt;&lt;/textarea&gt;&lt;br /&gt;
Be sure to put above lines after the ending of action-mappings.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
2.  Create a class for example MyRequestProcessor extending class RequestProcessor and override the method processPreprocess for example. You can override any other method. The processPreprocess always return true. Returning false from this method     will abort request processing. For example if user is not valid for the requested action then you may return false.&lt;br /&gt;
Before going to details let us see the sequence of processing a request in struts. Suppose user is requesting the action UserAction.&lt;br /&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;
user request----&amp;gt; ActionServlet---&amp;gt;RequestProcessor --if processPreprocess return true--&amp;gt;UserAction&lt;br /&gt;
&lt;br /&gt;
If you are overriding processPreprocess of RequestProcessor using your MyRequestProcessor then you can control user access.&lt;br /&gt;
&lt;br /&gt;
Here is the sample code for MyRequestProcessor&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;public class MyRequestProcessor
extends RequestProcessor {
  protected boolean processPreprocess (
      HttpServletRequest request,
      HttpServletResponse response) {
      HttpSession session = request.getSession(false);
  //If user is trying to access login page
  // then don't check
  if( request.getServletPath().equals("/loginInput.do")
      || request.getServletPath().equals("/login.do") )
      return true;
  //Check if userName attribute is there is session.
  //If so, it means user has allready logged in
  if( session != null &amp;amp;&amp;amp;
  session.getAttribute("userName") != null){
      return true;
//if user session is valid then check user requesting action is valid or not.
//you can check this from your database table or any other way. I assumed that user
//actions is saved in database.
boolean validRole = checkUserRoleFromDB(&lt;/code&gt;&lt;code&gt;session.getAttribute("userName")&lt;/code&gt;
&lt;code&gt;); // not implemented

if(validRole)
return true;

}
  else{
      try{
          //If no redirect user to login Page
          request.getRequestDispatcher
              ("/Login.jsp").forward(request,response);
      }catch(Exception ex){
      }
  }


  return false;
}


}&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="blogger-post-footer"&gt;Technology never stops.&lt;/div&gt;</description><link>http://makhaer.blogspot.com/2009/07/custom-request-processor-in-struts.html</link><thr:total>10</thr:total><author>khaer.mohammad@gmail.com (Mohammad Abul Khaer)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-243792444529211508.post-1500647653042265806</guid><pubDate>Sun, 22 Feb 2009 12:37:00 +0000</pubDate><atom:updated>2012-11-17T05:37:04.633-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Struts</category><title>Preventing Duplicate Form Submission in Struts using TOKEN</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
Duplicate form submission may occur in the following situations:-&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Using Refresh button &lt;/li&gt;
&lt;li&gt;Using the browser back button to traverse back and resubmit form &lt;/li&gt;
&lt;li&gt;Using Browser history feature and re-submit form. &lt;/li&gt;
&lt;li&gt;Malicious submissions to adversely impact the server or personal gains &lt;/li&gt;
&lt;li&gt;Clicking more than once on a transaction that take longer than usual&lt;/li&gt;
&lt;/ul&gt;
What happens in form submission? Suppose you have a form named adduser.jsp and an Action named saveUser.do. So, on clicking submit in the adduser.jsp page struts finds the mapping saveUser.do and redirect to this url. So, in the browser url you will find /app/saveUser.do.&lt;br /&gt;
and when you click on refresh same url is called and same form is submitted again. Struts provides several ways to protect this.&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;HTTP redirect after form submission&lt;/li&gt;
&lt;li&gt;using TOKEN&lt;/li&gt;
&lt;/ul&gt;
&lt;span style="font-weight: bold;"&gt;HTTP redirect&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Suppose form submission result is shown in a page called success.jsp. So, if redirect is set true in forward of action in struts.config URL in the URL bar becomes /app/success.jsp. So, if you refresh on again the success.jsp is called not the /app/saveUser.do. So, in this way we can protect against refresh. But, unfortunately this does not protect against goint to back button of browser and submit the form again.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt;Using TOKEN&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
This method generates a Token using session id, current time and messagediagest and save this token to session. The action responsible for rendering the form save the token using saveToken method. So, the session is saved in session and a hidden field name token with the value is set to html form. If you view the source of html form page you will find the hidden form as follows&lt;br /&gt;
&lt;br /&gt;
&lt;pre id="line406"&gt;&amp;lt;&lt;span class="start-tag"&gt;input&lt;/span&gt;&lt;span class="attribute-name"&gt; type&lt;/span&gt;=&lt;span class="attribute-value"&gt;"hidden" &lt;/span&gt;&lt;span class="attribute-name"&gt;name&lt;/span&gt;=&lt;span class="attribute-value"&gt;"org.apache.struts.taglib.html.TOKEN"&lt;/span&gt;&lt;span class="attribute-name"&gt;value&lt;/span&gt;=&lt;span class="attribute-value"&gt;"some value"&lt;/span&gt;&amp;gt;&lt;/pre&gt;
When client submit the form this hidden field also submitted. Struts check the two TOKEN (token from session and token submitted). We can check the two token using isTokenValid method. If they are equal this method returns true and the form is submitted for the first time. If not equal then duplicate form submission. Checking code is shown below:-&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;&lt;br /&gt;if(isTokenValid(request))&lt;br /&gt;resetToken(request);&lt;br /&gt;else{&lt;br /&gt;request.setAttribute("brtcerror","Duplicate Form Submission Error");&lt;br /&gt;return mapping.findForward("error");&lt;br /&gt;}&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt;resetToken &lt;/span&gt;method is used to clear the Token set for this action. Because if you have multiple form you must clear the Token. Other wise for new form you will always find duplicate form submission error. Suppose action addUser renders adduser.jsp page. So, you have to save token in addUser corresponding class by calling &lt;span style="font-weight: bold;"&gt;saveToken(request)&lt;/span&gt; method. You should validate this token in the submit action which is&lt;span style="font-weight: bold;"&gt; saveUser.do&lt;/span&gt; here.&lt;/div&gt;
&lt;div class="blogger-post-footer"&gt;Technology never stops.&lt;/div&gt;</description><link>http://makhaer.blogspot.com/2009/02/preventing-duplicate-form-submission-in.html</link><thr:total>4</thr:total><author>khaer.mohammad@gmail.com (Mohammad Abul Khaer)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-243792444529211508.post-1765172665093250548</guid><pubDate>Sat, 20 Dec 2008 10:56:00 +0000</pubDate><atom:updated>2012-11-17T05:37:59.567-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">jQuery</category><title>jQuery Autocomplete</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
Autocomplete using jQuery is quite easy. jQuery made this cumbersome work easy for programmers.&lt;br /&gt;
&lt;br /&gt;
So what is needed for autocomplete feature in your page&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;jquery.js&lt;/li&gt;
&lt;li&gt;jquery.autocomplete.js&lt;/li&gt;
&lt;li&gt;jquery.autocomplete.css file&lt;/li&gt;
&lt;/ol&gt;
Just include  these three files in header. Ad the following script to your header&lt;br /&gt;
&lt;br /&gt;
&lt;div align="center" style="color: green; text-align: left;"&gt;
&lt;pre&gt;function showItem(row) {
return row[0];
}

$(document).ready(function() {
$("#category").autocomplete(
 "getcategory.php",
 {
  minChars:1,
  max: 200,
  scrollHeight: 180,
  formatItem:showItem
 }
);
});&lt;/pre&gt;
&lt;/div&gt;
Let us depicts about the above code segments. Here #category means the category id on which you want autocomplete feature. and "getcategory.php" is the server side file which will provide result for autocomplete.&lt;br /&gt;
&lt;br /&gt;
Now let us discuss about the parameters.&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt;minChars&lt;/span&gt;: minimum character in the input to call autocomplete&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt;max:&lt;/span&gt; maximum item in the list. No more items exceeding this value will not be displayed. Its default value is 10&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt;scrollHeight:&lt;/span&gt; this is actually list height. If result is large scroll is needed.&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt;formatItem:&lt;/span&gt; if you want to format data you can use this parameter.&lt;br /&gt;
&lt;br /&gt;
Now how server will deliver data. Let us see the content of &lt;span style="font-weight: bold;"&gt;getcategory.php &lt;/span&gt;file&lt;br /&gt;
&lt;div style="color: green;"&gt;
&lt;br /&gt;
&lt;pre&gt;
$categories = array('IT', 'Software', 'Semantec', 'Hardware', 'Intel',
 'AMD', 'Politics', 'Economics', 'Business', 'Travel',
 'Psychology', 'Medical', 'Sports');

$q = strtolower($_GET["q"]);
$results = array();
// search categories
foreach($categories as $cat)
{
 if( strpos(strtolower($cat), $q) === 0 )
  echo "$cat\n";
}&lt;/pre&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
Now create a textbox with id "category". If you type you can view the autocomplete effect. It will display data matching to your input. If you want multiple item in your text box just set "&lt;span style="font-weight: bold;"&gt;multiple: true&lt;/span&gt;" in the autocomplete parameter list. By deafult data is separated by comma. But you can change using &lt;span style="font-weight: bold;"&gt;multipleSeparator&lt;/span&gt; parameter.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #3366ff; font-weight: bold;"&gt;View the &lt;/span&gt;&lt;a href="http://khaer.awardspace.com/blog/auto2bk/submit_report.html" style="color: #3366ff; font-weight: bold;"&gt;Demo&lt;/a&gt;&lt;span style="color: #3366ff; font-weight: bold;"&gt;.&lt;/span&gt;&lt;/div&gt;
&lt;div class="blogger-post-footer"&gt;Technology never stops.&lt;/div&gt;</description><link>http://makhaer.blogspot.com/2008/12/jquery-autocomplete.html</link><thr:total>4</thr:total><author>khaer.mohammad@gmail.com (Mohammad Abul Khaer)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-243792444529211508.post-6057787284266240963</guid><pubDate>Sat, 29 Nov 2008 06:17:00 +0000</pubDate><atom:updated>2012-11-17T05:38:27.511-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Web Design</category><title>Various Web Layouts (Fixed, Elastic, Liquid)</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div style="color: black; text-align: justify;"&gt;
&lt;span style="font-size: 100%;"&gt;&lt;span style="font-family: verdana;"&gt;Web designers basically have three layouts based on CSS. They are :-&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="color: black; font-family: verdana; text-align: justify;"&gt;
&lt;span style="font-size: 100%;"&gt;1. Fixed&lt;/span&gt;&lt;/div&gt;
&lt;div style="color: black; font-family: verdana; text-align: justify;"&gt;
&lt;span style="font-size: 100%;"&gt;2. Elastic&lt;/span&gt;&lt;/div&gt;
&lt;div style="color: black; font-family: verdana; text-align: justify;"&gt;
&lt;span style="font-size: 100%;"&gt;3. Liquid&lt;/span&gt;&lt;/div&gt;
&lt;div style="color: black; font-family: verdana; text-align: justify;"&gt;
&lt;span style="font-size: 100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="color: black; font-family: verdana; text-align: justify;"&gt;
&lt;span style="font-size: 100%;"&gt;All of the above has its own advantages and disadvantages. I will describe here details of these three.&lt;/span&gt;&lt;/div&gt;
&lt;span style="font-size: 100%;"&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;1. Fixed Layout&lt;/span&gt;Fixed layout websites looks same in all container. Whatever the monitor size, pixel it is always same. Because of its rigidity it is also called ice layout. Developer can organize elements any way he/she likes. If you set the width of your design to be 720 pixels wide, it will always be 720 pixels. If you then want a branding image spanning the top of your design, you know it needs to be 720 pixels wide to fit.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Disadvantages.&lt;/span&gt;&lt;/span&gt;   &lt;span style="font-size: 100%;"&gt;This layout cannot utilize space available. They are always same what ever the window size is. A site made for 800 600 screen resolution looks tiny in a higher resolution screen and in vice versa a site made for 1024 760 screen will cause scrolling in lower resolution. A reader with a mobile phone or a handheld computer will have to scroll laterally; a reader with a high-resolution monitor will see a narrow strip in the middle of the screen; when printing, the right-hand side can end up off-page. Besides, when the reader increases the text size, the text will sooner or later break out of a narrow column and we have an overlap that can render the page unreadable.&lt;/span&gt;&lt;span style="font-size: 100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: 100%; font-weight: bold;"&gt;2. Elastic Design Layout&lt;/span&gt;&lt;span style="font-size: 100%;"&gt;Actually elastic design mainly works on websites text. An elastic layout scales with users’ text size. Elastic design uses &lt;em&gt;em&lt;/em&gt; values for &lt;em&gt;all&lt;/em&gt; elements. Ems are a relative size, written like this: &lt;code&gt;1em&lt;/code&gt;, &lt;code&gt;0.5em&lt;/code&gt;, &lt;code&gt;1.5em&lt;/code&gt; etc. Ems can be specified to three decimal places like so: &lt;code&gt;1.063em&lt;/code&gt;.&lt;/span&gt; &lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;&lt;span style="font-size: 100%;"&gt;They are calculated based on the font size of the parent element. E.g. If a &lt;code&gt;&lt;/code&gt;&lt;div&gt;
has a computed font size of 16px then any element inside that layer —a child— inherits the same font size unless it is changed. If the child font size is changed to 0.75em then the computed size would be 0.75 × 16px = 12px.&lt;/div&gt;
&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="font-size: 100%;"&gt;If the user increases (or decreases) text size in their browser, the whole interface stretches (or shrinks.)&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;span style="font-size: 100%;"&gt;&lt;span style="font-weight: bold;"&gt;Disadvantages&lt;/span&gt;It has same disadvantages like liquid design except that it doesn't break because of changes in text size.&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style="color: black; font-family: verdana; text-align: justify;"&gt;
&lt;span class="Apple-style-span" style="font-size: 100%; font-weight: bold;"&gt;3. Liquid/Fluid Layout&lt;/span&gt;&lt;/div&gt;
&lt;div style="color: black; font-family: verdana; text-align: justify;"&gt;
&lt;span class="Apple-style-span" style="color: #232323; font-size: 100%; line-height: 19px;"&gt;&lt;span class="Apple-style-span"&gt;Liquid layout specify width height using percentage instead of px or em. For web designers the monitor screen does not have fixed width or height because these variables change, at times in unpredictable ways. People might have larger buttons, toolbars such as Yahoo or Google, they open the Favorites page on the left, they have a double task bar and so on.&lt;/span&gt;&lt;strong style="font-weight: normal; margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span"&gt;Therefore the width and height of the screen is different from user to user&lt;/span&gt;&lt;/strong&gt;&lt;span class="Apple-style-span"&gt;. &lt;span class="Apple-style-span" style="color: black; line-height: normal;"&gt;By the name liquid this type of design implies that what ever the container that is monitor or browser the layout will be furnished according to the space. So, high, low resulution is not a problem for liquidly designed site. Main point about liquid design is &lt;span class="Apple-style-span" style="font-weight: bold;"&gt;accessibility.&lt;/span&gt; Liquid design eliminates irritating design flows such as much white space, disapperance of certain sections etc.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="color: black; font-family: verdana; text-align: justify;"&gt;
&lt;span style="font-size: 100%;"&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Disadvantages&lt;/span&gt;&lt;br /&gt;Too much content required for this type of layout. Too much content can confuse user.The lines of text become way too long on a large monitor Overlap is hard to avoid in small windows when a column becomes too narrow to contain long words. CSS provides a solution for both problems (max-width and min-width), but Internet Explorer doesn't support any of those.&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style="color: black; font-family: verdana; text-align: justify;"&gt;
&lt;span style="font-size: 100%;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size: 100%;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="blogger-post-footer"&gt;Technology never stops.&lt;/div&gt;</description><link>http://makhaer.blogspot.com/2008/11/various-web-layouts-fixed-elastic.html</link><thr:total>2</thr:total><author>khaer.mohammad@gmail.com (Mohammad Abul Khaer)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-243792444529211508.post-5594554947291686883</guid><pubDate>Mon, 10 Nov 2008 11:28:00 +0000</pubDate><atom:updated>2012-11-17T05:38:59.016-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">jQuery</category><title>Simple Ajax Using jQuery</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Ajax is a technique for handling data without reloading a page or without sending a postback. Often we want a loading indicator while Ajax request (xmlhttp request) is processing. A simple example is gmail email load indicator. Implementing this requirement using jQuery is quite easy. Interesting fact is that jQuery encapsulates ajax events which makes development task for programmer easy. We will use &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;ajaxSend &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;and &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;ajaxComplete &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;events of jQuery. &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;ajaxSend &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;attach a function that should be executed before an ajax request is sent. On the other hand &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;ajaxComplete &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;attach a function that should be executed when an ajax request completes.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;Here are the steps:-&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;1. include the jquery.js file. Download it from &lt;/span&gt;&lt;/span&gt;&lt;a href="http://jquery.com/"&gt;&lt;span class="Apple-style-span"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="color: #3333ff;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;http://jquery.com&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;script src="/path/jquery.js" type="text/javascript"&gt;&lt;/script&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;2.bind an event to the div where loading image placed.Initially the div id "&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;loading"&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&amp;nbsp;is hidden.&amp;nbsp;Code example is given below:-&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;$(document).ready(function()&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;/*shows the loading div every time we have an Ajax call*/&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;$("#loading").bind("ajaxSend", function(){&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;$(this).show();&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;}).bind("ajaxComplete", function(){&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;$(this).hide();&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;});&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;});&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;The above code means when an ajax request is sent the div id "loading" is shown and when request completes the div hide again.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;3. Call a javascript function on an event such as button click. Suppose that the javascript function is &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;callAjax&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;4. jQuery has several variations of calling ajax. They are quite easy and friendly for programmers. They reduces headeche for various ajax states. Please check &lt;/span&gt;&lt;/span&gt;&lt;a href="http://docs.jquery.com/Ajax"&gt;&lt;span class="Apple-style-span"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="color: #6633ff;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;this link&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt; for ajax functions. I used here $.get. Examples is given below:-&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;$.get("test.php", { name:'john',age:20},callbackfunction);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class="Apple-style-span"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: verdana;"&gt;5. Now parse the result if you put it in xml response and put where you want. If you return not xml but some html then you can put inside a div or other using innerHTML.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class="Apple-style-span" style="font-family: -webkit-monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="blogger-post-footer"&gt;Technology never stops.&lt;/div&gt;</description><link>http://makhaer.blogspot.com/2008/11/simple-ajax-using-jquery.html</link><thr:total>2</thr:total><author>khaer.mohammad@gmail.com (Mohammad Abul Khaer)</author></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-243792444529211508.post-2154245775386457344</guid><pubDate>Thu, 16 Oct 2008 09:31:00 +0000</pubDate><atom:updated>2012-11-17T05:39:24.336-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">jQuery</category><title>jQuery selector example</title><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;span style="color: black;"&gt;Selector is most important part of jQuery. Here is some example how you can use jQuery to select an element from your html document. Suppose you have text box with id "user". Then the code to equivalent to document.getElementById("user").value is $("#user").val().&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: black;"&gt;Look, here the slash (#) symbol denotes the id. if you use this slash symbol that means you are accessing the element by its id.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: black; font-weight: bold;"&gt;var userName = $("#user").val();&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: black;"&gt;The above line get the value of user text field. Now to set a value to user text box you have to write the following code:-&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: black; font-weight: bold;"&gt;$("#user").val("John");&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: black;"&gt;Now, how to get an element by its name. jQuery give an easy command to do this.&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: black;"&gt;var stRoll = $("input[name=roll]"). If you have a radio group,textbox group, checkbox group with same name then the above code can be use to get value of all elements in the group.&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: black; font-weight: bold;"&gt;&lt;br /&gt;var values  = new Array();&lt;br /&gt;student = $("input[name=departments]");&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: black; font-weight: bold;"&gt;Below is some other examples of jQuery selectors:-&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: black;"&gt;$('div.panel')   -   All divs with class="panel"&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: black;"&gt;$('p#intro')  -   The paragraph with id="intro"&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: black;"&gt;$('div#content a:visible') -  All visible links inside the div with id="content"&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: black;"&gt;$('input[@name=email]')   -  All input fields with name="email"&lt;/span&gt;&lt;span style="color: black; font-weight: bold;"&gt;&lt;br /&gt;&lt;br /&gt;Below is some use of the above selectors:-&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: black;"&gt;$('div#primary').width(300)    -  Set the width of div id=“primary” to 300 px.&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: black;"&gt;$'p').css('line-height', '1.8em')  -  Apply a line-height of 1.8em to all paragraphs.&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: black;"&gt;$('li:odd').css({color: 'white', backgroundColor: 'black'})  -  Apply two CSS rules to every other list item; note that the css() function can take an object instead of two strings.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt;Here are some examples of methods that read values from the first matched element:&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
var width = $('#content').width() - How wide is the element with id content on the page&lt;br /&gt;
var src = $('img').attr('src') - What’s the src attribute of the first image on the page&lt;br /&gt;
var color = $('h1').css('color') - What colour is the first h1&lt;br /&gt;
&lt;br /&gt;
Interesting matter is that jquery methods used to set attribute is just a little modification of above codes. Just setting one or two arguments or setting one arguments representing multiple values can set attribute.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-weight: bold;"&gt;Here are examples:-&lt;/span&gt;&lt;br /&gt;
var width = $('#content').width("100px") - setting width to element with id content&lt;br /&gt;
var src = $('img').attr('src','c://image.jpg') -setting source to first image in page&lt;br /&gt;
var color = $('h1').css('color','red') - setting color to first h1 in page&lt;br /&gt;
&lt;br /&gt;
&lt;hr style="color: black;" /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: black;"&gt;To be continue&lt;/span&gt;&lt;/div&gt;
&lt;div class="blogger-post-footer"&gt;Technology never stops.&lt;/div&gt;</description><link>http://makhaer.blogspot.com/2008/10/selector-is-most-important-part-of.html</link><thr:total>4</thr:total><author>khaer.mohammad@gmail.com (Mohammad Abul Khaer)</author></item></channel></rss>