Archive for July, 2010

Keep your Quick Launch Simple

Friday, July 16th, 2010
Some times we’ll endup in having lots of shotcut icons on our desktop/quick launch toolbar. I was wondering how to reduce that since that looks very ugly for me to have long list of icons hanging on your quick launch bar.I was remembering that my room met was using some kind of utility to avoid this. After numerous trials i have got the answer back ;)
Create the shortcuts for all of your application which you wanted to get rid of from quick launch,into a folder(In my case it’s “D:\Kumar\Shortcuts”). I have followed the other quciker work around whcih is having call names for all the applications ;) . My list looks like the following. (i.e FF will call Firefox, EC will call Eclipse, ME will call to MyEclipse)
Shorcuts
Now how do i make this work through my “RUN” command in windows.
Go to My Computers -> Properties -> Advanced -> Click in Environment Variables -> Change the System Variable “PATH” like the following..
So you are going to append your folder(”D:\Kumar\Shortcuts”) with the existing value in “PATH”. After this go to Run command and type “FF” it should be opening FireFox for you.
Adding to System Var
Hope you liked it. :)
Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

about:config trick for window.close() In Firefox

Wednesday, July 7th, 2010
This article is from my exp. on turning on the configuration in FF after each release.The script window.close() won’t work after every release from mozilla. The reason i found was “dom.allow_scripts_to_close_windows” in all.js will be set to false by default. I was trying to do it in the hard way,i.e Go to the location of all.js and change it manually. But i found a another easy method we can call the about:config page in FireFox, we can toggle it easier. The following shows how to do it.
Enter about:config in location bar
Openingabtcnfg
Shows all the options available
options
Search for dom.allow_script
allow_scripts
Highlight the entry dom.allow_scripts_to_close_windows and double click to toggle to true
Then write a simple script to check window.close()
Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

Integrating Hibernate with Struts1.x

Friday, July 2nd, 2010
We have got list of post(s) about Hibernate. Today as a next step we’ll try to intergrate with MVC framework. We’ll take the most used one which Struts1.3. For example we’ll take the same Singer Example and we’ll work with that for intergrating with struts also.Since we have the domain object generated already, we can make use of the same domain object to populate the values from DB, when we use the Hibernate.
We just take the examples of listing all the Singers from Singers table. Since we are using Struts1.x, we may need to write the action class and form class. The following code shows Form Class. Since we are going to list all the Singers, then our Form looks like the following.
		package com.techmaddy.form;

		/*
		*  Copyright 2010 - Kumarasamy
		*	kumarasamy@techmaddy.com
		*/

		import javax.servlet.http.HttpServletRequest;

		import org.apache.struts.action.ActionForm;
		import org.apache.struts.action.ActionMapping;

		import com.techmaddy.singer.Singer;

		public class SingerForm extends ActionForm {

			private static final long serialVersionUID = 1L;

			private Singer[] singer =  new Singer[0];

			public Singer[] getSinger() {
				return singer;
			}

			public void setSinger(Singer[] singer) {
				this.singer = singer;
			}

			public void reset(ActionMapping mapping, HttpServletRequest request) {
				singer =  new Singer[0];
			}

		}
	
The DAO class will make a call to DB and returns the results. This is almost very similar to the class CRUDTest.java in Simple CRUD Operation With Hibernate. Instead of my CRUDTest class, we have an DAO Class which gets the data from DB.
My DAO Class looks like the following.
			package com.techmaddy.bo;

			/*
			*  Copyright 2010 - Kumarasamy
			*	kumarasamy@techmaddy.com
			*/

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

			import org.hibernate.Session;
			import org.hibernate.Transaction;
			import org.hibernate.Query;

			import com.techmaddy.singer.HibernateSessionFactory;
			import com.techmaddy.singer.Singer;

			public class SingerManager {

				public Singer[] getAllSingers() {
					List singer = new ArrayList();
					Session session = null;
					Transaction tx = null;

					session = HibernateSessionFactory.getSession();

					tx = session.beginTransaction();
					Query qry = session.createQuery("from Singer");
					for (Iterator iterator = qry.iterate(); iterator.hasNext();) {
						singer.add(iterator.next());
					}

					return (Singer[]) singer.toArray(new Singer[0]);
				}

			}
	
The same way, based in the action performed from the screen, we can make a call to Editing and deleting the Singers.The following Images shows the result screen.
Struts-Hibernate Integration
Download
To download the War file for Singer with Struts Integration Click Here
Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)
Get Adobe Flash player