<?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"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>JavaBeat &#187; NetBeans</title>
	<atom:link href="http://www.javabeat.net/category/tools-ides/netbeans/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.javabeat.net</link>
	<description>Java Technology News</description>
	<lastBuildDate>Thu, 23 May 2013 01:30:53 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>HelloWorld with Netbeans 7.2 beta and Scala 2.9</title>
		<link>http://www.javabeat.net/2012/06/helloworld-with-netbeans-7-2-beta-and-scala-2-9/</link>
		<comments>http://www.javabeat.net/2012/06/helloworld-with-netbeans-7-2-beta-and-scala-2-9/#comments</comments>
		<pubDate>Tue, 05 Jun 2012 00:00:16 +0000</pubDate>
		<dc:creator>Smita</dc:creator>
				<category><![CDATA[NetBeans]]></category>
		<category><![CDATA[netbeans 7.2]]></category>
		<category><![CDATA[scala]]></category>
		<category><![CDATA[scala 2.9]]></category>

		<guid isPermaLink="false">http://www.javabeat.net/?p=4117</guid>
		<description><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><p>Here is the step by step procedure to set up the scala(2.9) environment with Netbeans(7.2) on a Windows Vista system 1. Install Netbeans 7.2 Beta if not already installed from here. 2. Download the Scala installable from here. Install Scala on your system. 3. Set the environment variable SCALA_HOME pointing it to the Scala installation directory. (On Windows [...]</p>]]></description>
				<content:encoded><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><div class="wpInsert wpInsertInPostAd wpInsertLeft" style="float: left; margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Rect */
google_ad_slot = "9976259118";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div><a id="dd_start"></a><p>Here is the step by step procedure to set up the <strong>scala(2.9)</strong> environment with Netbeans(7.2) on a Windows Vista system</p>
<p>1. Install <strong>Netbeans 7.2</strong> Beta if not already installed from <a href="http://netbeans.org/community/releases/72/">here</a>.</p>
<p>2. Download the <strong>Scala</strong> installable from <a href="http://www.scala-lang.org/downloads">here</a>. Install <strong>Scala</strong> on your system.</p>
<p>3. Set the environment variable SCALA_HOME pointing it to the <strong>Scala</strong> installation directory. (On Windows Vista, Go to Start Menu -&gt;Right click on Computer -&gt; Select Properties -&gt; From the left menu, Click on Advanced system Settings -&gt; Click on the Environment variables button on the bottom right corner -&gt; Create new System variable named SCALA_HOME pointing to the Scala installation directory).</p>
<p>4. Now we need to install <strong>Scala</strong> plugin for <strong>Netbeans</strong>. Download the plugin <a href="http://plugins.netbeans.org/plugin/38999/nbscala-2-9-x-0-9">here</a> and extract the content into an appropriate folder.</p>
<p>5. Open Netbeans IDE.</p>
<p>6. On the Menu Bar, choose Tools -&gt; Plugin</p>
<p style="text-align: center;"><a href="http://www.javabeat.net/wp-content/uploads/2012/06/Tools_Plugins.jpg"><img class=" wp-image-4193 aligncenter" src="http://www.javabeat.net/wp-content/uploads/2012/06/Tools_Plugins.jpg" alt="" width="423" height="263" /></a></p>
<p>7. Choose Downloaded tab. Click on Add Plugins button. Browse to the folder containing scala plugins. Choose all the *.nbm files and hit the Install button on the bottom left corner.</p>
<p style="text-align: center;"><a href="http://www.javabeat.net/wp-content/uploads/2012/06/AddPlugins_Select1.jpg"><img class="aligncenter  wp-image-4187" src="http://www.javabeat.net/wp-content/uploads/2012/06/AddPlugins_Select1-e1339180670328-1024x506.jpg" alt="Add plugin and select all nbm files" width="423" height="263" /></a></p>
<p>5. You need to hit the Next / Continue button and accept the agreements on all the windows that pop up after that.</p>
<p style="text-align: center;"><a href="http://www.javabeat.net/wp-content/uploads/2012/06/Install_SelectedPlugins.jpg"><img class="aligncenter  wp-image-4189" src="http://www.javabeat.net/wp-content/uploads/2012/06/Install_SelectedPlugins-e1339180828864-1024x508.jpg" alt="Install_SelectedPlugins" width="423" height="263" /></a></p>
<p style="text-align: center;"><a href="http://www.javabeat.net/wp-content/uploads/2012/06/ContinueUnsigned-e1339179865267.jpg"><img class="aligncenter  wp-image-4201" src="http://www.javabeat.net/wp-content/uploads/2012/06/ContinueUnsigned-e1339179865267-1024x503.jpg" alt="" width="423" height="263" /></a></p>
<p style="text-align: center;"><a href="http://www.javabeat.net/wp-content/uploads/2012/06/Install_SelectedPluginsCont-e1339180958393.jpg"><img class="aligncenter  wp-image-4190" src="http://www.javabeat.net/wp-content/uploads/2012/06/Install_SelectedPluginsCont-e1339180958393-1024x508.jpg" alt="" width="423" height="263" /></a></p><div class="wpInsert wpInsertInPostAd wpInsertMiddle" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Middle-Med-Rect */
google_ad_slot = "7805667846";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
<p style="text-align: center;"><a href="http://www.javabeat.net/wp-content/uploads/2012/06/SuccessInstalled.jpg"><img class="aligncenter  wp-image-4192" src="http://www.javabeat.net/wp-content/uploads/2012/06/SuccessInstalled-e1339181197586-1024x506.jpg" alt="" width="423" height="263" /></a></p>
<p>Plugin auto installs everything.</p>
<p>6. Create New Project. You should now be able to see a new category named Scala. Choose Scala Application. Choose your project name / location and click on Finish. An object named Main which prints out &#8220;Hello World&#8221; gets created by default. You can run this file as is by hitting Shift+F6 just to check if the environment is correctly set. HelloWorld should get printed as output.</p>
<p style="text-align: center;"><a href="http://www.javabeat.net/wp-content/uploads/2012/06/NewScalaProject-e1339181343297.jpg"><img class="aligncenter  wp-image-4191" src="http://www.javabeat.net/wp-content/uploads/2012/06/NewScalaProject-e1339181343297-1024x506.jpg" alt="" width="423" height="263" /></a></p>
<p style="text-align: center;"><a href="http://www.javabeat.net/wp-content/uploads/2012/06/HelloWorld.jpg"><img class="aligncenter  wp-image-4188" src="http://www.javabeat.net/wp-content/uploads/2012/06/HelloWorld-e1339181397675-1024x508.jpg" alt="" width="423" height="263" /></a></p>
<p>Writing a first <strong>Scala</strong> program on <strong>Netbeans 7.2</strong> seemed a breeze. No headache of conf file changes. But <strong>Netbeans 7.2</strong> does seem a lot lot slower than its earlier version 7.0(I have not tried 7.1). Probably because it still is a Beta version.</p>
<p>Following are <span style="text-decoration: underline;"><strong>some gotchas</strong></span> if you are trying to get Scala to work on <strong>Netbeans 7.0</strong> or an earlier version of Scala-</p>
<p>1. After installing the plugin, you should be able to create a new Scala project. In case you are not, check if any of the scala plugins are not activated. Select them and activate them.</p>
<p>2. Error message &#8211; Could not load definitions from resource scala/tools/ant/antlib.xml. It could not be found.</p>
<p>Solution &#8211; Check if <strong>Scala</strong> has been correctly installed. Append &#8220;-J-Dscala.home=scalahomepath&#8221; property to the end of &#8220;netbeans_default_options&#8221; in NetBeansInstallationPath/etc/netbeans.conf where scalahomepath is the actual path to the Scala installation directory.</p>
<p>Please do let me know how your Scala environment setup with Netbeans went. I will be happy to respond to your questions if any. Please feel free to add your comments below.</p>
<p><em>Adios</em> until the next post !</p>
<div class='dd_outer'><div class='dd_inner'><div id='dd_ajax_float'><div class='dd_button_v'><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like href="http%3A%2F%2Fwww.javabeat.net%2Fcategory%2Ftools-ides%2Fnetbeans%2Ffeed%2F" send="false" show_faces="false"  layout="box_count" width="50"  ></fb:like></div><div style='clear:left'></div><div class='dd_button_v'><script type='text/javascript' src='https://apis.google.com/js/plusone.js'></script><g:plusone size='tall' href='http://www.javabeat.net/category/tools-ides/netbeans/feed/'></g:plusone></div><div style='clear:left'></div><div class='dd_button_v'><a href="http://twitter.com/share" class="twitter-share-button" data-url="http://www.javabeat.net/category/tools-ides/netbeans/feed/" data-count="vertical" data-text="NetBeans" data-via="javabeat" ></a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div><div style='clear:left'></div><div class='dd_button_extra_v'><script type="text/javascript">jQuery(document).load(function(){ stLight.options({publisher:'bab47279-62c9-46af-addc-79fd1fe8fee0'}); });</script><div class="st_email_custom"><span id='dd_email_text'>email</span></div></div><div style='clear:left'></div><div class='dd_button_extra_v'><div id='dd_print_button'><span id='dd_print_text'><a href='javascript:window:print()'>print</a></span></div></div><div style='clear:left'></div></div></div></div><script type="text/javascript">var dd_offset_from_content = 44; var dd_top_offset_from_content = 0;</script><script type="text/javascript" src="http://www.javabeat.net/wp-content/plugins/digg-digg//js/diggdigg-floating-bar.js?ver=5.3.0"></script><div class="wpInsert wpInsertInPostAd wpInsertBelow" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* JB-Footer-LU 468x15 */
google_ad_slot = "8789107210";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>]]></content:encoded>
			<wfw:commentRss>http://www.javabeat.net/2012/06/helloworld-with-netbeans-7-2-beta-and-scala-2-9/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>How to create EJB project in NetBeans 7.0?</title>
		<link>http://www.javabeat.net/2011/06/how-to-create-ejb-project-in-netbeans-7-0/</link>
		<comments>http://www.javabeat.net/2011/06/how-to-create-ejb-project-in-netbeans-7-0/#comments</comments>
		<pubDate>Mon, 13 Jun 2011 23:30:32 +0000</pubDate>
		<dc:creator>krishnas</dc:creator>
				<category><![CDATA[EJB 3.0]]></category>
		<category><![CDATA[NetBeans]]></category>

		<guid isPermaLink="false">http://www.javabeat.net/?p=2399</guid>
		<description><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><p>NetBeans IDE 7 CookbookWelcome to the NetBeans Cookbook. NetBeans is a Java Integrated Development Environment, IDE, which enables fast application development with the most adopted frameworks, technologies, and servers. Different than other IDEs, NetBeans comes already pre-packaged with a wide range of functionality out of the box, such as support for different frameworks, servers, databases, [...]</p>]]></description>
				<content:encoded><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><div class="wpInsert wpInsertInPostAd wpInsertLeft" style="float: left; margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Rect */
google_ad_slot = "9976259118";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div><p><center>NetBeans IDE 7 Cookbook</center>Welcome to the NetBeans Cookbook.</p>
<p>NetBeans is a Java Integrated Development Environment, IDE, which enables fast<br />
application development with the most adopted frameworks, technologies, and servers.</p>
<p>Different than other IDEs, <strong>NetBeans</strong> comes already pre-packaged with a wide range of<br />
functionality out of the box, such as support for different frameworks, servers, databases,<br />
and mobile development.</p>
<p>This book does require a minimal knowledge of Java platform, more specifically the<br />
language ifself. But the book might as well be used by either beginners, who are trying to<br />
dip their toes in new technology, or more experienced developers, who are trying to<br />
switch from other IDEs but want to decrease their learning curve of a new environment.<br />
<strong>NetBeans</strong> integrates so many different technologies, many of which are present in this<br />
book, that it is beyond the scope of this book to cover all of them in depth. We provide<br />
the reader with links and information where to go when further knowledge is required.</p>
<h1>What This Book Covers</h1>
<p><em>Chapter 1, NetBeans Head First</em> introduces the developer to the basics of <strong>NetBeans</strong> by<br />
creating basic Java projects and importing Eclipse or Maven projects.</p>
<p><em>Chapter 2, Basic IDE Usage</em> covers the creation of packages, classes, and constructors, as<br />
well as some usability feature.</p>
<p><em>Chapter 3, Designing Desktop GUI Applications</em> goes through the process of creating<br />
a desktop application, then connecting it to a database and even modifying it to look<br />
more professional.</p>
<p><em>Chapter 4, JDBC and NetBeans</em> helps the developer to setup <strong>NetBeans</strong> with the most<br />
common database systems on the market and shows some of the functionality built-in to<br />
<strong>NetBeans</strong> for handling SQL.</p>
<p><em>Chapter 5, Building Web Applications</em> introduces the usage of web frameworks such as<br />
JSF, Struts, and GWT.3</p>
<p><em>Chapter 6, Using JavaFX</em> explains the basic of JavaFX application states and connecting<br />
our JavaFX app to a web service interface.</p>
<p><em>Chapter 7, EJB Application</em> goes through the process of building an <strong>EJB</strong> application<br />
which supports <strong>JPA</strong>, stateless, and stateful beans and sharing a service through a web<br />
service interface.</p>
<p><em>Chapter 8, Mobile Development</em> teaches how to create your own CLDC or CDC<br />
applications with the help of <strong>NetBeans</strong> Visual Mobile Designer.</p>
<p><em>Chapter 9, Java Refactoring lets</em> <strong>NetBeans</strong> refactor your code to extract classes,<br />
interfaces, encapsulate fields, and other options.</p>
<p><em>Chapter 10, Extending the IDE</em> includes handy examples on how to create your own<br />
panels and wizards so you can extend the functionality of the IDE.</p>
<p><em>Chapter 11, Profiling and Testing</em> covers <strong>NetBeans</strong> Profiler, HTTP Monitor, and<br />
integration with tools that analyze code quality and load generator.</p>
<p><em>Chapter 12, Version Control</em> shows how to configure <strong>NetBeans</strong> to be used with the most<br />
common version control systems on the market.</p>
<p><center>EJB Application</center>In this chapter, we will cover:</p>
<ul>
<li>Creating an EJB project</li>
<li>Adding JPA support</li>
<li>Creating Stateless Session Bean</li>
<li>Creating Stateful Session Bean</li>
<li>Sharing a service through Web Service</li>
<li>Creating a Web Service client</li>
</ul>
<h2>Introduction</h2>
<p><strong>Enterprise Java Beans (EJB)</strong> is a framework of server-side components that encapsulates<br />
business logic.</p>
<p>These components adhere to strict specifications on how they should behave. This ensures<br />
that vendors who wish to implement <strong>EJB</strong>-compliant code must follow conventions, protocols,<br />
and classes ensuring portability.</p><div class="wpInsert wpInsertInPostAd wpInsertMiddle" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Middle-Med-Rect */
google_ad_slot = "7805667846";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
<p>The <strong>EJB</strong> components are then deployed in <strong>EJB</strong> containers, also called <strong>application servers</strong>,<br />
which manage persistence, transactions, and security on behalf of the developer.</p>
<p>If you wish to learn more about <strong>EJB</strong>s, visit http://jcp.org/en/jsr/detail?id=318 or</p>
<p>https://www.packtpub.com/developer-guide-for-ejb3/book.</p>
<p>For our <strong>EJB</strong> application to run, we will need the application servers.</p>
<p>Application servers are responsible for implementing the <strong>EJB</strong> specifications and creating the<br />
perfect environment for our <strong>EJB</strong>s to run in.</p>
<p>Some of the capabilities supported by <strong>EJB</strong> and enforced by Application Servers are:</p>
<ul>
<li>Remote access</li>
<li>Transactions</li>
<li>Security Scalability</li>
</ul>
<p><strong>NetBeans 6.9</strong>, or higher, supports the new Java EE 6 platform, making it the only IDE so far<br />
to bring the full power of <strong>EJB 3.1</strong> to a simple IDE interface for easy development.</p>
<p><strong>NetBeans</strong> makes it easy to develop an <strong>EJB</strong> application and deploy on different Application<br />
Servers without the need to over-configure and mess with different configuration files. It&#8217;s<br />
as easy as a project node right-click.</p>
<h2>Creating EJB project</h2>
<p>In this recipe, we will see how to create an <strong>EJB</strong> project using the wizards provided<br />
by <strong>NetBeans</strong>.</p>
<h3>Getting ready</h3>
<p>It is required to have <strong>NetBeans</strong> with Java EE support installed to continue with this recipe.</p>
<p>If this particular <strong>NetBeans</strong> version is not available in your machine, then you can download it<br />
from http://download.netbeans.org.</p>
<p>There are two application servers in this installation package, Apache Tomcat or GlassFish,<br />
and either one can be chosen , but at least one is necessary.</p>
<p>In this recipe, we will use the GlassFish version that comes together with NetBeans 7.0<br />
installation package.</p>
<h3>How to do it&#8230;</h3>
<ol>
<li>Lets create a new project by either clicking <strong>File</strong> and then <strong>New Project</strong>, or by pressing<br />
<em>Ctrl+Shift+N</em>.</li>
<li>In the <strong>New Project</strong> window, in the categories side, choose <strong>Java Web</strong> and in <strong>Projects<br />
side</strong>, select <strong>WebApplication</strong>, then click <strong>Next</strong>.</li>
<li>In <strong>Name and Location</strong>, under Project Name, enter <strong>EJBApplication</strong>.</li>
<li>Tick the <strong>Use Dedicated Folder for Storing Libraries</strong> option box.</li>
<li>Now either type the folder path or select one by clicking on <strong>browse</strong>.</li>
<li>After choosing the folder, we can proceed by clicking <strong>Next</strong>.</li>
<li>In <strong>Server and Settings</strong>, under <strong>Server</strong>, choose <strong>GlassFish Server 3.1</strong>.</li>
<li>Tick <strong>Enable Contexts and Dependency Injection</strong>.</li>
<li>Leave the other values with their default values and click <strong>Finish</strong>.</li>
</ol>
<p>The new project structure is created.</p>
<h3>How it works&#8230;</h3>
<p><strong>NetBeans</strong> creates a complete file structure for our project.</p>
<p>It automatically configures the compiler and test libraries and creates the GlassFish<br />
deployment descriptor.</p>
<p>The deployment descriptor filename specific for the GlassFish web server is<br />
glassfish-web.xml.</p>
<p><center><img src="images/2011/06/ejb-application/ejb-application-1.jpg" alt="" /></center></p>
<div class="wpInsert wpInsertInPostAd wpInsertBelow" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* JB-Footer-LU 468x15 */
google_ad_slot = "8789107210";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>]]></content:encoded>
			<wfw:commentRss>http://www.javabeat.net/2011/06/how-to-create-ejb-project-in-netbeans-7-0/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>NetBeans IDE 7.0 Final available for download!</title>
		<link>http://www.javabeat.net/2011/06/netbeans-ide-7-0-final-available-for-download/</link>
		<comments>http://www.javabeat.net/2011/06/netbeans-ide-7-0-final-available-for-download/#comments</comments>
		<pubDate>Sat, 11 Jun 2011 13:46:31 +0000</pubDate>
		<dc:creator>JavaBeat</dc:creator>
				<category><![CDATA[NetBeans]]></category>

		<guid isPermaLink="false">http://www.javabeat.net/examples/?p=301</guid>
		<description><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><p>NetBeans IDE 7.0 NetBeans™ IDE 7.0 introduces language support for coding to the proposed Java SE 7 specification with the JDK 7 developer preview. Developers can now take advantage of the new language features from Project Coin /JSR 334, with editor support for code completion, hints, and in specific cases converting existing Java SE 6 [...]</p>]]></description>
				<content:encoded><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><div class="wpInsert wpInsertInPostAd wpInsertLeft" style="float: left; margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Rect */
google_ad_slot = "9976259118";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div><h1>NetBeans IDE 7.0</h1>
<p>NetBeans™ IDE 7.0 introduces language support for coding to the proposed Java SE 7 specification with the JDK 7 developer preview. Developers can now take advantage of the new language features from Project Coin /JSR 334, with editor support for code completion, hints, and in specific cases converting existing Java SE 6 based code to use the new Java SE 7 based syntax. </p>
<p>The release also provides enhanced integration with the Oracle WebLogic server as well as support for Oracle Database and GlassFish 3.1. The Oracle WebLogic server integration enhancements include fast turnaround when redeploying applications; deploy on save; datasource management; server library configuration; the ability to explore deployed applications and resources, and to view server logs and the admin console from within the IDE. </p>
<p>Additional highlights include Maven 3 and HTML5 editing support; a new GridBagLayout designer for improved Swing GUI development; enhancements to the Java editor, and more. </p><div class="wpInsert wpInsertInPostAd wpInsertMiddle" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Middle-Med-Rect */
google_ad_slot = "7805667846";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
<p>NetBeans IDE 7.0 is available in English, Brazilian Portuguese, Japanese, Russian, and Simplified Chinese. </p>
<h3>Release Highlights</h3>
<h3>JDK 7</h3>
<ul>
<li>Project Coin support</li>
<li>Editor enhancements: Code completion, hints</li>
</ul>
<h3>WebLogic Server</h3>
<ul>
<li>Streamlined and faster deployment to WebLogic</li>
<li>New server runtime node displaying deployed applications and resources</li>
</ul>
<h3>Oracle Database</h3>
<ul>
<li>Simplified connection wizard</li>
<li>Guided installation to JDBC driver</li>
</ul>
<h3>GlassFish</h3>
<ul>
<li>GlassFish 3.1 support</li>
<li>Domain restart and log viewer for remote GlassFish</li>
</ul>
<h3>Java</h3>
<ul>
<li>Maven 3 support</li>
<li>JUnit 4.8.2 integration and various JUnit improvements</li>
<li>New improved visual customizer for GridBagLayout</li>
</ul>
<h3>Java EE</h3>
<ul>
<li>Improved support for CDI, REST services and Java Persistence</li>
<li>Improved editing for Expression Language in JSF, including code completion, refactoring and hints</li>
</ul>
<h3>Web Languages</h3>
<ul>
<li>HTML5 editing support</li>
<li>JSON formatter</li>
</ul>
<h3>PHP</h3>
<ul>
<li>Generate PhpDoc</li>
<li>Rename refactoring, Safe Delete Refactoring</li>
</ul>
<h3>C/C++</h3>
<ul>
<li>Easy import of project from user&#8217;s existing binary</li>
<li>New Project type where user&#8217;s source files are located on remote system</li>
</ul>
<h3>NetBeans Platform</h3>
<ul>
<li>Annotations for generating Action registrations in the layer</li>
<li>Performance enhancements &amp; tight integration with Profiler</li>
</ul>
<h3>General</h3>
<ul>
<li>Word wrap in Editor</li>
<li>Enhanced Profiler integration</li>
</ul>
<ul>
<li><a href="http://netbeans.org/downloads/index.html" target="_blank">NetBeans 7.0 Download</a></li>
</ul>
<div class="wpInsert wpInsertInPostAd wpInsertBelow" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* JB-Footer-LU 468x15 */
google_ad_slot = "8789107210";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>]]></content:encoded>
			<wfw:commentRss>http://www.javabeat.net/2011/06/netbeans-ide-7-0-final-available-for-download/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Window System in NetBeans Platform 6.9</title>
		<link>http://www.javabeat.net/2009/09/window-system-in-netbeans-platform-6-9/</link>
		<comments>http://www.javabeat.net/2009/09/window-system-in-netbeans-platform-6-9/#comments</comments>
		<pubDate>Thu, 17 Sep 2009 00:44:16 +0000</pubDate>
		<dc:creator>krishnas</dc:creator>
				<category><![CDATA[NetBeans]]></category>

		<guid isPermaLink="false">http://www.javabeat.net/?p=1762</guid>
		<description><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><p>NetBeans Platform 6.9 Developer&#8217;s Guide The NetBeans Platform 6.9 is the world&#8217;s only modular Swing application framework. It aims to drastically simplify desktop application development by providing a number of techniques, patterns, and full-blown Swing components. Most desktop applications have very similar technical requirements, such as the following: • Consistent user interface • Extensibility • [...]</p>]]></description>
				<content:encoded><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><div class="wpInsert wpInsertInPostAd wpInsertLeft" style="float: left; margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Rect */
