<?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>Paulo Canedo &#187; JSF</title>
	<atom:link href="http://www.paulocanedo.com.br/tag/jsf/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.paulocanedo.com.br</link>
	<description>Blog pessoal - TI, Java, NetBeans e Programação em geral</description>
	<lastBuildDate>Wed, 26 May 2010 16:30:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Creating a CRUD with JSF and Ajax using NetBeans 6.5 Beta</title>
		<link>http://www.paulocanedo.com.br/2008/09/05/creating-a-crud-with-jsf-and-ajax-using-netbeans-65-beta/</link>
		<comments>http://www.paulocanedo.com.br/2008/09/05/creating-a-crud-with-jsf-and-ajax-using-netbeans-65-beta/#comments</comments>
		<pubDate>Fri, 05 Sep 2008 03:29:24 +0000</pubDate>
		<dc:creator>Paulo Canedo</dc:creator>
				<category><![CDATA[English]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[NetBeans English]]></category>
		<category><![CDATA[CRUD]]></category>
		<category><![CDATA[derby]]></category>
		<category><![CDATA[JPA]]></category>
		<category><![CDATA[JSF]]></category>
		<category><![CDATA[NetBeans 6.5]]></category>
		<category><![CDATA[NetBeans pt_BR]]></category>
		<category><![CDATA[Topink]]></category>

		<guid isPermaLink="false">http://localhost/wordpress/?p=32</guid>
		<description><![CDATA[Pre-requisite: NetBeans 6.5 Beta, or most recent version with the &#8220;Java Web and EE&#8221; or &#8220;All&#8221; pack. The glassfish version 2 or 3 must be installed. On this tutorial we will see how to create a CRUD application (Create, Read, Update and Delete) using the NetBeans IDE 6.5 Beta. The main features demonstred in this [...]]]></description>
			<content:encoded><![CDATA[<p>Pre-requisite: NetBeans 6.5 Beta, or most recent version with the &#8220;Java Web and EE&#8221; or &#8220;All&#8221; pack. The glassfish version 2 or 3 must be installed.</p>
<p>On this tutorial we will see how to create a CRUD application (Create, Read, Update and Delete) using the NetBeans IDE 6.5 Beta. The main features demonstred in this tutorial are: work with a web project using glassfish and Java Server Faces; create a Persistence Unit; create an Entity Class; automaticaly generate jsf pages from an Entity Class.</p>
<p>Let&#8217;s start, first of all go to the Services Tab (Ctrl+5), open Databases node and follow the steps bellow:</p>
<ol>
<li>Click with right button in Java DB on Start Server (Picture 1)</li>
<li>Click again with right button in Java DB and now click on Create Database&#8230;</li>
<li>In the next window fill all fields according to Picture 2</li>
</ol>
<div class="wp-caption alignnone" style="width: 301px"><img style="border: 0pt none;" title="Picture 1 - Starting Java DB server" src="http://www.paulocanedo.com.br/images/nb65beta-crud/nb65beta_start_javadb.gif" border="0" alt="" width="291" height="399" /><p class="wp-caption-text">Picture 1 - Starting Java DB server</p></div>
<div class="wp-caption alignnone" style="width: 554px"><img style="border: 0pt none;" title="Picture 2 - Creating a new database in Java DB" src="http://www.paulocanedo.com.br/images/nb65beta-crud/nb65beta_create_db.gif" border="0" alt="" width="544" height="206" /><p class="wp-caption-text">Picture 2 - Creating a new database in Java DB</p></div>
<p>After the database creation, so let&#8217;s go to our NetBeans project:</p>
<ol>
<li>Create a new web project (File-&gt;New project) in Java Web category, then choose the option Web Application (Picture 3)</li>
<li>in the next window fill all the fields according with Picture 4</li>
<li>Define the web server (recommended glassfish v2 or v3) and the context path (Picture 5)</li>
<li>Click next and select the framework: JavaServer Faces (Picture 6)</li>
</ol>
<div class="wp-caption alignnone" style="width: 729px"><img style="border: 0pt none;" title="Picture 3 - Creating a new web project" src="http://www.paulocanedo.com.br/images/nb65beta-crud/nb65beta_new_project_web.gif" border="0" alt="" width="719" height="468" /><p class="wp-caption-text">Picture 3 - Creating a new web project</p></div>
<div class="wp-caption alignnone" style="width: 731px"><img style="border: 0pt none;" title="Picture 4 - Defining project name and project local" src="http://www.paulocanedo.com.br/images/nb65beta-crud/nb65beta_name_and_location.gif" border="0" alt="" width="721" height="470" /><p class="wp-caption-text">Picture 4 - Defining project name and project local</p></div>
<div class="wp-caption alignnone" style="width: 731px"><img style="border: 0pt none;" title="Picture 5 - Suggestions to choose the web server and your configurations" src="http://www.paulocanedo.com.br/images/nb65beta-crud/nb65beta_server_and_settings.gif" border="0" alt="" width="721" height="470" /><p class="wp-caption-text">Picture 5 - Suggestions to choose the web server and your configurations</p></div>
<div class="wp-caption alignnone" style="width: 701px"><img style="border: 0pt none;" title="Picture 6 - Adding the framework Java Server Faces to your project" src="http://www.paulocanedo.com.br/images/nb65beta-crud/nb65beta_frameworks.gif" border="0" alt="" width="691" height="387" /><p class="wp-caption-text">Picture 6 - Adding the framework Java Server Faces to your project</p></div>
<p>Now your project is created, to test if your project is working correctly with the web server, click with rigth button in project tab (Ctrl+1) and click Run.<br />
Well, the next step is create a new Persistence Unit, an Entity Class, the JPA (Java Persistence API) controllers:</p>
<ol>
<li>Click in File-&gt;New File, select the Persistence category, so choose the option Persistence Unit and click next</li>
<li>Click at the combobox arrow and select New Data Source &#8230;</li>
<li>Type a name to jndi (eg: dsExemploJsf or dsSampleJsf), at Database Connection select the connection with the database that you created in the begin of this tutorial, click ok</li>
<li>In Provider and Database window fill all fields according with Picture 8 and then click finish</li>
<li>Again click File-&gt;New File, in Persistence category, select Entity Class and click next</li>
<li>In the next window fill all fields according with Picture 9 and click finish</li>
</ol>
<div class="wp-caption alignnone" style="width: 731px"><img style="border: 0pt none;" title="Picture 7 - New Persistence Unit" src="http://www.paulocanedo.com.br/images/nb65beta-crud/nb65beta_new_persistence_unit.gif" border="0" alt="" width="721" height="470" /><p class="wp-caption-text">Picture 7 - New Persistence Unit</p></div>
<p><em></em></p>
<div class="wp-caption alignnone" style="width: 786px"><img style="border: 0pt none;" title="Picture 8 - Provider and Database" src="http://www.paulocanedo.com.br/images/nb65beta-crud/nb65beta_provider_and_database.gif" border="0" alt="" width="776" height="470" /><p class="wp-caption-text">Picture 8 - Provider and Database</p></div>
<p><em></em></p>
<div class="wp-caption alignnone" style="width: 731px"><img style="border: 0pt none;" title="Picture 9 - Creating a new Entity class" src="http://www.paulocanedo.com.br/images/nb65beta-crud/nb65beta_new_entity_class.gif" border="0" alt="" width="721" height="470" /><p class="wp-caption-text">Picture 9 - Creating a new Entity class</p></div>
<p>After generating the Livro.java (or Book.java) NetBeans shold automatically open it, let&#8217;s edit this file that way:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>0
1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">@Id
@GeneratedValue<span style="color: #009900;">&#40;</span>strategy <span style="color: #339933;">=</span> GenerationType.<span style="color: #006633;">AUTO</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">Long</span> id<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> isbn<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> title<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> author<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">Integer</span> numberOfPages<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">Double</span> weight<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">Long</span> getId<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">return</span> id<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Then put the cursor position at line imediatlly after:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>0
1
2
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setId<span style="color: #009900;">&#40;</span><span style="color: #003399;">Long</span> id<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">id</span> <span style="color: #339933;">=</span> id<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>then press simultaneously: alt+insert, select Getter and Setter&#8230; then select all fields and click ok.</p>
<p>After creation of the Entity Class, let&#8217;s go to more one netbeans wizard wich will generate all necessary code to work with JPA and JSF files, so click in File-&gt;New File, in Persistence category, choose the option: JSF Pages From Entity Classes, and follow steps:</p>
<ol>
<li>Choose Livro&#8217;s (or Book&#8217;s) Entity Classe (Picture 10)</li>
<li>Choose the packages where will be generated the files for JPA and JSF manipulation (Picture 11), here note that the option &#8220;Ajax-enable generated pages&#8221; is displayed, this option allows generated code to use Ajax technology, remember that this is only available from version 6.5 beta or the most recent version.</li>
</ol>
<div class="wp-caption alignnone" style="width: 801px"><img style="border: 0pt none;" title="Picture 10 - Select Entity Classes" src="http://www.paulocanedo.com.br/images/nb65beta-crud/nb65beta_new_jsf_from_entity_class.gif" border="0" alt="" width="791" height="515" /><p class="wp-caption-text">Picture 10 - Select Entity Classes</p></div>
<div class="wp-caption alignnone" style="width: 801px"><img style="border: 0pt none;" title="Picture 11 - Select packages to JPA and JSF" src="http://www.paulocanedo.com.br/images/nb65beta-crud/nb65beta_new_jsf_from_entity_class2.gif" border="0" alt="" width="791" height="515" /><p class="wp-caption-text">Picture 11 - Select packages to JPA and JSF</p></div>
<p>Now we have all necessary code, to test our project result, build the project (type Shift+11, clean and build project) click with right button in project name by Projects tab (Ctrl+1), after click &#8220;Undeploy and Deploy&#8221; to remove the web project of server (if there is) and deploy version that you already finished building (Picture 12).</p>
<p>If there are no errors message at Output tab (Ctrl+4), you can run the project using F6 key and see your CRUD working wonderful. (Pictures 13 and 14)</p>
<div class="wp-caption alignnone" style="width: 308px"><img style="border: 0pt none;" title="Picture 12 - Project Undeploy and Deploy" src="http://www.paulocanedo.com.br/images/nb65beta-crud/nb65beta_undeploy_deploy.gif" border="0" alt="" width="298" height="466" /><p class="wp-caption-text">Picture 12 - Project Undeploy and Deploy</p></div>
<div class="wp-caption alignnone" style="width: 683px"><img style="border: 0pt none;" title="Picture 13 - CRUD finished, inserting a new registry" src="http://www.paulocanedo.com.br/images/nb65beta-crud/nb65beta_new_livro.gif" border="0" alt="" width="673" height="521" /><p class="wp-caption-text">Picture 13 - CRUD finished, inserting a new registry</p></div>
<div class="wp-caption alignnone" style="width: 683px"><img style="border: 0pt none;" title="Picture 14 - CRUD finished, registries overview after insert confirmation" src="http://www.paulocanedo.com.br/images/nb65beta-crud/nb65beta_livro_created.gif" border="0" alt="" width="673" height="521" /><p class="wp-caption-text">Picture 14 - CRUD finished, registries overview after insert confirmation</p></div>
<p><strong>Conclusion: </strong> It&#8217;s not recommendable the use of this wizard to generate CRUD by NetBeans for people who don&#8217;t have experience with Java Server Faces to do their production work day by day. The importance of this NetBeans feature for this public is that they have access to development step by step about the creation of a CRUD using these wonderful Java frameworks. The learning on this activity is quite satisfactory. For those who already have experience just a look at the creation process and results will teach what to do. For those who want something practical, without much detail, and that is quite fast to do, this guide is quite helpful.</p>
<p>Revised by Ana Lyvia Liveira.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.paulocanedo.com.br/2008/09/05/creating-a-crud-with-jsf-and-ajax-using-netbeans-65-beta/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Criando um CRUD em JSF e Ajax com o NetBeans 6.5 Beta</title>
		<link>http://www.paulocanedo.com.br/2008/09/02/criando-um-crud-em-jsf-e-ajax-com-o-netbeans-65-beta/</link>
		<comments>http://www.paulocanedo.com.br/2008/09/02/criando-um-crud-em-jsf-e-ajax-com-o-netbeans-65-beta/#comments</comments>
		<pubDate>Tue, 02 Sep 2008 03:34:41 +0000</pubDate>
		<dc:creator>Paulo Canedo</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[NetBeans pt_BR]]></category>
		<category><![CDATA[CRUD]]></category>
		<category><![CDATA[derby]]></category>
		<category><![CDATA[JPA]]></category>
		<category><![CDATA[JSF]]></category>
		<category><![CDATA[NetBeans 6.5]]></category>
		<category><![CDATA[Topink]]></category>

		<guid isPermaLink="false">http://localhost/wordpress/?p=28</guid>
		<description><![CDATA[Pré-requisito: NetBeans 6.5 Beta, ou versão mais recente com o pacote Java Web and EE ou completo. O glassfish versão 2 ou 3 deve estar instalado. Neste tutorial podemos ver como criar uma aplicação CRUD (Create=Criar, Read=Ler, Update=Atualizar, Delete=Excluir) utilizando o NetBeans IDE 6.5 Beta. As principais características demonstrada neste tutorial são: trabalhar com um [...]]]></description>
			<content:encoded><![CDATA[<p>Pré-requisito: NetBeans 6.5 Beta, ou versão mais recente com o pacote Java Web and EE ou completo. O glassfish versão 2 ou 3 deve estar instalado.</p>
<p>Neste tutorial podemos ver como criar uma aplicação CRUD (Create=Criar, Read=Ler, Update=Atualizar, Delete=Excluir) utilizando o NetBeans IDE 6.5 Beta. As principais características demonstrada neste tutorial são: trabalhar com um projeto web utilizando glassfish e java server faces; criar um Persistence Unit (Unidade de Persistência); criar um Entity class (Entidade de classe); gerar automaticamente páginas jsf a partir do entity class.</p>
<p>Vamos começar, primeiramente vá até a aba Services (Ctrl+5), abra o nó Databases e siga os seguintes passos:</p>
<ol>
<li>clique com o botão direito em Java DB em seguida Start Server (Figura 1)</li>
<li>clique novamente com o botão direito em Java DB agora clique em Create Database&#8230;</li>
<li>na próxima janela preenche os campos de acordo com a Figura 2</li>
</ol>
<div class="wp-caption alignnone" style="width: 301px"><img style="border: 0pt none;" title="Figura 1 - Iniciando o servidor Java DB" src="http://www.paulocanedo.com.br/images/nb65beta-crud/nb65beta_start_javadb.gif" border="0" alt="" width="291" height="399" /><p class="wp-caption-text">Figura 1 - Iniciando o servidor Java DB</p></div>
<div class="wp-caption alignnone" style="width: 554px"><img style="border: 0pt none;" title="Figura 2 - Criando um novo banco de dados no Java DB" src="http://www.paulocanedo.com.br/images/nb65beta-crud/nb65beta_create_db.gif" border="0" alt="" width="544" height="206" /><p class="wp-caption-text">Figura 2 - Criando um novo banco de dados no Java DB</p></div>
<p>Agora com o banco de dados criado, vamos então para o nosso projeto no NetBeans, então:</p>
<ol>
<li> Crie um novo projeto web (File-&gt;New project) na categoria Java Web, escolha a opção Web Application (Figura 3)</li>
<li>na janela seguinte preencha os campos de acordo com a Figura 4</li>
<li>Defina o servidor web (recomendado o glassfish v2 ou v3) e o caminho do contexto (Figura 5)</li>
<li>clique em next e selecione o framework: JavaServer Faces (Figura 6)</li>
</ol>
<div class="wp-caption alignnone" style="width: 729px"><img style="border: 0pt none;" title="Figura 3 - Criando um novo projeto web" src="http://www.paulocanedo.com.br/images/nb65beta-crud/nb65beta_new_project_web.gif" border="0" alt="" width="719" height="468" /><p class="wp-caption-text">Figura 3 - Criando um novo projeto web</p></div>
<div class="wp-caption alignnone" style="width: 731px"><img style="border: 0pt none;" title="Figura 4 - Definindo o nome e local do projeto" src="http://www.paulocanedo.com.br/images/nb65beta-crud/nb65beta_name_and_location.gif" border="0" alt="" width="721" height="470" /><p class="wp-caption-text">Figura 4 - Definindo o nome e local do projeto</p></div>
<div class="wp-caption alignnone" style="width: 731px"><img style="border: 0pt none;" title="Figura 5 - Sugestões para escolha do servidor web e configurações" src="http://www.paulocanedo.com.br/images/nb65beta-crud/nb65beta_server_and_settings.gif" border="0" alt="" width="721" height="470" /><p class="wp-caption-text">Figura 5 - Sugestões para escolha do servidor web e configurações</p></div>
<div class="wp-caption alignnone" style="width: 701px"><img style="border: 0pt none;" title="Figura 6 - Adicionando o framework JavaServer Faces ao seu projeto" src="http://www.paulocanedo.com.br/images/nb65beta-crud/nb65beta_frameworks.gif" border="0" alt="" width="691" height="387" /><p class="wp-caption-text">Figura 6 - Adicionando o framework JavaServer Faces ao seu projeto</p></div>
<p>Agora seu projeto está criado, para testar se o seu projeto está funcionando corretamente com o servidor web, clique com o botão direito no projeto (janela projects &#8211; Ctrl+1) e clique em Run.<br />
Bom, o próximo passo é criarmos um Persistence Unit, um Entity class, os controllers do JPA (Java Persistence API):</p>
<ol>
<li>clique em File-&gt;new File, selecione a categoria Persistence, então escolha a opção Persistence Unit e clique em next</li>
<li>Vá até a setinha do combobox e selecione New Data Source&#8230;</li>
<li>digite um nome para o jndi name (ex.: dsExemploJsf), em Database Connection selecione a conexão com o banco de dados que você criou no início deste tutorial, clique em ok</li>
<li>na janela Provider and Database preencha os campos de acordo com a Figura 8 em seguida clique em finish</li>
<li>Novamente clique em File-&gt;new File, na categoria Persistence, selecione Entity Class e clique em next</li>
<li>na janela seguinte preencha os campos de acordo com a Figura 9 e clique em Finish</li>
</ol>
<div class="wp-caption alignnone" style="width: 731px"><img style="border: 0pt none;" title="Figura 7 - Novo Persistence Unit" src="http://www.paulocanedo.com.br/images/nb65beta-crud/nb65beta_new_persistence_unit.gif" border="0" alt="" width="721" height="470" /><p class="wp-caption-text">Figura 7 - Novo Persistence Unit</p></div>
<div class="wp-caption alignnone" style="width: 786px"><img style="border: 0pt none;" title="Figura 8 - Provider and Database" src="http://www.paulocanedo.com.br/images/nb65beta-crud/nb65beta_provider_and_database.gif" border="0" alt="" width="776" height="470" /><p class="wp-caption-text">Figura 8 - Provider and Database</p></div>
<div class="wp-caption alignnone" style="width: 731px"><a href="javascript:openpopup('images/nb65beta_new_entity_class.gif',721,470,false);"><img style="border: 0pt none;" title="Figura 9 - Criando um novo Entity class" src="http://www.paulocanedo.com.br/images/nb65beta-crud/nb65beta_new_entity_class.gif" border="0" alt="" width="721" height="470" /></a><p class="wp-caption-text">Figura 9 - Criando um novo Entity class</p></div>
<p>Depois de gerado o arquivo Livro.java o NetBeans abre automaticamente ele, vamos editar este arquivo para que fique da seguinte forma:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>0
1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">@Id
@GeneratedValue<span style="color: #009900;">&#40;</span>strategy <span style="color: #339933;">=</span> GenerationType.<span style="color: #006633;">AUTO</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">Long</span> id<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> isbn<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> titulo<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> autor<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">Integer</span> numeroPaginas<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">Double</span> peso<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">Long</span> getId<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">return</span> id<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Então posicione o cursor na linha imediatamente depois de:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>0
1
2
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setId<span style="color: #009900;">&#40;</span><span style="color: #003399;">Long</span> id<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">id</span> <span style="color: #339933;">=</span> id<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>e pressione simultaneamente: Alt+insert, selecione Getter and Setter&#8230; selecione todos os campos e clique em ok.</p>
<p>Após criarmos o Entity Class, vamos para mais um wizard do netbeans o qual irá nos gerar os códigos necessários para trabalhar com JPA e os arquivos JSF, para isso vamos em File-&gt;New File, na categoria Persistence, escolha a opção: JSF Pages From Entity Classes, e siga novamente os passos:</p>
<ol>
<li>Escolha a Entity class do Livro (Figura 10)</li>
<li>Escolha os pacotes para onde vão ficar os arquivos gerados para manipulação do JPA e JSF (Figura 11), nesta opção perceba que aparece a opção &#8220;Ajax-enable generated pages&#8221;, que fará com que o código gerado utilize tecnologia Ajax, lembrando que esta opção só está disponível a partir da versão 6.5 beta do NetBeans</li>
</ol>
<div class="wp-caption alignnone" style="width: 801px"><img style="border: 0pt none;" title="Figura 10 - Selecionar Entity classes" src="http://www.paulocanedo.com.br/images/nb65beta-crud/nb65beta_new_jsf_from_entity_class.gif" border="0" alt="" width="791" height="515" /><p class="wp-caption-text">Figura 10 - Selecionar Entity classes</p></div>
<div class="wp-caption alignnone" style="width: 801px"><img style="border: 0pt none;" title="Figura 11 - Selecionar pacotes para JPA e JSF" src="http://www.paulocanedo.com.br/images/nb65beta-crud/nb65beta_new_jsf_from_entity_class2.gif" border="0" alt="" width="791" height="515" /><p class="wp-caption-text">Figura 11 - Selecionar pacotes para JPA e JSF</p></div>
<p>Pronto, agora estamos com todo o código necessário pronto, para que possamos testar o resultado do nosso projeto, construa o projeto (tecle Shift+F11, limpa e constrói o projeto) clique com o botão direito no nome do projeto pela janela Projects (Ctrl+1) em seguida clique em &#8220;Undeploy and Deploy&#8221; para remover o projeto do servidor web (se houver) e implantar a versão que você acabou de construir (Figura 12).</p>
<p>Se não houver nenhuma mensagem de erro na janela Output (Ctrl+4), você pode executar o projeto através da tecla F6 e ver seu CRUD funcionando bonitinho. (Figuras 13 e 14)</p>
<div class="wp-caption alignnone" style="width: 308px"><img style="border: 0pt none;" title="Figura 12 - Undeploy and Deploy (Desimplantação e implantação) do projeto" src="http://www.paulocanedo.com.br/images/nb65beta-crud/nb65beta_undeploy_deploy.gif" border="0" alt="" width="298" height="466" /><p class="wp-caption-text">Figura 12 - Undeploy and Deploy (Desimplantação e implantação) do projeto</p></div>
<div class="wp-caption alignnone" style="width: 683px"><img style="border: 0pt none;" title="Figura 13 - CRUD pronto, criando um novo registro" src="http://www.paulocanedo.com.br/images/nb65beta-crud/nb65beta_new_livro.gif" border="0" alt="" width="673" height="521" /><p class="wp-caption-text">Figura 13 - CRUD pronto, criando um novo registro</p></div>
<div class="wp-caption alignnone" style="width: 683px"><img style="border: 0pt none;" title="Figura 14 - CRUD pronto, visão geral dos registro após confirmação de inserção do registro" src="http://www.paulocanedo.com.br/images/nb65beta-crud/nb65beta_livro_created.gif" border="0" alt="" width="673" height="521" /><p class="wp-caption-text">Figura 14 - CRUD pronto, visão geral dos registro após confirmação de inserção do registro</p></div>
<p><strong>Conclusão: </strong> Não é recomendável que uma pessoa que não tenha experiência com Java Server Faces utilize o assistente de geração de CRUD do NetBeans para fazer seu trabalho do dia a dia de produção, a importância dessa característica do IDE NetBeans para esse público é que tenham acesso ao desenvolvimento passo a passo da criação de um CRUD utilizando esses fantásticos frameworks para Java, o aprendizado nessa atividade é bastante satisfatório. Para quem já tem experiência basta olhar o processo de criação e os resultados e já saberá o que fazer. Para quem quer uma coisa prática, sem muito detalhe, e que seja bem rápido de fazer isso aqui é uma mão na roda.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.paulocanedo.com.br/2008/09/02/criando-um-crud-em-jsf-e-ajax-com-o-netbeans-65-beta/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
	</channel>
</rss>
