Tuesday, January 31, 2012

Auto Complete feature of dijit.form.FilteringSelect using Ajax and dojo.data.ItemFileWriteStore

Using Dojo widgets FilteringSelect and ItemFileWriteStore we can build a autocomplete or hint text feature for a input text box

Javascript is as follows

<script type="text/javascript">
<![CDATA[
dojo.require("dojo.data.ItemFileWriteStore");
dojo.require("dijit.form.FilteringSelect");
dojo.require("dijit.form.Button");
var couponStore;
dojo.addOnLoad(function () {
dojo.connect(dijit.byId('couponSelect'), 'onKeyUp', function () {
var xhrArgs = {
url: "/WebAdmin/report/coupon/"+ dojo.byId('couponSelect').value,
handleAs:'json',
load: function(data) {setData(data);},
error: function(error) {
dijit.byId('couponSelect').innerHTML= "An unexpected error occured" + error;
}
};
var items = dojo.xhrGet(xhrArgs);
function setData(items) {
couponStore = new dojo.data.ItemFileWriteStore({
data : {identifier:'name', items: items.items}
});
}
dijit.byId('couponSelect').set('store',couponStore);
});
});
]]>
</script>


The HTML declarative code is as follows

<div id="couponStore" dojoType="dojo.data.ItemFileReadStore" jsId="couponStore" url="/WebAdmin/report/coupon/test"/>
<form:select id="couponSelect" dojoType="dijit.form.FilteringSelect" store="couponStore" path="name" />


URL is mentioned in ItemFileWriteStore so by default it load some data into the FilteringSelect Widget.


Server Side looks something like this below
@ResponseBody
@RequestMapping(value = "/report/coupon/{coupon}")
public String filterCouponNames(@PathVariable("coupon") String name) throws JSONException {
log.info("Coupon name = {}", name);
JSONObject respObject = new JSONObject();
List<JSONObject> list = new ArrayList<JSONObject>();
List<AbstractCoupon> coupons = service.findCouponByFilter(name);
for (AbstractCoupon coupon : coupons) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("id", String.valueOf(coupon.getCouponId()));
jsonObject.put("name", coupon.getName());
jsonObject.put("type",coupon.getCouponType());
list.add(jsonObject);
}
respObject.put("identifier","name");
respObject.put("items",list);
log.info(respObject.toString());
return respObject.toString();

}

Hope this information is helpful to someone who is looking to integrate auto complete feature using dojo.

Thursday, January 26, 2012

Wednesday, January 25, 2012

My Brother-in-Law Wedding

I will remember my brother - in - law wedding took 8 extra days leave from work and compensate with loss of pay for 5 days for month of November. But the wedding event was memorable. We enjoyed a lot, dance lot drunk lot everything lot.

Here is some of the memories to cherish.

Tuesday, January 17, 2012

Explore to RatnaGiri & Ganpatipule

Our 1st halt was at Vithal Kamath on Mumbai - Goa road at 8:20 AM after 2hrs 30 mins of drive. We had our breakfast at Kamath. Decent preparation of South Indian food. Few pics taken at Vittal Kamath halt.




We resumed our journey at 9:10AM and headed towards Ratnagiri. We reached Chiplun around 10:45 AM took at quick tea break for 10 mins and then move towards Ratnagiri at 12:00PM we reached Hathkhamba and that is place where we took right diversion to get towards Ratnagiri. About 2kms - 3Kms approx of travel we reach Ratnagiri city.

Ratnagiri is clean and small town at Konkan parts of Maharastra. We visited to TheBaw palace though there is nothing much to see but there was a museum inside TheBaw palace. There was entry fee of Rs 3.00 for adults and Rs 1.00 for kids below 8 years.
Musuem has belonging of King TheBaw and there were some very old sculptures. Photography was banned inside the palace.


TheBaw Palace




Pots from Museum inside TheBaw palace

Then we headed towards next point which is adjacent to TheBaw palace called TheBaw point also called the Sunset point or Garden point. Very nice view from here. And the park is small but maintained well. To enter to the park there is entry fee of Rs 10/- for adults and for kids free.


View infront of TheBaw point


Views from TheBaw point


We can see near village of Ratnagiri from this place and lots of Fishermen locality (Koli) people inhabits from this point.

Fishering boats


Park view


Ratnagiri also have a small Aquarium with good collection of underwater animals.
They charge Rs 10 for adult and Rs 3 for kid. Also if you take picture inside the aquarium they charge some fees for photography.



Around 2:30PM, We found a Malawan restaurant "Vikas Malwani lajja". We had Chicken thali are awesome also the Malwan Vada are delicious. After good lunch we headed towards Ganpatipule, which is 23 KM from Ratnagiri. Roads are narrow but they are maintained the views is very nice. Some of the pictures taken while travelling towards Ganpatipule.

Early morning 5:35AM we started from Kamothe Sector -17. Climate was cool and traffic were less in Mumbai - Goa road. The distance from Kamothe to Ratnagiri was 336KM. We followed google maps and move on. direction

We checked in at hotel Shri Sagar at Ganapatipule. Rooms are good and it has garden restaurant as well.

Then evening we went to beach and temple darshan of Ganpatipule.

Day-2

After having breakfast we left hotel at 11AM and then we went to temple again.



We spent 30 mins near beach and had some good pictures of Camel at the beach.




Then around 11:45 we drove towards Jaigad fort reached Jaigad after an 1hr. Roads are very narrow cant drive more than 50 KMPH.


Entrance of Jaigad fort


Inside view Jaigad fort


Jaigad was our last destination of the tour. Around 12:30PM we started from Jaigad and headed towards Mumbai via Khandala & Neuli Phata.

We reached mumbai at 9:30 PM after having dinner at Penn.