google_ad_slot = "9976259118";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div><p><H1><CENTER>NetBeans Platform 6.9 Developer&#8217;s Guide</CENTER></H1><br />
<P>The <b>NetBeans Platform 6.9</b> is the world&#8217;s only modular Swing application framework. It aims<br />
to drastically simplify desktop application development by providing a number of<br />
techniques, patterns, and full-blown Swing components.</P><br />
<P>Most desktop applications have very similar technical requirements, such as the<br />
following:</P><br />
<P>• Consistent user interface • Extensibility • Data display • Configuration settings • Help<br />
system • Distribution mechanisms • Online update function • Cross-operating system<br />
support</P><br />
<P>Fulfilling these technical requirements over and over again for each new application is<br />
expensive, superfluous, and boring. The <b>NetBeans Platform 6.9</b> gives the developer a<br />
transparent, open source, extensible, and free framework that addresses all of these<br />
technical requirements.</P><br />
<P>This book doesn&#8217;t aim to explicate all that the <b>NetBeans Platform 6.9</b> offers or to explore<br />
each and every corner of its many features. Rather, this book guides you through the<br />
development of a specific Java desktop application, while showing you everything that is<br />
relevant in the context of the particular application itself. That process, in turn, will lead<br />
you through the main features relevant to the development of most general applications<br />
on the <b>NetBeans Platform 6.9</b>.</P><br />
<P>The central driver of the book is, therefore, the creation of a complete Java desktop<br />
application, chapter by chapter, step-by-step, sequentially through the progression of<br />
chapters in this book</P><br />
<H1>What This Book Covers</H1><br />
<P><b><I>Chapter 1, Module:</I></b> A module is the basic building block of a <b>NetBeans Platform 6.9</b><br />
application. In the chapter dealing with this theme, you learn why it makes sense to<br />
develop modular applications, while examining the features of modules, as well as their<br />
interdependencies. Moreover, you examine module versioning and the lifecycle of<br />
modules, as well as the entry points into that lifecycle.</P><br />
<P><b><I>Chapter 2, Forms:</I></b> Almost every large desktop application needs to provide a number of<br />
forms that accept data from the user. You learn how forms are created for usage on the<br />
<b>NetBeans Platform 6.9</b>, how their layout is set, and how to implement the related handling of<br />
events.</P><br />
<P><b><I>Chapter 3, <b>Window System</b>:</I></b> The NetBeans Window System, together with the APithat it<br />
exposes, lets you arrange forms on the screen within a docking framework. You learn<br />
how to create windows, what their lifecycle looks like, and how to infl uence that<br />
lifecycle. In addition, you examine how a window is positioned within the layout of the<br />
application, how to influence the window layout, and how to create groups of related<br />
windows.</P><br />
<P><b><I>Chapter 4, Lookup:</I></b> The Lookup APiprovides a communication mechanism, comparable<br />
to an event bus, which is of central significance in the creation of <b>NetBeans Platform 6.9</b><br />
applications. You learn how to use the Lookup to find services so that loosely-coupled<br />
communication between modules can be established. You also learn how to listen to the<br />
Lookup so that content can be added dynamically to a <b>NetBeans Platform 6.9</b> application.<br />
You examine how a Lookup can act as a proxy for another Lookup and how this<br />
functions as the basis of context sensitivity, also known as &#8220;selection management&#8221;, in<br />
<b>NetBeans Platform 6.9</b> applications.</P><br />
<P><b><I>Chapter 5, Actions:</I></b> You learn how to create global actions and how to invoke them from<br />
menus and toolbars. You also examine how to connect actions to shortcuts, allowing<br />
them to be invoked from a keyboard.</P><br />
<P><b><I>Chapter 6, Nodes and Explorer Views:</I></b> A sophisticated MVC implementation for<br />
displaying business objects is made available via a set of extensible Swing components,<br />
which you can use without very much work at all. You explore how generic hierarchical<br />
models, known as &#8220;nodes&#8221;, can represent and display business objects in advanced Swing<br />
components called &#8220;explorer views&#8221;. You use fl at as well as hierarchical structures and<br />
are shown how easily one view can be exchanged for another and how they can be<br />
synchronized with each other. You also spend some time learning about the<br />
asynchronous creation of nodes and how context sensitive actions are attached to a node.<br />
Last but not least, you learn how the properties of a node can be displayed in property<br />
views and how to create the related property editors.</P><br />
<P><b><I>Chapter 7, File System:</I></b> The File System APilets you access a <b>NetBeans Platform 6.9</b>&#8216;s<br />
virtual filesystem, which serves as the application&#8217;s central registry. You learn how to<br />
access the configuration system, as well as other systems that can be created on top of the<br />
same API. Finishing up, you create new folders, files, and attributes in the filesystem.</P><br />
<P><b><I>Chapter 8, Data System:</I></b> The Datasystems APigives you access to the content of files.<br />
You learn how to extend a <b>NetBeans Platform 6.9</b> application to provide support for custom<br />
data types. You also discover how the features available to data content can change in<br />
relation to the current status of the underlying file.</P><br />
<P><b><I>Chapter 9, Dialogs:</I></b> The responsibilities of dialogs in an application extend from the<br />
display of simple messages to the management of step-by-step procedural wizards. In that<br />
context, you learn how to display simple messages, standard dialogs, and sophisticated<br />
multi-step wizards to the user.</P><br />
<P><b><I>Chapter 10, Settings:</I></b> Large applications, such as those based on the <b>NetBeans Platform 6.9</b>,<br />
typically have many different kinds of users. Not all of them need all the application&#8217;s<br />
features and not all of them use those features in the same way. As the application<br />
becomes larger, a centralized approach is needed, so that each module added to the<br />
application can contribute to a centralized Options window. That is the theme of this<br />
chapter, which introduces you to the most important APIs and the entry points into the<br />
centralized Options window.</P><br />
<P><b><I>Chapter 11, Help:</I></b> HTML files constituting your documentation can be integrated into<br />
the application. When the user clicks on the Help buttons in the application, or when they<br />
invoke an Action to display the entire help content, your HTML files can be displayed to<br />
them. This chapter shows you how to configure the help system and gets you started with<br />
a few help topics, a table of contents, and an indexing system.</P><br />
<P><b><I>Chapter 12, Branding:</I></b> Branding enables the application&#8217;s ancillary details, such as icons<br />
and splash screens, to be customized. For example, you learn how to exchange the<br />
custom splash screen with your own.</P><br />
<P><b><I>Chapter 13, Distribution and Updates:</I></b> To let you distribute applications, you examine<br />
the various distribution mechanisms for <b>NetBeans Platform 6.9</b> applications. You generate a<br />
distribution and an installer, with a special focus on how to let an application be updated<br />
online.</P></p>
<ul>
<li>Buy <a href="http://astore.amazon.com/javabeat-20/detail/1849511764" >NetBeans Books</a> from <a href="http://astore.amazon.com/javabeat-20">Java Books Store</a></li>
</ul>
<p><H1><CENTER>Window System in NetBeans Platform 6.9</CENTER></H1><br />
<P><b>Large desktop applications need to provide many different views for visualizing<br />
data. These views have to be managed and shown and the <b>NetBeans Platform 6.9</b><br />
handles these requirements for you out of the box via its docking framework.</b></P><br />
<P>While it once might have been sufficient for a docking framework to provide static<br />
fixed window layouts, today the user expects far more fl exibility. Windows should<br />
be able to be opened, movable, and, generally, customizable at runtime. The user<br />
tends to assume that the positions of views are modifiable and that they persist<br />
across restarts of the application. Not only that, but applications are assumed to be<br />
so fl exible that views should be detachable from the application&#8217;s main window,<br />
enabling them to be displayed on multiple monitors at the same time. While once the<br />
simple fact of the availability of menus and toolbars was sufficient, today a far more<br />
dynamic handling is needed so that window content can be adapted dynamically.<br />
Connected to these expectations of fl exibility, plugins are increasingly becoming a<br />
standard technology, with the user assuming their windows to be pluggable, too.</P><br />
<P>In short, the requirements for window management have become quite complex<br />
and can only be met by means of an external docking framework, otherwise all these<br />
various concerns would need to be coded (and debugged, tested, and maintained)<br />
by hand. The <b>NetBeans Platform 6.9</b> provides all of these features via its docking<br />
framework, known as the NetBeans <b>Window System</b>. It also provides an APito let<br />
you programmatically access the <b>Window System</b>. Together, the <b>Window System</b> and<br />
its APifulfill all the requirements described above, letting you concentrate on your<br />
domain knowledge and business logic rather than on the work of creating a custom<br />
window management facility for each of your applications.</P><br />
<P>This chapter teaches you the following:</P><br />
<UL><br />
<LI>How to define views</LI><br />
<LI>How to position views in the main window</LI><br />
<LI>How to customize the default window layout</LI><br />
<LI>How to group views so that they open and close as a unit</LI><br />
<LI>How to change the persistence of views across restarts of the application</LI><br />
</UL><br />
<H1>Creating a window</H1><br />
<P>The NetBeans <b>Window System</b> simplifies window management by letting you use<br />
a default component for displaying windows. The default component, that is, the<br />
superclass of all windows, is the TopComponent class, which is derived from the<br />
standard JComponent class. It defines many methods for controlling a window<br />
and handles notification of main <b>Window System</b> events.</P><br />
<P>The WindowManager is the central class controlling all the windows in the<br />
application. Though you can implement this class yourself, this is seldom done<br />
as normally the default WindowManager is sufficient. Similarly, you typically use<br />
the standard TopComponent class, rather than creating your own top-level Swing<br />
components. In contrast to the TopComponent class, the default WindowManager<br />
cannot manage your own top-level Swing components, so these cannot take<br />
advantage of the <b>Window System</b> API.</P><br />
<P>Now let&#8217;s create a TopComponent and let it be an editor for working with tasks. This<br />
is done easily by using the <B>New Window</B> wizard.</P><br />
<OL><br />
<LI>In the <B>Projects</B> window, right-click the <B>TaskEditor</B> module project node and<br />
choose <B>New | Window</B>.</LI><br />
<LI>On the first page of the wizard select Editor for <B>Window Position</B> and <B>Open<br />
on Application Start</B>. Click <B>Next</B>.</LI><br />
<P><CENTER><IMG SRC="images/2010/09/WindowSystem/1.jpg"/></CENTER></P><br />
<LI>In the next page of the wizard, type <B>TaskEditor</B> in <B>Class Name Prefix</B>. This<br />
prefix is used for all the generated files. It is possible to specify an icon that<br />
will be displayed in the tab of the new window, but let&#8217;s skip that for the<br />
moment. Click <B>Finish</B> and all the files are generated into your module<br />
source structure.</LI><br />
<P><CENTER><IMG SRC="images/2010/09/WindowSystem/2.jpg"/></CENTER></P><br />
<LI>Next, open the newly created <B>TaskEditorTopComponent</B> and drag the<br />
<B>TaskEditorPanel</B> from the <B>Palette</B>, which is where you put it at the end<br />
of the last chapter, onto the form.</LI><br />
<LI>The size of the component automatically adjusts to the required size of<br />
the panel. Position the panel with the preferred spacing to the left and top<br />
and activate the automatic resizing of the panel in horizontal and vertical<br />
direction. The form should now look similar to the following screenshot:</LI><br />
<P><CENTER><IMG SRC="images/2010/09/WindowSystem/3.jpg"/></CENTER></P><br />
<LI>Sta rt the application. You now see a tab containing the new <B>TaskEditor</B><br />
Window, which holds your form.</LI><br />
<P><CENTER><IMG SRC="images/2010/09/WindowSystem/4.jpg"/></CENTER></P><br />
</OL><br />
<H1>Examining the generated files</H1><br />
<P>You have used a wizard to create a new TopComponent. However, the wizard did<br />
more than that. Let&#8217;s take a look at all the files that have been created and at all the<br />
files that have been modified, as well as how these files work together.</P><br />
<P>The only Java class that was generated is the TopComponent that will contain the<br />
<B>TaskEditor</B>, shown as follows:</P><br />
<P><PRE><CODE><br />
	@ConvertAsProperties(dtd = &#8220;-//com.netbeansrcp.taskeditor//TaskEditor//<br />
	EN&#8221;, autostore = false)<br />
	public final class TaskEditorTopComponent extends TopComponent {<br />
		private static TaskEditorTopComponent instance;<br />
			/** path to the icon used by the component and its open action */<br />
			// static final String ICON_PATH = &#8220;SET/PATH/TO/ICON/HERE&#8221;;<br />
			private static final String PREFERRED_ID = &#8220;TaskEditorTopComponent&#8221;;<br />
			public TaskEditorTopComponent() {<br />
				initComponents();<br />
				setName(NbBundle.getMessage(TaskEditorTopComponent.class,<br />
					&#8220;CTL_TaskEditorTopComponent&#8221;));<br />
				setToolTipText(NbBundle.getMessage(TaskEditorTopComponent.class,<br />
					&#8220;HINT_TaskEditorTopComponent&#8221;));<br />
				// setIcon(ImageUtilities.loadImage(ICON_PATH, true));<br />
			}<br />
				/**This method is called from within the constructor to<br />
				* initialize the form.<br />
				* WARNING: Do NOT modify this code. The content of this method is<br />
				* always regenerated by the Form Editor.<br />
				*/<br />
				// &lt;editor-fold defaultstate=&#8221;collapsed&#8221; desc=&#8221;Generated Code&#8221;&gt;<br />
				private void initComponents() {<br />
					javax.swing.GroupLayout layout = new javax.swing.<br />
							GroupLayout(this);<br />
					this.setLayout(layout);<br />
					layout.setHorizontalGroup(<br />
						layout.createParallelGroup(javax.swing.GroupLayout.<br />
						Alignment.LEADING).addGap(0, 555, Short.MAX_VALUE));<br />
					layout.setVerticalGroup(layout.createParallelGroup(<br />
						javax.swing.GroupLayout.Alignment.LEADING)<br />
						.addGap(0, 442, Short.MAX_VALUE)<br />
					);<br />
				}// &lt;/editor-fold&gt;<br />
				// Variables declaration &#8211; do not modify<br />
				// End of variables declaration<br />
				/**<br />
					* Gets default instance. Do not use directly: reserved for<br />
					*.settings files only,<br />
					* i.e. deserialization routines; otherwise you could get a<br />
					non-deserialized instance.<br />
					* To obtain the singleton instance, use {@link #findInstance}.<br />
				*/<br />
				public static synchronized TaskEditorTopComponent getDefault() {<br />
					if (instance == null) {<br />
						instance = new TaskEditorTopComponent();<br />
					}<br />
					return instance;<br />
				}<br />
				/**<br />
				* Obtain the TaskEditorTopComponent instance. Never call {<br />
					@link #getDefault} directly!<br />
				*/<br />
				public static synchronized TaskEditorTopComponent findInstance() {<br />
					TopComponent win = WindowManager.getDefault().findTopComponent<br />
							(PREFERRED_ID);<br />
					if (win == null) {<br />
						Logger.getLogger(TaskEditorTopComponent.class.getName()).<br />
							warning(&#8220;Cannot find &#8221; + PREFERRED_ID + &#8221; component.<br />
							It will not be located properly in the window system.&#8221;);<br />
						return getDefault();<br />
					}<br />
					if (win instanceof TaskEditorTopComponent) {<br />
						return (TaskEditorTopComponent) win;<br />
					}<br />
					Logger.getLogger(TaskEditorTopComponent.class.getName()).<br />
						warning(&#8220;There seem to be multiple components with the &#8216;&#8221; +<br />
						PREFERRED_ID<br />
						+ &#8220;&#8216; ID. That is a potential source of errors and<br />
						unexpected behavior.&#8221;);<br />
					return getDefault();<br />
				}<br />
				@Override<br />
				public int getPersistenceType() {<br />
					return TopComponent.PERSISTENCE_ALWAYS;<br />
				}<br />
				@Override<br />
				public void componentOpened() {<br />
					// TODO add custom code on component opening<br />
				}<br />
				@Override<br />
				public void componentClosed() {<br />
					// TODO add custom code on component closing<br />
				}<br />
				void writeProperties(java.util.Properties p) {<br />
					// better to version settings since initial version<br />
					as advocated at<br />
					// http://wiki.apidesign.org/wiki/PropertyFiles<br />
					p.setProperty(&#8220;version&#8221;, &#8220;1.0&#8243;);<br />
					// TODO store your settings<br />
				}<br />
				Object readProperties(java.util.Properties p) {<br />
					if (instance == null) {<br />
						instance = this;<br />
					}<br />
					instance.readPropertiesImpl(p);<br />
					return instance;<br />
				}<br />
				private void readPropertiesImpl(java.util.Properties p) {<br />
					String version = p.getProperty(&#8220;version&#8221;);<br />
					// TODO read your settings according to their version<br />
				}<br />
				@Override<br />
				protected String preferredID() {<br />
					return PREFERRED_ID;<br />
				}<br />
			}<br />
</CODE></PRE></P><br />
<P>As expected, the class TaskEditorTopComponent extends the TopComponent class.</P><br />
<P>Let&#8217;s look at it more closely:</P><br />
<UL><br />
<LI>For efficient resource usage, the generated TopComponent is implemented<br />
as a singleton. A private constructor prohibits its incorrect usage from<br />
outside by disallowing direct instantiation of the class. The static attribute<br />
instance holds the only instance in existence. The static method getDefault<br />
creates and returns this instance if necessary on demand. Typically,<br />
getDefault should never be called directly. Instead of this, you should use<br />
findInstance, which delegates to getDefault if necessary. findInstance<br />
tries to retrieve the instance using the Window Manager and the ID of the<br />
TopComponent before falling back to the singleton instance. This ensures the<br />
correct usage of persistent information.</LI><br />
<LI>The constructor creates the component tree for the TaskEditorTopComponent<br />
by calling the method init Components(). This method contains only code<br />
generated via the NetBeans &#8220;Matisse&#8221; Form Builder and is read-only in the<br />
NetBeans Java editor. You can change the code in this method using the<br />
Form Builder&#8217;s Property Sheet, as will be shown later.</LI><br />
<LI>The static property PreferredID holds the TopComponent ID used for<br />
identification of the TopComponent. As indicated by its name, the ID can<br />
be changed by the <b>Window System</b>, if name clashes occur. The ID is used<br />
throughout all the configuration files.</LI><br />
<LI>The methods comp onentOpened() and componentClosed() are part of the<br />
lifecycle of the TopComponent.</LI><br />
<LI>You learn about the method getPersistenceType() later, in the section<br />
about the persistence of TopComponents.</LI><br />
</UL><br />
<P><PRE><CODE><br />
	<B>What does the Java code do and not do?</B><br />
	The Java code only defines the visual aspects of the<br />
	TaskEditorTopComponent and manages the singleton instance of this<br />
	component. In no way does the code describe how and where the instance<br />
	is shown. That&#8217;s the task of the two XML files, described below.<br />
</CODE></PRE></P><br />
<P>Two small XML files are created by the wizard. The first is the TopComponent&#8217;s<br />
settings file:</P><br />
<P><PRE><CODE><br />
	&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;UTF-8&#8243;?&gt;<br />
	&lt;!DOCTYPE settings PUBLIC &#8220;-//NetBeans//DTD Session settings 1.0//EN&#8221;<br />
		&#8220;http://www.netbeans.org/dtds/sessionsettings-1_0.dtd&#8221;&gt;<br />
	&lt;settings version=&#8221;1.0&#8243;&gt;<br />
		&lt;module name=&#8221;com.netbeansrcp.taskeditor&#8221; spec=&#8221;1.0&#8243;/&gt;<br />
		&lt;instanceof class=&#8221;org.openide.windows.TopComponent&#8221;/&gt;<br />
		&lt;instanceof class=&#8221;com.netbeansrcp.taskeditor.<br />
			TaskEditorTopComponent&#8221;/&gt;<br />
		&lt;instance class=&#8221;com.netbeansrcp.taskeditor.TaskEditorTopComponent&#8221;<br />
			method=&#8221;getDefault&#8221;/&gt;<br />
	&lt;/settings&gt;<br />
</CODE></PRE></P><br />
<P>The settings file describes the persistent instance of the TopComponent. As you can<br />
see, the preceding configuration describes that the TopComponent belongs to the<br />
module <B>TaskEditor</B> in the specification version &#8220;1.0&#8243; and that it is an instance of<br />
the types TopComponent and TaskEditorTopComponent. Also described is that the<br />
instance that is created is done so using the method call TaskEditorTopComponent.<br />
getDefault().</P><br />
<P><PRE><CODE><br />
	&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;UTF-8&#8243;?&gt;<br />
	&lt;!DOCTYPE tc-ref PUBLIC &#8220;-//NetBeans//DTD Top Component in Mode Properties<br />
		2.0//EN&#8221; &#8220;http://www.netbeans.org/dtds/tc-ref2_0.dtd&#8221;&gt;<br />
	&lt;tc-ref version=&#8221;2.0&#8243; &gt;<br />
		&lt;module name=&#8221;com.netbeansrcp.taskeditor&#8221; spec=&#8221;1.0&#8243;/&gt;<br />
		&lt;tc-id id=&#8221;TaskEditorTopComponent&#8221;/&gt;<br />
		&lt;state opened=&#8221;true&#8221;/&gt;<br />
	&lt;/tc-ref&gt;<br />
</CODE></PRE></P><br />
<P>The WSTCREF (<b>Window System</b> creation file) describes the position of the<br />
TopComponent within the main window. This becomes clearer with the following<br />
file. The other important information in the WSTCREF file is the opened state at<br />
application start.</P><br />
<P>Typically, you do not have to change these two configuration files by hand. This<br />
is not true for the following file, the layer.xml, which you often need to change<br />
manually, to register new folders and files in the filesystem.</P><br />
<P><PRE><CODE><B><br />
	&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;UTF-8&#8243;?&gt;<br />
	&lt;!DOCTYPE filesystem PUBLIC &#8220;-//NetBeans//DTD Filesystem 1.2//EN&#8221; &#8220;http://<br />
		www.netbeans.org/dtds/filesystem-1_2.dtd&#8221;&gt;<br />
	&lt;filesystem&gt;<br />
		&lt;folder name=&#8221;Actions&#8221;&gt;<br />
			&lt;folder name=&#8221;Window&#8221;&gt;<br />
				&lt;file name=&#8221;com-netbeansrcp-taskeditor.TaskEditorAction.instance&#8221;&gt;<br />
					&lt;attr name=&#8221;component&#8221;<br />
						methodvalue=&#8221;com.netbeansrcp.taskeditor.<br />
						TaskEditorTopComponent.findInstance&#8221;/&gt;<br />
					&lt;attr name=&#8221;displayName&#8221;<br />
						bundlevalue=&#8221;com.netbeansrcp.taskeditor.<br />
						Bundle#CTL_TaskEditorAction&#8221;/&gt;<br />
					&lt;attr name=&#8221;instanceCreate&#8221; methodvalue=&#8221;org.openide.windows.<br />
						TopComponent.openAction&#8221;/&gt;<br />
				&lt;/file&gt;<br />
			&lt;/folder&gt;<br />
		&lt;/folder&gt;<br />
		&lt;folder name=&#8221;Menu&#8221;&gt;<br />
			&lt;folder name=&#8221;Window&#8221;&gt;<br />
				&lt;file name=&#8221;TaskEditorAction.shadow&#8221;&gt;<br />
					&lt;attr name=&#8221;originalFile&#8221; stringvalue=&#8221;Actions/Window/com<br />
						netbeansrcp-taskeditor-TaskEditorAction.instance&#8221;/&gt;<br />
				&lt;/file&gt;<br />
			&lt;/folder&gt;<br />
		&lt;/folder&gt;<br />
		&lt;folder name=&#8221;Windows2&#8243;&gt;<br />
			&lt;folder name=&#8221;Components&#8221;&gt;<br />
				&lt;file name=&#8221;TaskEditorTopComponent.settings&#8221;<br />
					url=&#8221;TaskEditorTopComponentSettings.xml&#8221;/&gt;<br />
			&lt;/folder&gt;<br />
			&lt;folder name=&#8221;Modes&#8221;&gt;<br />
				&lt;folder name=&#8221;editor&#8221;&gt;<br />
					&lt;file name=&#8221;TaskEditorTopComponent.wstcref&#8221;<br />
						url=&#8221;TaskEditorTopComponentWstcref.xml&#8221;/&gt;<br />
				&lt;/folder&gt;<br />
			&lt;/folder&gt;<br />
		&lt;/folder&gt;<br />
	&lt;/filesystem&gt;<br />
</B></CODE></PRE></P><br />
<P>The layer.xml is integrated into the central registry (also known as the<br />
SystemFileSystem) using the via a registration entry in the module&#8217;s <B>manifest</B><br />
file. The SystemFileSystem is a virtual filesystem for user settings. Each module<br />
can supply a layer file for merging configuration data from the module into the<br />
SystemFileSystem.<P><br />
<P>The <b>Window System</b> APiand the Actions APireserve a number of folders in the<br />
central registry for holding its configuration data. These folders enable specific<br />
subfolders and files relating to <b>Window System</b> registration to be added to<br />
the filesystem.</P><br />
<UL><br />
<LI>Let&#8217;s have a look at the folder Windows2. Windows2 contains a folder<br />
named Components, which contains a virtual file with the name of the<br />
TopComponent and the extension .settings. This .settings file redirects<br />
to the real settings file. It is used to make the configuration known to the<br />
<b>Window System</b>.</LI><br />
<LI>In addition, the Windows2 folder contains a folder named Modes, which<br />
contains a folder named editor. Modes represent the possible positions at<br />
which TopComponents can be shown in the application. The editor folder<br />
contains a .wstcref file for our TopComponent, which refers to the real<br />
WSTCREF file. This registers the TopComponent in the mode editor, so it<br />
shows up where typically editor windows are opened, which is the central<br />
part of the main window.</LI><br />
<LI>Next, take a look at the folder Actions. It contains a folder named<br />
Window which contains a file declaring the action opening the<br />
TaskEditorTopComponent. The name is typically following Java class<br />
naming conventions with dots replaced by dashes and ending in .instance.<br />
The declaration of the virtual file itself consists of three critical parts. The<br />
attribute component describes how to create the component (methodvalue<br />
declares which method to call). The attribute displayName describes the<br />
default action name as shown in the example, in menu items. A possible<br />
declaration is the bundle value which describes the bundle and key to use<br />
to retrieve the display name. The attribute instanceCreate uses a static<br />
method call to create a real action to use.</LI><br />
<LI>The folder Menu describes the application main menu. The folder Window<br />
contains a .shadow file. The attribute originalFile uses the full path in the<br />
SystemFileSytem to delegate to the original action declaration. As described<br />
above, .shadow files are used as symbolic links to real-defined virtual files.<br />
This declaration adds the action to the real menu bar of the application.</LI><br />
</UL><br />
<P>As a result, important parts of the <b>Window System</b> APiare not called<br />
programmatically, but are simply used declaratively. Declarative aspects include<br />
configuration and the positioning of windows, as well as the construction of<br />
the menu.</P><br />
<P>In addition, you discovered that the wizard for creating TopComponents always<br />
creates singleton views. If you would like to change that, you need to adapt the<br />
code created by the wizard. For the time being, it is sufficient to use the singleton<br />
approach, particularly as it is more resource-friendly.</P></p><div class="wpInsert wpInsertInPostAd wpInsertMiddle" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Middle-Med-Rect */
google_ad_slot = "7805667846";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
<h2>NetBeans Articles</h2>
<ul>
<li><a href="http://www.javabeat.net/tips/63-create-ejb-30-project-in-netbeans-61.html">Create EJB 3.0 project in NetBeans 6.1</a></li>
<li><a href="http://www.javabeat.net/articles/81-jpa-in-netbeans-61-1.html">JPA in NetBeans 6.1</a> by <a href="http://www.javabeat.net/authors/SriHari/">SriHari</a></li>
<li><a href="http://www.javabeat.net/articles/netbeans/1/">NetBeans Articles</a></li>
<li><a href="http://www.javabeat.net/dlinks/netbeans/">NetBeans Links</a></li>
<li>Buy <a href="http://astore.amazon.com/javabeat-20/detail/1849511764">NetBeans Books</a> from <a href="http://astore.amazon.com/javabeat-20">Java Books Store</a></li>
</ul>
<div class="wpInsert wpInsertInPostAd wpInsertBelow" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* JB-Footer-LU 468x15 */
google_ad_slot = "8789107210";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>]]></content:encoded>
			<wfw:commentRss>http://www.javabeat.net/2009/09/window-system-in-netbeans-platform-6-9/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Developing JSF NetBeans 6.0</title>
		<link>http://www.javabeat.net/2008/12/java-ee-5-0-development-with-netbeans-6-0-developing-web-applications-using-jsf/</link>
		<comments>http://www.javabeat.net/2008/12/java-ee-5-0-development-with-netbeans-6-0-developing-web-applications-using-jsf/#comments</comments>
		<pubDate>Sun, 14 Dec 2008 16:04:10 +0000</pubDate>
		<dc:creator>krishnas</dc:creator>
				<category><![CDATA[NetBeans]]></category>

		<guid isPermaLink="false">http://www.javabeat.net/?p=2247</guid>
		<description><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><p>Before JSF was developed, Java web applications were typically developed using non-standard web application frameworks such as Apache Struts, Tapestry, Spring Web MVC, or many others. These frameworks are built on top of the Servlet and JSP standards, and automate a lot of functionality that needs to be manually coded whenusing these APIs directly. Having a wide variety [...]</p>]]></description>
				<content:encoded><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><div class="wpInsert wpInsertInPostAd wpInsertLeft" style="float: left; margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Rect */
google_ad_slot = "9976259118";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div><p>Before <b><i>JSF</i></b> was developed, Java <b><i>web application</i></b>s were typically developed using non-standard <b><i>web application</i></b> frameworks such as Apache Struts, Tapestry, Spring Web MVC, or many others. These frameworks are built on top of the Servlet and <i>JSP </i>standards, and automate a lot of functionality that needs to be manually coded whenusing these APIs directly.</p>
<p>Having a wide variety of <b><i>web application</i></b> frameworks available (at the time of writing, Wikipedia lists 35 Java <b><i>web application</i></b> frameworks, and this list is far from extensive!), often resulted in &#8220;analysis paralysis&#8221;, that is, developers often spend an inordinate amount of time evaluating frameworks for their applications.</p>
<p>The introduction of <b><i>JSF</i></b> to the Java EE 5 specifi cation resulted in having a standard <b><i>web application</i></b> framework available in any Java EE 5 compliant application server.</p>
<p><i>We don&#8217;t mean to imply that other <b><i>web application</i></b> frameworks are obsolete or that they shouldn&#8217;t be used at all, however, a lot of<br />
organizations consider <b><i>JSF</i></b> the &#8220;safe&#8221; choice since it is part of the standard and should be well supported for the foreseeable future. Additionally, <b><i>NetBeans</i></b> offers excellent <b><i>JSF</i></b> support, making <b><i>JSF</i></b> a very attractive choice.</i></p>
<p>Strictly speaking, <b><i>JSF</i></b> is not a <b><i>web application</i></b> framework as such, but a component framework. In theory, <b><i>JSF</i></b> can be used to write applications that are not web-based, however, in practice <b><i>JSF</i></b> is almost always used for this purpose.</p>
<p>In addition to being the standard Java EE 5 component framework, one benefi t of <b><i>JSF</i></b> is that it was designed with graphical tools in mind, making it easy for tools and IDEs such as <b><i>NetBeans</i></b> to take advantage of the <b><i>JSF</i></b> component model with drag-and-drop support for components. <b><i>NetBeans</i></b> provides a Visual Web <b><i>JSF </i></b>Designer that allow us to visually create <b><i>JSF</i></b> applications. This tool is discussed in detail in Chapter 6.</p>
<h2 style="text-align: center;"><span style="text-decoration: underline;"><span style="color: #000080; text-decoration: underline;">Developing Our first <b><i>JSF</i></b> Application</span></span></h2>
<p>From an application developer&#8217;s point of view, a <b><i>JSF</i></b> application consists of a series of <i>JSP</i> pages containing custom <b><i>JSF</i></b> tags, one or more <b><i>JSF</i></b> managed beans, and a confi guration fi le named <b><i>faces-config.xml</i></b>. The <b><i>faces-config.xml</i></b> fi le declares the managed beans in the application, as well as the navigation rules to follow when navigating from one <b><i>JSF</i></b> page to another.</p>
<h2>Creating a New <b><i>JSF</i></b> Project</h2>
<p>To create a new <b><i>JSF</i></b> project, we need to go to File | New Project, select the Java Web project category, and Web Application as the project type. After clicking Next&gt;, we need to enter a Project Name, and optionally change other information for our project, although <b><i>NetBeans</i></b> provides sensible defaults.</p>
<p style="text-align: center;"><a href="http://www.javabeat.net/wp-content/uploads/2008/12/netbeans-jsf-1.gif"><img class="aligncenter  wp-image-6713" alt="netbeans-jsf-1" src="http://www.javabeat.net/wp-content/uploads/2008/12/netbeans-jsf-1.gif" width="437" height="296" /></a></p>
<p>O n the next page in the wizard, we can select the Server, Java EE Version, and Context Path of our application. In our example we will simply pick the default values.</p>
<p style="text-align: center;"><a href="http://www.javabeat.net/wp-content/uploads/2008/12/netbeans-jsf-2.gif"><img class="aligncenter  wp-image-6714" alt="netbeans-jsf-2" src="http://www.javabeat.net/wp-content/uploads/2008/12/netbeans-jsf-2.gif" width="475" height="296" /></a></p>
<p>On the next page of the new project wizard, we can select what frameworks our web application will use.</p>
<p style="text-align: center;"><a href="http://www.javabeat.net/wp-content/uploads/2008/12/netbeans-jsf-3.gif"><img class="aligncenter  wp-image-6715" alt="netbeans-jsf-3" src="http://www.javabeat.net/wp-content/uploads/2008/12/netbeans-jsf-3.gif" width="440" height="308" /></a></p>
<p>Unsurprisingly, for <b><i>JSF</i></b> applications we need to select the JavaServer Faces framework.</p>
<p><i>The Visual Web JavaServer Faces framework allows us to quickly build web pages by dragging-and-dropping components from the <b><i>NetBeans </i></b>palette into our pages. Although it certainly allows us to develop applications a lot quicker than manually coding, it hides a lot of the &#8220;ins&#8221; and &#8220;outs&#8221; of <b><i>JSF</i></b>. Having a background in standard <b><i>JSF</i></b> development will help us understand what the <b><i>NetBeans</i></b> Visual Web functionality does behind the scenes. Visual Web <b><i>JSF</i></b> is covered in Chapter 6.</i></p>
<p>Whe n clicking Finish, the wizard generates a skeleton <b><i>JSF</i></b> project for us, consisting of a single <i>JSP</i> file called welcome<b><i>JSF</i></b>.jsp, and a few confi guration fi les: <i><i>web.xml</i></i>, <b><i>faces-config.xml</i></b> and, if we are using the default bundled GlassFish server, the GlassFish specifi c sun-<i><i>web.xml</i></i> fi le is generated as well.</p>
<p><a href="http://www.javabeat.net/wp-content/uploads/2008/12/netbeans-jsf-4.gif"><img class="aligncenter size-full wp-image-6716" alt="netbeans-jsf-4" src="http://www.javabeat.net/wp-content/uploads/2008/12/netbeans-jsf-4.gif" width="292" height="300" /></a></p>
<p><i><i>web.xml</i></i> is the standard confi guration fi le needed for all Java <b><i>web application</i></b>s. <b><i>faces-config.xml</i></b> is a <b><i>JSF</i></b>-specifi c confi guration fi le used to declare <b><i>JSF</i></b>-managed beans and navigation rules. sun-<i><i>web.xml</i></i> is a GlassFish-specifi c confi guration file that allows us to override the application&#8217;s default context root, add security role mappings, and perform several other confi guration tasks.</p>
<pre class="brush: java; title: ; notranslate">The generated &amp;lt;i&amp;gt;JSP&amp;lt;/i&amp;gt; looks like this:
&amp;amp;lt;%@ page contentType=&amp;quot;text/html&amp;quot;%&amp;amp;gt;
&amp;amp;lt;%@page pageEncoding=&amp;quot;UTF-8&amp;quot;%&amp;amp;gt;
&amp;amp;lt;%@taglib prefix=&amp;quot;f&amp;quot; uri=&amp;quot;http://java.sun.com/&amp;lt;b&amp;gt;&amp;lt;i&amp;gt;JSF&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;/core&amp;quot;%&amp;amp;gt;
&amp;amp;lt;%@taglib prefix=&amp;quot;h&amp;quot; uri=&amp;quot;http://java.sun.com/&amp;lt;b&amp;gt;&amp;lt;i&amp;gt;JSF&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;/html&amp;quot;%&amp;amp;gt;
&amp;amp;lt;!DOCTYPE HTML PUBLIC &amp;quot;-//W3C//DTD HTML 4.01 Transitional//EN&amp;quot;
&amp;quot;http://www.w3.org/TR/html4/loose.dtd&amp;quot;&amp;amp;gt;
&amp;amp;lt;%--
This file is an entry point for JavaServer Faces application.
--%&amp;amp;gt;
&amp;amp;lt;html&amp;amp;gt;
&amp;amp;lt;head&amp;amp;gt;
&amp;amp;lt;meta http-equiv=&amp;quot;Content-Type&amp;quot; content=&amp;quot;text/html;
charset=UTF-8&amp;quot;&amp;amp;gt;
&amp;amp;lt;title&amp;amp;gt;&amp;lt;i&amp;gt;JSP&amp;lt;/i&amp;gt; Page&amp;amp;lt;/title&amp;amp;gt;
&amp;amp;lt;/head&amp;amp;gt;
&amp;amp;lt;body&amp;amp;gt;
&amp;amp;lt;f:view&amp;amp;gt;
&amp;amp;lt;h1&amp;amp;gt;
&amp;amp;lt;h:outputText value=&amp;quot;JavaServer Faces&amp;quot;/&amp;amp;gt;
&amp;amp;lt;/h1&amp;amp;gt;
&amp;amp;lt;/f:view&amp;amp;gt;
&amp;amp;lt;/body&amp;amp;gt;
&amp;amp;lt;/html&amp;amp;gt;
</pre>
<p>As we can see, a <b><i>JSF</i></b> enabled <i>JSP</i> file is a standard <i>JSP</i> fi le using a couple of <b><i>JSF</i></b>-specifi c tag libraries. The fi rst tag library, declared in our <i>JSP</i> by the following line:</p>
<pre class="brush: java; title: ; notranslate">&amp;amp;lt;%@taglib prefix=&amp;quot;f&amp;quot; uri=&amp;quot;http://java.sun.com/&amp;lt;b&amp;gt;&amp;lt;i&amp;gt;JSF&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;/core&amp;quot;%&amp;amp;gt;
</pre>
<p>is the core <b><i>JSF</i></b> tag library, this library includes a number of tags that are independent of the rendering mechanism of the <b><i>JSF</i></b> application (recall that <b><i>JSF</i></b> can be used for applications other than <b><i>web application</i></b>s). By convention, the prefi x f (for faces) is<br />
used for this tag library. The second tag library in the generated <i>JSP</i>, declared by the following line:</p>
<pre class="brush: java; title: ; notranslate">&amp;amp;lt;%@taglib prefix=&amp;quot;h&amp;quot; uri=&amp;quot;http://java.sun.com/&amp;lt;b&amp;gt;&amp;lt;i&amp;gt;JSF&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;/html&amp;quot;%&amp;amp;gt;
</pre>
<p>is the <b><i>JSF</i></b> HTML tag library. This tag library includes a number of tags that are used to implement HTML specifi c functionality, such as creating HTML forms and input fi elds. By convention, the prefi x h (for HTML) is used for this tag library.</p>
<p>The first <b><i>JSF</i></b> tag we see in the generated <i>JSP</i> fi le is the &lt;f:view&gt; tag. When writing a Java <b><i>web application</i></b> using <b><i>JSF</i></b>, all <b><i>JSF</i></b> custom tags must be enclosed inside an &lt;f:view&gt; tag. In addition to <b><i>JSF</i></b>-specifi c tags, this tag can contain standard HTML<br />
tags, as well as tags from other tag libraries, such as the JSTL tags discussed in the previous chapter.</p>
<p>The next <b><i>JSF</i></b>-specifi c tag we see in the above <i>JSP</i> is &lt;h:outputText&gt;. This tag simply displays the value of its value attribute in the rendered page. The application generated by the new project wizard is a simple, but complete, <b><i>JSF </i></b><b><i>web application</i></b>. We can see it in action by right-clicking on our project in the project window and selecting Run. At this point the application server is started (if it wasn&#8217;t already running), the application is deployed and the default system browser opens, displaying our application&#8217;s welcome page.</p>
<p style="text-align: center;"><a href="http://www.javabeat.net/wp-content/uploads/2008/12/netbeans-jsf-5.gif"><img class="aligncenter  wp-image-6717" alt="netbeans-jsf-5" src="http://www.javabeat.net/wp-content/uploads/2008/12/netbeans-jsf-5.gif" width="463" height="146" /></a></p>
<h2>Modifying Our <i>JSP</i> to Capture User Data</h2>
<p>The g enerated application, of course, is nothing but a starting point for us to create a new application. We will now modify the generated welcome<b><i>JSF</i></b>.jsp fi le to collect some data from the user.</p>
<p>The fi rst thing we need to do is to add an &lt;h:form&gt; tag inside the &lt;f:view&gt; tag. The &lt;h:form&gt; tag is equivalent to the &lt;form&gt; tag in standard HTML pages. We can either type the &lt;h:form&gt; tag directly in the page or drag the <b><i>JSF</i></b> Form item from the palette<br />
into the appropriate place in the page markup.</p>
<p style="text-align: center;"><a href="http://www.javabeat.net/wp-content/uploads/2008/12/netbeans-jsf-6.gif"><img class="aligncenter  wp-image-6718" alt="netbeans-jsf-6" src="http://www.javabeat.net/wp-content/uploads/2008/12/netbeans-jsf-6.gif" width="380" height="179" /></a></p>
<p>If we choose the second approach, the following window will pop-up:</p>
<p style="text-align: center;"><a href="http://www.javabeat.net/wp-content/uploads/2008/12/netbeans-jsf-7.gif"><img class="aligncenter  wp-image-6719" alt="netbeans-jsf-7" src="http://www.javabeat.net/wp-content/uploads/2008/12/netbeans-jsf-7.gif" width="496" height="149" /></a></p>
<p>Selecting Empty Form will generate an empty &lt;h:form&gt; tag which we can use to add our own input fields.</p>
<p><i>The Form Generated from Entity Class selection is a very nice <b><i>NetBeans </i></b>feature that allows us to generate a form that will include input fi elds mapping to all properties in a Java Persistence API (JPA) entity. JPA is covered in detail in Chapter 5.</i></p>
<pre class="brush: java; title: ; notranslate">After adding the &amp;amp;lt;h:form&amp;amp;gt; tag and a number of additional &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;JSF&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt; tags, our page now
looks like this:
&amp;amp;lt;%@page contentType=&amp;quot;text/html&amp;quot;%&amp;amp;gt;
&amp;amp;lt;%@page pageEncoding=&amp;quot;UTF-8&amp;quot;%&amp;amp;gt;
&amp;amp;lt;%@taglib prefix=&amp;quot;f&amp;quot; uri=&amp;quot;http://java.sun.com/&amp;lt;b&amp;gt;&amp;lt;i&amp;gt;JSF&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;/core&amp;quot;%&amp;amp;gt;
&amp;amp;lt;%@taglib prefix=&amp;quot;h&amp;quot; uri=&amp;quot;http://java.sun.com/&amp;lt;b&amp;gt;&amp;lt;i&amp;gt;JSF&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;/html&amp;quot;%&amp;amp;gt;
&amp;amp;lt;!DOCTYPE HTML PUBLIC &amp;quot;-//W3C//DTD HTML 4.01 Transitional//EN&amp;quot;
&amp;quot;http://www.w3.org/TR/html4/loose.dtd&amp;quot;&amp;amp;gt;
&amp;amp;lt;html&amp;amp;gt;
&amp;amp;lt;head&amp;amp;gt;
&amp;amp;lt;meta http-equiv=&amp;quot;Content-Type&amp;quot;
content=&amp;quot;text/html; charset=UTF-8&amp;quot;&amp;amp;gt;
&amp;amp;lt;link rel=&amp;quot;stylesheet&amp;quot; type=&amp;quot;text/css&amp;quot;
href=&amp;quot;../css/style.css&amp;quot;&amp;amp;gt;
&amp;amp;lt;title&amp;amp;gt;&amp;lt;i&amp;gt;JSP&amp;lt;/i&amp;gt; Page&amp;amp;lt;/title&amp;amp;gt;
&amp;amp;lt;/head&amp;amp;gt;
&amp;amp;lt;body&amp;amp;gt;
&amp;amp;lt;f:view&amp;amp;gt;
&amp;amp;lt;h1&amp;amp;gt;&amp;amp;lt;h:outputText value=&amp;quot;JavaServer Faces&amp;quot; /&amp;amp;gt;&amp;amp;lt;/h1&amp;amp;gt;
&amp;amp;lt;h:form&amp;amp;gt;
&amp;amp;lt;h:panelGrid columns=&amp;quot;3&amp;quot;
columnClasses=&amp;quot;rightalign,leftalign,leftalign&amp;quot;&amp;amp;gt;
&amp;amp;lt;!-- First row begins here --&amp;amp;gt;
&amp;amp;lt;h:outputLabel value=&amp;quot;Salutation: &amp;quot;
for=&amp;quot;salutation&amp;quot;/&amp;amp;gt;
&amp;amp;lt;h:selectOneMenu id=&amp;quot;salutation&amp;quot; label=&amp;quot;Salutation&amp;quot;
value=&amp;quot;#{RegistrationBean.salutation}&amp;quot; &amp;amp;gt;
&amp;amp;lt;f:selectItem itemLabel=&amp;quot;&amp;quot; itemValue=&amp;quot;&amp;quot;/&amp;amp;gt;
&amp;amp;lt;f:selectItem itemLabel=&amp;quot;Mr.&amp;quot; itemValue=&amp;quot;MR&amp;quot;/&amp;amp;gt;
&amp;amp;lt;f:selectItem itemLabel=&amp;quot;Mrs.&amp;quot; itemValue=&amp;quot;MRS&amp;quot;/&amp;amp;gt;
&amp;amp;lt;f:selectItem itemLabel=&amp;quot;Miss&amp;quot; itemValue=&amp;quot;MISS&amp;quot;/&amp;amp;gt;
&amp;amp;lt;f:selectItem itemLabel=&amp;quot;Ms&amp;quot; itemValue=&amp;quot;MS&amp;quot;/&amp;amp;gt;
&amp;amp;lt;f:selectItem itemLabel=&amp;quot;Dr.&amp;quot; itemValue=&amp;quot;DR&amp;quot;/&amp;amp;gt;
&amp;amp;lt;/h:selectOneMenu&amp;amp;gt;
&amp;amp;lt;h:message for=&amp;quot;salutation&amp;quot;/&amp;amp;gt;
&amp;amp;lt;!-- Second row begins here --&amp;amp;gt;
&amp;amp;lt;h:outputLabel value=&amp;quot;First Name:&amp;quot;
for=&amp;quot;firstName&amp;quot;/&amp;amp;gt;
&amp;amp;lt;h:inputText id=&amp;quot;firstName&amp;quot; label=&amp;quot;First Name&amp;quot;
required=&amp;quot;true&amp;quot;
value=&amp;quot;#{RegistrationBean.firstName}&amp;quot; /&amp;amp;gt;
&amp;amp;lt;h:message for=&amp;quot;firstName&amp;quot; /&amp;amp;gt;
&amp;amp;lt;!-- Third row begins here --&amp;amp;gt;
&amp;amp;lt;h:outputLabel value=&amp;quot;Last Name:&amp;quot; for=&amp;quot;lastName&amp;quot;/&amp;amp;gt;
&amp;amp;lt;h:inputText id=&amp;quot;lastName&amp;quot; label=&amp;quot;Last Name&amp;quot;
required=&amp;quot;true&amp;quot;
value=&amp;quot;#{RegistrationBean.lastName}&amp;quot; /&amp;amp;gt;
&amp;amp;lt;h:message for=&amp;quot;lastName&amp;quot; /&amp;amp;gt;
&amp;amp;lt;!-- Fourth row begins here --&amp;amp;gt;
&amp;amp;lt;h:outputLabel for=&amp;quot;age&amp;quot; value=&amp;quot;Age:&amp;quot;/&amp;amp;gt;
&amp;amp;lt;h:inputText id=&amp;quot;age&amp;quot; label=&amp;quot;Age&amp;quot; size=&amp;quot;2&amp;quot;
value=&amp;quot;#{RegistrationBean.age}&amp;quot;/&amp;amp;gt;
&amp;amp;lt;h:message for=&amp;quot;age&amp;quot;/&amp;amp;gt;
&amp;amp;lt;!-- Fifth row begins here --&amp;amp;gt;
&amp;amp;lt;h:outputLabel value=&amp;quot;Email Address:&amp;quot; for=&amp;quot;email&amp;quot;/&amp;amp;gt;
&amp;amp;lt;h:inputText id=&amp;quot;email&amp;quot; label=&amp;quot;Email Address&amp;quot;
required=&amp;quot;true&amp;quot;
value=&amp;quot;#{RegistrationBean.email}&amp;quot; /&amp;amp;gt;
&amp;amp;lt;h:message for=&amp;quot;email&amp;quot; /&amp;amp;gt;
&amp;amp;lt;!-- Sixth row begins here --&amp;amp;gt;
&amp;amp;lt;h:panelGroup/&amp;amp;gt;
&amp;amp;lt;h:commandButton id=&amp;quot;register&amp;quot; value=&amp;quot;Register&amp;quot;
action=&amp;quot;submit&amp;quot; /&amp;amp;gt;
&amp;amp;lt;/h:panelGrid&amp;amp;gt;
&amp;amp;lt;/h:form&amp;amp;gt;
&amp;amp;lt;/f:view&amp;amp;gt;
&amp;amp;lt;/body&amp;amp;gt;
&amp;amp;lt;/html&amp;amp;gt;
</pre>
<p>The following screenshot illustrates how our page will be rendered at runtime:</p>
<p><a href="http://www.javabeat.net/wp-content/uploads/2008/12/netbeans-jsf-8.gif"><img class="aligncenter size-full wp-image-6720" alt="netbeans-jsf-8" src="http://www.javabeat.net/wp-content/uploads/2008/12/netbeans-jsf-8.gif" width="442" height="349" /></a></p>
<p>All <b><i>JSF</i></b> input fi elds must be inside a &lt;h:form&gt; tag. The &lt;h:panelGrid&gt; helps us to easily align <b><i>JSF</i></b> tags in our page. It can be thought of as a grid where other <b><i>JSF </i></b>tags will be placed. The columns attribute of the &lt;h:panelGrid&gt; tag indicates how many columns the grid will have, each <b><i>JSF</i></b> component inside the &lt;h:panelGrid&gt; component will be placed in an individual cell of the grid, when the number of components matching the value of the columns attribute (three in our example) has been placed inside &lt;h:panelGrid&gt;, a new row is automatically started. Each row in our &lt;h:panelGrid&gt; consists of an &lt;h:outputLabel&gt; tag, an input fi eld, and an &lt;h:message&gt; tag.</p>
<p>The columnClasses attribute of &lt;h:panelGrid&gt; allow us to assign CSS styles to each column inside the panel grid. Its value attribute must consist of a comma separated list of CSS styles (defi ned in a CSS stylesheet). The fi rst style will be applied to the fi rst column, the second style will be applied to the second column, the third style will be applied to the third column, so on and so forth. If our panel grid had more than three columns, then the fourth column would have been styled using the fi rst style in the columnClasses attribute, the fi fth column would have been styled using the second style in the columnClasses attribute, so on and so forth.</p>
<p><i>The CSS stylesheet for our example is very simple, therefore it is not shown. However, it is part of the code download for this chapter.</i></p>
<p>If we wish to style rows in an &lt;h:panelGrid&gt;, we can do so with its rowClasses attribute, which works the same way that the columnClasses works for columns. &lt;h:outputLabel&gt;, generates a label for an input fi eld in the form. The value of its for attribute must match the value of the id attribute of the corresponding input field.</p>
<p>&lt;h:message&gt; generates an error message for an input fi eld. The value of its for fi eld must match the value of the id attribute for the corresponding input fi eld. The fi rst row in our grid contains an &lt;h:selectOneMenu&gt;. This tag generates an HTML &lt;select&gt; tag on the rendered page.</p>
<p>Every <b><i>JSF</i></b> tag has an id attribute. The value for this attribute must be a string containing a unique identifi er for the tag. If we don&#8217;t specify a value for this attribute, one will be generated automatically. It is a good idea to explicitly state the ID of every component, since this ID is used in runtime error messages (affected components are a lot easier to identify if we explicitly set their IDs).</p>
<p>For More Information:</p>
<p>When using &lt;h:label&gt; tags to generate labels for input fi elds, or when using &lt;h:message&gt; tags to generate validation errors, we need to explicitly set the value of the id tag, since we need to specify it as the value of the for attribute of the corresponding &lt;h:label&gt; and &lt;h:message&gt; tags.</p>
<p>Every <b><i>JSF</i></b> input tag has a label attribute. This attribute is used to generate validation error messages on the rendered page. If we don&#8217;t specify a value for the label attribute, then the fi eld will be identifi ed in the error message by it&#8217;s ID. Each <b><i>JSF</i></b> input fi eld has a value attribute. In the case of &lt;h:selectOneMenu&gt;, this attribute indicates which of the options in the rendered &lt;select&gt; tag will be selected. The value of this attribute must match the value of the itemValue attribute of one of the nested &lt;f:selectItem&gt; tags. The value of this attribute is usually a value binding expression, which means that the value is read at runtime from a <b><i>JSF</i></b>-managed bean. In our example, the value binding expression #{RegistrationBean.salutation} is used. What will happen is, at runtime <b><i>JSF</i></b> will look for a managed bean named RegistrationBean, and look for an attribute named salutation on this bean, the getter method for this attribute will be invoked, and its return value will be used to determine the selected value of the rendered HTML &lt;select&gt; tag.</p>
<p>Nested inside the &lt;h:selectOneMenu&gt; there are a number of &lt;f:selectItem&gt; tags. These tags generate HTML &lt;option&gt; tags inside the HTML &lt;select&gt; tag generated by &lt;h:selectOneMenu&gt;. The value of the itemLabel attribute is the value that the user will see, while the value of the itemValue attribute will be the value that will be sent to the server when the form is submitted.</p>
<p>All other rows in our grid contain &lt;h:inputText&gt; tags. This tag generates an HTML input fi eld of type text, which accepts a single line of typed text as input. We explicitly set the id attribute of all of our &lt;h:inputText&gt; fi elds; this allows us to refer to them from the corresponding &lt;h:outputLabel&gt; and &lt;h:message&gt; fi elds. We also set the label attribute for all of our &lt;h:inputText&gt; tags; this results in user friendlier error messages.</p>
<p>Some of our &lt;h:inputText&gt; fi elds require a value. These fi elds have their required attribute set to true, and each <b><i>JSF</i></b> input fi eld has a required attribute. If we require the user to enter a value for this attribute, then we need to set this attribute to true. This attribute is optional, and if we don&#8217;t explicitly set a value for it, then it defaults to false.</p>
<p>In the last row of our grid, we added an empty &lt;h:panelGroup&gt; tag. The purpose of this tag is to allow adding several tags into a single cell of an &lt;h:panelGrid&gt;. Any tags placed inside this tag are placed inside the same cell of the grid where &lt;h:panelGrid&gt; is placed. In this particular case, all we want to do is to have an &#8221;empty&#8221; cell in the grid so that the next tag, &lt;h:commandButton&gt;, is aligned with the input fi elds in the rendered page.</p>
<p>&lt;h:commandButton&gt; is used to submit a form to the server. The value of it&#8217;s value attribute is used to generate the text of the rendered button. The value of it&#8217;s action attribute is used to determine what page to display after the button is pressed. This<br />
is specifi ed in the navigation rules of the application&#8217;s <b><i>faces-config.xml</i></b> fi le, which will be covered later in the chapter.</p>
<p>In our example, we are using static navigation. When using <b><i>JSF</i></b> static navigation, the value of the action attribute of a command button is hard coded in the <i>JSP </i>markup. An alternate to static navigation is dynamic navigation. When using dynamic navigation, the value of the action attribute of the command button is a value binding expression resolving to a method returning a String in a managed bean. The method may then return different values based on certain conditions. Navigation would proceed to a different page, depending on the value of the method.</p>
<p><i>As long as it returns a String, the managed bean method executed when using dynamic navigation can contain any logic inside it, and is frequently used to save data in a managed bean into a database.</i></p>
<p>Both when using static or dynamic navigation, the page to navigate to is defi ned in the application&#8217;s <b><i>faces-config.xml</i></b> confi guration fi le. Later in this chapter, we will explain how we can graphically confi gure navigation rules using the <b><i>NetBeans</i></b> Page<br />
Flow editor.</p>
<h2>Creating Our Managed Bean</h2>
<p><b><i>JSF</i></b>-managed beans are standard JavaBeans that are used to hold user-entered data in <b><i>JSF</i></b> applications. <b><i>JSF</i></b>-managed beans need to be declared in the application&#8217;s <b><i>faces-config.xml</i></b> fi le. <b><i>NetBeans</i></b> can help expedite things by automatically adding our managed beans to <b><i>faces-config.xml</i></b>.</p>
<p>In order to create a new managed bean, we need to go to File | New, select JavaServer Faces from the category list, and <b><i>JSF</i></b> Managed Bean from the file type list.</p>
<p style="text-align: center;"><a href="http://www.javabeat.net/wp-content/uploads/2008/12/netbeans-jsf-9.gif"><img class="aligncenter  wp-image-6721" alt="netbeans-jsf-9" src="http://www.javabeat.net/wp-content/uploads/2008/12/netbeans-jsf-9.gif" width="439" height="298" /></a></p>
<p>In the next screen in the wizard, we need to enter a name for our managed bean, as well as a package.</p>
<p style="text-align: center;"><a href="http://www.javabeat.net/wp-content/uploads/2008/12/netbeans-jsf-10.gif"><img class="aligncenter  wp-image-6722" alt="netbeans-jsf-10" src="http://www.javabeat.net/wp-content/uploads/2008/12/netbeans-jsf-10.gif" width="439" height="307" /></a></p>
<p>Most default values are sensible and in most cases can be accepted. The only one we should change if necessary is the Scope field.</p>
<p>Managed beans can have different scopes. A scope of request means that the bean is only available in a single HTTP request. Managed beans can also have session scope, in which case they are available in a single user&#8217;s HTTP session. A scope of application means that the bean is accessible to all users in the application, across user sessions. Managed beans can also have a scope of none, which means that the managed bean is not stored at any scope, but is created on demand as needed. We should select the appropriate scope for our managed bean. In our particular example, the default request scope will meet our needs.</p>
<p>Af ter fi nishing the wizard, two things happen: a boilerplate version of our managed bean is created in the specifi ed package, and our managed bean is added to the application&#8217;s <b><i>faces-config.xml</i></b>.</p>
<p>The generated managed bean source simply consists of the class and a public no argument constructor.</p>
<pre class="brush: java; title: ; notranslate">package com.ensode.&amp;lt;b&amp;gt;&amp;lt;i&amp;gt;JSF&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;.managedbeans;
public class RegistrationBean {
/** Creates a new instance of RegistrationBean */
public RegistrationBean() {
}
}
The application's &amp;lt;b&amp;gt;&amp;lt;i&amp;gt;faces-config.xml&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt; contains our managed bean declaration.
&amp;amp;lt;?xml version='1.0' encoding='UTF-8'?&amp;amp;gt;
&amp;amp;lt;faces-config version=&amp;quot;1.2&amp;quot;
xmlns=&amp;quot;http://java.sun.com/xml/ns/javaee&amp;quot;
xmlns:xsi=&amp;quot;http://www.w3.org/2001/XMLSchema-instance&amp;quot;
xsi:schemaLocation=&amp;quot;http://java.sun.com/xml/ns/javaee

http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd&quot;&amp;gt;

&amp;amp;lt;managed-bean&amp;amp;gt;
&amp;amp;lt;managed-bean-name&amp;amp;gt;
RegistrationBean
&amp;amp;lt;/managed-bean-name&amp;amp;gt;
&amp;amp;lt;managed-bean-class&amp;amp;gt;
com.ensode.&amp;lt;b&amp;gt;&amp;lt;i&amp;gt;JSF&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;.managedbeans.RegistrationBean
&amp;amp;lt;/managed-bean-class&amp;amp;gt;
&amp;amp;lt;managed-bean-scope&amp;amp;gt;request&amp;amp;lt;/managed-bean-scope&amp;amp;gt;
&amp;amp;lt;/managed-bean&amp;amp;gt;
&amp;amp;lt;/faces-config&amp;amp;gt;
</pre>
<p>The value of the &lt;managed-bean-name&gt; element matches the value we entered in the Class Name fi eld in the wizard. Notice that this value is what we used in the value binding expressions in our page to access the managed bean properties. Although the value we gave the managed bean matches it&#8217;s class name, this is not mandatory. The value we entered in the wizard&#8217;s Class Name fi eld is also used as the name of the class that was generated by the wizard, as can be seen by the value of the &lt;managed-bean-class&gt; element, which is the fully qualifi ed name of our managed bean class. Unsurprisingly, the package structure matches the value we entered in the Package fi eld in the wizard. Finally, we see the scope we selected in the wizard as the value of the &lt;managed-bean-scope&gt; element.</p>
<p>At this point, we need to modify our managed bean by adding properties that will hold the user-entered values.</p>
<p><i>Automatic Generation of Getter and Setter Methods: Netbeans can automatically generate getter and setter methods for our<br />
properties. We simply need to click the keyboard shortcut for &#8220;insert code&#8221;, which defaults to Alt+Insert in Windows and Linux, then select Getters and Setters.</i></p>
<pre class="brush: java; title: ; notranslate">package com.ensode.&amp;lt;b&amp;gt;&amp;lt;i&amp;gt;JSF&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;.managedbeans;
public class RegistrationBean {
/** Creates a new instance of RegistrationBean */
public RegistrationBean() {
}
private String salutation;
private String firstName;
private String lastName;
private Integer age;
private String email;
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getSalutation() {
return salutation;
}
public void setSalutation(String salutation) {
this.salutation = salutation;
}
public Integer getAge() {
return age;
}
public void setAge(Integer age) {
this.age = age;
}
}
</pre>
<p>No tice that the names of all of the bean&#8217;s properties (instance variables) match the names we used in the <i>JSP</i>&#8216;s value binding expressions. These names must match so that <b><i>JSF</i></b> knows how to map the bean&#8217;s properties to the value binding expressions.</p>
<h2>Implementing Navigation</h2>
<p>The last thing we need to do before we can test our application is to implement application navigation. For our application we need to create a confi rmation page, then add navigation rules to our <i>JSP</i> page so that the application navigates from the input page to the confi rmation page when the user submits the form.</p>
<p><b><i>NetBeans</i></b> allows us to save some time by allowing us to graphically add navigation rules via the <b><i>NetBeans</i></b> Page Flow Editor. To do so, we need to open faces-confi g. xml and click on the PageFlow button in the toolbar above the fi le. In our particular case we haven&#8217;t yet created the confi rmation page we wish to navigate to. This is not a problem, since it can be created &#8220;on demand&#8221; by <b><i>NetBeans</i></b> by right-clicking on the PageFlow editor and selecting New File from the resulting pop-up menu.</p>
<p style="text-align: center;"><a href="http://www.javabeat.net/wp-content/uploads/2008/12/netbeans-jsf-11.gif"><img class="aligncenter  wp-image-6723" alt="netbeans-jsf-11" src="http://www.javabeat.net/wp-content/uploads/2008/12/netbeans-jsf-11.gif" width="466" height="257" /></a></p>
<p>At this point the standard New <i>JSP</i> File wizard appears. We enter confirmation. jsp as the name of the new <i>JSP</i>. The new page is automatically created and added to the page fl ow editor.</p>
<p style="text-align: center;"><a href="http://www.javabeat.net/wp-content/uploads/2008/12/netbeans-jsf-12.gif"><img class="aligncenter  wp-image-6724" alt="netbeans-jsf-12" src="http://www.javabeat.net/wp-content/uploads/2008/12/netbeans-jsf-12.gif" width="498" height="262" /></a></p>
<p>We can graphically connect the two pages by clicking on the connector to the right of welcome<b><i>JSF</i></b>.jsp and dragging it to confi rmation.jsp.</p>
<p style="text-align: center;"><a href="http://www.javabeat.net/wp-content/uploads/2008/12/netbeans-jsf-13.gif"><img class="aligncenter  wp-image-6725" alt="netbeans-jsf-13" src="http://www.javabeat.net/wp-content/uploads/2008/12/netbeans-jsf-13.gif" width="480" height="246" /></a></p>
<p>Doing so generates a navigation case from welcome<b><i>JSF</i></b>.jsp to confi rmation.jsp. As we can see, the navigation case is given a default outcome name of case1. We need to modify this to be the value of the action attribute of the &lt;h:commandButton&gt; in welcome<b><i>JSF</i></b>.jsp.</p>
<p>To do this, we simply double-click on the text representing the navigation case outcome name, then replace it with the appropriate value.</p>
<p style="text-align: center;"><a href="http://www.javabeat.net/wp-content/uploads/2008/12/netbeans-jsf-14.gif"><img class="aligncenter  wp-image-6726" alt="netbeans-jsf-14" src="http://www.javabeat.net/wp-content/uploads/2008/12/netbeans-jsf-14.gif" width="440" height="251" /></a></p><div class="wpInsert wpInsertInPostAd wpInsertMiddle" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Middle-Med-Rect */
google_ad_slot = "7805667846";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
<p>At this point, the navigation case name is updated with the value we entered.</p>
<p style="text-align: center;"><a href="http://www.javabeat.net/wp-content/uploads/2008/12/netbeans-jsf-15.gif"><img class="aligncenter  wp-image-6727" alt="netbeans-jsf-15" src="http://www.javabeat.net/wp-content/uploads/2008/12/netbeans-jsf-15.gif" width="491" height="303" /></a></p>
<p>If we had been using dynamic navigation (and, of course, if there were more than two <i>JSP</i> pages in the application), we would simply drag the connector from welcome<b><i>JSF</i></b>. jsp to another page to create a different navigation case based on the value of the managed bean method executed when clicking the page&#8217;s command button.</p>
<p>The <b><i>NetBeans</i></b> PageFlow editor updates our application&#8217;s <b><i>faces-config.xml</i></b> behind the scenes. It adds a &lt;navigation-rule&gt; element to it.</p>
<pre class="brush: java; title: ; notranslate">&amp;amp;lt;navigation-rule&amp;amp;gt;
&amp;amp;lt;from-view-id&amp;amp;gt;/welcome&amp;lt;b&amp;gt;&amp;lt;i&amp;gt;JSF&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;.jsp&amp;amp;lt;/from-view-id&amp;amp;gt;
&amp;amp;lt;navigation-case&amp;amp;gt;
&amp;amp;lt;from-outcome&amp;amp;gt;submit&amp;amp;lt;/from-outcome&amp;amp;gt;
&amp;amp;lt;to-view-id&amp;amp;gt;/confirmation.jsp&amp;amp;lt;/to-view-id&amp;amp;gt;
&amp;amp;lt;/navigation-case&amp;amp;gt;
&amp;amp;lt;/navigation-rule&amp;amp;gt;
</pre>
<p>The &lt;fr om-view-id&gt; element is the name of the <i>JSP</i> originating the navigation. It is the <i>JSP</i> we drag from in the PageFlow editor to create the navigation case. The value of the &lt;to-view-id&gt; element is the destination page. It is generated from the <i>JSP</i> we drag the navigation case to in the PageFlow editor. The value of the &lt;from-outcome&gt; element is the name of the navigation case outcome in the PageFlow editor.</p>
<p>If we had been using dynamic navigation, we would have separate &lt;navigationcase&gt; elements for each possible return value of the managed bean method bound to the page&#8217;s command button, the body of the &lt;from-outcome&gt; element of each navigation case would be one possible return value, and the body of the &lt;to-viewid&gt; would be the page we would navigate to for that particular navigation case.</p>
<p><i>Notice that the value of the &lt;from-view-id&gt; element starts with a forward slash (/). A common mistake when setting up <b><i>JSF</i></b> navigation is to forget this initial tag. When this happens, <b><i>JSF</i></b> will fail to find the destination <i>JSP</i> and will simply redisplay the page that initiated the navigation. Using <b>NetBean&#8217;s PageFlow editor</b> prevents us from making that mistake.</i></p>
<p>After setting up our navigation case, we now need to modify the generated confirmation.jsp so that it displays the values in our managed bean.</p>
<pre class="brush: java; title: ; notranslate">&amp;amp;lt;%@pa ge contentType=&amp;quot;text/html&amp;quot; pageEncoding=&amp;quot;UTF-8&amp;quot;%&amp;amp;gt;
&amp;amp;lt;!DOCTYPE HTML PUBLIC &amp;quot;-//W3C//DTD HTML 4.01 Transitional//EN&amp;quot;
&amp;quot;http://www.w3.org/TR/html4/loose.dtd&amp;quot;&amp;amp;gt;
&amp;amp;lt;%@ taglib prefix=&amp;quot;f&amp;quot; uri=&amp;quot;http://java.sun.com/&amp;lt;b&amp;gt;&amp;lt;i&amp;gt;JSF&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;/core&amp;quot; %&amp;amp;gt;
&amp;amp;lt;%@ taglib prefix=&amp;quot;h&amp;quot; uri=&amp;quot;http://java.sun.com/&amp;lt;b&amp;gt;&amp;lt;i&amp;gt;JSF&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;/html&amp;quot; %&amp;amp;gt;
&amp;amp;lt;html&amp;amp;gt;
&amp;amp;lt;head&amp;amp;gt;
&amp;amp;lt;meta http-equiv=&amp;quot;Content-Type&amp;quot; content=&amp;quot;text/html;
charset=UTF-8&amp;quot;&amp;amp;gt;
&amp;amp;lt;link rel=&amp;quot;stylesheet&amp;quot; type=&amp;quot;text/css&amp;quot;
href=&amp;quot;../css/style.css&amp;quot;&amp;amp;gt;
&amp;amp;lt;title&amp;amp;gt;Confirmation Page&amp;amp;lt;/title&amp;amp;gt;
&amp;amp;lt;/head&amp;amp;gt;
&amp;amp;lt;body&amp;amp;gt;
&amp;amp;lt;h2&amp;amp;gt;Confirmation Page&amp;amp;lt;/h2&amp;amp;gt;
&amp;amp;lt;f:view&amp;amp;gt;
&amp;amp;lt;h:panelGrid columns=&amp;quot;2&amp;quot;
columnClasses=&amp;quot;rightalign-bold,normal&amp;quot;&amp;amp;gt;
&amp;amp;lt;!-- First row begins here --&amp;amp;gt;
&amp;amp;lt;h:outputText value=&amp;quot;Salutation: &amp;quot;/&amp;amp;gt;
&amp;amp;lt;h:outputText
value=&amp;quot;#{RegistrationBean.salutation}&amp;quot; /&amp;amp;gt;
&amp;amp;lt;!-- Second row begins here --&amp;amp;gt;
&amp;amp;lt;h:outputText value=&amp;quot;First Name:&amp;quot;/&amp;amp;gt;
&amp;amp;lt;h:outputText value=&amp;quot;#{RegistrationBean.firstName}&amp;quot; /&amp;amp;gt;
&amp;amp;lt;!-- Third row begins here --&amp;amp;gt;
&amp;amp;lt;h:outputText value=&amp;quot;Last Name:&amp;quot;/&amp;amp;gt;
&amp;amp;lt;h:outputText value=&amp;quot;#{RegistrationBean.lastName}&amp;quot; /&amp;amp;gt;
&amp;amp;lt;!-- Fourth row begins here --&amp;amp;gt;
&amp;amp;lt;h:outputText value=&amp;quot;Age:&amp;quot;/&amp;amp;gt;
&amp;amp;lt;h:outputText value=&amp;quot;#{RegistrationBean.age}&amp;quot;/&amp;amp;gt;
&amp;amp;lt;!-- Fifth row begins here --&amp;amp;gt;
&amp;amp;lt;h:outputText value=&amp;quot;Email Address:&amp;quot;/&amp;amp;gt;
&amp;amp;lt;h:outputText value=&amp;quot;#{RegistrationBean.email}&amp;quot; /&amp;amp;gt;
&amp;amp;lt;/h:panelGrid&amp;amp;gt;
&amp;amp;lt;/f:view&amp;amp;gt;
&amp;amp;lt;/body&amp;amp;gt;
&amp;amp;lt;/html&amp;amp;gt;
</pre>
<p>As we can see, our confi rmation page is very simple. It consists of a series of &lt;h:outputText&gt; tags containing labels and value binding expressions bound to our managed bean&#8217;s properties.</p>
<h2>Executing Our Application</h2>
<p>We are now ready to execute our <b><i>JSF</i></b> application. The easiest way to do so is to right-click on welcome<b><i>JSF</i></b>.jsp and click on Run File in the resulting pop-up menu, or, if our application is set as the main project, we can click directly to the &#8220;Run&#8221; icon in the tool bar at the top of the IDE.</p>
<p>At this point GlassFish (or whatever application server we are using for our project) will start automatically, if it hadn&#8217;t been started already, the default browser will open and it will automatically be directed to our page&#8217;s URL.</p>
<p>After entering some data on the page, it should look something like the following screenshot.</p>
<p style="text-align: center;"><a href="http://www.javabeat.net/wp-content/uploads/2008/12/netbeans-jsf-17.gif"><img class="aligncenter  wp-image-6729" alt="netbeans-jsf-17" src="http://www.javabeat.net/wp-content/uploads/2008/12/netbeans-jsf-17.gif" width="514" height="300" /></a></p>
<p>When we click on the Register button, our RegistrationBean managed bean is populated with the values we entered into the page. Each property in the fi eld will be populated according to the value binding expression in each input field.</p>
<p>At this point <b><i>JSF</i></b> navigation &#8220;kicks-in&#8221;, and we are taken to the Confi rmation Page.</p>
<p style="text-align: center;"><a href="http://www.javabeat.net/wp-content/uploads/2008/12/netbeans-jsf-18.gif"><img class="aligncenter  wp-image-6730" alt="netbeans-jsf-18" src="http://www.javabeat.net/wp-content/uploads/2008/12/netbeans-jsf-18.gif" width="514" height="314" /></a></p>
<p>The values displayed in the confi rmation page are taken from our managed bean, confi rming that the bean&#8217;s properties were populated correctly.</p>
<h2><b><i>JSF</i></b> Validation</h2>
<p>Earlier i n this chapter we discussed how the required attribute for <b><i>JSF</i></b> input fi elds allows us to easily make input fields mandatory.</p>
<p>If a user attempts to submit a form with one or more required fi elds missing, an error message is automatically generated.</p>
<p style="text-align: center;"><a href="http://www.javabeat.net/wp-content/uploads/2008/12/netbeans-jsf-19.gif"><img class="aligncenter  wp-image-6731" alt="netbeans-jsf-19" src="http://www.javabeat.net/wp-content/uploads/2008/12/netbeans-jsf-19.gif" width="502" height="290" /></a></p>
<p>The error message is generated by the &lt;h:message&gt; tag corresponding to the invalid fi eld. The string First Name in the error message corresponds to the value of the label attribute for the fi eld. Had we omitted the label attribute, the value of the fi elds id attribute would have been shown instead. As we can see, the required attribute makes it very easy to implement mandatory fi eld functionality in our application.</p>
<p>Recall that the age fi eld is bound to a property of type Integer in our managed bean. If a user enters a value that is not a valid integer into this fi eld, a validation error is automatically generated.</p>
<p><a href="http://www.javabeat.net/wp-content/uploads/2008/12/netbeans-jsf-20.gif"><img class="aligncenter size-full wp-image-6732" alt="netbeans-jsf-20" src="http://www.javabeat.net/wp-content/uploads/2008/12/netbeans-jsf-20.gif" width="178" height="65" /></a></p>
<p>Of course, a negative age wouldn&#8217;t make much sense, however, our application validates that user input is a valid integer with essentially no effort on our part. The email address input fi eld of our page is bound to a property of type String in our managed bean. As such, there is no built-in validation to make sure that the user enters a valid email address. In cases like this, we need to write our own custom <b><i>JSF</i></b> validators.</p>
<p>Custom <b><i>JSF</i></b> validators must implement the javax.faces.validator.Validator interface. This interface contains a single method named validate(). This method takes three parameters: an instance of javax.faces.context.FacesContext, an instance of javax.faces.component.UIComponent containing the <b><i>JSF</i></b> component we are validating, and an instance of java.lang.Object containing the user entered value for the component. The following example illustrates a typical custom validator.</p>
<pre class="brush: java; title: ; notranslate">package com.ensode.&amp;lt;b&amp;gt;&amp;lt;i&amp;gt;JSF&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;.validators;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.component.html.HtmlInputText;
import javax.faces.context.FacesContext;
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;
public class EmailValidator implements Validator {
public void validate(FacesContext facesContext,
UIComponent uIComponent, Object value) throws
ValidatorException {
Pattern pattern = Pattern.compile(&amp;quot;\\w+@\\w+\\.\\w+&amp;quot;);
Matcher matcher = pattern.matcher(
(CharSequence) value);
HtmlInputText htmlInputText = (HtmlInputText) uIComponent;
String label;
if (htmlInputText.getLabel() == null ||
htmlInputText.getLabel().trim().equals(&amp;quot;&amp;quot;)) {
label = htmlInputText.getId();
} else {
label = htmlInputText.getLabel();
}
if (!matcher.matches()) {
FacesMessage facesMessage =
new FacesMessage(label +
&amp;quot;: not a valid email address&amp;quot;);
throw new ValidatorException(facesMessage);
}
}
}
</pre>
<p>In our example, the validate() method does a regular expression match against the value of the <b><i>JSF</i></b> component we are validating. If the value matches the expression, validation succeeds, otherwise, validation fails and an instance of javax.faces. validator.ValidatorException is thrown.</p>
<p><i>The primary purpose of our custom validator is to illustrate how to write custom <b><i>JSF</i></b> validations, and not to create a foolproof email address validator. There may be valid email addresses that don&#8217;t validate using our validator.</i>.</p>
<p>The constructor of ValidatorException takes an instance of javax.faces. application.FacesMessage as a parameter. This object is used to display the error message on the page when validation fails. The message to display is passed as a String to the constructor of FacesMessage. In our example, if the label attribute of the component is not null nor empty, we use it as part of the error message,<br />
otherwise we use the value of the component&#8217;s id attribute. This behavior follows the pattern established by standard <b><i>JSF</i></b> validators.</p>
<p>Before we can use our custom validator in our pages, we need to declare it in the application&#8217;s <b><i>faces-config.xml</i></b> confi guration fi le. To do so, we need to add a &lt;validator&gt; element just before the closing &lt;/faces-config&gt; element.</p>
<pre class="brush: java; title: ; notranslate">&amp;amp;lt;validator&amp;amp;gt;
&amp;amp;lt;validator-id&amp;amp;gt;emailValidator&amp;amp;lt;/validator-id&amp;amp;gt;
&amp;amp;lt;validator-class&amp;amp;gt;
com.ensode.&amp;lt;b&amp;gt;&amp;lt;i&amp;gt;JSF&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;.validators.EmailValidator
&amp;amp;lt;/validator-class&amp;amp;gt;
&amp;amp;lt;/validator&amp;amp;gt;
</pre>
<p>The body of the &lt;validator-id&gt; sub element must contain a unique identifi er for our validator. The value of the &lt;validator-class&gt; element must contain the fully qualifi ed name of our validator class.</p>
<p>Once we add our validator to the application&#8217;s <b><i>faces-config.xml</i></b>, we are ready to use it in our pages.</p>
<p>In our particular case, we need to modify the email fi eld to use our custom validator. &lt;h:inputText id=&#8221;email&#8221; label=&#8221;Email Address&#8221;<br />
required=&#8221;true&#8221; value=&#8221;#{RegistrationBean.email}&#8221;&gt; &lt;f:validator validatorId=&#8221;emailValidator&#8221;/&gt; &lt;/h:inputText&gt;</p>
<p>All we need to do is nest an &lt;f:validator&gt; tag inside the input fi eld we wish to have validated using our custom validator. The value of the validatorId attribute of &lt;f:validator&gt; must match the value of the body of the &lt;validator-id&gt; element in <b><i>faces-config.xml</i></b>.</p>
<p>At this point we are ready to test our custom validator.</p>
<p style="text-align: center;"><a href="http://www.javabeat.net/wp-content/uploads/2008/12/netbeans-jsf-23.gif"><img class="aligncenter  wp-image-6735" alt="netbeans-jsf-23" src="http://www.javabeat.net/wp-content/uploads/2008/12/netbeans-jsf-23.gif" width="530" height="219" /></a></p>
<p>When entering an invalid email address into the email address input fi eld and submitting the form, our custom validator logic was executed and the String we passed as a parameter to FacesMessage in our validator() method is shown as the error text by the &lt;h:message&gt; tag for the fi eld.</p>
<h2>Displaying Tabular Data</h2>
<p>JavaServer Faces includes the &lt;h:dataTable&gt; tag that makes it easy to iterate through an array or collection of objects. With <b><i>NetBeans</i></b>, a data table tag can be added to a page by simply dragging the <b><i>JSF</i></b> Data Table item from the <b><i>NetBeans </i></b>palette into our page. In order to demonstrate the usage of this tag, let&#8217;s create a new Web Application project, and add a new <i>JSP</i> named registrationlist.jsp to it.</p>
<p style="text-align: center;"><a href="http://www.javabeat.net/wp-content/uploads/2008/12/netbeans-jsf-16.gif"><img class="aligncenter  wp-image-6728" alt="netbeans-jsf-16" src="http://www.javabeat.net/wp-content/uploads/2008/12/netbeans-jsf-16.gif" width="490" height="232" /></a></p>
<p>After dragging the <b><i>JSF</i></b> Data Table item into the appropriate location in our registrationlist.jsp page, the following window pops up.</p>
<p style="text-align: center;"><a href="http://www.javabeat.net/wp-content/uploads/2008/12/netbeans-jsf-22.gif"><img class="aligncenter  wp-image-6734" alt="netbeans-jsf-22" src="http://www.javabeat.net/wp-content/uploads/2008/12/netbeans-jsf-22.gif" width="545" height="146" /></a></p>
<p>We can either select to create an Empty Table or a Table Generated from an Entity Class.</p>
<p><i>An Entity Class refers to a Java Persistence API (JPA) entity. We will discuss JPA in detail in Chapter 5 Interacting With Databases through the Java Persistence API.</i></p>
<p>Selecting to create an empty table generates the following markup in our page:</p>
<p>Selecting to create an empty table generates the following markup in our page:</p>
<pre class="brush: java; title: ; notranslate">
&amp;amp;lt;h:form&amp;amp;gt;
&amp;amp;lt;h:dataTable value=&amp;quot;#{arrayOrCollectionOf}&amp;quot;
var=&amp;quot;item&amp;quot;&amp;amp;gt;
&amp;amp;lt;/h:dataTable&amp;amp;gt;
&amp;amp;lt;/h:form&amp;amp;gt;
</pre>
<p>Notice that <b><i>NetBeans</i></b> automatically wraps the generated &lt;h:dataTable&gt; tag in an &lt;h:form&gt; tag. The &lt;h:form&gt; tag is necessary if we plan to have any input fi elds in our table. Since this is not the case in our example, we can safely delete it. The value of the value attribute of &lt;h:dataTable&gt; typically resolves to an array or collection of objects. <b><i>NetBeans</i></b> places the placeholder value binding expression #{arrayOrCollectionOf} as its value; we must replace this with a value binding expression resolving to one of the appropriate types.</p>
<p>The value of the var attribute of &lt;h:dataTable&gt; is used to refer to the current element in the table. As we iterate through the elements of the array or collection from the value attribute, we can use the value of the item attribute to refer to the current element in the array or collection.</p>
<p>We need to add a &lt;h:column&gt; tag inside the &lt;h:dataTable&gt; tag for each column we wish to add to the table. The following example illustrates typical usage of &lt;h:dataTable&gt; and &lt;h:column&gt;.</p>
<pre class="brush: java; title: ; notranslate">&amp;amp;lt;%@page contentType=&amp;quot;text/html&amp;quot; pageEncoding=&amp;quot;UTF-8&amp;quot;%&amp;amp;gt;
&amp;amp;lt;!DOCTYPE HTML PUBLIC &amp;quot;-//W3C//DTD HTML 4.01 Transitional//EN&amp;quot;
&amp;quot;http://www.w3.org/TR/html4/loose.dtd&amp;quot;&amp;amp;gt;
&amp;amp;lt;%@ taglib prefix=&amp;quot;f&amp;quot; uri=&amp;quot;http://java.sun.com/&amp;lt;b&amp;gt;&amp;lt;i&amp;gt;JSF&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;/core&amp;quot; %&amp;amp;gt;
&amp;amp;lt;%@ taglib prefix=&amp;quot;h&amp;quot; uri=&amp;quot;http://java.sun.com/&amp;lt;b&amp;gt;&amp;lt;i&amp;gt;JSF&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;/html&amp;quot; %&amp;amp;gt;
&amp;amp;lt;html&amp;amp;gt;
&amp;amp;lt;head&amp;amp;gt;
&amp;amp;lt;meta http-equiv=&amp;quot;Content-Type&amp;quot;
content=&amp;quot;text/html; charset=UTF-8&amp;quot;&amp;amp;gt;
&amp;amp;lt;title&amp;amp;gt;&amp;lt;i&amp;gt;JSP&amp;lt;/i&amp;gt; Page&amp;amp;lt;/title&amp;amp;gt;
&amp;amp;lt;/head&amp;amp;gt;
&amp;amp;lt;body&amp;amp;gt;
&amp;amp;lt;f:view&amp;amp;gt;
&amp;amp;lt;h:form&amp;amp;gt;
&amp;amp;lt;h:dataTable
value=
&amp;quot;#{RegistrationListController.registrationBeanList}&amp;quot;
var=&amp;quot;item&amp;quot; border=&amp;quot;1&amp;quot; cellspacing=&amp;quot;0&amp;quot;
cellpadding=&amp;quot;5&amp;quot;&amp;amp;gt;
&amp;amp;lt;h:column&amp;amp;gt;
&amp;amp;lt;f:facet name=&amp;quot;header&amp;quot;&amp;amp;gt;
&amp;amp;lt;h:outputText value=&amp;quot;Salutation&amp;quot;/&amp;amp;gt;
&amp;amp;lt;/f:facet&amp;amp;gt;
&amp;amp;lt;h:outputText value=&amp;quot;#{item.salutation}&amp;quot;/&amp;amp;gt;
&amp;amp;lt;/h:column&amp;amp;gt;
&amp;amp;lt;h:column&amp;amp;gt;
&amp;amp;lt;f:facet name=&amp;quot;header&amp;quot;&amp;amp;gt;
&amp;amp;lt;h:outputText value=&amp;quot;First Name&amp;quot;/&amp;amp;gt;
&amp;amp;lt;/f:facet&amp;amp;gt;
&amp;amp;lt;h:outputText value=&amp;quot;#{item.firstName}&amp;quot;/&amp;amp;gt;
&amp;amp;lt;/h:column&amp;amp;gt;
&amp;amp;lt;h:column&amp;amp;gt;
&amp;amp;lt;f:facet name=&amp;quot;header&amp;quot;&amp;amp;gt;
&amp;amp;lt;h:outputText value=&amp;quot;Last Name&amp;quot;/&amp;amp;gt;
&amp;amp;lt;/f:facet&amp;amp;gt;
&amp;amp;lt;h:outputText value=&amp;quot;#{item.lastName}&amp;quot;/&amp;amp;gt;
&amp;amp;lt;/h:column&amp;amp;gt;
&amp;amp;lt;h:column&amp;amp;gt;
&amp;amp;lt;f:facet name=&amp;quot;header&amp;quot;&amp;amp;gt;
&amp;amp;lt;h:outputText value=&amp;quot;Age&amp;quot;/&amp;amp;gt;
&amp;amp;lt;/f:facet&amp;amp;gt;
&amp;amp;lt;h:outputText value=&amp;quot;#{item.age}&amp;quot;/&amp;amp;gt;
&amp;amp;lt;/h:column&amp;amp;gt;
&amp;amp;lt;/h:dataTable&amp;amp;gt;
&amp;amp;lt;/h:form&amp;amp;gt;
&amp;amp;lt;/f:view&amp;amp;gt;
&amp;amp;lt;/body&amp;amp;gt;
&amp;amp;lt;/html&amp;amp;gt;
</pre>
<p>In this example, we will be iterating through a collection of RegistrationBean objects. The objects will be stored as a property named registrationBeanList of type java.util.List in a managed bean called RegistrationListController, therefore we set the value of the value attribute of &lt;h:dataTable&gt; to #{RegistrationListController.registrationBeanList}.</p>
<p><b><i>NetBeans</i></b> creates a sensible value for the var attribute, therefore we leave it as is. &lt;h:dataTable&gt; contains a few attributes that allow us to control the look of the generated table. These attributes are identical to attributes in a standard HTML table. In our example, we set a border of 1 pixel in the table by setting the value of the border attribute to 1. We set the spacing between table cells to zero by setting the cellspacing attribute to 0. We also set the spacing (padding) inside table cells to 5 pixels by setting the cellpadding attribute to 5.</p>
<p>Since our table will have four columns, we need to add four nested &lt;h:column&gt; tags into our data table (one for each column).</p>
<p>Noti ce each &lt;h:column&gt; tag has a nested &lt;f:facet&gt; tag. <b><i>JSF</i></b> tags might define one or more facets. Facets are components that are rendered differently from other components in the parent component. Each facet must have a unique name for each parent component. &lt;h:column&gt; defi nes a facet with a name of header, this facet will be rendered as the header of the generated table. To render a facet inside a <b><i>JSF </i></b>component, the &lt;f:facet&gt; tag is used. In our example we give our facet the name of header by assigning this value to its name property. At runtime, <b><i>JSF</i></b> renders the tag inside &lt;f:facet&gt; as the header of the column rendered by the facet&#8217;s parent &lt;h:column&gt; tag. Each &lt;f:facet&gt; tag must have a single child tag, which can be any HTML <b><i>JSF</i></b> tag.</p>
<p><i>Add ing Multiple Child Components to a Facet: Although the &lt;f:facet&gt; tag only accepts a single child component, we can add multiple components to it by nesting them inside an &lt;f:panelGroup&gt; tag.</i></p>
<p>Although not shown in the example, &lt;h:column&gt; also defi nes a facet with a name of footer that can be used to render a footer for the column. We simply would add a second facet named footer inside our &lt;h:column&gt; tag. Next we add the tags that will be displayed as a single cell for the particular column. We can access the current item in the collection or array. We will be iterating, by using the value of the var attribute of &lt;h:dataTable&gt; (item, in our particular example).</p>
<p>In our example we simply display the values for a single property or each item, however any <b><i>JSF</i></b> component can be placed inside &lt;h:column&gt;.Before we can deploy our application and see the above page in action, we need to create the RegistrationListController managed bean.</p>
<p><i> Recall that the easiest way to create <b><i>JSF</i></b> managed beans is by going to File | New, selecting the JavaServer Faces category, and <b><i>JSF</i></b> Managed Bean as the fi le type. This procedure is covered in detail earlier in this chapter.</i></p>
<p>Our managed bean is shown next:</p>
<pre class="brush: java; title: ; notranslate">package com.ensode.&amp;lt;b&amp;gt;&amp;lt;i&amp;gt;JSF&amp;lt;/i&amp;gt;&amp;lt;/b&amp;gt;;
import java.util.ArrayList;
import java.util.List;
public class RegistrationListController {
private List&amp;amp;lt;RegistrationBean&amp;amp;gt; registrationBeanList;
public RegistrationListController() {
}
public String populateList() {
registrationBeanList = new
ArrayList&amp;amp;lt;RegistrationBean&amp;amp;gt;();
registrationBeanList.add(populateBean(
&amp;quot;MS&amp;quot;, &amp;quot;Carol&amp;quot;, &amp;quot;Jones&amp;quot;, 35));
registrationBeanList.add(populateBean(
&amp;quot;MRS&amp;quot;, &amp;quot;Glenda&amp;quot;, &amp;quot;Murphy&amp;quot;, 39));
registrationBeanList.add(populateBean(
&amp;quot;MISS&amp;quot;, &amp;quot;Stacy&amp;quot;, &amp;quot;Clark&amp;quot;, 36));
registrationBeanList.add(populateBean(
&amp;quot;MR&amp;quot;, &amp;quot;James&amp;quot;, &amp;quot;Fox&amp;quot;, 40));
registrationBeanList.add(populateBean(
&amp;quot;DR&amp;quot;, &amp;quot;Henry&amp;quot;, &amp;quot;Bennett&amp;quot;, 53));
return &amp;quot;success&amp;quot;;
}
public List&amp;amp;lt;RegistrationBean&amp;amp;gt; getRegistrationBeanList() {
return registrationBeanList;
}
public void setRegistrationBeanList(
List&amp;amp;lt;RegistrationBean&amp;amp;gt; registrationBeanList) {
this.registrationBeanList = registrationBeanList;
}
private RegistrationBean populateBean(String salutation,
String firstName, String lastName, Integer age) {
RegistrationBean registrationBean;
registrationBean = new RegistrationBean();
registrationBean.setSalutation(salutation);
registrationBean.setFirstName(firstName);
registrationBean.setLastName(lastName);
registrationBean.setAge(age);
return registrationBean;
}
}
</pre>
<p>Notice that the bean has a property named registrationBeanList of type java.util.List. This is the property we used as the value of the value property in the &lt;h:dataTable&gt; tag in the page above.</p>
<p>The bean&#8217;s populateList() method will be called from another <i>JSP</i> via dynamic navigation. This method populates the registrationBeanList property in the bean.</p>
<p><i>A real application would more than likely retrieve this information from a relational database. To keep our example simple we are simply populating the bean from new instances of RegistrationBean we create on the fly.</i></p>
<p>Now we need to modify the <i>JSP</i> that will be invoked initially. When creating the project, <b><i>NetBeans</i></b> automatically sets it up so that a <i>JSP</i> called welcome<b><i>JSF</i></b>.jsp will be invoked when we point the browser to our application&#8217;s URL. We need to modify this <i>JSP</i> so that it will invoke the populateList() method of our RegistrationBeanList managed bean when navigating to the page we wrote earlier.</p>
<pre class="brush: java; title: ; notranslate">&amp;amp;lt;f:view&amp;amp;gt;
&amp;amp;lt;h:form&amp;amp;gt;
&amp;amp;lt;h:commandLink value=&amp;quot;Populate List&amp;quot;
action=&amp;quot;#{RegistrationListController.populateList}&amp;quot; /&amp;amp;gt;
&amp;amp;lt;/h:form&amp;amp;gt;
&amp;amp;lt;/f:view&amp;amp;gt;
</pre>
<p>For brevity, we are only showing the relevant parts of the <i>JSP</i>. Our <i>JSP</i> will have an &lt;h:commandLink&gt; tag used for navigation. &lt;h:commandLink&gt; is functionally equivalent to &lt;h:commandButton&gt;, the main difference is that it is rendered as a link as opposed to a button. The value of the value attribute of &lt;h:commandLink&gt; is used to render the link text; its action attribute is used for navigation. In this case we are using dynamic navigation. When using dynamic navigation, a value binding expression is used as the value of the action attribute. This value binding expression must resolve to a method that returns a String.</p>
<p>The method must take no arguments. When using dynamic navigation, the method that the value binding expression resolves to may return different strings depending on its logic. We can have a page navigate to different pages depending on the value returned by this method. To do this we would have to add a &lt;navigation-case&gt; element for each possible value that the method may return.</p>
<p>In our example, the populateList() method of the RegistrationListController managed bean is invoked when a user clicks on the link. This method populates the list that we will iterate through and returns the value of success. Before we deploy our application, we need to defi ne the navigation between our two pages. Normally this is done by manually editing faces-confi g.xml. However,<br />
when using <b><i>NetBeans</i></b>, it can be done graphically in the <b><i>NetBeans</i></b> PageFlow editor as explained earlier in this chapter.</p>
<p style="text-align: center;"><a href="http://www.javabeat.net/wp-content/uploads/2008/12/netbeans-jsf-24.gif"><img class="aligncenter  wp-image-6736" alt="netbeans-jsf-24" src="http://www.javabeat.net/wp-content/uploads/2008/12/netbeans-jsf-24.gif" width="549" height="306" /></a></p>
<p>The above screenshot shows the PageFlow editor after connecting the initial page containing the &lt;h:commandLink&gt; that initiates navigation to the page that iterates through the list of RegistrationBean instances, and after changing the default navigation case to success. Notice that the text in the navigation case matches the return value of the populateList() method in the RegistrationListController method. This is how the navigation case is linked to the method&#8217;s return value.</p>
<p><em id="__mceDel">At this point we are ready to test our application. We can execute the initial welcome<b><i>JSF</i></b>.jsp page by right-clicking on it and selecting Run File.</em></p>
<p style="text-align: center;"><a href="http://www.javabeat.net/wp-content/uploads/2008/12/netbeans-jsf-23.gif"><img class="aligncenter  wp-image-6735" alt="netbeans-jsf-23" src="http://www.javabeat.net/wp-content/uploads/2008/12/netbeans-jsf-23.gif" width="530" height="219" /></a></p>
<p>At thi s point, the application server is started (if it hadn&#8217;t been started previously), the application is deployed, and a browser window opens displaying the page.</p>
<p>Here we can see the link that was generated by the &lt;h:commandLink&gt; tag in our <i>JSP</i>. Clicking on that link results in executing the populateList() method in the RegistrationListController managed bean and navigating to the <i>JSP</i> containing the &lt;h:dataTable&gt; tag.</p>
<p>Here we can see the table generated by &lt;h:dataTable&gt;, the headers (Salutation, First Name, Last Name, and Age) are generated by the &lt;f:facet&gt; tags inside each &lt;h:column&gt;. While iterating through the collection of RegistrationBean objects in the registrationBeanList property of the RegistrationListController managed bean, each cell in each row displays the property corresponding to the</p>
<p>&lt;c:outputText&gt; tag inside each &lt;c:column&gt; tag in the table.</p>
<h2><em id="__mceDel"><em id="__mceDel"><em id="__mceDel"><em id="__mceDel">Summary</em></em></em></em></h2>
<p>In this chapter we saw how <b><i>NetBeans</i></b> can help us easily create new <b><i>JSF</i></b> projects by automatically adding all required libraries and confi guration fi les. We also saw how we can create <b><i>JSF</i></b> forms for data input and data tables for displaying tabular data by simply dragging and dropping icons from the <b><i>NetBeans </i></b>palette into our page.</p>
<p><em id="__mceDel"><em id="__mceDel"><em id="__mceDel"><em id="__mceDel">Additionally, we saw how <b><i>NetBeans</i></b> can simplify and signifi cantly speed up development of <b><i>JSF</i></b> applications by automatically adding managed bean defi nitions to the application&#8217;s &lt;<b><i>faces-config.xml</i></b>&gt; confi guration fi le, and by allowing us to graphically defi ne navigation rules by taking advantage of the <b><i>NetBeans </i></b>PageFlow editor.</em></em></em></em></p>
<div class="wpInsert wpInsertInPostAd wpInsertBelow" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* JB-Footer-LU 468x15 */
google_ad_slot = "8789107210";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>]]></content:encoded>
			<wfw:commentRss>http://www.javabeat.net/2008/12/java-ee-5-0-development-with-netbeans-6-0-developing-web-applications-using-jsf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to develop Spring Framework MVC application in NetBeans?</title>
		<link>http://www.javabeat.net/2008/11/developing-a-spring-framework-mvc-application-step-by-step-using-netbeans/</link>
		<comments>http://www.javabeat.net/2008/11/developing-a-spring-framework-mvc-application-step-by-step-using-netbeans/#comments</comments>
		<pubDate>Mon, 24 Nov 2008 07:39:46 +0000</pubDate>
		<dc:creator>krishnas</dc:creator>
				<category><![CDATA[NetBeans]]></category>
		<category><![CDATA[Spring Framework]]></category>
		<category><![CDATA[Spring MVC]]></category>

		<guid isPermaLink="false">http://www.javabeat.net/?p=204</guid>
		<description><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><p>This is a step-by-step guide on how to develop a Spring Framework MVC application from scratch using NetBeans.Spring is basically a technology committed to enabling you to build applications using Plain Old Java Objects (POJOs). It enables you to develop components as POJOs containing only our business logic, while the framework takes care of the [...]</p>]]></description>
				<content:encoded><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><div class="wpInsert wpInsertInPostAd wpInsertLeft" style="float: left; margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Rect */
google_ad_slot = "9976259118";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div><p><span style="font-size: 13px;">This is a step-by-step guide on how to develop a Spring Framework MVC application from scratch using NetBeans.</span>Spring is basically a technology committed to enabling you to build applications using Plain Old Java Objects (POJOs). It enables you to develop components as POJOs containing only our business logic, while the framework takes care of the many value adds you need to build enterprise applications — even in areas that you may not have considered when initially authoring the application. This objective requires a complicated framework, which conceals much difficulty from the developer. Because your business logic is abstracted from infrastructure concerns, it’s also likely to enjoy a longer existence, improving the return on investment of writing it. Business logic should change at the pace of your business; only if it is abstracted from infrastructure concerns can the impact on your code base of expected infrastructure change (such as selecting the application server) be reduced.</p>
<h2>1. Create web project in Eclipse</h2>
<p><span style="text-decoration: underline;"><strong>Prerequisite software</strong></span></p>
<ul>
<li>Java SDK 1.5/1.6</li>
<li>NetBeans 5.0 and above</li>
<li>Spring Framework 2.0</li>
<li>MySQL</li>
</ul>
<p><span style="text-decoration: underline;"><strong>For Creating Web application project using NetBeans, please do the follwoing steps</strong></span></p>
<ol>
<li>Choose File &gt; New Project (Ctrl-Shift-N) from the main menu. Under Categories select Java Web (If you are using NetBeans 6.0 or 6.1, select Web); under Projects select Web Application. Click Next.</li>
<li>In Project Name, enter SpringDemo. From the Server drop-down list, select the server you plan to work with. Leave all other settings at their defaults and click Next.</li>
<li>Select a Spring framework 2.5 checkbox. When you reach the final panel of the wizard, click Finish.</li>
</ol>
<h2>2. Download Spring Framework 2.5.1</h2>
<p>To download the Spring Frame work click on &#8220;<a href="http://www.springframework.org/download" target="_blank">Download</a>&#8221; link. Then select &#8220;spring-framework-2.5.1-with-dependencies.zip&#8221; link. This download contains all the dependencies required to run the spring framework. Save the downloaded file onto your favorite directory. Now extract the downloaded file (spring-framework-2.5.1-with-dependencies.zip) into your favorite directory.</p>
<p>The dist directory of the spring framework contains the spring modules (modules directory) library files. We are mostly concern with these jar files. We will copy these jar files later into our development environment. These jar files are:</p>
<ul>
<li>spring-aop.jar</li>
<li>spring-beans.jar</li>
<li>spring-context.jar</li>
<li>spring-context-support.jar</li>
<li>spring-core.jar</li>
<li>spring-jdbc.jar</li>
<li>spring-jms.jar</li>
<li>spring-orm.jar</li>
<li>spring-test.jar</li>
<li>spring-tx.jar</li>
<li>spring-web.jar</li>
<li>spring-webmvc.jar</li>
<li>spring-webmvc-portlet.jar</li>
<li>spring-webmvc-struts.jar</li>
</ul>
<h2>3. Configure web.xml</h2>
<p>Go to the &#8216;springdemo/WEB-INF&#8217; directory. Modify the minimal &#8216;web.xml&#8217; file to suit our needs. We define a DispatcherServlet that is going to control where all our request are routed based on information we will enter at a later point. It also has a standard servlet-mapping entry that maps to the url patterns that we will be using. Let any url with an &#8216;.htm&#8217; extension be routed to the &#8216;springdemo&#8217; dispatcher.</p>
<p><strong>Code:</strong></p>
<pre class="brush: java; title: ; notranslate">
&lt;context-param&gt;
		 &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
		 &lt;param-value&gt;/WEB-INF/springDemo-servlet.xml&lt;/param-value&gt;
	 &lt;/context-param&gt;

	 &lt;servlet&gt;
		&lt;servlet-name&gt;context&lt;/servlet-name&gt;
		&lt;servlet-class&gt;org.springframework.web.context.ContextLoaderServlet&lt;/servlet-class&gt;
		&lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
	 &lt;/servlet&gt;

	 &lt;servlet&gt;
		&lt;servlet-name&gt;springDemo&lt;/servlet-name&gt;
		&lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
		&lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
	 &lt;/servlet&gt;

	 &lt;servlet-mapping&gt;
		&lt;servlet-name&gt;springDemo&lt;/servlet-name&gt;
		&lt;url-pattern&gt;*.htm&lt;url-pattern&gt;
	 &lt;/servlet-mapping&gt;
</pre>
<p>Next, create a file called &#8216;springdemo-servlet.xml&#8217; in the springdemo/WEB-INF directory. This is the file where definitions used by the DispatcherServlet should be entered. It is named based on the servlet-name from web.xml with &#8216;-servlet&#8217; appended. This is a standard naming convention used in the Spring Framework.</p>
<h2>4. Copy jars to &#8220;WEB-INF/lib&#8221;</h2>
<p>Then, from the Spring distribution, copy spring.jar (spring-framework-2.5.1/dist/spring.jar) to the new WEB-INF/lib directory. Also copy commons-logging jars to the WEB-INF/lib directory (spring-framework-2.5.1/lib/jakarta-commons/commons-logging.jar). These jars will be deployed to the server and they are also used during the build process.</p>
<h2>5. Configuration of database</h2>
<p>Download &#8220;hibernate 3.0&#8243; jar from http://www.hibernate.org/ and add the jar to the WEB-INF/lib directory. Add &#8220;mysql-connector-java-5.0.3-bin&#8221; to the WEB-INF/lib directory. (optional step if you are not having Netbeans 6 and above version installed in you system)</p>
<h2>6. Create database and tables in MySQL</h2>
<ul>
<li>Create database by name &#8220;springdemo&#8221;.</li>
</ul>
<ul>
<li>Create a table by name &#8220;user&#8221; under &#8220;springdemo&#8221; database.</li>
</ul>
<p><span style="text-decoration: underline;">&#8220;user&#8221; table consists of the following fields:</span></p>
<ol>
<li>USER_ID integer</li>
<li>FIRST_NAME varchar(45)</li>
<li>LAST_NAME varchar(45)</li>
<li>COMPANY varchar(45)</li>
<li>COMMENTS varchar(200)</li>
</ol>
<p>Since we are using hibernate we have to create a OR mapping file. The mapping file for &#8220;user&#8221; is created as an xml file by name &#8220;User.hbm&#8221; under com.simpleweb.user.bean directory under Source Packages directory.</p>
<p><strong>Code:</strong></p>
<pre class="brush: java; title: ; notranslate">
&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;!DOCTYPE hibernate-mapping PUBLIC
&quot;-//Hibernate/Hibernate Mapping DTD 2.0//EN&quot;
&quot;http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd&quot;&gt;

&lt;hibernate-mapping&gt;
 &lt;class name=&quot;com.simpleweb.user.bean.User&quot; table=&quot;user&quot; lazy=&quot;false&quot; &gt;
	 &lt;id name=&quot;userId&quot; column=&quot;USER_ID&quot; type=&quot;java.lang.Integer&quot;&gt;
		 &lt;generator/&gt;
	 &lt;/id&gt;
	 &lt;property name=&quot;firstName&quot; column=&quot;FIRST_NAME&quot; type=&quot;java.lang.String&quot; /&gt;
	 &lt;property name=&quot;lastName&quot; column=&quot;LAST_NAME&quot; type=&quot;java.lang.String&quot; /&gt;
	 &lt;property name=&quot;company&quot; column=&quot;COMPANY&quot; type=&quot;java.lang.String&quot; /&gt;
	 &lt;property name=&quot;comments&quot; column=&quot;COMMENTS&quot; type=&quot;java.lang.String&quot; /&gt;
 &lt;/class&gt;
&lt;/hibernate-mapping&gt;
</pre>
<p>Configure database configurations by adding the following code in &#8220;springdemo-servlet.xml&#8221;</p>
<p><strong>Code:</strong></p>
<pre class="brush: java; title: ; notranslate">
&lt;!-- DataSource Property --&gt;
&lt;bean id=&quot;userDataSource&quot;&gt;
	 &lt;property name=&quot;driverClassName&quot;&gt;&lt;value&gt;com.mysql.jdbc.Driver&lt;/value&gt;
	 &lt;/property&gt;&lt;property name=&quot;url&quot;&gt;&lt;value&gt;jdbc:mysql:///springdemo&lt;/value&gt;
	 &lt;/property&gt;&lt;property name=&quot;username&quot;&gt;&lt;value&gt;root&lt;/value&gt;&lt;/property&gt;
	 &lt;property name=&quot;password&quot;&gt;&lt;value&gt;mysql&lt;/value&gt;&lt;/property&gt;
&lt;/bean&gt;

 &lt;!-- Database Property --&gt;
&lt;bean id=&quot;userHibernateProperties&quot;&gt;
	 &lt;property name=&quot;properties&quot;&gt;
		 &lt;props&gt;
			 &lt;prop key=&quot;hibernate.hbm2ddl.auto&quot;&gt;update&lt;/prop&gt;
			 &lt;prop key=&quot;hibernate.dialect&quot;&gt;org.hibernate.dialect.MySQLDialect&lt;/prop&gt;
&lt;prop key=&quot;hibernate.query.substitutions&quot;&gt;true 'T', false 'F'&lt;/prop&gt;
			 &lt;prop key=&quot;hibernate.show_sql&quot;&gt;true&lt;/prop&gt;
			 &lt;prop key=&quot;hibernate.c3p0.minPoolSize&quot;&gt;5&lt;/prop&gt;
			 &lt;prop key=&quot;hibernate.c3p0.maxPoolSize&quot;&gt;20&lt;/prop&gt;
			 &lt;prop key=&quot;hibernate.c3p0.timeout&quot;&gt;600&lt;/prop&gt;
			 &lt;prop key=&quot;hibernate.c3p0.max_statement&quot;&gt;50&lt;/prop&gt;
			 &lt;prop key=&quot;hibernate.c3p0.testConnectionOnCheckout&quot;&gt;false&lt;/prop&gt;
		 &lt;/props&gt;
	 &lt;/property&gt;
&lt;/bean&gt;

   &lt;!-- Hibernate SessionFactory --&gt;
&lt;bean id=&quot;userSessionFactory&quot;&gt;
	 &lt;property name=&quot;dataSource&quot;&gt;&lt;ref local=&quot;userDataSource&quot;/&gt;&lt;/property&gt;
	 &lt;property name=&quot;hibernateProperties&quot;&gt;&lt;ref bean=&quot;userHibernateProperties&quot; /&gt;&lt;/property&gt;

	 &lt;!--  OR mapping files. --&gt;
	 &lt;property name=&quot;mappingResources&quot;&gt;
		 &lt;list&gt;
			 &lt;value&gt;com/simpleweb/user/hibernate/User.hbm.xml&lt;/value&gt;
		 &lt;/list&gt;
	 &lt;/property&gt;
&lt;/bean&gt;
</pre>
<h2>7. Modify index.jsp</h2>
<p>Open the index.jsp in WEB-INF folder and do the following changes in the code:</p>
<p><strong>Code:</strong></p>
<pre class="brush: java; title: ; notranslate">
&lt;%@page contentType=&quot;text/html&quot;%&gt;
&lt;%@page pageEncoding=&quot;UTF-8&quot;%&gt;

&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot; &quot;http://www.w3.org/TR/html4/loose.dtd&quot;&gt;

&lt;html&gt;
    &lt;head&gt;
        &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=UTF-8&quot;&gt;
        &lt;title&gt;User Registration&lt;/title&gt;
    &lt;/head&gt;
    &lt;body&gt;
        &lt;jsp:forward page=&quot;addedituser.htm&quot;/&gt;
    &lt;/body&gt;
&lt;/html&gt;
</pre>
<h2>8. Creating the Controller</h2>
<p>Create your Controller and name as AddEditUserController.java and place it in the springdemo/source packages/ directory.</p>
<p><strong>Code:</strong></p>
<pre class="brush: java; title: ; notranslate">	package com.simpleweb.user.controller;

import org.springframework.web.servlet.mvc.Controller;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import java.io.IOException;

public class AddEditUserController implements Controller {

 }

</pre>
<p>This is as basic a Controller as you can use. We will be expanding this later on, and we will also later on extend some provided abstract base implementations. The Controller handles the request and returns a ModelAndView.</p>
<p>Now, add a bean entry named addEditUserController in springdemo-servlet.xml and make the class AddEditUserController. This defines the controller that our application will be using. We also need to add a URL mapping so the DispatcherServlet knows which controller should be invoked for different URL&#8217;s.</p>
<p><strong>Code:</strong></p>
<pre class="brush: java; title: ; notranslate">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
 &lt;!DOCTYPE beans PUBLIC &quot;-//SPRING//DTD BEAN//EN&quot; &quot;http://www.springframework.org/dtd/spring-beans.dtd&quot;&gt;

 &lt;!--
   - Application context definition for &quot;springdemo&quot; DispatcherServlet.
   --&gt;

 &lt;beans&gt;
     &lt;bean id=&quot;addEditUserController&quot;/&gt;

     &lt;bean id=&quot;urlMapping&quot;&gt;
         &lt;property name=&quot;mappings&quot;&gt;
             &lt;props&gt;
                 &lt;prop key =&quot;/addedituser.htm&quot;&gt;addEditUserController&lt;/prop&gt;
             &lt;/props&gt;
         &lt;/property&gt;
     &lt;/bean&gt;
 &lt;/beans&gt;
</pre>
<h2>9. Decouple the view and controller</h2>
<p>Right now the controller specifies the full path of the view, which creates an unnecessary dependency between the controller and the view. Ideally we would like to map to the view using a logical name, allowing us to switch the view without having to change the controller. You can set this mapping in a properties file if you like using a ResourceBundleViewResolver and a SimpleUrlHandlerMapping class. If your mapping needs are simple it is easier to just set a prefix and a suffix on the InternalResourceViewResolver. The latter approach is the one that we will implement now, so modify the springapp-servlet.xml and include this viewResolver entry. We have elected to use a JstlView which will enable us to use JSTL.</p>
<p>Add the following to your existing &#8220;springdemo-servlet.xml&#8221;</p>
<p><strong>Code:</strong></p>
<pre class="brush: java; title: ; notranslate">
&lt;bean id=&quot;viewResolver&quot; class = &quot;org.springframework.web.servlet.view.InternalResourceViewResolver&quot;&gt;
	 &lt;property name=&quot;viewClass&quot;&gt;&lt;value&gt;org.springframework.web.servlet.view.JstlView&lt;/value&gt;&lt;/property&gt;
	 &lt;property name =&quot;prefix&quot;&gt;&lt;value&gt;/com/simpleweb/user/pages/&lt;/value&gt;&lt;/property&gt;
	 &lt;property name =&quot;suffix&quot;&gt;&lt;value&gt;.jsp&lt;/value&gt;&lt;/property&gt;
&lt;/bean&gt;
</pre>
<p><em id="__mceDel">So now I can remove the prefix and suffix from the view name in the controller.</em></p>
<h2>10. Add some classes for business logic</h2>
<p>We would like to add a little bit of business logic in form of a User class and a class that will manage all the users. In order to separate the web dependent logic from the business logic I will create separate packages for the Java source com.simpleweb.user.controller, com.simpleweb.user.bean, com.simpleweb.user.services and com.simpleweb.user.dao. The User class is implemented as a JavaBean and it has the default constructor (automatically provided if we don&#8217;t specify any constructors) and getters and setters for the instance variables userId, firstName, lastName, company and comments. I also make it Serializable to pass this class between different application layers.</p>
<p><strong>Code:</strong></p><div class="wpInsert wpInsertInPostAd wpInsertMiddle" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Middle-Med-Rect */
google_ad_slot = "7805667846";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
<pre class="brush: java; title: ; notranslate">package com.simpleweb.user.bean;

import java.io.Serializable;

public class User implements Serializable {

	/** Creates a new instance of User */
	public User() {
	}

	private Integer userId;
	private String firstName;
	private String lastName;
	private String company;
	private String comments;

	public String getFirstName() {
	return firstName;
	}

	public void setFirstName(String firstName) {
	 this.firstName = firstName;
	}

	public String getLastName() {
	 return lastName;
	}

	public void setLastName(String lastName) {
	 this.lastName = lastName;
	}

	public String getCompany() {
	 return company;
	}

	public void setCompany(String company) {
	 this.company = company;
	}

	public String getComments() {
	 return comments;
	}

	public void setComments(String comments) {
	 this.comments = comments;
	}

	public Integer getUserId() {
	 return userId;
	}

	public void setUserId(Integer userId) {
	 this.userId = userId;
	}
}
</pre>
<p>Create a &#8220;Transfer Object&#8221; as UserTO under com.simpleweb.user.bean package.</p>
<p><strong>Code:</strong></p>
<pre class="brush: java; title: ; notranslate">package com.simpleweb.user.bean;

import java.io.Serializable;

public class UserTO extends User implements Serializable {

	/** Creates a new instance of UserTO */
	public UserTO() {
	}
}
</pre>
<p>Now, I modify the above created Controller &#8220;AddEditUserController&#8221; class as shown below to hold a reference of this &#8220;UserTO&#8221; object</p>
<p><strong>Code:</strong></p>
<pre class="brush: java; title: ; notranslate">package com.simpleweb.user.controller;

import com.simpleweb.user.bean.UserTO;
import com.simpleweb.user.services.UserServiceImpl;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.SimpleFormController;

public class AddEditUserController extends SimpleFormController {

	/** Creates a new instance of AddEditUserController */
	public AddEditUserController() {
	}

	protected Object formBackingObject(HttpServletRequest request) throws ServletException {
	 UserTO userTO = new UserTO();
	 return userTO;
	}
}

</pre>
<h2>11. Creating a View</h2>
<p>Now it is time to create our view. We will use a JSP page that we decided to name user.jsp. We&#8217;ll put it in the WebPages directory under com/simpleweb/user/pages directory.</p>
<p><strong>Code:</strong></p>
<pre class="brush: java; title: ; notranslate">
&lt;%@page contentType=&quot;text/html&quot;%&gt;
 &lt;%@page pageEncoding=&quot;UTF-8&quot;%&gt;
 &lt;%@taglib uri=&quot;http://java.sun.com/jsp/jstl/core&quot; prefix=&quot;c&quot;%&gt;
 &lt;%@ taglib prefix=&quot;spring&quot; uri=&quot;http://www.springframework.org/tags&quot; %&gt;

 &lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;
 &quot;http://www.w3.org/TR/html4/loose.dtd&quot;&gt;

&lt;html&gt;
&lt;head&gt;
 &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=UTF-8&quot;&gt;
 &lt;title&gt;User Page&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;form name=&quot;userTO&quot;  method=&quot;POST&quot; action=&quot;addedituser.htm&quot;&gt;
	&lt;table style=&quot;width: 500px;&quot;  border=&quot;0&quot; align=&quot;center&quot;&gt;
		&lt;tbody&gt;
			&lt;tr&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;width: 100px;&quot; align=&quot;center&quot;&gt;&lt;H3&gt;User Registration&lt;/H3&gt;&lt;/td&gt;
			&lt;/tr&gt;
			&lt;tr&gt;
				&lt;td style=&quot;width: 100px;&quot; &gt;First Name&lt;/td&gt;
				&lt;td &gt;
					&lt;spring:bind path=&quot;userTO.firstName&quot;&gt;
						&lt;input type=&quot;text&quot; name=&quot;${status.expression}&quot;  maxlength=&quot;50&quot; style=&quot;width:128px;&quot; value=&quot;&lt;c:out value='${status.value}' escapeXml='true'/&gt;&quot; &gt;
					&lt;/spring:bind&gt;
				&lt;/td&gt;
			&lt;/tr&gt;

			&lt;tr&gt;
				&lt;td style=&quot;width: 100px;&quot; &gt;Last Name&lt;/td&gt;
				&lt;td &gt;
					&lt;spring:bind path=&quot;userTO.lastName&quot;&gt;
						&lt;input type=&quot;text&quot; name=&quot;${status.expression}&quot;  maxlength=&quot;50&quot; style=&quot;width:128px;&quot; value=&quot;&lt;c:out value='${status.value}' escapeXml='true'/&gt;&quot; &gt;
					&lt;/spring:bind&gt;
				&lt;/td&gt;
			&lt;/tr&gt;

			&lt;tr&gt;
				&lt;td style=&quot;width: 100px;&quot; &gt;Company&lt;/td&gt;
				&lt;td &gt;
					&lt;spring:bind path=&quot;userTO.company&quot;&gt;
						&lt;input type=&quot;text&quot; name=&quot;${status.expression}&quot;  maxlength=&quot;50&quot; style=&quot;width:128px;&quot; value=&quot;&lt;c:out value='${status.value}' escapeXml='true'/&gt;&quot; &gt;
					&lt;/spring:bind&gt;
				&lt;/td&gt;
			&lt;/tr&gt;

			&lt;tr&gt;
				&lt;td style=&quot;width: 100px;&quot; &gt;Comments&lt;/td&gt;
				&lt;td &gt;
					&lt;spring:bind path=&quot;userTO.comments&quot;&gt;
						&lt;textarea name=&quot;${status.expression}&quot; id=&quot;comments&quot; style=&quot;width:400px;&quot; rows=&quot;5&quot;&gt;&lt;c:out value='${status.value}' escapeXml='true'/&gt;&lt;/textarea&gt;
					&lt;/spring:bind&gt;
				&lt;/td&gt;
			&lt;/tr&gt;

			&lt;tr&gt;
				&lt;td colspan=&quot;2&quot; align=&quot;center&quot;&gt;
					&lt;input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;Submit&quot;&gt;
					&lt;input type=&quot;reset&quot; name=&quot;reset&quot; value=&quot;Reset&quot;&gt;
				&lt;/td&gt;
			&lt;/tr&gt;
		&lt;/tbody&gt;
	&lt;/table&gt;
&lt;/form&gt;
&lt;/body&gt;
 &lt;/html&gt;
</pre>
<p>This form uses a tag library named &#8220;spring&#8221; that is provided with the Spring Framework. We have to copy this file from the Spring distribution spring-framework-2.5.1/dist/spring.tld to the springdemo/WEB-INF directory. Now we must also add a &lt;taglib&gt; entry to web.xml.</p>
<p><strong>Code:</strong></p>
<pre class="brush: java; title: ; notranslate">
&lt;taglib&gt;
	&lt;taglib-uri&gt;/spring&lt;/taglib-uri&gt;
	&lt;taglib-location&gt;/WEB-INF/spring.tld&lt;/taglib-location&gt;
&lt;/taglib&gt;
</pre>
<p>We also have to declare this taglib in a page directive in the jsp file. We declare a form the normal way with a &lt;form&gt; tag and an &lt;input&gt; text field and a submit button.</p>
<p>When the user enters record information it has to be handled by the controller and the business logic will be handles by the service object and data by dao layer.</p>
<p>Create &#8220;UserServiceImpl.java&#8221; under com.simpleweb.user.services package.</p>
<p><strong>Code:</strong></p>
<pre class="brush: java; title: ; notranslate">package com.simpleweb.user.services;

public class UserServiceImpl {

	/** Creates a new instance of UserServiceImpl */
	public UserServiceImpl() {
	}

}</pre>
<p>Create &#8220;UserDAOImpl.java&#8221; under com.simpleweb.user.dao package.</p>
<p><strong>Code:</strong></p>
<pre class="brush: java; title: ; notranslate">package com.simpleweb.user.dao;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

public class UserDAOImpl extends HibernateDaoSupport {

	/** Creates a new instance of UserDAOImpl */
	public UserDAOImpl() {
	}
}</pre>
<p>Add the following code as shown below to &#8220;AddEditUserController.java&#8221;:</p>
<p><strong>Code:</strong></p>
<pre class="brush: java; title: ; notranslate">public ModelAndView onSubmit(Object command) throws Exception{
	try {
		UserTO userTO = (UserTO) command;
		userService.register(userTO);
		return new ModelAndView(getSuccessView(),&quot;userTO&quot;,userTO);
	} catch (Exception e) {
		return new ModelAndView(getSuccessView(),&quot;error&quot;,e.toString());
	}
 }

 private UserServiceImpl userService;

 public UserServiceImpl getUserService() {
	 return userService;
 }

 public void setUserService(UserServiceImpl userService) {
	 this.userService = userService;
 }</pre>
<p>&#8220;OnSubmit()&#8221; handles the fom submission by retrieving the details from the form and sent to service layer and inturn to data layer for persistence.</p>
<p>Configure &#8220;UserDAOImpl.java&#8221; and &#8220;UserServiceImpl.java&#8221; in &#8220;springdemo-servlet.xml&#8221; as shown below:</p>
<p><strong>Code:</strong></p>
<pre class="brush: java; title: ; notranslate">
&lt;bean id=&quot;userDAO&quot;&gt;
	&lt;property name=&quot;sessionFactory&quot; ref=&quot;userSessionFactory&quot; /&gt;
&lt;/bean&gt;

&lt;bean id=&quot;userService&quot;&gt;
	&lt;property name=&quot;userDAO&quot; ref=&quot;userDAO&quot; /&gt;
&lt;/bean&gt;
</pre>
<p>Add the following code as shown below to &#8220;UserServiceImpl.java&#8221;:</p>
<p><strong>Code:</strong></p>
<pre class="brush: java; title: ; notranslate">private UserDAOImpl userDAO;

public void register(UserTO userTO) {

	try {
		User user = new User();
		BeanUtils.copyProperties(userTO, user);
		userDAO.register(user);

	} catch (Exception exp) {
		hrow new RuntimeException(exp.toString());
	}
}

public UserDAOImpl getUserDAO() {
	return userDAO;
}

public void setUserDAO(UserDAOImpl userDAO) {
	this.userDAO = userDAO;
}</pre>
<p>Add the following code as shown below to &#8220;UserDAOImpl.java&#8221;:</p>
<p><strong>Code:</strong></p>
<pre class="brush: java; title: ; notranslate">public void register(User user) {
	try {
		getHibernateTemplate().save(user);
	} catch (Exception e) {
		throw new RuntimeException(e.toString());
	}
}</pre>
<h2>12. Deploying and Running the Project</h2>
<p>Whether you are using the GlassFish application server or Tomcat, the process for deploying your project is the same. If you installed GlassFish or Tomcat through the IDE download, your server is already registered in the IDE. If you need to make any changes to server settings, or would like to register a different server with the IDE, choose Tools &gt; Servers from the main menu to open the Server Manager.</p>
<p>To deploy the SpringDemo project to the server:</p>
<ul>
<li>From the Projects window, right-click the project node and choose Deploy (If you are using NetBeans 6.0 or 6.1, choose Undeploy and Deploy). The IDE compiles the project, starts the server, then deploys the project to it. You can see any output generated in the Output window. The output should complete with a BUILD SUCCESSFUL message.To check that the application has indeed been deployed to the server, open the Services window (Ctrl-5) and expand the Servers node. All servers that are registered in the IDE are listed here. For GlassFish, expand Applications &gt; Web Applications to view the application. For Tomcat, expand Web Applications to view the SpringDemo application.</li>
</ul>
<p>To run the application:</p>
<ul>
<li>In the Projects window, right-click the SpringDemo project node and choose Run. The index.jsp page opens in the IDE&#8217;s default browser.</li>
</ul>
<h2>13. Summary</h2>
<p>This article concludes, creating a Simple Spring Framework Web application in NetBeans IDE with the database hit using Hibernate.</p>
<p><strong>Note:</strong> Netbeans 6 and above has a plugin for various frameworks including Spring framework. With the plug-in, we can avoid boiler plate configuration to get it started.</p>
<div class="wpInsert wpInsertInPostAd wpInsertBelow" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* JB-Footer-LU 468x15 */
google_ad_slot = "8789107210";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>]]></content:encoded>
			<wfw:commentRss>http://www.javabeat.net/2008/11/developing-a-spring-framework-mvc-application-step-by-step-using-netbeans/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JAX-WS Web Services in NetBeans 6.1</title>
		<link>http://www.javabeat.net/2008/08/jax-ws-web-services-in-netbeans-6-1/</link>
		<comments>http://www.javabeat.net/2008/08/jax-ws-web-services-in-netbeans-6-1/#comments</comments>
		<pubDate>Tue, 05 Aug 2008 13:07:08 +0000</pubDate>
		<dc:creator>krishnas</dc:creator>
				<category><![CDATA[NetBeans]]></category>
		<category><![CDATA[Webservices]]></category>
		<category><![CDATA[JAX-WS WebServices]]></category>

		<guid isPermaLink="false">http://www.javabeat.net/?p=200</guid>
		<description><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><p>Java API for XML Web Services(JAX-WS) is an important part of latest JEE specification (Java EE 5 platform). In this article we will see how to develop JAX-WS based web services using NetBeans 6.1 IDE. This article will not provide any of the theoretical information about JAX-WS. Software used NetBeans 6.1 Java 5.0/6.0 GlassFish V2 [...]</p>]]></description>
				<content:encoded><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><div class="wpInsert wpInsertInPostAd wpInsertLeft" style="float: left; margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Rect */
