<?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>Rafael Liu Blog &#187; tutorial</title>
	<atom:link href="http://rafaelliu.net/tag/tutorial/feed/" rel="self" type="application/rss+xml" />
	<link>http://rafaelliu.net</link>
	<description>Café, pinguins e outras coisas</description>
	<lastBuildDate>Wed, 28 Mar 2012 21:54:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.3</generator>
		<item>
		<title>Estrutura de um projeto Seam</title>
		<link>http://rafaelliu.net/2008/08/30/estrutura-de-um-projeto-seam/</link>
		<comments>http://rafaelliu.net/2008/08/30/estrutura-de-um-projeto-seam/#comments</comments>
		<pubDate>Sat, 30 Aug 2008 21:15:50 +0000</pubDate>
		<dc:creator>rafaelliu</dc:creator>
				<category><![CDATA[JBoss]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[seam]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://rafaelliu.wordpress.com/?p=59</guid>
		<description><![CDATA[O seam-gen é um gerador de scaffolding muito útil para quem programa em Seam. O seam-gen em si é uma ferramenta CLI, mas o JBoss Tools nos dá uma GUI para facilitar nossa vida. Bom, então o primeiro passo é instalar o plugin do JBoss Tools. É só baixar do site deles e descompactar no [...]]]></description>
			<content:encoded><![CDATA[<p>O seam-gen é um gerador de <em>scaffolding</em> muito útil para quem programa em Seam. O seam-gen em si é uma ferramenta CLI, mas o JBoss Tools nos dá uma GUI para facilitar nossa vida. Bom, então o primeiro passo é instalar o plugin do JBoss Tools. É só baixar do site deles e descompactar no diretório do Eclipse, nada de mais.</p>
<p>Você notará que serão adicionadas várias perspectivas, entre elas, a Seam. Vamos selecionar essa perspectiva e criar um novo Seam Project. Com isso já temos um projeto funcional com segurança, apresentação de erros, e conexão com banco de dados. Também é criado um projeto &lt;projeto&gt;-Test para testes. Vamos entender um pouco do que nos foi gerado.</p>
<ol>
<li>classe usada pelo Seam para autenticação<a href="/wp-content/uploads/2009/04/seam-gen-structure.png"><img class="alignright size-medium wp-image-141" title="seam-gen-structure" src="http://rafaelliu.net/wp-content/uploads/2009/04/seam-gen-structure-97x300.png" alt="seam-gen-structure" width="97" height="300" /></a></li>
<li>arquivo chave. Indica ao Seam que ele deve procurar nesse diretório por componentes</li>
<li>persistence.xml do JPA</li>
<li>arquivo com algumas propriedados a serem substituidas pelo Ant no components.xml</li>
<li>import.sql do Hibernate</li>
<li>mensagens para internacionalização</li>
<li>arquivo Drools com regras de autorização</li>
<li>datasource gerado para o JBoss</li>
<li>arquivo de configuração do Seam (componentes, integração)</li>
<li>arquivo de configuração WAR do JBoss</li>
<li>arquivo de configuração do Seam (regras de fluxo, segurança, controle de conversação)</li>
<li>similar ao arquivo pages.xml, mas específico para o login.xhtml</li>
<li>arquivo de configuração do plugin Hibernate Console</li>
</ol>
<p>Vamos ver por alto algumas configurações interessantes. Na parte de segurança temos no components.xml:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;event</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;org.jboss.seam.security.notLoggedIn&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;action</span> <span style="color: #000066;">execute</span>=<span style="color: #ff0000;">&quot;#{redirect.captureCurrentView}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/event<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;event</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;org.jboss.seam.security.loginSuccessful&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;action</span> <span style="color: #000066;">execute</span>=<span style="color: #ff0000;">&quot;#{redirect.returnToCapturedView}&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/event<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>O Seam possui o conceito de eventos. Eventos são mensagens que podem ser capturadas ou lançadas, no estilo <em>broadcast</em>. O Seam em si lança vários eventos e podemos capturar esses eventos através de XML, como no exemplo acima. O trecho acima está invocando métodos do componente <em>built-in </em><code>#{redirect}</code> quando eventos de segurança forem lançados. Ele especifica que a <em>view id </em>JSF deve ser salva quando o usuário não-logado tentar acessar uma página restrita e que essa view id deve ser restaurada uma vez que ele se autentique.<br />
Um outro trecho especifica que componente é responsável pela autenticação:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;security:identity</span> <span style="color: #000066;">authenticate-method</span>=<span style="color: #ff0000;">&quot;#{authenticator.authenticate}&quot;</span></span>
<span style="color: #009900;"><span style="color: #000066;">security-rules</span>=<span style="color: #ff0000;">&quot;#{securityRules}&quot;</span></span>
<span style="color: #009900;"><span style="color: #000066;">remember-me</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div>

<p>E no pages.xml dizemos que página deve ser utilizada para login:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exception</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.jboss.seam.security.NotLoggedInException&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;redirect</span> <span style="color: #000066;">view-id</span>=<span style="color: #ff0000;">&quot;/login.xhtml&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;message<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Please log in first<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/message<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/redirect<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/exception<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Aqui temos um tratamento de exceção bem parecido com o de servlets que definimos no web.xml. O usuário será redirecionado para a página login.xhtml e uma mensagem JSF será adicionada.<br />
Se olharmos no login.pages.xml vemos ainda:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;navigation</span> <span style="color: #000066;">from-action</span>=<span style="color: #ff0000;">&quot;#{identity.login}&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;rule</span> <span style="color: #000066;">if</span>=<span style="color: #ff0000;">&quot;#{identity.loggedIn}&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;redirect</span> <span style="color: #000066;">view-id</span>=<span style="color: #ff0000;">&quot;/home.xhtml&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/rule<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/navigation<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>O que nos lembra bastante as <em>navigation rules</em> JSF. De fato parecem muito, mas as extendem em funcionalidade, podendo não só enviar o usuário para outra página como também lançar um evento, executar um método para avaliar qual será a próxima página, e algumas coisas mais avançadas.</p>
<p>O objetivo desse post é apenas nos familiarizar mais com o Seam e dar uma visão sobre o <em>scaffold</em> que nos foi gerado de base e que iremos usar para desenvolver nossa aplicação. Ainda vamos falar com mais detalhes de eventos, componentes e configurações.</p>
]]></content:encoded>
			<wfw:commentRss>http://rafaelliu.net/2008/08/30/estrutura-de-um-projeto-seam/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Parte I: O que é Seam?</title>
		<link>http://rafaelliu.net/2008/08/12/parte-i-o-que-e-seam/</link>
		<comments>http://rafaelliu.net/2008/08/12/parte-i-o-que-e-seam/#comments</comments>
		<pubDate>Tue, 12 Aug 2008 11:08:52 +0000</pubDate>
		<dc:creator>rafaelliu</dc:creator>
				<category><![CDATA[JBoss]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[seam]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://rafaelliu.wordpress.com/?p=53</guid>
		<description><![CDATA[Como recebo vários hints no post JBoss Seam no Tomcat, resolvi escrever mais sobre Seam. Esse post abre uma série de tutoriais de Seam. Seam é um framework muito amplo. Pegue alguns dos frameworks mais representativos, ponha algumas práticas de desenvolvimento e misture: assim que vejo o Seam. O Seam em sua plenitude usa os [...]]]></description>
			<content:encoded><![CDATA[<p>Como recebo vários <em>hints</em> no <em>post</em> <a title="JBoss Seam no Tomcat" href="http://rafaelliu.wordpress.com/2008/07/28/jboss-seam-no-tomcat/" target="_blank">JBoss Seam no Tomcat</a>, resolvi escrever mais sobre Seam. Esse <em>post</em> abre uma série de tutoriais de Seam.</p>
<p>Seam é um <em>framework</em> <strong>muito</strong> amplo. Pegue alguns dos <em>frameworks</em> mais representativos, ponha algumas práticas de desenvolvimento e misture: assim que vejo o Seam. O Seam em sua plenitude usa os <em>frameworks:</em> EJB3, JSF, Facelets, Hibernate, Hibernate Validations, Richfaces, Ajax4JSF, jBPM, Drools (qualquer associação ao nome JBoss é mera coincidência). É muita coisa. Mas ele não só usa esses <em>frameworks,</em> ele também provê uma integração entre eles, disponibiliza componentes <em>built-in</em> (à la Spring, cujo qual inclusive pode-se integrar) e introduz algumas melhorias sobre eles. Além disso ele apregoa algumas práticas como desenvolvimento orientado a componentes e desencoraja outras, como desenvolvimento em camadas.</p>
<p>Vou deixar de lado o que cada <em>framework</em> faz, pois não entra no mérito do que o Seam tem a oferecer. Dando um enfoque bem prático, o Seam:</p>
<ul>
<li>Reduz plumbing code do JSF. Quem já programou com JSF sabe do que estou falando (Não? FacesContext? faces-config.xml?).</li>
<li>Resolve o infame problema do &#8220;<em>back button</em>&#8221; em JSF. E <em>reload,</em> e <em>bookmarking,</em> e &#8230;</li>
<li>Facilita o uso de JPA. Tem um código cheio de merges()? Usa uma <em>long-running transaction</em> num <em>page flow</em>?</li>
<li>Possibilita <em>page flows</em> usando o jBPM.</li>
<li>Permite aplicações <em>multi-windows</em>. E finalmente poder clicar &#8220;Abrir em nova janela&#8221; nos links!</li>
<li>Permite o uso de <em>workspaces.</em> Como no Linux.</li>
<li>Faz uso extensivo de anotações. Mas também permiti o uso de XML.</li>
<li>Possui uma penca de tags JSF. Uns muito úteis, uns bem exóticos&#8230;</li>
<li>E muito mais!</li>
</ul>
<p>Dada essa introdução, vou detalhar nos próximos posts cada um desses itens dizendo como realizamos eles com o uso so Seam. Esse blog não é sobre Seam, então esperem outros posts no meio. Até mais!</p>
<p>referência: http://docs.jboss.com/seam/latest/reference/en-US/html/Book-Preface.html</p>
]]></content:encoded>
			<wfw:commentRss>http://rafaelliu.net/2008/08/12/parte-i-o-que-e-seam/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

