provide-free-support Ujjwal's Blog: March 2011

Tuesday, March 15, 2011

Jquery Autocomplete with DataSource

Hi All,

Recently i needed an autocomplete textbox in which i need to store an ID and display a list. So, i gone for Jquery autocomplete which i was very used to. I have used this before but it was just for single list where i was not storing any ID. I tried my hands on with JSON using Jquery autocomplete but it was not giving me results the way i wanted.

So, finally, i found a solution as mentioned below ::

1) A textbox for autocomplete


<input type="text" id="input" name="input"/>


2) An onload script


function loadData(){
$("#input").autocomplete('<%=request.getContextPath()%>/showMyCity.do' , {
        extraParams: { locationName : function() { 
        return document.getElementById('input').value; 
            }
         },
        minChars: 0,
        width: 185,
        matchContains: "word",
        autoFill: false,
        max:50,
        formatItem:function(row) {
            return row[0];
        },
        formatResult: function(row) {
            return row[0];
        }
    });
    
    
    $("#input").result(function(event, data, formatted) {
        if (data)
            document.getElementById("selectedLocation").value=data[1];
            
            
    });

}



3) Jsp page which results your search :


<c:forEach items="${LOCATION_LIST}" var="bean">

<c:out value="${bean.description}"/>|<c:out value="${bean.code}"/>
</c:forEach>




With a pipe character added in between, you can hide/show text on autocomplete.

This resoved my issue and i need not  have to use JSON for that.

Cheers,

Ujjwal Soni

UBS



Monday, March 14, 2011

URL rewriting for multi country website like /countryname/cityname


Hello Everyone,


Recently, i had to develop a website which needed a different URL mapping, it needed a url mapping like /France/Paris (ie: country/city).I looked out for many options, first of all i tried it with url rewriting servlet and implemented a filter with it, but it was not exactly the thing i wanted. So i looked out for other options and finally i found UrlRewriteFilter from tuckey.


I downloaded the jars from www.tuckey.org/urlrewrite and configured that in web.xml file.


I found its configuration too easy, you need to configure that in web.xml under filter tag.
<filter>
     <filter-name>UrlRewriteFilter</filter-name>
     <filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
  </filter>
 
  <filter-mapping>
    <filter-name>UrlRewriteFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>


Secondly, there is a seperate xml file called urlrewrite.xml that is needed by this filter.

You need to configure url rewriting rules in there. You can also use expression language to define a rule for your URL type.


So, i did someting like this to achieve my goal.

 <rule>
     <from>^/([a-z\s-] )$</from>
         <to type="redirect">%{context-path}/redirectAction.do?country=$1</to>
    </rule>
   
    <rule>
     <from>^/([a-z\s-] )/$</from>
         <to type="redirect">%{context-path}/redirectAction.do?country=$1</to>
    </rule>
   
    <rule>
     <from>^/([a-z/\s/-] )/([a-z/\s/-] )$</from>
         <to type="redirect">%{context-path}/redirectAction.do?country=$1&amp;city=$2</to>
    </rule>
      
    <rule>
     <from>^/([a-z/\s/-] )/([a-z/\s/-] )/$</from>
         <to type="redirect">%{context-path}/redirectAction.do?country=$1&amp;city=$2</to>
    </rule>


The above configuration helped me to accept multi spaced url's like www.ujjwalbsoni.blogspot.com/United States Of America/New York



I created an action in struts that gets me the names of countries and cities accordingly and i finally got what i wanted.


Expression for redirect rule was really tedious since i was having multiple spaces in country/city names. But finally, i created and succeeded in making one and using that.




Cheers!!!


Ujjwal Soni


UBS


Thursday, March 3, 2011

A great new java framework playframework

Hi,




Today, my friend told me about a new emerging java framework, its known as Play Framework.

Its new and really awesome...Its not a game framework, but its like an MVC framework, a bit simpler one.

Check out this link http://www.playframework.org/documentation/1.1.1/5things

Cheers!!!

Ujjwal Soni












Generating xlsx excel 2007 files using jdk 1.4

Hi,

i need to generate excel 2007 reports in java, well, i had many options to do this like Jexcel, apache poi, Aspose...but this list got smaller since i had to do this in jdk 1.4,  since i had to do this in older jdk, i chose apache poi, but apache poi supports generating xlsx only on jdk 1.6, some blogs says that if we backport then poi can work on older jdk's, so i tried backporting it and converted jars in jdk 1.4, all was done and it worked for generating xls files, but when i changed it for xlsx using XHSSF class, it started throwing errors, i did lot of research but at the end, all was in vain. later on i read somewhere that apache poi backporting leads to serious memory issues on jdk 1.4, so i had gone for Jexcel, well jexcel needs a license and i gotaa use open source so i winded up this idea.

Finally, i had chosen Apache POI with Jdk 1.6 and its working great.

Cheers!!

Ujjwal
best-it-exam-    | for-our-work-    | hottst-on-sale-    | it-sale-    | tast-dumps-us-    | test-king-number-    | pass-do-it-    | just-do-it-    | pass-with-us-    | passresults-everything-    | passtutor-our-dumps-    | realtests-us-exam-    | latest-update-source-for-    | cbtnuggets-sale-exam    | experts-revised-exam    | certguide-sale-exam    | test4-sale-exam    | get-well-prepared-    | certkiller-sale-exam    | buy-discount-dumps    | how-to-get-prepared-for-the    | in-an-easy-way    | brain-dumps-sale    | with-pass-exam-guarantee    | accurate-study-material    | at-first-try    | 100%-successful-rate    | get-certification-easily    | material-provider-exam    | real-exam-practice    | with-pass-score-guarantee    | certification-material-provider    | for-certification-professionals    | get-your-certification-successfully    | 100%-Pass-Rate    | in-pdf-file    | practice-exam-for    | it-study-guides    | study-material-sku    | study-guide-pdf    | prep-guide-demo    | certification-material-id    | actual-tests-demo    | brain-demos-test    | best-pdf-download    | our-certification-material    | best-practice-test    | leading-provider-on    | this-course-is-about    | the-most-reliable    | high-pass-rate-of    | high-pass-rate-demo    | recenty-updated-key    | only-for-students-free-download    | courseware-plus-kit-for    | accurate-answers-of    | the-most-reliable-id    | provide-training-for    | welcome-to-buy    | material-for-success-pass    | provide-free-support    | best-book-for-pass    | accuracy-of-the-answers    | pass-guarantee-id    | pass-exam-key    | pass-sku-id    | study-for-exid    | pdf-sku-exid    | sku-pdf-id    | pdf-demo-key    | exam-demo-ske    | pass-it-dump    |
http://inn-on-the-hill.com/    | http://inn-on-the-hill.com/    |