google_ad_slot = "9976259118";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div><p><strong style="font-size: 13px;"><em>Java API for XML Web Services(JAX-WS)</em></strong><span style="font-size: 13px;"> is an important part of latest JEE specification (Java EE 5 platform). In this article we will see how to develop </span><strong style="font-size: 13px;"><em>JAX-WS</em></strong><span style="font-size: 13px;"> based </span><em style="font-size: 13px;">web services</em><span style="font-size: 13px;"> using </span><strong style="font-size: 13px;"><em>NetBeans 6.1</em></strong><span style="font-size: 13px;"> IDE. This article will not provide any of the theoretical information about </span><strong style="font-size: 13px;"><em>JAX-WS</em></strong><span style="font-size: 13px;">.</span></p>
<h2>Software used</h2>
<ul>
<li><strong><em>NetBeans 6.1 </em></strong></li>
<li><strong><em>Java 5.0/6.0</em></strong></li>
<li><strong><em>GlassFish V2</em></strong></li>
</ul>
<h2>Creating a Web project in NetBeans 6.1</h2>
<p>To start with first of all we will have to create a web application from the web category. Let us name the project as &#8220;MyJaxWSApplication&#8221;. To create a create a web application we will do the following.</p>
<p>1. Choose File &gt; New Project. Select Web Application from the Web category. Name the project as &#8220;MyJaxWSApplication&#8221; and click on Next.</p>
<p><a href="http://www.javabeat.net/wp-content/uploads/2008/08/1.png"><img class="aligncenter size-medium wp-image-917" title="1" alt="" src="http://www.javabeat.net/wp-content/uploads/2008/08/1-300x185.png" width="300" height="185" /></a></p>
<p>2. In Server and Settings select the server that you want to use. Here we are going to use GlassFish.</p>
<p><a href="http://www.javabeat.net/wp-content/uploads/2008/08/2.png"><img class="aligncenter size-medium wp-image-920" title="2" alt="" src="http://www.javabeat.net/wp-content/uploads/2008/08/2-300x185.png" width="300" height="185" /></a></p>
<p>3. Click Next and Finish.</p>
<p>Now its time to create <strong><em>web service</em></strong> form Java class</p>
<h2>Creating Web Service project in NetBeans 6.1</h2>
<ul>
<ul>
<li>Select the project you created and right click on the project node.</li>
<li>Choose New &gt; <strong><em>Web Service</em></strong>.</li>
</ul>
</ul>
<p><a href="http://www.javabeat.net/wp-content/uploads/2008/08/3.png"><img class="aligncenter size-medium wp-image-922" title="3" alt="" src="http://www.javabeat.net/wp-content/uploads/2008/08/3-300x158.png" width="300" height="158" /></a></p>
<ul>
<ul>
<li>A New <strong><em>Web service</em></strong> dialog window will open. Give the web service name as &#8220;Adder&#8221;, give the package name as &#8220;ws&#8221;. Make sure Create web service from scrach option is selected. Click on finish.</li>
</ul>
</ul>
<p><a href="http://www.javabeat.net/wp-content/uploads/2008/08/4.png"><img class="aligncenter size-medium wp-image-925" title="4" alt="" src="http://www.javabeat.net/wp-content/uploads/2008/08/4-300x223.png" width="300" height="223" /></a></p><div class="wpInsert wpInsertInPostAd wpInsertMiddle" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Middle-Med-Rect */
google_ad_slot = "7805667846";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
<ul>
<ul>
<li><strong><em>Web Services</em></strong> node will get created in projects window. Web Services node will contain a Adder node indicating the new <strong><em>web service</em></strong> we created just now. In the editor window area visual designer will open up as shown below.</li>
</ul>
</ul>
<p><a href="http://www.javabeat.net/wp-content/uploads/2008/08/5.png"><img class="aligncenter size-medium wp-image-927" title="5" alt="" src="http://www.javabeat.net/wp-content/uploads/2008/08/5-300x154.png" width="300" height="154" /></a></p>
<ul>
<ul>
<li>Click Add Operation in the visual designer. A dialog box appears where you can define the new operation. In the dialog box enter the name of the service as &#8220;Add2Numbers&#8221; set the return type to &#8220;int&#8221;, then add two parameters. name the parameters as &#8220;number1&#8243; and &#8220;number2&#8243; select the type of both the parameters as &#8220;int&#8221;. Then click on OK</li>
</ul>
</ul>
<p><a href="http://www.javabeat.net/wp-content/uploads/2008/08/6.png"><img class="aligncenter size-medium wp-image-929" title="6" alt="" src="http://www.javabeat.net/wp-content/uploads/2008/08/6-300x233.png" width="300" height="233" /></a></p>
<ul>
<ul>
<li>The designer now displays the following:</li>
</ul>
</ul>
<p><a href="http://www.javabeat.net/wp-content/uploads/2008/08/7.png"><img class="aligncenter size-medium wp-image-931" title="7" alt="" src="http://www.javabeat.net/wp-content/uploads/2008/08/7-300x202.png" width="300" height="202" /></a></p>
<ul>
<ul>
<li>Now see the source genarated by the IDE by clicking on source tab in the visual designer. The IDE will generate the following source for you.</li>
</ul>
</ul>
<pre class="brush: java; title: ; notranslate">
package ws;

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;

