<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>

<channel>
	<title>TechSpirit</title>
	<atom:link href="http://www.karthikbala.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.karthikbala.com</link>
	<description>Blog with Technology and Spirituality</description>
	<pubDate>Sat, 30 Aug 2008 09:23:08 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.5</generator>
	<language>en</language>
			<item>
		<title>Head Rush - The Jr. Programmers Syndrome</title>
		<link>http://www.karthikbala.com/2008/08/30/head-rush-the-jr-programmers-syndrome/</link>
		<comments>http://www.karthikbala.com/2008/08/30/head-rush-the-jr-programmers-syndrome/#comments</comments>
		<pubDate>Sat, 30 Aug 2008 09:23:08 +0000</pubDate>
		<dc:creator>Karthik</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[fun]]></category>

		<category><![CDATA[head rush]]></category>

		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.karthikbala.com/?p=14</guid>
		<description><![CDATA[If you are a serious programmer and if you have started programming only a year back, you should have felt the Head Rush or be ready for one, let me explain what this syndrome is all about:]]></description>
			<content:encoded><![CDATA[<p>If you are a serious programmer and if you have started programming only a year back, you should have felt the Head Rush or be ready for one, let me explain what this syndrome is all about:</p>
<p>You the programmer got an idea, a very intelligent idea which is going to change your projects implementation plan, idea which will ease your project&#8217;s development plan (something like writing an API on which your project would depend), idea which will fetch you the highest reputation in your company.</p>
<p>Once  you got this idea in your mind at first you will go crazy and soon when you get to the ground multiple neurons start firing your brain (like multiple threads fighting for the same resource). You will be thinking of an algorithm, soon the idea of hiccups in the implementation comes in and very soon the performance matters you and apart from all these knowing that &#8216;only showing the implementation of your idea makes you a hero&#8217;, you want to implement the idea very soon, very soon until which no food tastes you.</p>
<p>Now you will start dying to streamline your thoughts. like above said when you start thinking of an algorithm the idea of hiccups in the implementation comes in the middle and the feeling of being a hero always come in the middle of other ideas, at this time you will start feeling the blood rushing into your brain, a pressure which a beginner programmer cant bear but the poor you without knowing it would try to bear that little headache that already started in your head. You will be thinking of all the implementation/performance tweaks to your idea which would make it more powerful.</p>
<p>Whatever you are doing, this idea will be in your mind, no matter how the world is doing you will be in this idea, neither the god can dare to separate you from this idea and now the headache starts increasing making you unable to bear it, may be any other person would have neglected the idea and would have taken rest for a while (that&#8217;s the only solution to this).</p>
<p>But an intelligent programmer soon after feeling that he is not capable of writing a single line of code got an idea to recover soon for which he visited a multispeciality hospital where he was charged Rs.450 as just a consultation fees and given a normal paracetamol.</p>
<p>Soon after returning from the hospital and before taking any medication he had a very painful vomiting and you know what Head Rush is gone. But how and when ? When he was vomiting he realized he has gone crazy, he realized he need to be stable, he realized he need to streamline his thoughts, he realized there is no hurry for the implementation after all the idea is yours and you will be the Hero. Now the happy programmer started blogging about the fun he had with a smile on his face <img src='http://www.karthikbala.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Happy programming</p>
]]></content:encoded>
			<wfw:commentRss>http://www.karthikbala.com/2008/08/30/head-rush-the-jr-programmers-syndrome/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Ladies and gentlemen, this is Java EE 5!</title>
		<link>http://www.karthikbala.com/2008/07/11/ladies-and-gentlemen-this-is-java-ee-5/</link>
		<comments>http://www.karthikbala.com/2008/07/11/ladies-and-gentlemen-this-is-java-ee-5/#comments</comments>
		<pubDate>Fri, 11 Jul 2008 21:58:27 +0000</pubDate>
		<dc:creator>Karthik</dc:creator>
		
		<category><![CDATA[JSF]]></category>

		<category><![CDATA[Java]]></category>

		<category><![CDATA[NetBeans]]></category>

		<category><![CDATA[glassfish]]></category>

		<category><![CDATA[javaee5]]></category>

		<category><![CDATA[song]]></category>

		<guid isPermaLink="false">http://www.karthikbala.com/?p=13</guid>
		<description><![CDATA[I found the following interesting in Arun&#8217;s Blog, which reflects most of my daily life  
Ladies and gentlemen, this is Java EE 5!
One, two, three, four, five
There&#8217;s a technology I use day and night
For my application with a web frontend
They told me to use .Net
But I really don´t wanna
So many bugs I fixed last [...]]]></description>
			<content:encoded><![CDATA[<p>I found the following interesting in <a href="http://blogs.sun.com/arungupta/">Arun&#8217;s Blog</a>, which reflects most of my daily life <img src='http://www.karthikbala.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Ladies and gentlemen, this is Java EE 5!</p>
<p>One, two, three, four, five<br />
There&#8217;s a technology I use day and night<br />
For my application with a web frontend<br />
They told me to use .Net<br />
But I really don´t wanna</p>
<p>So many bugs I fixed last week.<br />
My code is neat and talk is a cheap<br />
I like Glassfish, JSF, persistence API<br />
And as I continue you know they´re gettin´ sweeter</p>
<p>So what can I do I really beg you my Lord<br />
To me codin&#8217; it´s just like a sport<br />
All the bad code from the past, let me dump it<br />
Please set in the trumpet</p>
<p>A little bit of injection in my life<br />
A little bit of persistence by my side<br />
A little bit of NetBeans is all I need<br />
A little bit of EJB&#8217;s what I see<br />
A little bit of standards in the sun<br />
A little bit of XML all night long<br />
A little bit web services here I am<br />
A little bit of code makes me real man</p>
<p>This is Java EE 5!</p>
<p>Jump up and down and move your code around<br />
Shake your head to the sound bury bad code under ground<br />
Move one step left and one step right<br />
One to the front and one to the side<br />
Refactor it once and refactor it twice<br />
If it looks like this you&#8217;re doin´ it right</p>
<p>A little bit of injection in my life<br />
A little bit of persistence by my side<br />
A little bit of NetBeans is all I need<br />
A little bit of EJB&#8217;s is what I see<br />
A little bit of standards in the sun<br />
A little bit of XML all night long<br />
A little bit web services here I am<br />
A little bit of code makes me real man</p>
<p>This is Java EE 5!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.karthikbala.com/2008/07/11/ladies-and-gentlemen-this-is-java-ee-5/feed/</wfw:commentRss>
		</item>
		<item>
		<title>jMaki widgets for WordPress</title>
		<link>http://www.karthikbala.com/2008/07/02/jmaki-widgets-for-wordpress/</link>
		<comments>http://www.karthikbala.com/2008/07/02/jmaki-widgets-for-wordpress/#comments</comments>
		<pubDate>Wed, 02 Jul 2008 10:44:04 +0000</pubDate>
		<dc:creator>Karthik</dc:creator>
		
		<category><![CDATA[Java]]></category>

		<category><![CDATA[Technology]]></category>

		<category><![CDATA[Jmaki]]></category>

		<category><![CDATA[plugin]]></category>

		<category><![CDATA[widget]]></category>

		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.karthikbala.com/?p=11</guid>
		<description><![CDATA[For those who doesn&#8217;t know jMaki, 
&#8220;jMaki is an Ajax framework that provides a lightweight model for creating JavaScript centric Ajax-enabled web applications using Java, Ruby, PHP, and Phobos.&#8221;
i call it a widgetting framework, jMaki provides widgets which are the wrappers to the most popular javascript libraries like Dojo, Scriptaculous, Google, Yahoo etc&#8230; These wrappers [...]]]></description>
			<content:encoded><![CDATA[<p>For those who doesn&#8217;t know <a href="https://ajax.dev.java.net/">jMaki</a>, </p>
<p>&#8220;jMaki is an Ajax framework that provides a lightweight model for creating JavaScript centric Ajax-enabled web applications using Java, Ruby, PHP, and Phobos.&#8221;</p>
<p>i call it a widgetting framework, jMaki provides widgets which are the wrappers to the most popular javascript libraries like Dojo, Scriptaculous, Google, Yahoo etc&#8230; These wrappers are available for PHP and JSP which makes it very easy to add those javascript libraries to your PHP or JSP applications.</p>
<p>To a trial I started adding jMaki accordion widget to my wordpress blog which has turned to a WordPress plugin (<a href="http://wordpress.org/extend/plugins/jmaki-accordion/">download</a>), below is the screenshot of the accordion added to my sidebar</p>
<p><a href='http://www.karthikbala.com/wp-content/uploads/2008/07/jmaki-accordion-screenshot.bmp'><img src="http://www.karthikbala.com/wp-content/uploads/2008/07/jmaki-accordion-screenshot.bmp" alt="" title="jmaki-accordion-screenshot" class="alignnone size-medium wp-image-12" /></a></p>
<p>If you want to add other jMaki widgets to your blog, first go through the article:<br />
<a href="http://lonewolf-online.net/computers/knowledgebase/wordpress-how-to-create-widgets">wordpress-how-to-create-widgets</a><br />
which will explain you of the basics of creating a WordPress plugin.</p>
<p>By now if you have gone through the above article you should be knowing how to say &#8216;Hello World&#8217; from your sidebar. Now at the place(method) where you have written </p>
<pre lang="LANGUAGE">echo "Hello World";</pre>
<p>you need to replace that with the jMaki code which will look like this:</p>
<pre lang="LANGUAGE">
addWidget( array(
                          "name" => "jmaki.accordionMenu",
                       "style"=>"{height:40em}",
                          "value" =>"{
                           menu : [
                           {label:  'Blogs',
                                menu: [
                                    { label : ' Greg Murray',
                                      href : 'http://weblogs.java.net/blog/gmurray71/'
                                    },
                                    { label : 'J Naveen',
                                      href : 'http://jaininaveen.blogspot.com/'
                                    },
                                    { label : 'Prashanth Ellina',
                                      href : 'http://blog.prashanthellina.com/'
                                    },
                                    { label : 'Carla Mott',
                                      href : 'http://weblogs.java.net/blog/carlavmott/'
                                    },
                                    { label : 'Arun Gupta',
                                      href : 'http://blogs.sun.com/arungupta/'
                                    },
                                     { label : 'Vikraman',
                                      href : 'http://vikraman.blogspot.com/'
                                    }
                                    ]
                           },
                           {label: 'Sites',
                                menu: [
                                    { label : 'TollyZone',
                                      href : 'http://jmaki.karthikbala.com/tollyzone'
                                     },
                                    { label : 'Zenmocha',
                                      href : 'http://www.zenmocha.com'
                                    },
                                    { label : 'TechSpirit',
                                      href : 'http://www.karthikbala.com'
                                    },
                                    { label : 'Indian Capitals',
                                      href : 'http://indiancapitals.com'
                                    }
                                    ]
                           }
                                    ]
                       }"
            ) );
</pre>
<p>The above code is for the accordion widget, it differs from widget to widget, you can find them from <a href="http://wiki.java.net/bin/view/Projects/jMakiDataModels">here</a> and before that u want to download jMaki from <a href="https://ajax.dev.java.net/files/documents/3115/94868/jmaki-php-1.8.0.zip">here</a> but the above piece of code depends on other file called jmaki.php which you can add to your plugin directory and import that in this file by adding the line</p>
<pre lang="LANGUAGE"> require_once("jmaki.php") ;</pre>
<p>but i got a problem saying permission denied to access files, for which i need to set variables in &#8216;php.ini&#8217; which is not preferred when writing a plugin, so smartly i added the required function in jmaki.php to mywidget.php. Still jmaki.php inturn calls other javascript functions which comes with jmaki-min.js which inturn make use of other files.The directory structure for a widget jmaki.accordion should be like this:</p>
<pre lang="LANGUAGE">
/- accordion
    |
    +-accordion.php
    |
    +-resources
    |    |
    |    +-jmaki.js
    |    |
    |    +-config.json
    |    |
    |    +-jmaki
    |        |
    |        +-accordion
    |        |    |
    |        |    +-component.css
    |        |    |
    |        |    +-component.js
    |        |    |
    |        |    +-component.htm
    |        |
    |        +-resources
    |             |
    |             +styles
    |                |
    |                +-themes
    |                     |
    |                     +-theme.css
</pre>
<p>You can find all those required files from the jmaki package you downloaded. <a href="http://www.ajax.dev.java.net">jMaki</a> website has got good documentation to start over.</p>
<p>Note:<a href="http://wordpress.org/extend/plugins/jmaki-accordion/">jmaki-accordion widget</a> is in <a href="http://stack5.com/en/top-50-wordpress-plugins/">top 50 wordpress plugins</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.karthikbala.com/2008/07/02/jmaki-widgets-for-wordpress/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Installing Firefox3.0 in Ubuntu</title>
		<link>http://www.karthikbala.com/2008/06/17/installing-firefox30-in-ubuntu/</link>
		<comments>http://www.karthikbala.com/2008/06/17/installing-firefox30-in-ubuntu/#comments</comments>
		<pubDate>Wed, 18 Jun 2008 06:53:52 +0000</pubDate>
		<dc:creator>Karthik</dc:creator>
		
		<category><![CDATA[firefox]]></category>

		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.karthikbala.com/?p=10</guid>
		<description><![CDATA[Did you set the World Record?
You can participate in setting the world record by downloading Firefox today.
To manually install firefox in ubuntu follow these steps:
Preparing your system
sudo apt-get install libstdc++5
First you need to take backup of your old firefox preferences
sudo cp -R ~/.mozilla ~/.mozillabackup
Now you need to download firefox 3.0 from here
Now you have firefox-3.0.tar.bz2 [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Did you set the World Record?</strong></p>
<p>You can participate in setting the world record by downloading Firefox today.</p>
<p>To manually install firefox in ubuntu follow these steps:</p>
<p><strong>Preparing your system</strong></p>
<p>sudo apt-get install libstdc++5</p>
<p>First you need to take backup of your old firefox preferences</p>
<p>sudo cp -R ~/.mozilla ~/.mozillabackup</p>
<p>Now you need to download firefox 3.0 from <a title="firefox" href="http://www.mozilla.com/en-US/firefox/" target="_blank">here</a></p>
<p>Now you have firefox-3.0.tar.bz2 file</p>
<p>Unzip the .tar.bz2 file in /opt directory using the following command</p>
<p>sudo tar -C /opt -jxvf firefox-3.0.tar.bz2</p>
<p>Now you need to link the plugins using the following command</p>
<p>cd /opt/firefox/plugins/</p>
<p>sudo ln -s /usr/lib/mozilla-firefox/plugins/* .</p>
<p>Now you need to create a link to your new firefox launcher using the following command</p>
<p>sudo dpkg-divert <code>--divert /usr/bin/firefox.ubuntu --rename /usr/bin/firefox</code></p>
<p>sudo ln -s /opt/firefox/firefox /usr/bin/firefox</p>
<p>sudo dpkg-divert <code>--divert /usr/bin/mozilla-firefox.ubuntu --rename /usr/bin/mozilla-firefox</code></p>
<p>sudo ln -s /opt/firefox/firefox /usr/bin/mozilla-firefox</p>
<p>This will complete the installation of firefox 3.0</p>
<p>If you want to open firefox 3 go to Applications—&gt;Internet—&gt;Firefox Web Browser</p>
<p>If you want firefox with google toolbar you can get here:<script type="text/javascript"><!--
google_ad_client = "pub-2945383363046281";
/* 110x32, created 5/1/08 */
google_ad_slot = "8282021149";
google_ad_width = 110;
google_ad_height = 32;
google_cpa_choice = ""; // on file
//-->
// &#8211;&gt;
// &#8211;&gt;
// &#8211;&gt;
// &#8211;&gt;</script><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script></p>
<p>Credits: <a title="ubuntugeek" href="http://www.ubuntugeek.com" target="_blank">http://www.ubuntugeek.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.karthikbala.com/2008/06/17/installing-firefox30-in-ubuntu/feed/</wfw:commentRss>
		</item>
		<item>
		<title>JSF Step by Step</title>
		<link>http://www.karthikbala.com/2008/05/12/jsf-step-by-step/</link>
		<comments>http://www.karthikbala.com/2008/05/12/jsf-step-by-step/#comments</comments>
		<pubDate>Tue, 13 May 2008 06:28:34 +0000</pubDate>
		<dc:creator>Karthik</dc:creator>
		
		<category><![CDATA[JSF]]></category>

		<category><![CDATA[NetBeans]]></category>

		<category><![CDATA[JavaServer Faces]]></category>

		<guid isPermaLink="false">http://www.karthikbala.com/?p=9</guid>
		<description><![CDATA[JSF – Java Server faces

What Is JavaServer Faces?
JavaServer Faces is a new framework for building Web applications using Java.
All JSF projects need a particular directory structure as mentioned by the JSF framework.
This directory structure can be easily obtained by starting a JSF project in NetBeans.
To start a new JSF project in NetBeans

Go to File Menu [...]]]></description>
			<content:encoded><![CDATA[<p><strong><span style="font-size: 14pt;">JSF – Java Server faces</span></strong></p>
<p class="MsoNormal"><strong></strong></p>
<h2><a name="_What_Is_JavaServer_Faces?"></a><span style="font-size: 12pt;">What Is JavaServer Faces?</span></h2>
<p class="MsoNormal">JavaServer Faces is a new framework for building Web applications using Java.</p>
<p>All JSF projects need a particular directory structure as mentioned by the JSF framework.</p>
<p>This directory structure can be easily obtained by starting a JSF project in NetBeans.</p>
<h2><a name="_To_create_a_new Project in Netbeans"></a>To start a new JSF project in NetBeans</h2>
<ol style="margin-top: 0in;" type="1">
<li class="MsoNormal">Go to File Menu <span style="font-family: Wingdings;"><span>à</span></span> New Project</li>
<li class="MsoNormal">New Project Dialog box will open choose categories as web and project as Web Application. Click on the next button.</li>
<li class="MsoNormal">In the next page give the desired Project Name for eg We have given vahanJSF and give the location where you want to save the project.</li>
</ol>
<p class="MsoNormal"><img style="vertical-align: middle;" src="http://www.karthikbala.com/images/jsf/starting.PNG" alt="" width="668" height="502" /></p>
<p class="MsoNormal">4. And in the same page select the server as tomcat. Netbeans is shipped with bundled Tomcat but you can choose other version of Tomcat if you desire by    selecting the server combobox. <a href="#_Adding_a_new_Server_1">To add a new server</a>.<br />
5.In the next page select the framework as JavaServer Faces this will enable the NetBeans to recognise the project as a type of JSF.<br />
Now you can see your project appears in left pane under Projects tab.<br />
6.Expand the new projec to see its directory structure viz. Web Pages, Configuration Files, etc..</p>
<p class="MsoNormal" style="margin-left: 0.25in;"><img style="border: 0pt none ; vertical-align: middle;" src="http://www.karthikbala.com/images/jsf/index.PNG" border="0" alt="" width="668" height="502" /></p>
<h2><span style="font-size: 12pt;">To create a new Web Page</span></h2>
<p class="MsoNormal"><strong></strong></p>
<p class="MsoNormal"><strong>1. </strong>Right click on the Web Pages <span style="font-family: Wingdings;"><span>à</span></span> New <span style="font-family: Wingdings;"><span>à</span></span> JSP.</p>
<p class="MsoNormal"><strong></strong></p>
<p class="MsoNormal"><strong><img style="border: 0pt none ; vertical-align: middle;" src="http://www.karthikbala.com/images/jsf/new_jsp.PNG" border="0" alt="" width="668" height="502" /></strong></p>
<p class="MsoNormal"><strong></strong></p>
<p class="MsoNormal"><strong>2. </strong>Give the name of the JSP page. We have given login. Click on Finish.</p>
<p class="MsoNormal"><strong>3. </strong>JSP pages acts as an interface containing only components like textboxes, comboboxes, radiobutton etc and these components are bound with backend bean where all the business logic is written. Backend bean is nothing but a java class file where we write java coding for our business logic.</p>
<p class="MsoNormal"><strong>To create a backend bean:</strong></p>
<p class="MsoNormal"><strong></strong></p>
<p class="MsoNormal"><strong>1. </strong>Right click on the Source Packages <span style="font-family: Wingdings;"><span>à</span></span> New <span style="font-family: Wingdings;"><span>à</span></span> Java Class.<img style="border: 0pt none ; vertical-align: middle;" src="http://www.karthikbala.com/images/jsf/new_java_class.PNG" border="0" alt="" width="668" height="502" /></p>
<p class="MsoNormal"><strong>2. </strong>Give Class name and the name of the Package. We have given Class name as loginbean and Package as vahanPackage. Click on Finish.</p>
<p class="MsoNormal">Any bean that u create in the project shud be registered in the faces-config.xml file i.e present in the Configuration Files as like</p>
<p class="MsoNormal">&lt;managed-bean&gt;<br />
&lt;managed-bean-name&gt;loginbean&lt;/managed-bean-name&gt;</p>
<p class="MsoNormal">&lt;managed-bean-class&gt;vahanPackage.loginbean&lt;/managed-bean-class&gt;</p>
<p class="MsoNormal">&lt;managed-bean-scope&gt;request&lt;/managed-bean-scope&gt;&lt;/managed-bean&gt;</p>
<p class="MsoNormal"><strong>Or another way to add a bean is to </strong></p>
<p class="MsoNormal"><strong></strong></p>
<p class="MsoNormal"><strong><span>1.</span></strong><span> </span>Right-click the project and choose New <span style="font-family: Wingdings;"><span>à</span></span> File/Folder. Under the Web category, select the JSF Managed Bean template and click Next.</p>
<p class="MsoNormal"><img style="border: 0pt none ; vertical-align: middle;" src="http://www.karthikbala.com/images/jsf/new_folder.PNG" border="0" alt="" width="668" height="502" /></p>
<p class="MsoNormal"><strong>2.</strong> Give the name and Package as you have given earlier. We have given Class name as userbean and Package as vahanPackage. Click on Finish.</p>
<p class="MsoNormal"><img style="border: 0pt none ; vertical-align: middle;" src="http://www.karthikbala.com/images/jsf/finish.PNG" border="0" alt="" width="575" height="432" /></p>
<p class="MsoNormal"><strong>3.</strong> Now open the Configuration file and see all the lines are added in it that you have added manually.<img style="border: 0pt none ; vertical-align: middle;" src="http://www.karthikbala.com/images/jsf/faces_config.PNG" border="0" alt="" width="668" height="502" /></p>
<p class="MsoNormal">As we have created JSP page and backend bean so we’ll proceed with the coding part.</p>
<p class="MsoNormal"><strong>1.</strong> Open the JSP page. Now we need to declare the JSF tag libraries in the JSF file. Change the following code:</p>
<p><span style="font-size: 12pt; font-family: ">&lt;%&#8211;</span><span style="font-size: 12pt; font-family: ">&lt;%@taglib uri=&#8221;http://java.sun.com/jsp/jstl/core&#8221; prefix=&#8221;c&#8221;%&gt;</span><span style="font-size: 12pt; font-family: ">&#8211;%&gt;</span></p>
<p>To the following:</p>
<p><span style="font-size: 12pt; font-family: ">&lt;%@ taglib prefix=&#8221;f&#8221; uri=&#8221;http://java.sun.com/jsf/core&#8221; %&gt;</span><span style="font-size: 12pt; font-family: ">&lt;%@ taglib prefix=&#8221;h&#8221; uri=&#8221;http://java.sun.com/jsf/html&#8221; %&gt;</span></p>
<p>Examine the prefix given as h and f</p>
<p>h denotes the basic html tags<br />
f denotes the jsf tags</p>
<p>These prefix letters can be changed according to ur choice but not recommended.</p>
<p><strong>2. </strong>Change the contents of both the <tt><span style="font-size: 10pt;">title</span></tt> and <tt><span style="font-size: 10pt;">h1</span></tt> tags to <tt><span style="font-size: 10pt;">Vahan.</span></tt></p>
<p><tt><strong><span style="font-family: ">3. </span></strong></tt>Now add a JSF form to the file. In the Palette(Window <span style="font-family: Wingdings;"><span>à</span></span> Palette), click the JSF Form button, drag it to below the <tt><span style="font-size: 10pt;">h1</span></tt> tag, and release the mouse button. In the dialog box, leave Empty Form selected and click OK. The IDE fills in the following code in bold:</p>
<p><strong><span style="font-size: 12pt; font-family: ">&lt;f:view&gt;</span></strong><strong><span style="font-size: 12pt; font-family: ">&lt;h:form&gt;</span></strong><strong><span style="font-size: 12pt; font-family: ">&lt;/h:form&gt;</span></strong><strong><span style="font-size: 12pt; font-family: ">&lt;/f:view&gt;</span></strong></p>
<p><tt><strong><span style="font-family: ">4. </span></strong></tt>We are going to use <tt><span style="font-size: 10pt;">inputText</span></tt> components to get the user input and a <tt><span style="font-size: 10pt;">commandButton</span></tt> component to submit the form. So our code will look like</p>
<p>&lt;%@page contentType=&#8221;text/html&#8221;%&gt;</p>
<p>&lt;%@page pageEncoding=&#8221;UTF-8&#8243;%&gt;</p>
<p>&lt;%&#8211;</p>
<p>The taglib directive below imports the JSTL library. If you uncomment it,</p>
<p>you must also add the JSTL library to the project. The Add Library&#8230; action</p>
<p>on Libraries node in Projects view can be used to add the JSTL 1.1 library.</p>
<p>&#8211;%&gt;</p>
<p>&lt;%@ taglib prefix=&#8221;f&#8221; uri=&#8221;http://java.sun.com/jsf/core&#8221; %&gt;</p>
<p>&lt;%@ taglib prefix=&#8221;h&#8221; uri=&#8221;http://java.sun.com/jsf/html&#8221; %&gt;</p>
<p>&lt;!DOCTYPE HTML PUBLIC &#8220;-//W3C//DTD HTML 4.01 Transitional//EN&#8221;</p>
<p>&#8220;http://www.w3.org/TR/html4/loose.dtd&#8221;&gt;</p>
<p>&lt;html&gt;</p>
<p>&lt;head&gt;</p>
<p>&lt;meta http-equiv=&#8221;Content-Type&#8221; content=&#8221;text/html; charset=UTF-8&#8243;&gt;</p>
<p>&lt;title&gt;Vahan&lt;/title&gt;</p>
<p>&lt;/head&gt;</p>
<p>&lt;body&gt;</p>
<p>&lt;h1&gt;Vahan&lt;/h1&gt;</p>
<p>&lt;f:view&gt;</p>
<p>&lt;center&gt;</p>
<p>&lt;h1&gt;</p>
<p>&lt;h:outputText value=&#8221;Welcome to Login Page&#8221;/&gt;</p>
<p>&lt;/h1&gt;</p>
<p>&lt;h:form&gt;</p>
<p>&lt;p&gt;</p>
<p>&lt;h:outputText value=&#8221;UserName &#8220;/&gt;</p>
<p>&lt;h:inputText value=&#8221;#{loginbean.userName}&#8221; id=&#8221;tf_UserName&#8221;/&gt;</p>
<p>&lt;/p&gt;</p>
<p>&lt;p&gt;</p>
<p>&lt;h:outputText value=&#8221;Password<span> </span>&#8220;/&gt;</p>
<p>&lt;h:inputText value=&#8221;#{loginbean.password}&#8221; id=&#8221;tf_Password&#8221;/&gt;</p>
<p>&lt;/p&gt;</p>
<p>&lt;p&gt;</p>
<p>&lt;h:commandButton action=&#8221;#{loginbean.submit}&#8221; value=&#8221;SUBMIT&#8221; /&gt;</p>
<p>&lt;/p&gt;</p>
<p>&lt;/center&gt;</p>
<p>&lt;/h:form&gt;</p>
<p>&lt;/f:view&gt;</p>
<p>&lt;/body&gt;</p>
<p>&lt;/html&gt;</p>
<p>Look at the value of inputText is given as {loginbean.userName} this means the value is bind with the userName property of the loginbean. So as to bind the value with a property in the bean we need to create setter and getter methods for that particular value.</p>
<p class="MsoNormal" style="margin-left: 0in; text-indent: 0in;"><strong><span>5.</span></strong>Now open loginbean.java. Add the following field declarations (shown in bold) to loginbean.java:</p>
<p><span style="font-size: 12pt; font-family: ">public class loginbean<span> </span>{<span> </span></span><span style="font-size: 12pt; font-family: "><strong>String userName;</strong></span><strong><span style="font-size: 12pt; font-family: ">String password; 6.</span></strong><span style="font-size: 12pt; font-family: ">Now let&#8217;s generate getters and setters for the fields.Right-click on fieldname(username) in the file and choose Refactor-&gt;Encapsulate Fields. </span><strong></strong>&lt;!&#8211;[if !vml]&#8211;&gt;<img style="border: 0pt none ; vertical-align: middle;" src="http://www.karthikbala.com/images/jsf/encapsulate.PNG" border="0" alt="" width="668" height="502" /></p>
<p class="MsoNormal"><strong>7. </strong>A dialog box will open. Select both the check boxes for password also. Click next.</p>
<p class="MsoNormal"><img style="border: 0pt none ; vertical-align: middle;" src="http://www.karthikbala.com/images/jsf/encapsulate2.PNG" border="0" alt="" width="668" height="502" /></p>
<p class="MsoNormal"><strong>8. </strong>Refactoring window will open then click on the DoRefactoring button. The IDE switches the access level for the fields to private and creates the getter and setter methods.</p>
<p class="MsoNormal"><img style="border: 0pt none ; vertical-align: middle;" src="http://www.karthikbala.com/images/jsf/encapsulate3.PNG" border="0" alt="" width="668" height="502" /></p>
<p class="MsoNormal"><strong>9. </strong>Now the code for loginbean.java would look like</p>
<p class="MsoNormal">public class loginbean {</p>
<p class="MsoNormal">private String userName;</p>
<p class="MsoNormal">private String password;</p>
<p class="MsoNormal">public String getUserName() {</p>
<p class="MsoNormal">return userName;</p>
<p class="MsoNormal">}</p>
<p class="MsoNormal">public void setUserName(String userName) {</p>
<p class="MsoNormal">this.userName = userName;</p>
<p class="MsoNormal">}</p>
<p class="MsoNormal">public String getPassword() {</p>
<p class="MsoNormal">return password;</p>
<p class="MsoNormal">}</p>
<p class="MsoNormal">public void setPassword(String password) {</p>
<p class="MsoNormal">this.password = password;</p>
<p class="MsoNormal">}</p>
<p class="MsoNormal"><strong>10. </strong>Add a new JSP page called welcome.jsp. Add the following lines.</p>
<p class="MsoNormal">&lt;%@ taglib prefix=&#8221;f&#8221; uri=&#8221;http://java.sun.com/jsf/core&#8221; %&gt;</p>
<p class="MsoNormal">&lt;%@ taglib prefix=&#8221;h&#8221; uri=&#8221;http://java.sun.com/jsf/html&#8221; %&gt;</p>
<p class="MsoNormal">&lt;html&gt;</p>
<p class="MsoNormal">&lt;head&gt;</p>
<p class="MsoNormal">&lt;meta http-equiv=&#8221;Content-Type&#8221; content=&#8221;text/html; charset=UTF-8&#8243;&gt;</p>
<p class="MsoNormal">&lt;title&gt;Welcome to Vahan&lt;/title&gt;</p>
<p class="MsoNormal">&lt;/head&gt;</p>
<p class="MsoNormal">&lt;body&gt;</p>
<p class="MsoNormal">&lt;h1&gt;Welcome to Vahan&lt;/h1&gt;</p>
<p class="MsoNormal">&lt;f:view&gt;</p>
<p class="MsoNormal">&lt;h:form&gt;</p>
<p class="MsoNormal">&lt;p&gt;You&#8217;ve successfully registered with Vahan.&lt;/p&gt;</p>
<p class="MsoNormal">&lt;p&gt;Your name is &lt;h:outputText value=&#8221;#{loginbean.userName}&#8221; /&gt;&lt;/p&gt;</p>
<p class="MsoNormal">&lt;/h:form&gt;</p>
<p class="MsoNormal">&lt;/f:view&gt;</p>
<p class="MsoNormal">&lt;/body&gt;</p>
<p class="MsoNormal">&lt;/html&gt;</p>
<h2><span style="font-size: 12pt;">Setting Page Navigation</span></h2>
<p>Page navigation in the JSF framework is controlled by the <tt><span style="font-family: ">faces-config.xml</span></tt> file, which is located under the Configuration Files node in the Projects window. For each page you set up a navigation rule which contains one or more navigation cases. For now, we will just map the submit action from the <tt><span style="font-family: ">commandButton</span></tt> to <tt><span style="font-family: ">welcome.jsp.</span></tt></p>
<p style="margin-left: 0.5in; text-indent: -0.25in;"><strong><span>1.<span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal; font-family: "> </span></span></strong>Double-click <tt><span style="font-family: ">faces-config.xml</span></tt> to open the file in the Source Editor.</p>
<p style="margin-left: 0.5in; text-indent: -0.25in;"><strong><span>2.<span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal; font-family: "> </span></span></strong>Right-click anywhere in the file and choose Java ServerFaces <span style="font-family: Wingdings;"><span>à</span></span> Add Navigation Rule. Type <tt><span style="font-family: ">/login.jsp</span></tt> in the Rule from View field and optionally enter a description of the rule. Then click Add.</p>
<p><img style="border: 0pt none ; vertical-align: middle;" src="http://www.karthikbala.com/images/jsf/navigation.PNG" border="0" alt="" width="668" height="502" /></p>
<h2><span style="font-size: 12pt;">3. </span><span style="font-size: 12pt; font-weight: normal;">This window will appear.</span></h2>
<h2><span style="font-weight: normal;"><img style="border: 0pt none ; vertical-align: middle;" src="http://www.karthikbala.com/images/jsf/navigation2.PNG" border="0" alt="" width="668" height="502" /></span></h2>
<h2 style="margin-left: 0.25in;"><span style="font-size: 12pt;">4.</span><span style="font-size: 12pt; font-weight: normal;">Click on Add.The following code is entered in <tt><span style="font-family: ">faces-config.xml</span></tt>:</span></h2>
<h2 style="margin-left: 0.25in;"><span style="font-size: 12pt; font-weight: normal;">&lt;navigation-rule&gt;</span></h2>
<h2><span style="font-size: 12pt; font-weight: normal;">&lt;description&gt;</span></h2>
<h2><span style="font-size: 12pt; font-weight: normal;">login</span></h2>
<h2><span style="font-size: 12pt; font-weight: normal;">&lt;/description&gt;</span></h2>
<h2><span style="font-size: 12pt; font-weight: normal;">&lt;from-view-id&gt;/login.jsp&lt;/from-view-id&gt;</span></h2>
<h2><span style="font-size: 12pt; font-weight: normal;">&lt;/navigation-rule&gt;</span></h2>
<h2><span style="font-size: 12pt;">5. </span><span style="font-size: 12pt; font-weight: normal;">Right-click inside <tt><span style="font-family: ">faces-config.xml</span></tt> and choose Java ServerFaces &gt; Add Navigation Case. Set the following:</span></h2>
<ul type="disc">
<li class="MsoNormal">From View: <tt><span style="font-size: 10pt;">/login.jsp</span></tt></li>
<li class="MsoNormal">From Outcome: <tt><span style="font-size: 10pt;">submit</span></tt></li>
<li class="MsoNormal">To View: <tt><span style="font-size: 10pt;">/welcome.jsp</span></tt></li>
</ul>
<h2><span><img style="border: 0pt none ; vertical-align: middle;" src="http://www.karthikbala.com/images/jsf/navigation3.PNG" border="0" alt="" width="668" height="502" /></span></h2>
<h2 style="margin-left: 0.25in;"><span style="font-size: 12pt;">6.</span><span style="font-size: 12pt; font-weight: normal;"> Click on Add Following lines will appear.</span></h2>
<h2 style="margin-left: 0.25in;"><span style="font-size: 12pt;">&lt;navigation-case&gt;</span></h2>
<h2 style="margin-left: 0.25in;"><span style="font-size: 12pt;">&lt;from-outcome&gt;submit&lt;/from-outcome&gt;</span></h2>
<h2 style="margin-left: 0.25in;"><span style="font-size: 12pt;">&lt;to-view-id&gt;/welcome.jsp&lt;/to-view-id&gt;</span></h2>
<h2 style="margin-left: 0.25in;"><span style="font-size: 12pt;">&lt;/navigation-case&gt;</span></h2>
<p class="MsoNormal"><strong>How to set/add compiletime (classpath) and runtime libraries for a Project in Netbeans?</strong></p>
<p class="MsoNormal"><strong></strong></p>
<ol style="margin-top: 0in;" type="1">
<li class="MsoNormal">Right click on Project <span style="font-family: Wingdings;"><span>à</span></span> Properties.</li>
<li class="MsoNormal">A dialog box will open. Choose libraries under categories on left side. Click on <strong>Add Jar/Folder</strong> on the right hand side of the dialog box.</li>
</ol>
<p class="MsoNormal"><img style="border: 0pt none ; vertical-align: middle;" src="http://www.karthikbala.com/images/jsf/navigation4.PNG" border="0" alt="" width="668" height="502" /></p>
<ol style="margin-top: 0in;" type="1">
<li class="MsoNormal">Select all the jar files from where you have kept it.</li>
</ol>
<p class="MsoNormal"><img style="border: 0pt none ; vertical-align: middle;" src="http://www.karthikbala.com/images/jsf/lib.PNG" border="0" alt="" width="668" height="502" /></p>
<p class="MsoNormal"><strong>2. </strong>If Package is checked then they become war files i.e. runtime libraries. So if you want any file to be only compiled<span> </span>not packaged then uncheck it eg (servlet.jar/ servlet-api.jar). Click on ok and jar files will be added under Libraries folder of your project.</p>
<p class="MsoNormal"><strong></strong></p>
<p class="MsoNormal"><strong><img style="border: 0pt none ; vertical-align: middle;" src="http://www.karthikbala.com/images/jsf/lib2.PNG" border="0" alt="" width="668" height="502" /></strong></p>
<p class="MsoNormal"><strong></strong></p>
<p class="MsoNormal"><strong></strong></p>
<p class="MsoNormal"><strong></strong></p>
<p class="MsoNormal"><strong></strong></p>
<p class="MsoNormal"><strong></strong></p>
<p class="MsoNormal"><strong></strong></p>
<p class="MsoNormal"><strong></strong></p>
<p class="MsoNormal"><strong></strong></p>
<p class="MsoNormal"><strong></strong></p>
<p class="MsoNormal"><strong></strong></p>
<p class="MsoNormal"><strong></strong></p>
<p class="MsoNormal"><strong></strong></p>
<p class="MsoNormal"><strong></strong></p>
<p class="MsoNormal"><strong></strong></p>
<p class="MsoNormal"><strong></strong></p>
<p class="MsoNormal"><strong>Note:</strong></p>
<p class="MsoNormal"><strong>1. </strong>servlet.jar/servlet-api.jar should never be packaged as it conflicts with the servlet.jar file of Tomcat.</p>
<p class="MsoNormal"><strong></strong></p>
<p class="MsoNormal"><img style="border: 0pt none ; vertical-align: middle;" src="http://www.karthikbala.com/images/jsf/lib3.PNG" border="0" alt="" width="668" height="502" /></p>
<p class="MsoNormal"><strong>2. </strong>Lib folder of your project should never be inside WEB-INF folder as all the files/folders inside WEB-INF get packaged by default thereby avoiding us to unpackage particular jars of lib. As you can see in the snapshot below, we have removed lib folder.</p>
<p class="MsoNormal">
<p class="MsoNormal"><img style="border: 0pt none ; vertical-align: middle;" src="http://www.karthikbala.com/images/jsf/web_inf.PNG" border="0" alt="" width="668" height="502" /></p>
<p class="MsoNormal">
<p class="MsoNormal"><strong>3. </strong>If you want a client to establish a connection to RMI server then you have to add the following line:- permission java.security.AllPermission;<span> </span>in C:\j2sdk1.4.2_08\jre\lib\security\java.security. Its not necessary to install<span> </span>j2sdk1.4.2_08 in c: drive.</p>
<p class="MsoNormal"><img style="border: 0pt none ; vertical-align: middle;" src="http://www.karthikbala.com/images/jsf/permission.PNG" border="0" alt="" width="668" height="502" /></p>
<h2><span style="font-size: 12pt;">Configuring and Running the Application</span></h2>
<h2><span style="font-size: 12pt; font-weight: normal;">Now let&#8217;s set the IDE to display <tt><span style="font-family: ">login.jsp</span></tt> when it runs the application and, finally, test the application.</span></h2>
<h2 style="margin-left: 0.5in; text-indent: -0.25in;"><span style="font-size: 12pt;"><span>1.<span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal; font-family: "> </span></span></span><span style="font-size: 12pt; font-weight: normal;">Right-click the project and choose Properties.</span></h2>
<h2 style="margin-left: 0.5in; text-indent: -0.25in;"><span style="font-size: 12pt;"><span>2.<span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal; font-family: "> </span></span></span><span style="font-size: 12pt; font-weight: normal;">Click the Run node and type <tt><span style="font-family: ">/faces/login.jsp</span></tt> in the Relative URL field. Then click OK.</span></h2>
<h2><span><img style="border: 0pt none ; vertical-align: middle;" src="http://www.karthikbala.com/images/jsf/run.PNG" border="0" alt="" width="668" height="502" /></span></h2>
<h2><span style="font-size: 12pt;">3. </span><span style="font-size: 12pt; font-weight: normal;">Right-click the project and choose Run. The IDE builds the project, starts the application server, deploys the application, and shows the following page in the external browser:</span></h2>
<h2><a name="_Adding_a_new_Server"></a><a name="_Adding_a_new_Server_1"></a><span style="font-size: 12pt;">Adding a new Server</span></h2>
<h2 style="margin-left: 0in; text-indent: 0in;"><span style="font-size: 12pt;"><span>1.<span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal; font-family: "> </span></span></span><span style="font-size: 12pt; font-weight: normal;">Download a new server. We have downloaded apache-tomcat-6.0.14.</span></h2>
<h2 style="margin-left: 0in; text-indent: 0in;"><span style="font-size: 12pt;"><span>2.<span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal; font-family: "> </span></span></span><span style="font-size: 12pt; font-weight: normal;">Open </span><span style="font-size: 12pt;">D:\apache-tomcat-6.0.14\conf\tomcat-users.xml</span><span style="font-size: 12pt; font-weight: normal;">. Its not necessary that you download tomcat in D drive. You open<span> </span>tomcat-users.xml by right clicking on it and choose edit or editplus.</span></h2>
<h2 style="margin-left: 45pt; text-indent: -45pt;"><span style="font-size: 12pt;"><span>3.</span></span><span style="font-size: 12pt; font-weight: normal;"> Add these lines in it i.e. you have to create role as manager.</span></h2>
<h2 style="margin-left: 27pt; text-indent: -0.25in;"><span style="font-size: 12pt; font-weight: normal;">&lt;?xml version=&#8217;1.0&#8242; encoding=&#8217;utf-8&#8242;?&gt;</span></h2>
<h2 style="margin-left: 27pt; text-indent: -0.25in;"><span style="font-size: 12pt; font-weight: normal;">&lt;tomcat-users&gt;</span></h2>
<h2 style="margin-left: 27pt; text-indent: -0.25in;"><span style="font-size: 12pt; font-weight: normal;">&lt;role rolename=&#8221;manager&#8221;/&gt;</span></h2>
<h2 style="margin-left: 27pt; text-indent: -0.25in;"><span style="font-size: 12pt; font-weight: normal;">&lt;user username=&#8221;manager&#8221; password=&#8221;manager&#8221; roles=&#8221;manager&#8221;/&gt;</span></h2>
<h2 style="margin-left: 27pt; text-indent: -0.25in;"><span style="font-size: 12pt; font-weight: normal;">&lt;/tomcat-users&gt;</span></h2>
<h2 style="margin-left: 45pt; text-indent: -45pt;"><span style="font-size: 12pt;"><span>4.<span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal; font-family: "> </span></span></span><span style="font-size: 12pt; font-weight: normal;">Save the changes. Go to Netbeans and open Window </span><span style="font-weight: normal; font-size: 12pt; font-family: Wingdings;"><span>à</span></span><span style="font-size: 12pt; font-weight: normal;"> Runtime.</span></h2>
<h2 style="margin-left: 0.75in;"><span><img style="border: 0pt none ; vertical-align: middle;" src="http://www.karthikbala.com/images/jsf/runtime.PNG" border="0" alt="" width="575" height="432" /></span></h2>
<h2 style="margin-left: 1in; text-indent: -1in;"><span style="font-size: 12pt;"><span>5.<span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal; font-family: "> </span></span></span><span style="font-size: 12pt; font-weight: normal;">Runtime window will open. Right click on Servers </span><span style="font-weight: normal; font-size: 12pt; font-family: Wingdings;"><span>à</span></span><span style="font-size: 12pt; font-weight: normal;"> Add Server.</span></h2>
<h2 style="margin-left: 0.75in; text-indent: -0.75in;"><span><img style="border: 0pt none ; vertical-align: middle;" src="http://www.karthikbala.com/images/jsf/add_server.PNG" border="0" alt="" width="668" height="502" /></span></h2>
<h2 style="margin-left: 0.25in; text-indent: -0.25in;"><span style="font-size: 12pt;"><span>6.<span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal; font-family: "> </span></span></span><span style="font-size: 12pt; font-weight: normal;">Choose the type of server you want to add. For adding versions higher than Tomcat5.5,<span> </span>select Tomcat5.5.</span></h2>
<h2 style="margin-left: 0.25in; text-indent: -0.25in;"><span style="font-size: 12pt;"><span>7.<span style="font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal; font-family: "> </span></span></span><span style="font-size: 12pt; font-weight: normal;">Give the name of the server and click on next.</span></h2>
<h2><span><img style="border: 0pt none ; vertical-align: middle;" src="http://www.karthikbala.com/images/jsf/add_server2.PNG" border="0" alt="" width="668" height="502" /></span></h2>
<p class="MsoNormal"><strong>8. </strong>In Catalina Home, Browse and give the location of the apache-tomcat -6.0.14. Give username as password as manager.</p>
<p class="MsoNormal"><strong></strong></p>
<p class="MsoNormal"><img style="border: 0pt none ; vertical-align: middle;" src="http://www.karthikbala.com/images/jsf/add_server3.PNG" border="0" alt="" width="668" height="502" /></p>
<p class="MsoNormal"><strong>9. </strong>Click on Finish. You can see apache-tomcat-6.0.14 is added in Servers.</p>
<p class="MsoNormal"><img style="border: 0pt none ; vertical-align: middle;" src="http://www.karthikbala.com/images/jsf/add_server4.PNG" border="0" alt="" width="668" height="502" /></p>
<p class="MsoNormal"><strong><a href="#_To_create_a_new%20Project%20in%20Netbeans">Go Back</a></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.karthikbala.com/2008/05/12/jsf-step-by-step/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Crawling made Easy</title>
		<link>http://www.karthikbala.com/2008/05/01/crawling-made-easy/</link>
		<comments>http://www.karthikbala.com/2008/05/01/crawling-made-easy/#comments</comments>
		<pubDate>Fri, 02 May 2008 05:12:36 +0000</pubDate>
		<dc:creator>Karthik</dc:creator>
		
		<category><![CDATA[Java]]></category>

		<category><![CDATA[Web Crawling]]></category>

		<category><![CDATA[crawling]]></category>

		<guid isPermaLink="false">http://www.karthikbala.com/?p=7</guid>
		<description><![CDATA[In this post i will explain how to crawl a website and get the required content all using Java.
Am on a project where am crawling different telugu cinema websites, getting the required content and displaying them all together on a single page i.e on my personal webpage.
So as a part of that i crawled www.telugulo.com [...]]]></description>
			<content:encoded><![CDATA[<p>In this post i will explain how to crawl a website and get the required content all using Java.</p>
<p>Am on a project where am crawling different telugu cinema websites, getting the required content and displaying them all together on a single page i.e on my personal webpage.</p>
<p>So as a part of that i crawled <a title="www.telugulo.com" href="http://www.telugulo.com" target="_blank">www.telugulo.com</a> from which i have extracted the cinema part, so lets see how i did it&#8230; excuse me if you dont understand telugu but for learning crawling it wont be a constraint.</p>
<p>When i click on the cinema link which is in the homepage of www.telugulo.com it took me to a page with url <strong>http://telugulo.com/news.php?section=2</strong> and in this particular page i found headlines interesting and thought of extracting all the headlines.</p>
<p>Then i wrote a program which will open the page and extract the headlines for every half an hour such that i always have the latest headlines. and then i can use the headlines for any purpose, either to directly display them on my website or blahblah&#8230;</p>
<p><code>So now lets look at how java helps in doing all these:</code></p>
<p>Note the url which u want to crawl, here it is http://telugulo.com/news.php?section=2</p>
<ol>
<li><span style="color: #333399;">String strurl = http://telugulo.com/news.php?section=2;</span></li>
<li><span style="color: #333399;">URL url = new URL(strurl);</span></li>
<li><span style="color: #333399;">System.out.println(&#8221;Received url is &#8220;+url);</span></li>
<li><span style="color: #333399;">URLConnection hpCon = url.openConnection();</span></li>
<li><span style="color: #333399;">InputStream ins = hpCon.getInputStream();</span></li>
<li><span style="color: #333399;">InputStreamReader bis = new InputStreamReader(ins);</span></li>
<li><span style="color: #333399;">BufferedReader </span><span style="color: #333399;">teluStream</span><span style="color: #333399;"> = new BufferedReader(bis);</span></li>
<li><span style="color: #333399;">System.out.println(&#8221;got the stream&#8221;);</span></li>
</ol>
<p>Look at the above code,</p>
<p>line 4 opens the connection on the given url and now the hpCon is the connection on the given url,</p>
<p>line 5 gets the content present in the page as a stream</p>
<p>line 7 uses a bufferedreader which is used to read a character stream</p>
<p>so now <span style="color: #333399;">teluStream.readline() </span>is the function u need to read the content of the page line by line</p>
<p>once u got the line, check if it is the headline and if it is so, extract it and save it in a local file.</p>
<p>I recommend you to use firefox where u can add several plugins that make ur crawling job more easy<br />
<script type="text/javascript"><!--
google_ad_client = "pub-2945383363046281";
/* 110x32, created 5/1/08 */
google_ad_slot = "8282021149";
google_ad_width = 110;
google_ad_height = 32;
google_cpa_choice = ""; // on file
//-->
</script><br />
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />
Now let me tell you how i extracted the headlines:</p>
<p>I found the headlines as images rather to a text, each headline we read in that page is an image, so now i want to extract those images</p>
<p>and there are many images in the page and to exactly extract the headlines we need to find some difference with other images on the page</p>
<p>i found that these headline images are starting after a particular phrase</p>
<pre id="line342"><strong><span class="attribute-name">alt</span>=<span class="attribute-value">"taja"</span></strong></pre>
<p><strong> </strong>which means fresh.</p>
<p>so i just did <span style="color: #333399;">teluStream.readline()</span> until the line gets the phrase alt=&#8221;taja&#8221; and started extracting for the first five images which are none other than the required headlines</p>
<p>i used a while just like below to extract the headline images:</p>
<ol>
<li><span style="color: #333399;">String streamLine;</span></li>
<li><span style="color: #333399;">int i = 0;</span></li>
<li>S<span style="color: #333399;">tring gifStr[] = new String[5];</span></li>
<li><span style="color: #333399;">while((streamLine = teluStream.readLine())!=null)</span></li>
<li><span style="color: #333399;">{</span></li>
<li><span style="color: #333399;">if(streamLine.contains(regx))</span></li>
<li><span style="color: #333399;">{</span></li>
<li><span style="color: #333399;">while((streamLine = teluStream.readLine())!= null &amp;&amp; i&lt;5)</span></li>
<li><span style="color: #333399;">{</span></li>
<li><span style="color: #333399;">if(streamLine.contains(&#8221;gif&#8221;))</span></li>
<li><span style="color: #333399;">{</span></li>
<li><span style="color: #333399;">gifStr[i] = streamLine;</span></li>
<li><span style="color: #333399;">System.out.println(&#8221;gif string: &#8220;+i+gifStr[i]);</span></li>
<li><span style="color: #333399;">i++;</span></li>
<li><span style="color: #333399;">}</span></li>
<li><span style="color: #333399;">}</span></li>
<li><span style="color: #333399;">break;</span></li>
<li><span style="color: #333399;">}</span></li>
<li><span style="color: #333399;">}<br />
</span></li>
</ol>
<p>The while loop iterates for all the lines in the whole page, but i just wanted the images after the phrase alt=&#8221;taja&#8221;  so</p>
<p>line 6 checks if the line contains the taja phrase, if so</p>
<p>line 8 is an another while loop which iterates for i &lt; 5</p>
<p>line 10 checks if the line contains a gif (image), if so</p>
<p>in line 12 we store that particular line into an array</p>
<p>as we got the first image we increament the i in line 14</p>
<p>we are almost done, we found the lines in the page which contains the information we want</p>
<p>now in that each line we have to extract the exact path of the image,</p>
<p>the programmer who designed the page only writes the image path in the page and its the browsers duty to get the image from that path and display in the specified area</p>
<p>so now our duty is to get the path and open a connection on that path and then get the content of that image as similar to that of getting the content of the page that we have done very intially</p>
<p>but first lets c how we get the exact path from the line we extracted out of a big page</p>
<p>the line we extracted looks like this :</p>
<pre id="line342"><strong>&lt;<span class="start-tag">td</span>&gt;&lt;<span class="start-tag">a</span><span class="attribute-name"> href</span>=<span class="attribute-value">"view_news.php?id=6528"</span>&gt;&lt;<span class="start-tag">img</span><span class="attribute-name"> src</span>=<span class="attribute-value">"./images/Head-chiranjeevi-jeevithaniki-pargu-lankai-enduku.gif" </span><span class="attribute-name">border</span>=<span class="attribute-value">0</span>&gt;&lt;/<span class="end-tag">a</span>&gt;&lt;/<span class="end-tag">td</span>&gt;</strong></pre>
<p>we want that img src in the above line, a simple string manipulation would give us the img src, lets c the manipulation part of the game:</p>
<ol>
<li><span style="color: #333399;"> /*</span></li>
<li><span style="color: #333399;"> * This function returns the image path from given String</span></li>
<li><span style="color: #333399;"> */</span></li>
<li><span style="color: #333399;"> public String getImageurl(String urlLine) throws Exception {</span></li>
<li><span style="color: #333399;"> String str1[],str2[]; </span></li>
<li><span style="color: #333399;"> URL url = new URL(siteName);</span></li>
<li><span style="color: #333399;"> </span></li>
<li><span style="color: #333399;"> str1 = urlLine.split(&#8221;&lt;img src=&#8221;);</span></li>
<li><span style="color: #333399;"> if (str1[1].contains(&#8221;\&#8221;"))</span></li>
<li><span style="color: #333399;"> {</span></li>
<li><span style="color: #333399;"> str2 = str1[1].split(&#8221;\&#8221;");</span></li>
<li><span style="color: #333399;"> } </span></li>
<li><span style="color: #333399;"> System.out.println(str2.length + &#8221;  &#8221; + str2[0]);</span></li>
<li><span style="color: #333399;"> int l = str2.length;</span></li>
<li><span style="color: #333399;"> String imageUrl = &#8220;http://&#8221; + www.telugulo.com + &#8220;/&#8221; + str2[1];</span></li>
<li><span style="color: #333399;"> System.out.println(imageUrl);</span></li>
<li><span style="color: #333399;"> return imageUrl;</span></li>
<li><span style="color: #333399;"> }</span></li>
</ol>
<p>the getImageurl is the function which will return us the exact path of the image</p>
<p>String urlLine the argument passed to the function is the line which contains the img src</p>
<p>when i checked the line clearly i found that the img src is in between the inverted comas, but i found there are another inverted comas also in the line</p>
<p>so i used the split function to split the line into two parts such that the first inverted comas section is removed</p>
<p>the split function splits the line into parts based on the argument u passed to the function and it always returns the array with the splitted values</p>
<p>if u use split(is) on a line &#8220;karthik is hero&#8221;</p>
<p><span style="color: #333399;">String line = &#8220;karthik is hero&#8221;;</span></p>
<p><span style="color: #333399;">String result[] = line.split(is);</span></p>
<p>then result[0] will contain &#8220;karthik&#8221; and result[1] will contain &#8220;hero&#8221; notice here the result will not include the value that u used to split</p>
<p>so line 8 splits the given line into 2 parts, where the second part will have the img src</p>
<p>the second part look like this</p>
<p><strong><strong><span class="attribute-value">&#8220;./images/Head-chiranjeevi-jeevithaniki-pargu-lankai-enduku.gif&#8221; </span><span class="attribute-name">border</span>=<span class="attribute-value">0</span>&gt;&lt;/<span class="end-tag">a</span>&gt;&lt;/<span class="end-tag">td</span>&gt;</strong></strong></p>
<p>notice in the above <strong><strong>&lt;<span class="start-tag">img</span><span class="attribute-name"> src</span>=<span class="attribute-value"> </span></strong></strong><span class="attribute-value">is not included, neither it is included in the first part of the split result</span></p>
<p>line 11 splits the above line with <strong>&#8220;</strong><br />
then guess into how many parts the line will be split into</p>
<p>exactly, into 3 parts</p>
<p>where the first part is null as &#8220;inverted comma&#8221; which is the split value is the starting character</p>
<p>the second part is <strong><strong><span class="attribute-value">./images/Head-chiranjeevi-jeevithaniki-pargu-lankai-enduku.gif</span></strong></strong></p>
<p>and the third part is <strong><strong><span class="attribute-value"> </span><span class="attribute-name">border</span>=<span class="attribute-value">0</span>&gt;&lt;/<span class="end-tag">a</span>&gt;&lt;/<span class="end-tag">td</span>&gt;</strong></strong></p>
<p>so what we want is the second part, but the second part is not a complete url, the host name i.e www.telugulo.com is missing</p>
<p>line 15 adds the host name to the img src making it a complete url, upon which u can open connection as we did intially and get the stream and write the stream into a file headline.gif</p>
]]></content:encoded>
			<wfw:commentRss>http://www.karthikbala.com/2008/05/01/crawling-made-easy/feed/</wfw:commentRss>
		</item>
		<item>
		<title>I Lost to I&#8217;m Lost</title>
		<link>http://www.karthikbala.com/2007/12/19/i-lost-to-im-lost/</link>
		<comments>http://www.karthikbala.com/2007/12/19/i-lost-to-im-lost/#comments</comments>
		<pubDate>Wed, 19 Dec 2007 10:24:53 +0000</pubDate>
		<dc:creator>Karthik</dc:creator>
		
		<category><![CDATA[Spirituality]]></category>

		<category><![CDATA[GOD]]></category>

		<category><![CDATA[Laziness]]></category>

		<category><![CDATA[Success]]></category>

		<category><![CDATA[Transformation]]></category>

		<guid isPermaLink="false">http://www.karthikbala.com/?p=6</guid>
		<description><![CDATA[[digg=http://digg.com/arts_culture/I_Lost_to_I_m_Lost]
Is that confusing?? This title can mean either as - I Lost to  &#8216;I am Lost&#8217;(Noun) - or - transformation from &#8216;I Lost&#8217; to &#8216;I am Lost&#8217;., Realizing that I Lost to &#8216;I am Lost&#8217; made me transform to &#8216;I am Lost&#8217;. Okie let me explain how I Lost and what &#8216;I am Lost&#8217; [...]]]></description>
			<content:encoded><![CDATA[<p>[digg=http://digg.com/arts_culture/I_Lost_to_I_m_Lost]</p>
<p>Is that confusing?? This title can mean either as - I Lost to  &#8216;I am Lost&#8217;(Noun) - or - transformation from &#8216;I Lost&#8217; to &#8216;I am Lost&#8217;., Realizing that I Lost to &#8216;I am Lost&#8217; made me transform to &#8216;I am Lost&#8217;. Okie let me explain how I Lost and what &#8216;I am Lost&#8217; is. From my childhood and as aplicable to many of u we in general have that great feeling of &#8220;I can do&#8221; or further extending it &#8220;If I Can&#8217;t, Nobody Can&#8221;. We always say to ourself that we can do anything but with always adding an exception to it saying if and only if i really wanted to do. So ever u removed that exception and kept that I Can Do in action may be not really but there wud b many situations like interviews, exams etc to prove ourselves where we likely remember the &#8220;I can do&#8221; offcourse before attending an interview u obviously feel so but after missing it u wud remember ur exception and happily extend it to ur I Can Do philosophy and wud say I really doesnt put my effort otherwise I wud have cracked it..</p>
<p>Howmany more days are u going to cheat urself&#8230;.</p>
<p>Accepting this, Realizing this - that u have lost many times and its not possible for u to do whatever u want wud change u instantly. Wakeup from the very beautiful dream</p>
<p>u wud be surprising by this time do this post has really got a solution for this whole drama or whtever u name it <img src='http://www.karthikbala.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> yeah there is i.e &#8216;I am Lost&#8217; if and only if u understand it and accept it.</p>
<p>&#8216;I am Lost&#8217; is a philosophy where one will be lost in the thought of most subtle, divine, powerful and something which can be everything and nothing at the same time. Got any idea of what it can be? How can anything be everything and nothing at the same time, there is ONE which we all know. And that is GOD every religion says and ofcourse everyone of say GOD is ONE, HE has no form, no shape, no name, no attributes and at the same time we do also say HE is the almighty, HE is all pervasive, HE is the supremo etc&#8230;. Now u consider someone or something whom u feel GOD.</p>
<p>We loose many times because of lack of seriousness, laziness and this laziness is because we are addicted to our bodily pleasures and one easy solution to it is to feel GOD. Yeah feeling God is good in many ways. You have to feel as if you are God, feel feel and feel it until u lost in HIM. Lost in HIM?? yeah that happens, u wud even forget that u exist you will b enjoying in that divine glory and u now become GOD. And what more u want dear now u r GOD and where is the place for failure to YOU.  GOD never fails sweet offcourse u know it <img src='http://www.karthikbala.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>For all those enjoying the bliss of laziness and if at all if u had that enough and want to see the other side of world feeling GOD is the easiest or i wud like to call &#8216;laziest&#8217; way of putting an end to your laziness.</p>
<p>Constant Remembrance(TM)  of GOD wud help u a lot in absorbing into HIM. Forget urself, feel that u are GOD and feel that it is HE who is acting from ur body and not you. Whatever is happening think that HE is doing that and not you. Totally it is not you, its HIM.</p>
<p>P.S - Constant Rememberance is service mark of SRCM, Chennai.(www.srcm.org)</p>
<p>God in this article refer to Divine Light and does not relate to any religion.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.karthikbala.com/2007/12/19/i-lost-to-im-lost/feed/</wfw:commentRss>
		</item>
		<item>
		<title>JSF - Thirdparty components</title>
		<link>http://www.karthikbala.com/2007/12/05/jsf-thirdparty-components/</link>
		<comments>http://www.karthikbala.com/2007/12/05/jsf-thirdparty-components/#comments</comments>
		<pubDate>Wed, 05 Dec 2007 11:25:38 +0000</pubDate>
		<dc:creator>Karthik</dc:creator>
		
		<category><![CDATA[JSF]]></category>

		<category><![CDATA[Jmaki]]></category>

		<guid isPermaLink="false">http://www.karthikbala.com/?p=5</guid>
		<description><![CDATA[My struggle with adding thirdpary components into my jsf project started a week back and now am successful with the most efficient and powerful library jmaki. yeah jmaki is powerful because it gives the programmer full control on its working. I had given a try to apache myfaces and jboss richfaces but both doesnt show [...]]]></description>
			<content:encoded><![CDATA[<p>My struggle with adding thirdpary components into my jsf project started a week back and now am successful with the most efficient and powerful library jmaki. yeah jmaki is powerful because it gives the programmer full control on its working. I had given a try to apache myfaces and jboss richfaces but both doesnt show up their implementation or behavioral pattern. But jmaki widgets are simply a wrapper to the javascript and u r alway welcome to change its way of implementation.</p>
<p>The coolest is jmaki comes as an addon to the netbeans ide and once u have added it all u have to do is drag and drop.. all the library inclusion and neccessary file inclusion will be automatically done.</p>
<p>A small example of dropdowndatepicker widget of jmaki to c how jmaki rocks:</p>
<p><strong>my jsf page:</strong><br />
&lt;h:form id=&#8221;cal&#8221;&gt;<br />
&lt;a:widget name=&#8221;dojo.dropdowndatepicker&#8221;/&gt;<br />
&lt;h:inputText id=&#8221;selval&#8221; value=&#8221;#{calendar.date}&#8221;/&gt;<br />
&lt;h:commandButton action=&#8221;#{calendar.submit}&#8221; value=&#8221;Submit&#8221;/&gt;<br />
&lt;/h:form&gt;</p>
<p>every jmaki component uses a <em>publish/subscribe</em> mechanism i.e when an action performed on a widget, it publishes that action or listener and in <strong>glue.js</strong> u can subscribe to that like this:</p>
<p>jmaki.subscribe(&#8221;*onSelect&#8221;, function(args) { &#8212;ur javascript here&#8212;-});</p>
<p>the args parameter above will be receiving the selected value of the widget, so my js is</p>
<p>var target = document.getElementById(&#8217;cal:selval&#8217;);</p>
<p>target.value = args.value;                  // passing the widget&#8217;s value to the component&#8217;s value attribute</p>
<p>the code written in glue.js is always shipped with the jsf page and thats taken care by jmaki framework.</p>
<p>jmaki can b downloded from https://ajax.dev.java.net/</p>
]]></content:encoded>
			<wfw:commentRss>http://www.karthikbala.com/2007/12/05/jsf-thirdparty-components/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Beginning JSF (Programmer to Programmer)</title>
		<link>http://www.karthikbala.com/2007/11/12/begining-jsf-programmer-to-programmer/</link>
		<comments>http://www.karthikbala.com/2007/11/12/begining-jsf-programmer-to-programmer/#comments</comments>
		<pubDate>Tue, 13 Nov 2007 06:26:52 +0000</pubDate>
		<dc:creator>Karthik</dc:creator>
		
		<category><![CDATA[JSF]]></category>

		<category><![CDATA[Technology]]></category>

		<category><![CDATA[J2EE]]></category>

		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.karthikbala.com/?p=4</guid>
		<description><![CDATA[Any jsf project needs a particular directory structure as mentioned by the jsf framework.
This directory structure can be easily obtained by starting a jsf project in NetBeans.
To start a new jsf project in NetBeans:
1) Go to file click on new project.
2) Select the category as web and project as web application.
3) In the next page [...]]]></description>
			<content:encoded><![CDATA[<p>Any jsf project needs a particular directory structure as mentioned by the jsf framework.</p>
<p>This directory structure can be easily obtained by starting a jsf project in NetBeans.</p>
<p>To start a new jsf project in NetBeans:</p>
<p>1) Go to file click on new project.<br />
2) Select the category as web and project as web application.<br />
3) In the next page give the desired name for the project and location where to save the project.<br />
4) And in the same page select the server as tomcat that comes along with NetBeans.<br />
5) In the next page select the framework as JavaServer Faces this will enable the NetBeans to recognise the project as a type of jsf.<br />
6) Now you can see the new project under the projects window.<br />
7) Expand the new projec to see its directory structure viz. Web Pages, Configuration Files, etc..</p>
<p>To create a web page:</p>
<p>1) Right click on the Web Pages and select a new jsp page. (Only jsp pages acts as a jsf pages)<br />
2) This jsp page can be used to create the the user interface i.e web pages of ur project and the bussiness logic should not be mixed up in this page as we do in jsp.<br />
3) Interface can be created using jsf tags which provide rich user interface components that comes with properties to link up them with the business logic that u wud write in a backend bean.<br />
4) Backend beans are the java class files where u wud do ordinary java coding for ur bussiness logic.</p>
<p>To create a backend bean:</p>
<p>1) Right click on the Source Packages and select a new Java Class.<br />
2) In the wizard opened select names for the java file and for the package.</p>
<p>Any bean that u create in the project shud be registered in the faces-config.xml file i.e present in the Configuration Files as like</p>
<p>&lt;managed-bean&gt;<br />
&lt;managed-bean-name&gt;anyName&lt;/managed-bean-name&gt;<br />
&lt;managed-bean-class&gt;package.beanName&lt;/managed-bean-class&gt;<br />
&lt;managed-bean-scope&gt;session&lt;/managed-bean-scope&gt;<br />
&lt;/managed-bean&gt;</p>
<p>The below example wud clearly explain you the relationship between the jsp page and the backend bean.</p>
<p>Let us consider the example of a login page with two inputtext boxes for username and password and a button to submit.</p>
<p>Upon submit the username and password that the user enters in the webpage shud be verified and be allowed to the next page if he is authenticated.</p>
<p>so first to create the user interface on the web page</p>
<p>Open ur web page that was created earlier</p>
<p>We use the jsf tags that comes with the jsf library to create the user interface</p>
<p>To do so we need to import those library before we start using them</p>
<p>So the first two lines of any jsf page wud be the below ones:</p>
<p>&lt;%@ taglib uri=&#8221;http://java.sun.com/jsf/html&#8221; prefix=&#8221;h&#8221; %&gt;<br />
&lt;%@ taglib uri=&#8221;http://java.sun.com/jsf/core&#8221; prefix=&#8221;f&#8221; %&gt;</p>
<p>At the end of the above lines examine the prefix given as h and f</p>
<p>h denotes the basic html tags<br />
f denotes the jsf tags</p>
<p>These prefix letters can be changed according to ur choice but not recommended</p>
<p>The complete page wud look like</p>
<p>&lt;html&gt;<br />
&lt;head&gt;<br />
&lt;title&gt;Online Exam&lt;/title&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
&lt;f:view&gt;<br />
&lt;h1&gt;<br />
&lt;h:outputText value=&#8221;Login&#8221;/&gt;<br />
&lt;/h1&gt;<br />
&lt;p&gt;<br />
&lt;h:messages style=&#8221;color:darkred&#8221;/&gt;<br />
&lt;/p&gt;<br />
&lt;h:form id=&#8221;backlogForm&#8221;&gt;<br />
&lt;p&gt;<br />
&lt;h:outputText value=&#8221;UserName &#8220;/&gt;<br />
&lt;h:inputText value=&#8221;#{loginBean.userName}&#8221; id=&#8221;tf_UserName&#8221;/&gt;<br />
&lt;/p&gt;<br />
&lt;p&gt;<br />
&lt;h:outputText value=&#8221;Password  &#8220;/&gt;<br />
&lt;h:inputText value=&#8221;#{loginBean.password}&#8221; id=&#8221;tf_Password&#8221;/&gt;<br />
&lt;/p&gt;</p>
<p>&lt;h:commandButton action=&#8221;#{loginBean.submit}&#8221; value=&#8221;SUBMIT&#8221; /&gt;</p>
<p>&lt;/p&gt;<br />
&lt;/h:form&gt;<br />
&lt;/f:view&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</p>
<p>The above tags like h:outputText, h:messages, h:inputText are used in creating the user interface.</p>
<p>Look at the value of inputText is given as {vloginBena.userName} this means the value is bind with the userName property of the vloginBean.</p>
<p>so as to bind the value with a property in the bean we need to create setter and getter methods for that particular value.</p>
<p>To do so we need to have the following lines inside the class file:</p>
<p>String userName;</p>
<p>public String getUserName() {<br />
return userName;<br />
}</p>
<p>public void setUserName(String usr) {<br />
userName = usr;<br />
}</p>
<p>The above lines are the very common lines you wud encounter regularly in the jsf.</p>
<p>The above lines wud enable u to set or get the value of the interface components of ur web page inside the java file or the backend bean.</p>
<p>Now let us c how the java code of our example wud look like:</p>
<p>package beans;</p>
<p>import java.io.IOException;<br />
import java.sql.*;<br />
import javax.faces.FactoryFinder;<br />
import javax.faces.application.ApplicationFactory;<br />
import javax.faces.application.FacesMessage;<br />
import javax.faces.application.Application;<br />
import javax.faces.application.ViewHandler;<br />
import javax.faces.context.ExternalContext;<br />
import javax.faces.context.FacesContext;<br />
import javax.servlet.ServletContext;<br />
import javax.servlet.http.HttpSession;</p>
<p>public class LoginBean {</p>
<p>String userName;<br />
String password;<br />
String result = null;</p>
<p>public String getUserName() {<br />
return userName;<br />
}</p>
<p>public void setUserName(String usr) {<br />
userName = usr;<br />
}</p>
<p>public String getPassword() {<br />
return password;<br />
}</p>
<p>public void setPassword(String pwd) {<br />
password = pwd;<br />
}</p>
<p>public String submit() {</p>
<p>String userId = null;<br />
String password = null;</p>
<p>userId = getUserName();<br />
password = getPassword();<br />
System.out.println(&#8221;username is &#8220;+userId);<br />
System.out.println(&#8221;password is &#8220;+password);<br />
String result = null;</p>
<p>//If null user name / password  - redirect with error<br />
if (&#8221;".equals(userId) || &#8220;&#8221;.equals(password)) {<br />
// The below lines wud display a message on the web page by using the<br />
// h:messages tag that we used in the jsp page<br />
FacesMessage fm = new FacesMessage(&#8221;Field is Empty&#8221;);<br />
FacesContext.getCurrentInstance().addMessage(&#8221;Field is Empty&#8221;, fm);<br />
return &#8220;none&#8221;;<br />
}</p>
<p>//All the print statements wud get printed in the tomcat server console<br />
System.out.println(&#8221;auth start&#8221;);<br />
String auth = authenticateUser(userId, password);<br />
if(auth.equals(&#8221;pass&#8221;)){<br />
System.out.println(&#8221;authenticated&#8221;);</p>
<p>try {<br />
/*values can be stored in session<br />
such that they can be accessed from other beans<br />
*/<br />
HttpSession session = (HttpSession)                                     facesContext.getExternalContext().getSession(false);<br />
session.setAttribute(&#8221;userId&#8221;, userId);<br />
session.setAttribute(&#8221;password&#8221;, password);</p>
<p>/* Now redirect the user to home.jsp with user information<br />
The below value is returned to the faces-config.xml file where the navigation rule is applied see the faces-config.xml file at the end of this bean.*/<br />
return &#8220;welcome&#8221;;<br />
}<br />
catch (Exception e) {</p>
<p>FacesMessage fm = new FacesMessage(&#8221;session exception &#8221; +e.getMessage());<br />
FacesContext.getCurrentInstance().addMessage(&#8221;session exception &#8220;+e.getMessage(), fm);<br />
result = &#8220;none&#8221;;<br />
}<br />
}<br />
else{<br />
FacesMessage fm = new FacesMessage(&#8221;username and password doesnt match&#8221;);<br />
FacesContext.getCurrentInstance().addMessage(&#8221;username and password doesnt match&#8221;, fm);<br />
}<br />
return result;<br />
}</p>
<p>private String authenticateUser(String usr, String pwd){</p>
<p>if(usr.equals(&#8221;test&#8221;) &amp;&amp; pwd.equals(&#8221;test&#8221;)) {<br />
System.out.println(&#8221;pass&#8221;);<br />
return &#8220;pass&#8221;;<br />
}<br />
else<br />
return &#8220;fail&#8221;;<br />
}<br />
}</p>
<p>The faces-config.xml file wud look like:</p>
<p>&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;UTF-8&#8243;?&gt;<br />
&lt;!DOCTYPE faces-config PUBLIC &#8220;-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN&#8221; &#8220;http://java.sun.com/dtd/web-facesconfig_1_1.dtd&#8221;&gt;<br />
&lt;!&#8211; =========== FULL CONFIGURATION FILE ================================== &#8211;&gt;<br />
&lt;faces-config xmlns=&#8221;http://java.sun.com/JSF/Configuration&#8221;&gt;</p>
<p>&lt;navigation-rule&gt;<br />
&lt;from-view-id&gt;/login.jsp&lt;/from-view-id&gt;<br />
&lt;navigation-case&gt;<br />
&lt;!&#8211; Add a navigation from login page to next page &#8211;&gt;<br />
&lt;from-action&gt;#{loginBean.submit}&lt;/from-action&gt;<br />
&lt;from-outcome&gt;welcome&lt;/from-outcome&gt;<br />
&lt;to-view-id&gt;/nextpage.jsp&lt;/to-view-id&gt;<br />
&lt;/navigation-case&gt;<br />
&lt;/navigation-rule&gt;</p>
<p>&lt;managed-bean&gt;<br />
&lt;managed-bean-name&gt;loginBean&lt;/managed-bean-name&gt;<br />
&lt;managed-bean-class&gt;beans.LoginBean&lt;/managed-bean-class&gt;<br />
&lt;managed-bean-scope&gt;session&lt;/managed-bean-scope&gt;<br />
&lt;/managed-bean&gt;</p>
<p>&lt;/faces-config&gt;</p>
<p>Any jsf project you do will require editing these basic three pages else others for advanced functions.</p>
<p>The component that plays vital role in many forms is the drop down button.</p>
<p>You may need to do certain action performed on the remaining components on the selection of the<br />
value in the drop down button like disabling (non editable) the components or even making them invisible.</p>
<p>So lets c how to dynamically vary the form based on the value selected in the combo box.</p>
<p>So lets now look at the syntax of a combobox:</p>
<p>&lt;h:selectOneMenu value=&#8221;#{feeReg.cm_VEH_TYPE}&#8221;<br />
onchange=&#8221;submit()&#8221; id=&#8221;cm_VEH_TYPE&#8221;<br />
valueChangeListener=&#8221;#{feeReg.cm_VEH_TYPE_Changed}&#8221;<br />
immediate=&#8221;true&#8221;&gt;<br />
&lt;f:selectItems value=&#8221;#{feeReg.cm_VEH_TYPE_List}&#8221;/&gt;<br />
&lt;h:outputLabel id=&#8221;cm_VEH_TYPELabel&#8221; for=&#8221;cm_VEH_TYPE&#8221; value=&#8221;Vehicle Type:&#8221;/&gt;<br />
&lt;/h:selectOneMenu&gt;</p>
<p>h:selectOneMenu is the jsf tag to implement a combo box, look at the various parameters that u can pass to tis tag, value which we have seen, valueChangeListener is the one which will watch for the value change and will call the code that is assigned to this parameter, here we refered it to a method cm_VEH_TYPE_Changed in the feeReg bean. So what u write inside a this method will be a normal java code for ur bussiness logic.</p>
<p>And now in the logic u may want to disable or make other components in the form invisible but how wud u access the components in the bean to dynamically change them.</p>
<p>As we have seen earlier we can set or get the value of inputtext box by using the setter and getter method written inside the bean and are linked up to the component to its value parameter. So similarly there are parmeters like disabled and rendered that can be applied to any of the components and set their value that is true or false by calling the bean.</p>
<p>so lets c how we do it:</p>
<p>Suppose we want to disable or make an inputtext box invisible</p>
<p>&lt;h:inputText id=&#8221;tf_SEAT_CAP&#8221; value=&#8221;#{feeReg.tf_SEAT_CAP}&#8221; disabled=&#8221;#{feeReg.tf_SEAT_CAP_Disabled}&#8221;<br />
rendered=&#8221;#{feeReg.tf_SEAT_CAP_Rendered}&#8221;&gt;<br />
&lt;h:outputLabel id=&#8221;tf_SEAT_CAPLabel&#8221; for=&#8221;tf_SEAT_CAP&#8221;&gt;<br />
&lt;h:outputText value=&#8221;Seating Capacity:&#8221;/&gt;<br />
&lt;/h:outputLabel&gt;<br />
&lt;/h:inputText&gt;</p>
<p>Look at the above h:inputText tag with several parmeters like id, value, disabled and rendered.</p>
<p>The value that is assigned to the &#8220;disabled&#8221; shud be true or false but we have not declared it directly instead we are redirecting it to a property inside a bean where its value is assigned.</p>
<p>A property inside a bean by definition shud have a setter and getter method.</p>
<p>So now once u have the setter and getter methods for a disabled property of inputText box u can dynamically set the value true or false in your bussiness logic.</p>
<p>And the same way goes for &#8220;rendered&#8221; which is used to make a component visible or invisible.</p>
<p>And in the above code the h:outputLabel is used to assign a label for the inputText box.<br />
The &#8220;for&#8221; parmeter of the h:outputLabel will assign the label to the particular component with the &#8216;id&#8217; as assigned to the &#8216;for&#8217;.<br />
So giving an &#8216;id&#8217; for all the component is a good idea.</p>
<p>Rest all in the next post. untill then happy coding..</p>
]]></content:encoded>
			<wfw:commentRss>http://www.karthikbala.com/2007/11/12/begining-jsf-programmer-to-programmer/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Hi ya&#8230;</title>
		<link>http://www.karthikbala.com/2007/11/01/hi-ya/</link>
		<comments>http://www.karthikbala.com/2007/11/01/hi-ya/#comments</comments>
		<pubDate>Fri, 02 Nov 2007 05:30:36 +0000</pubDate>
		<dc:creator>Karthik</dc:creator>
		
		<category><![CDATA[Spirituality]]></category>

		<category><![CDATA[Technology]]></category>

		<category><![CDATA[Introduction]]></category>

		<guid isPermaLink="false">http://www.karthikbala.com/?p=3</guid>
		<description><![CDATA[TechSpirit - Am not trying to compare these two. Technology and Spirituality are my two great interests and have been living with these two from a long time.. So I got something on these two to share with the world. Yes as I said am not going to compare these two for now but may [...]]]></description>
			<content:encoded><![CDATA[<p style="TEXT-ALIGN: justify"><span>TechSpirit</span> - Am not trying to compare these two. Technology and Spirituality are my two great interests and have been living with these two from a long time.. So I got something on these two to share with the world. Yes as I said am not going to compare these two for now but may be in future. Have been watching the relation between these and found some&#8230; may be we can find few relations between any two odd objects too, so I don&#8217;t want to discuss these until I found something very sound.</p>
<p style="TEXT-ALIGN: justify"><span style="color: #339966;"><span>Technology and Me:</span><br />
</span>I looked at that beautiful white angel like machine when I started my first computer course - Logo in my eighth standard and fallen in love with computers when I completed the course (reason: I scored my first ever 100%)। And it took almost three years to get back to that angel in the summer vacation after my 12th for the courses on C and MS-Office. So the love for computers made me to take Information Technology as my major in under graduation. The reason why IT but not CSE is I read much on daily news papers describing the word IT rather than computer science(the IT down trend, the IT boom, the sept 11 attack etc). But only after joining the college I found that I made a mistake off course that doesn&#8217;t made a big difference. I might have not found my mistake if I have studied in any other university other than Anna, no other univ in India shows such a discrimination between these two branches hats off to Anna. I had my first email account with yahoo(may be for chat rooms i didn&#8217;t remember) in my B.Tech first year and my relation with tech continued from then. <span><span style="color: #ff6600;">Life Mein Twist</span></span> - yeah the twist in the tech part of my life came when I met my tech guru and my college friend <span style="color: #ffff99;">Prashanth Ellina</span>. This guy is a tech savvy, computer geek and &#8230;.he deserves an article in my blog <img src='http://www.karthikbala.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> so, guys searching for a guru, follow my posts to know more abt him.. missing it may take u 1000 more years(dont forget u r into a blog with spirituality) to find one again. I didnt bank on much technology during my engineering days which led to unemployment after my under graduation. I started my career as Technical Support Executive in Sutherland and thereafter worked as a lecturer in Bapatla Engineering College, Andhra Pradesh. Finally four months back as neo back to the core I entered into the world of my pleasure - field of technology. Though HCL is my payee I work in National Informatics Center where am working under National Road Transport dept. for building a software application for Regional Transport Offices. My work includes hands on Core Java, Swings, RMI, Servlets, JSP, JSF, application servers, NetBeans IDE and few other support tools. I will be very happy to suggest you on any of these and if any of u are into any of these fields let me know.</p>
<p style="TEXT-ALIGN: justify"><span style="color: #339966;"><span>Spirituality and Me:</span><br />
</span>The word spirituality doesn&#8217;t has any meaning for me when I was introduced to meditation in 12th class by my friend Ramakrishna। I started meditation with an interest on it, an interest with no specific reason।I was a guy fond of powers(alladin and gini impressed me) fortunately or unfortunately the one I started named &#8216;Anapanasati&#8217; (type of meditation) talks more about powers and supernatural things like cosmic energy, souls etc॥ which seemed very interesting to me and practiced it with great enthu. Lost in touch with my friend and meditation after my 12th for almost two years. <span><span style="color: #ff6600;">Life Mein Twist</span></span> - While I was going home from college in B.Tech second year I was told about <span style="font-weight: bold;">Shri Ram Chandra Mission</span> (SRCM) by my fellow passengers. Soon after I returned Chennai I joined in the Mission, the Meditation that this Mission teaches is completely different to the one I practiced before and I loved the new one (more abt SRCM on nxt posts).</p>
<p style="TEXT-ALIGN: justify"><span>Its me, SRCM Abhyasi and </span><span>HCL Employee</span><span>&#8230;</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.karthikbala.com/2007/11/01/hi-ya/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