/**
*
* @author Sri hari
*/
@WebService()
public class Adder {

/**
 * Web service operation
 */
@WebMethod(operationName = &quot;Add2Numbers&quot;)
public int Add2Numbers(@WebParam(name = &quot;number1&quot;)
int number1, @WebParam(name = &quot;number2&quot;)
int number2) {
	//TODO write your implementation code here:
	return 0;
}

}</pre>
<ul>
<ul>
<li>Now change the Add2Numbers method like the following, So that our operation will simply add two numbers and return the result.</li>
</ul>
</ul>
<pre class="brush: java; title: ; notranslate">
/**
 * Web service operation
 */
@WebMethod(operationName = &quot;Add2Numbers&quot;)
public int Add2Numbers(@WebParam(name = &quot;number1&quot;)
int number1, @WebParam(name = &quot;number2&quot;)
int number2) {
	return number1 + number2;
}</pre>
<ul>
<li>Now we successfully developed a web service wich will add two numbers.</li>
</ul>
<h2>Web Service Deployment in NetBeans 6.1</h2>
<p>Now we will deploy the web service like below:</p>
<ul>
<li>Right click the project node and select Undeploy and Deploy.</li>
<li>Once you do that IDE will start the server (GlassFish) and deploys the application to the server.</li>
</ul>
<h2>Web Service Testing in NetBeans 6.1</h2>
<p>Now its time to test the web service.</p>
<p>In the IDE&#8217;s Projects tab, expand the <strong><em>Web Services</em></strong> node of the project. Right-click the services node, and choose Test <strong><em>Web Service</em></strong>. (Applicable only when deployed using <strong><em>GlassFish</em></strong>). AdderService <strong><em>Web Service</em></strong> Tester page shown below will open in the browser.</p>
<p>Enter the integer values in the textbox of the test page and click on add2Numbers button. This will lead to the result page as shown below.</p>
<p><a href="http://www.javabeat.net/wp-content/uploads/2008/08/8.png"><img class="aligncenter size-medium wp-image-933" title="8" alt="" src="http://www.javabeat.net/wp-content/uploads/2008/08/8-300x108.png" width="300" height="108" /></a></p>
<h2>Summary</h2>
<p>In this article you have learnt how to develop a <strong><em>web service</em></strong> using <strong><em>Netbeans 6.1</em></strong> and deploy the service in <strong><em>GlassFish</em></strong> application server. This article doesnot cover the creation of stubs using <strong>Netbeans 6.1</strong> IDE. There are many ways to create stubs to test the web service. So keep learning. This is not the end, Still miles to go.</p>
<div class="wpInsert wpInsertInPostAd wpInsertBelow" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* JB-Footer-LU 468x15 */
google_ad_slot = "8789107210";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>]]></content:encoded>
			<wfw:commentRss>http://www.javabeat.net/2008/08/jax-ws-web-services-in-netbeans-6-1/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>JPA and NetBeans</title>
		<link>http://www.javabeat.net/2008/07/jpa-in-netbeans-6-1/</link>
		<comments>http://www.javabeat.net/2008/07/jpa-in-netbeans-6-1/#comments</comments>
		<pubDate>Mon, 28 Jul 2008 13:04:04 +0000</pubDate>
		<dc:creator>krishnas</dc:creator>
				<category><![CDATA[JPA]]></category>
		<category><![CDATA[NetBeans]]></category>

		<guid isPermaLink="false">http://www.javabeat.net/?p=197</guid>
		<description><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><p>In this article we will see how to use Java Persistence API (JPA) in NetBeans 6.1 with in a Java application. The JPA was first introduced as part of the Java EE 5 platform. This article will not provide any of the theoretical information about JPA. Software used NetBeans IDE 6.1 JDK version 5.0/6.0 MySql [...]</p>]]></description>
				<content:encoded><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><div class="wpInsert wpInsertInPostAd wpInsertLeft" style="float: left; margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Rect */
google_ad_slot = "9976259118";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div><p><span style="font-size: 13px;">In this article we will see how to use </span><b style="font-size: 13px;"><i>Java Persistence API (JPA)</i></b><span style="font-size: 13px;"> in </span><b style="font-size: 13px;"><i>NetBeans 6.1</i></b><span style="font-size: 13px;"> with in a Java application. The </span><b style="font-size: 13px;"><i>JPA</i></b><span style="font-size: 13px;"> was first introduced as part of the Java EE 5 platform. This article will not provide any of the theoretical information about </span><b style="font-size: 13px;"><i>JPA</i></b><span style="font-size: 13px;">.</span></p>
<h2>Software used</h2>
<ul>
<li><b><i>NetBeans IDE 6.1</i></b></li>
<li><b><i>JDK version 5.0/6.0</i></b></li>
<li><b><i>MySql 5.0</i></b></li>
</ul>
<h2>Creating a database in MySql 5.0</h2>
<p>To start with first of all we will have to create a database in <b><i>MySql</i></b>. Let us name the database as “jpaDB”. To create a database we will execute the following in the mysql command line prompt.</p>
<pre class="brush: java; title: ; notranslate">
CREATE DATABASE jpaDB;

GRANT ALL ON jpaDB.* TO jpaDB@&quot;%&quot; IDENTIFIED BY &quot;jpaDB&quot;;
GRANT ALL ON jpaDB.* TO jpaDB@&quot;localhost&quot; IDENTIFIED BY &quot;jpaDB&quot;;

USE jpaDB;       </pre>
<p style="text-align: center;">
<a href="http://www.javabeat.net/wp-content/uploads/2008/07/jpa-1.png"><img class="aligncenter  wp-image-6743" alt="jpa-1" src="http://www.javabeat.net/wp-content/uploads/2008/07/jpa-1.png" width="474" height="211" /></a></p>
<h2>Set up a connection to a MySQL database from NetBeans IDE 6.1</h2>
<p><b><i>NetBeans IDE 6.1</i></b> comes with support for the MySQL database. To set up MySql properly in <b><i>Netbeans IDE 6.1</i></b> follow the steps below.</p>
<ul>
<ul>
<li>1. In Services window expand Databases node. See the screen shot below.</li>
</ul>
</ul>
<p><a href="http://www.javabeat.net/wp-content/uploads/2008/07/jpa-2.png"><img class="aligncenter size-full wp-image-6744" alt="jpa-2" src="http://www.javabeat.net/wp-content/uploads/2008/07/jpa-2.png" width="402" height="231" /></a></p>
<ul>
<ul>
<li>2. Right click on <b><i>MySQL</i></b> server node. <b><i>MySQL</i></b> Server Properties dialog window opens.</li>
</ul>
</ul>
<p style="text-align: center;"><a href="http://www.javabeat.net/wp-content/uploads/2008/07/jpa-3.png"><img class="aligncenter  wp-image-6745" alt="jpa-3" src="http://www.javabeat.net/wp-content/uploads/2008/07/jpa-3.png" width="456" height="269" /></a></p>
<ul>
<ul>
<li>3. Already host name, port number and admin user name will be pre populated in the dialog. If not then fill in properties and click on ok.</li>
</ul>
</ul>
<p><i>Note: Before you can connect to a <b><i>MySQL</i></b> Database Server, you must first ensure that the <b><i>MySQL Database Server</i></b> is running on your machine. The <b><i>MySQL</i></b> Server node in the Service indicates whether the MySQL Database Server is connected, as shown in the following image.</i></p>
<ul>
<ul>
<li>4. After starting the Database Server on your machine, start the MySQL Database Server in the IDE by right-clicking the MySQL Server node and choosing Start.</li>
<li>5. Now expand the <b><i>MySQL</i></b> server node. We can see the database which we created using command prompt. (We also can create the database using netbeans itself. Since we have created the database already we don’t cover those steps in this artical).</li>
</ul>
</ul>
<p><a href="http://www.javabeat.net/wp-content/uploads/2008/07/jpa-4.png"><img class="aligncenter size-full wp-image-6746" alt="jpa-4" src="http://www.javabeat.net/wp-content/uploads/2008/07/jpa-4.png" width="400" height="255" /></a></p>
<ul>
<ul>
<li>6. Now we will connect the database as shown below in the figure. Enter the password for the user if there is one, then click OK to create the new database connection. Click OK again if no schema is required.</li>
</ul>
</ul>
<p style="text-align: center;"><a href="http://www.javabeat.net/wp-content/uploads/2008/07/jpa-5.png"><img class="aligncenter  wp-image-6747" alt="jpa-5" src="http://www.javabeat.net/wp-content/uploads/2008/07/jpa-5.png" width="421" height="288" /></a></p>
<ul>
<li>7. we can see the database appearing in the services window.</li>
</ul>
<h2>Creating Table in MySql 5.0</h2>
<p>Now we will create a table and name it as &#8220;USER&#8221;.<br />
In the services window expand the database (See the figure below)<br />
we created in the previous section. Right click on the table node.<br />
select create table.</p>
<p><a href="http://www.javabeat.net/wp-content/uploads/2008/07/jpa-6.png"><img class="aligncenter size-full wp-image-6748" alt="jpa-6" src="http://www.javabeat.net/wp-content/uploads/2008/07/jpa-6.png" width="402" height="241" /></a></p>
<p>Invoking on create table node will result in create table dialog.<br />
This window will halp us in creating the table with ease as shown in the below diagram.</p>
<p style="text-align: center;"><a href="http://www.javabeat.net/wp-content/uploads/2008/07/jpa-7.png"><img class="aligncenter  wp-image-6749" alt="jpa-7" src="http://www.javabeat.net/wp-content/uploads/2008/07/jpa-7.png" width="465" height="239" /></a><br />
<a href="http://www.javabeat.net/wp-content/uploads/2008/07/jpa-8.png"><img class="aligncenter size-full wp-image-6750" alt="jpa-8" src="http://www.javabeat.net/wp-content/uploads/2008/07/jpa-8.png" width="354" height="210" /></a></p>
<h2>Create a JavaApplication in NetBeans 6.1</h2>
<p>Now create a java application in <b><i>NetBeans IDE</i></b>. Let us name the application as MyJPAApplication.</p>
<p>Next step is to generate a Entity class which will map to User table.</p>
<p style="text-align: center;"><a href="http://www.javabeat.net/wp-content/uploads/2008/07/jpa-9.png"><img class="aligncenter  wp-image-6751" alt="jpa-9" src="http://www.javabeat.net/wp-content/uploads/2008/07/jpa-9.png" width="366" height="251" /></a></p>
<p>Select the database created as shown in the below figure.</p><div class="wpInsert wpInsertInPostAd wpInsertMiddle" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Middle-Med-Rect */
google_ad_slot = "7805667846";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
<p style="text-align: center;"><a href="http://www.javabeat.net/wp-content/uploads/2008/07/jpa-10.png"><img class="aligncenter  wp-image-6752" alt="jpa-10" src="http://www.javabeat.net/wp-content/uploads/2008/07/jpa-10.png" width="473" height="312" /></a></p>
<p>You can now see the tables available in the database will be listed in the Available Tables menu.<br />
Select the user table and click on Add to move it to Selected tables menu.</p>
<p style="text-align: center;"><a href="http://www.javabeat.net/wp-content/uploads/2008/07/jpa-11.png"><img class="aligncenter  wp-image-6753" alt="jpa-11" src="http://www.javabeat.net/wp-content/uploads/2008/07/jpa-11.png" width="473" height="312" /></a></p>
<p>Change the class name in the next wizard as UserGenEntity. Then click on Create Persistence Unit button.</p>
<p style="text-align: center;"><a href="http://www.javabeat.net/wp-content/uploads/2008/07/jpa-12.png"><img class="aligncenter  wp-image-6754" alt="jpa-12" src="http://www.javabeat.net/wp-content/uploads/2008/07/jpa-12.png" width="473" height="312" /></a></p>
<p>In the create persistant unit wizard, change the Table Generation Strategy option to Create.</p>
<p><a href="http://www.javabeat.net/wp-content/uploads/2008/07/jpa-13.png"><img class="aligncenter size-full wp-image-6755" alt="jpa-13" src="http://www.javabeat.net/wp-content/uploads/2008/07/jpa-13.png" width="512" height="251" /></a></p>
<p>Now in the final wizard there will not be any information or warning messages shown. Then click on finish.</p>
<p style="text-align: center;"><a href="http://www.javabeat.net/wp-content/uploads/2008/07/jpa-14.png"><img class="aligncenter  wp-image-6756" alt="jpa-14" src="http://www.javabeat.net/wp-content/uploads/2008/07/jpa-14.png" width="473" height="312" /></a></p>
<p>Once you clicked on finish. you can see the class named UserGenEntity getting generated in the Projects window of the IDE. You can also see the TopLink libraries getting added to the Libraries node as shown below.</p>
<p><a href="http://www.javabeat.net/wp-content/uploads/2008/07/jpa-15.png"><img class="aligncenter size-full wp-image-6757" alt="jpa-15" src="http://www.javabeat.net/wp-content/uploads/2008/07/jpa-15.png" width="381" height="426" /></a></p>
<p>Next step is to implement a Manager Class which handles the <b><i>JPA persistence-context</i></b>. That means this class is responsible to provide <b><i>CRUD</i></b> functionality for your instances and to communicate with your database.<br />
We will name this manager class as UserManager. UserManager code is given in the below listing.</p>
<h2>Sample JPA Application</h2>
<pre class="brush: java; title: ; notranslate">
package com.myJpa;

import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Query;

/**
 *
 * @author Sri hari
 */
public class UserManager {

    private EntityManager em;

    public UserManager(EntityManagerFactory emf) {
        em = emf.createEntityManager();
    }

    public void createUser(UserGenEntity user) {
        em.getTransaction().begin();
        em.persist(user);
        em.getTransaction().commit();
    }

    public UserGenEntity searchById(Integer id) {
        return em.find(UserGenEntity.class, id);
    }

    public void updateUser(UserGenEntity user) {
        em.getTransaction().begin();
        em.merge(user);
        em.getTransaction().commit();
    }

    public void removeUser(UserGenEntity user) {
        em.getTransaction().begin();
        em.remove(user);
        em.getTransaction().commit();
    }

    public List getAll() {
        Query query = em.createQuery(&quot;select a from UserGenEntity a&quot;);
        List list = query.getResultList();
        return list;
    }

    public void close() {
        em.close();
    }
}
        </pre>
<p>Code List has the following methods:</p>
<ul>
<li>createUser &#8212; this method is used to create a user in the database.</li>
<li>searchById &#8212; this method is used to search a user by ID.</li>
<li>updateUser &#8212; this method is used to update a user from the table.</li>
<li>removeUser &#8212; this method is used to remove a user from the table.</li>
<li>getAll &#8212; this method is used to get all the users from the table.</li>
</ul>
<h2>Testing the JPA code</h2>
<p>Now its time to test the code and see how it works. Before that don&#8217;t forget to add the driver for MySQL to your project library.</p>
<p><a href="http://www.javabeat.net/wp-content/uploads/2008/07/jpa-16.png"><img class="aligncenter size-full wp-image-6758" alt="jpa-16" src="http://www.javabeat.net/wp-content/uploads/2008/07/jpa-16.png" width="372" height="401" /></a></p>
<p>Testing can be done using JUnit or a simple Java class with main method. Here we will create a simple java class with main method to test our code.</p>
<pre class="brush: java; title: ; notranslate">
package com.myJpa;

import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

/**
 *
 * @author Sri hari
 */
public class TestJPA {

    private UserManager um;
    private EntityManager em;
    private EntityManagerFactory emf;
    private static final UserGenEntity user1 = new UserGenEntity(1, &quot;Muthu&quot;, &quot;Dhanagopal&quot;);
    private static final UserGenEntity user2 = new UserGenEntity(2, &quot;Sri&quot;, &quot;Hari&quot;);

    protected void setUp() throws Exception {
        emf = Persistence.createEntityManagerFactory(&quot;MyJPAApplicationPU&quot;);
        em = emf.createEntityManager();
        um = new UserManager(emf);
    }

    protected void close() throws Exception {
        um.close();
        em.close();
        emf.close();
    }

    public void test() {
        um.createUser(user1);
        UserGenEntity user = um.searchById(1);
        System.out.println(&quot;After creation of user in table&quot;);
        System.out.println(&quot;Firstname: &quot; + user.getFirstname());
        System.out.println(&quot;Lastname: &quot; + user.getLastname());

        user.setFirstname(&quot;Muthukumar&quot;);
        um.updateUser(user);

        user = um.searchById(1);
        System.out.println(&quot;After update.&quot;);
        System.out.println(&quot;Firstname: &quot; + user.getFirstname());
        System.out.println(&quot;Lastname: &quot; + user.getLastname());

        System.out.println(&quot;Adding one more record&quot;);
        um.createUser(user2);

        List list = um.getAll();
        System.out.println(&quot;Number of users: &quot; + list.size());
    }

    public static void main(String args[]) {
        System.out.println(&quot;Inside TestJPA main&quot;);
        TestJPA testJPA = new TestJPA();
        try {
            testJPA.setUp();
            testJPA.test();
            testJPA.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        System.out.println(&quot;End of TestJPA main&quot;);
    }
}
        </pre>
<h2>Result</h2>
<pre class="brush: java; title: ; notranslate">
init:
deps-jar:
compile-single:
run-single:
Inside TestJPA main
[TopLink Info]: 2008.07.27 09:42:50.500--ServerSession(16602326)--TopLink, version: Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))
[TopLink Info]: 2008.07.27 09:42:52.253--ServerSession(16602326)--file:/C:/NetBeansProjects/MyJPAApplication/build/classes/-MyJPAApplicationPU login successful
[TopLink Warning]: 2008.07.27 09:42:52.410--ServerSession(16602326)--Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.DatabaseException
Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'user' already exists
Error Code: 1050
Call: CREATE TABLE user (ID INTEGER NOT NULL, FIRSTNAME VARCHAR(255), LASTNAME VARCHAR(255), PRIMARY KEY (ID))
Query: DataModifyQuery()
After creation of user in table
Firstname: Muthu
Lastname: Dhanagopal
After update.
Firstname: Muthukumar
Lastname: Dhanagopal
Adding one more record
Number of users: 2
[TopLink Info]: 2008.07.27 09:42:52.864--ServerSession(16602326)--file:/C:/NetBeansProjects/MyJPAApplication/build/classes/-MyJPAApplicationPU logout successful
End of TestJPA main
BUILD SUCCESSFUL (total time: 7 seconds)</pre>
<h2>Summary</h2>
<p>In this article you have learnt how to develop a JPA persistence layer using Java Application. This is not the end, Still miles to go.</p>
<div class="wpInsert wpInsertInPostAd wpInsertBelow" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* JB-Footer-LU 468x15 */
google_ad_slot = "8789107210";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>]]></content:encoded>
			<wfw:commentRss>http://www.javabeat.net/2008/07/jpa-in-netbeans-6-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create EJB 3.0 project in NetBeans 6.1</title>
		<link>http://www.javabeat.net/2008/07/create-ejb-3-0-project-in-netbeans-6-1/</link>
		<comments>http://www.javabeat.net/2008/07/create-ejb-3-0-project-in-netbeans-6-1/#comments</comments>
		<pubDate>Fri, 04 Jul 2008 10:17:47 +0000</pubDate>
		<dc:creator>JavaBeat</dc:creator>
				<category><![CDATA[EJB]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[NetBeans]]></category>

		<guid isPermaLink="false">http://www.javabeat.net/examples/?p=112</guid>
		<description><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><p>Introduction This article explains how to create EJB 3.0 project using NetBeans IDE 6.1. This article will not explain the details of EJB 3.0 but will give basic knowledge on how to create simple EJB 3.0 project using NetBeans 6.1 IDE. Creating Project in NetBeans 6.1 Step 1 : Create Project Show Full Image Step [...]</p>]]></description>
				<content:encoded><![CDATA[<p>Connect to us ( <a href="https://twitter.com/javabeat">@twitter</a> | <a href="https://www.facebook.com/javabeat.net">@facebook )</p><div class="wpInsert wpInsertInPostAd wpInsertLeft" style="float: left; margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Rect */
google_ad_slot = "9976259118";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div><h2>Introduction</h2>
<p>This article explains how to create EJB 3.0 project using NetBeans IDE 6.1. This article will not explain the<br />
details of EJB 3.0 but will give basic knowledge on how to create simple EJB 3.0 project using NetBeans 6.1 IDE.</p>
<h2>Creating Project in NetBeans 6.1</h2>
<h3>Step 1 : Create Project</h3>
<p><img src="images/2008/07/1.gif" alt="" width="500" /></p>
<p><a href="articleImageOpen('images/2008/07/1.gif');">Show Full Image</a></p>
<h3>Step 2 : Select Enterprice Project</h3>
<p><img src="images/2008/07/2.gif" alt="" width="500" /></p>
<p><a href="articleImageOpen('images/2008/07/2.gif');">Show Full Image</a></p>
<h3>Step 3 : Specify Project Name</h3>
<p><img src="images/2008/07/3.gif" alt="" width="500" /></p><div class="wpInsert wpInsertInPostAd wpInsertMiddle" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* Article-Middle-Med-Rect */
google_ad_slot = "7805667846";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
<p><a href="articleImageOpen('images/2008/07/3.gif');">Show Full Image</a></p>
<h3>Step 4 : Select server and create EJB,WEb modules</h3>
<p><img src="images/2008/07/4.gif" alt="" width="500" /></p>
<p><a href="articleImageOpen('images/2008/07/4.gif');">Show Full Image</a></p>
<h3>Step 5 : Project is created</h3>
<p><img src="images/2008/07/5.gif" alt="" width="500" /></p>
<p><a href="articleImageOpen('images/2008/07/5.gif');">Show Full Image</a></p>
<div class="wpInsert wpInsertInPostAd wpInsertBelow" style="margin: 5px; padding: 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-1490953723360528";
/* JB-Footer-LU 468x15 */
google_ad_slot = "8789107210";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>]]></content:encoded>
			<wfw:commentRss>http://www.javabeat.net/2008/07/create-ejb-3-0-project-in-netbeans-6-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
