<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress.com" -->
<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/"
	>

<channel>
	<title>facelets &amp;laquo; WordPress.com Tag Feed</title>
	<link>http://en.wordpress.com/tag/facelets/</link>
	<description>Feed of posts on WordPress.com tagged "facelets"</description>
	<pubDate>Fri, 27 Nov 2009 23:57:16 +0000</pubDate>

	<generator>http://en.wordpress.com/tags/</generator>
	<language>en</language>

<item>
<title><![CDATA[Java EE Got it Wrong]]></title>
<link>http://zerocredibility.wordpress.com/2009/11/17/java-ee-got-it-wrong/</link>
<pubDate>Tue, 17 Nov 2009 18:08:14 +0000</pubDate>
<dc:creator>Jeffrey Blattman</dc:creator>
<guid>http://zerocredibility.wordpress.com/2009/11/17/java-ee-got-it-wrong/</guid>
<description><![CDATA[After working on two large-scale, cross contains / platform, web application projects, I&#8217;ve co]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>After working on two large-scale, cross contains / platform, web application projects, I&#8217;ve come to the conclusion that Java EE is fatally flawed.</p>
<p>If someone asked you to state the most important, guiding principle of the Java language, what would you say? You would would probably say &#8220;write once, run anywhere.&#8221; Indeed, for Java SE this holds true most all of the time. In Java EE however, it is hopelessly broken. The reality is that every web container is slightly different in ways that force developers work around problems, avoid certain features, or even have different code paths. Different code paths in a language that was never designed for it.</p>
<p>Different aspects of Java EE have different levels of stability. JSP works almost the same across all containers. Things like JSF and Java Persistence (JPA) however are hopeless. My most recent experience is writing a web administration console using JSF for the <a href="https://opensso.dev.java.net/">OpenSSO</a> project. OpenSSO claims to support at at least 8 different web containers. Every container required JSF tweaking that ranged from annoying to just plain terrible. Needless to say I had egg on my face to some degree over the choice to use JSF. It was a no-brainer for me. JSF is the chosen MVC framework for Java EE. My mistake.</p>
<p>The only container where JSF &#8220;just worked&#8221; was Tomcat. Tomcat isn&#8217;t a Java EE container at all.Tomcat doesn&#8217;t include JSF or any of it&#8217;s dependencies. We might be on to something here. Let&#8217;s look at another example: Spring. Spring is essentially a lighter-weight, simpler replacement for Java EE. Why is Spring so popular? One reason is that it is an elegant design. But another, perhaps more important reasons is that no matter what container you are developing on, Spring is Spring. It&#8217;s the same JAR, the same code, the same implementation. It makes very few assumptions about the capabilities of the underlying container. Another example is Facelets, a light-weight JSP replacment. I use JSF+Facelets on the OpenSSO project, and it has been flawless (the Facelets part). Why? Because I include the Facelets JAR, it is not provided by the system.</p>
<p>What if Java EE had followed the same model? Java EE should have been nothing more than a plugin framework and some base services. Want to use JSF in your project? Just include it from a managed, networked Java EE module repository. Include the one, common implementation of JSF. Include the approved version for your level of Java EE. If you support Java EE 5, you get JSF version X, across all web containers.</p>
<p>&#160;</p>
<p>&#160;</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[JSF + Facelets tutorial - ciąg dalszy [część 2]]]></title>
<link>http://ryznar.wordpress.com/2009/11/09/jsf-facelets-tutorial-ciag-dalszy-czesc-2/</link>
<pubDate>Mon, 09 Nov 2009 17:59:46 +0000</pubDate>
<dc:creator>Paweł Ryznar</dc:creator>
<guid>http://ryznar.wordpress.com/2009/11/09/jsf-facelets-tutorial-ciag-dalszy-czesc-2/</guid>
<description><![CDATA[Miało być dwa wpisy odnośnie JSF i Facelets, ale założenia się zmieniły i będzie trzy Dzisiaj w sumi]]></description>
<content:encoded><![CDATA[Miało być dwa wpisy odnośnie JSF i Facelets, ale założenia się zmieniły i będzie trzy Dzisiaj w sumi]]></content:encoded>
</item>
<item>
<title><![CDATA[JSF et Facelets]]></title>
<link>http://jawher.wordpress.com/2009/11/08/jsf-et-facelets/</link>
<pubDate>Sun, 08 Nov 2009 00:39:22 +0000</pubDate>
<dc:creator>jawher</dc:creator>
<guid>http://jawher.wordpress.com/2009/11/08/jsf-et-facelets/</guid>
<description><![CDATA[Extrait du synopsis : Cet article a pour objectif de vous présenter la technologie de présentation F]]></description>
<content:encoded><![CDATA[Extrait du synopsis : Cet article a pour objectif de vous présenter la technologie de présentation F]]></content:encoded>
</item>
<item>
<title><![CDATA[Facelets tutorial - wprowadzenie - część 1]]></title>
<link>http://ryznar.wordpress.com/2009/11/07/facelets-tutorial-krotkie-wprowadzenie-czesc-1/</link>
<pubDate>Sat, 07 Nov 2009 13:28:44 +0000</pubDate>
<dc:creator>Paweł Ryznar</dc:creator>
<guid>http://ryznar.wordpress.com/2009/11/07/facelets-tutorial-krotkie-wprowadzenie-czesc-1/</guid>
<description><![CDATA[Tym razem wpis nie będzie o problemach ale o czymś działającym Poprzednio odniosłem się do przykłado]]></description>
<content:encoded><![CDATA[Tym razem wpis nie będzie o problemach ale o czymś działającym Poprzednio odniosłem się do przykłado]]></content:encoded>
</item>
<item>
<title><![CDATA[Step by step tutorial to setup Primefaces in Netbeans6.x]]></title>
<link>http://technicalbrainwave.wordpress.com/2009/11/07/step-by-step-tutorial-to-setup-primefaces-in-netbeans6-x/</link>
<pubDate>Fri, 06 Nov 2009 16:37:21 +0000</pubDate>
<dc:creator>Gift Sam</dc:creator>
<guid>http://technicalbrainwave.wordpress.com/2009/11/07/step-by-step-tutorial-to-setup-primefaces-in-netbeans6-x/</guid>
<description><![CDATA[Introduction: This tutorial shows how to setup Primefaces component suite for a JSF or a Facelets pr]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p style="text-align:left;"><strong>Introduction:</strong></p>
<p style="text-align:left;">This tutorial shows how to setup Primefaces component suite for a JSF or a Facelets project along with Richfaces in Netbeans6.x. Furthermore, you can learn how to make a hello world application using Primefaces in JSF. First let me give a small intro about Primefaces, which is an open source component suite for Java Server Faces and contains so many obliging features. At first Primefaces is a light weight component that contains more than <a href="http://97.107.138.40:8080/prime-showcase/ui/home.jsf">seventy ajax powered JSF components</a> with rich look and feel. In addition it has TouchFaces module features which is a UI kit used for developing mobile web applications. Also the most important thing is Primefaces is compatable with other components libraries like Richfaces, even the ajax integration part can be attained without any conflicts. Thats ok!! Now let us come to the point this article explains the configuration features of Primefaces with Netbeans6.x.<!--more--></p>
<p style="text-align:left;"><strong>Prerequisites:</strong></p>
<ul style="text-align:left;">
<li>IDE – Netbeans 6.x</li>
<li>Tomcat 6.x/Glassfish/Jboss</li>
<li>JDK 1.5 and above</li>
</ul>
<p style="text-align:left;">I assume you have all the prerequisites which I had mention above. Now lets us move to the Configuration part of primefaces with Netbeans6.x which can be accomplished by five easy steps,</p>
<p style="text-align:left;"><strong>Step1(Setup the project):</strong></p>
<p style="text-align:left;">In Step1, let us see how to set up a JSF web project in Netbeans6.x. Select File <strong><em>&#8212;&#62; </em></strong>Newproject &#8212;&#62; Choose category as Java Web and select Web Application in Projects and click next &#8212;&#62; Give your desired name for the project and click next &#8212;&#62; Choose your server and the JavaEE Version and click next &#8212;&#62; Select Java ServerFaces check box for the JSF project or Facelets checkbox for the Facelets project in the Framework. Now we had created a web project and next we can move to the second step.</p>
<p style="text-align:left;"><strong>Step2(Library Configurations)</strong></p>
<p style="text-align:left;">In step two, Let us see how to configure the required libraries for the Primefaces, Downloading Primefaces binaries can be done by two options. <em><strong>Manual Download</strong><strong>(<em><strong>Option</strong></em>1)</strong></em>, we need to manually download all the required libraries of Primefaces. Alternatively, you may use Maven if you are a Maven user<em><strong>(Option2)</strong></em>, Good news for you because maven itself automatically download the required binaries of Primefaces.</p>
<p style="text-align:left;"><em><strong>Manual Download(Option1)</strong></em></p>
<p style="text-align:left;">Download and ensure that your projects WEB-INF/lib directory contains the below jar files inorder to use Primefaces  library together with Richfaces in a JSF project and for Facelets projects add necessary jar files, the link <a href="http://technicalbrainwave.wordpress.com/2009/10/16/jsffaceletsrichfaces-installation-guide/">JSF+Facelets+Richfaces Installation Guide</a> would be helpful to do so. You can also download the latest Primefaces jar files from the <a href="http://code.google.com/p/primefaces/downloads/list">PrimeFaces google code project site</a>.</p>
<ul style="text-align:left;">
<li>primefaces-ui-0.9.3.jar</li>
<li>optimus0.8.0.jar</li>
<li>facestrace1.1.0.jar</li>
<li>commons-beanutils.jar</li>
<li>commons-collections.jar</li>
<li>commons-digester.jar</li>
<li>commons-logging.jar</li>
<li>jsf-api.jar</li>
<li>jsf-impl.jar</li>
<li>jstl.jar</li>
<li>commons-discovery-0.4.jar</li>
<li>commons-codec-1.4.jar</li>
<li>slf4j-api-1.5.8.jar</li>
<li>slf4j-simple-1.5.8.jar</li>
<li>guice-2.0.jar</li>
<li>richfaces-api-3.3.1.GA.jar</li>
<li>richfaces-impl-3.3.1.GA.jar</li>
<li>richfaces-ui-3.3.1.GA.jar</li>
</ul>
<blockquote>
<p style="text-align:left;"><em><strong>Note:</strong></em> optimus0.8.0.jar and facestrace1.1.0.jar is requirement optional and it doest not required to make the UI components work.</p>
</blockquote>
<p style="text-align:left;"><em><strong>Maven</strong></em><em><strong>(Option2)</strong></em></p>
<p style="text-align:left;">I am not aware of using maven practically, but theoretically I have passed through maven. I like it because it contains good features for managing the         libraries. I got this resource from the <a href="http://primefaces.prime.com.tr/en/downloads.html">download section of Primefaces</a>. The following repository definition should be added in repositories section of pom.xml file .</p>
<pre class="brush: css;">
&#60;repository&#62;
&#60;id&#62;prime-repository&#60;/id&#62;
&#60;name&#62;Prime Technology Maven Repository&#60;/name&#62;
&#60;url&#62;http://repository.prime.com.tr/&#60;/url&#62;
&#60;layout&#62;default&#60;/layout&#62;
&#60;/repository&#62;
</pre>
<p>Add the dependency configuration for the user interface components like the below example</p>
<pre class="brush: css;">
&#60;dependency&#62;
&#60;groupId&#62;org.primefaces&#60;/groupId&#62;
&#60;artifactId&#62;primefaces-ui&#60;/artifactId&#62;
&#60;version&#62;0.9.3&#60;/version&#62;
&#60;/dependency&#62;
</pre>
<p>I hope you had configured the libraries either by following option1 or option2. If so stay tuned, now let us move to the next step.</p>
<p><strong>Step3(web.xml configuration)</strong><em><strong><br />
</strong></em></p>
<p>In step3, let us configure the web.xml for the Primefaces.</p>
<pre class="brush: css;">
&#60;web-app version=&#34;2.5&#34; xmlns=&#34;http://java.sun.com/xml/ns/javaee&#34; xmlns:xsi=&#34;http://www.w3.org/2001/XMLSchema-instance&#34; xsi:schemaLocation=&#34;http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd&#34;&#62;&#60;/pre&#62;
&#60;context-param&#62;
 &#60;param-name&#62;com.sun.faces.verifyObjects&#60;/param-name&#62;
 &#60;param-value&#62;false&#60;/param-value&#62;
 &#60;/context-param&#62;
 &#60;context-param&#62;
 &#60;param-name&#62;com.sun.faces.validateXml&#60;/param-name&#62;
 &#60;param-value&#62;true&#60;/param-value&#62;
 &#60;/context-param&#62;
 &#60;context-param&#62;
 &#60;param-name&#62;javax.faces.STATE_SAVING_METHOD&#60;/param-name&#62;
 &#60;param-value&#62;client&#60;/param-value&#62;
 &#60;/context-param&#62;

&#60;!--Configuration for Richfaces--&#62;

&#60;filter&#62;
 &#60;display-name&#62;RichFaces Filter&#60;/display-name&#62;
 &#60;filter-name&#62;richfaces&#60;/filter-name&#62;
 &#60;filter-class&#62;org.ajax4jsf.Filter&#60;/filter-class&#62;
 &#60;/filter&#62;
 &#60;filter-mapping&#62;
 &#60;filter-name&#62;richfaces&#60;/filter-name&#62;
 &#60;servlet-name&#62;Faces Servlet&#60;/servlet-name&#62;
 &#60;dispatcher&#62;REQUEST&#60;/dispatcher&#62;
 &#60;dispatcher&#62;FORWARD&#60;/dispatcher&#62;
 &#60;dispatcher&#62;INCLUDE&#60;/dispatcher&#62;
 &#60;/filter-mapping&#62;

&#60;!--End of the configuration part for Richfaces--&#62;

servlet&#62;
 &#60;servlet-name&#62;Faces Servlet&#60;/servlet-name&#62;
 &#60;servlet-class&#62;javax.faces.webapp.FacesServlet&#60;/servlet-class&#62;
 &#60;load-on-startup&#62;1&#60;/load-on-startup&#62;
 &#60;/servlet&#62;
 &#60;servlet-mapping&#62;
 &#60;servlet-name&#62;Faces Servlet&#60;/servlet-name&#62;
 &#60;url-pattern&#62;/faces/*&#60;/url-pattern&#62;
 &#60;/servlet-mapping&#62;
 &#60;context-param&#62;
 &#60;param-name&#62;org.richfaces.SKIN&#60;/param-name&#62;
 &#60;param-value&#62;classic&#60;/param-value&#62;
 &#60;/context-param&#62;

 &#60;!-- Configuration part for the Primefaces--&#62;

 &#60;servlet&#62;
 &#60;servlet-name&#62;Resource Servlet&#60;/servlet-name&#62;
 &#60;servlet-class&#62;
 org.primefaces.ui.resource.ResourceServlet
 &#60;/servlet-class&#62;
 &#60;load-on-startup&#62;2&#60;/load-on-startup&#62;
 &#60;/servlet&#62;
 &#60;servlet-mapping&#62;
 &#60;servlet-name&#62;Resource Servlet&#60;/servlet-name&#62;
 &#60;url-pattern&#62;/primefaces_resources/*&#60;/url-pattern&#62;
 &#60;/servlet-mapping&#62;

 &#60;!-- End of the configuration part for the Primefaces--&#62;

&#60;session-config&#62;
 &#60;session-timeout&#62;
 30
 &#60;/session-timeout&#62;
 &#60;/session-config&#62;
 &#60;welcome-file-list&#62;
 &#60;welcome-file&#62;faces/welcomeJSF.jsp&#60;/welcome-file&#62;
 &#60;/welcome-file-list&#62;
&#60;/web-app&#62;</pre>
<p>In the above configuration, Primefaces configuration for the JSF project is specified. If you want to configure Primefaces for the Facelets projects add the Facelets neccesary configuration in the web.xml and also you can see the loading order of servlets is specified. Servlets with lower values are loaded before servlets with higher values. So the servlet<em><strong>(Faces Servlet) </strong></em>that manages the request  processing lifecycle for web applications<em><strong> </strong></em>which utilize the JavaServer  Faces to construct the user interface is loaded first and the PrimeFaces UI module&#8217;s servlet<em><strong>(Resource Servlet)</strong></em> loaded second. Now the web.xml configuration part gets over and let us move to the next step.</p>
<p><strong>Step4(Taglib specifications):</strong></p>
<p>In step4, Let us learn how to specify the taglibs for the Facelets or JSF projects. For <strong><em>Facelets projects</em></strong>, though the Facelets web page are created in the xhtml documents, the taglibs should be specified like the below</p>
<pre class="brush: css;">
&#60;html xmlns:p=&#34;http://primefaces.prime.com.tr/ui&#34; /&#62;
</pre>
<p>As you all know for <em><strong>JSF project</strong></em>, the JSF web page are created in the JSP documents, the taglibs should be specified like the below</p>
<pre class="brush: css;">
&#60;%@ taglib uri=&#34;http://primefaces.prime.com.tr/ui&#34; prefix=&#34;p&#34; %&#62;
</pre>
<p>So far we had completed most of the configurations and only one more step is there to finish the set up process of Primefaces in Netbeans6.x.</p>
<p><strong>Step5(Resources Components):</strong></p>
<p>The resource components should be added between the head tag of the page, inorder to include the css and script resources.</p>
<pre class="brush: css;">
&#60;head&#62;
&#60;meta http-equiv=&#34;Content-Type&#34; content=&#34;text/html; charset=UTF-8&#34;/&#62;
&#60;p:resources/&#62;
&#60;/head&#62;
</pre>
<p>Setup process of Primefaces in Netbeans6.x has been completed and now let us create a hello world page using Primefaces UI components. The following code should be conjured to do so,</p>
<pre class="brush: css;">

&#60;%@page contentType=&#34;text/html&#34; pageEncoding=&#34;UTF-8&#34;%&#62;

 &#60;%@ taglib uri=&#34;http://java.sun.com/jsf/html&#34; prefix=&#34;h&#34;%&#62;
 &#60;%@ taglib uri=&#34;http://java.sun.com/jsf/core&#34; prefix=&#34;f&#34;%&#62;
 &#60;%@ taglib uri=&#34;http://richfaces.org/a4j&#34; prefix=&#34;a4j&#34;%&#62;
 &#60;%@ taglib uri=&#34;http://richfaces.org/rich&#34; prefix=&#34;rich&#34;%&#62;
 &#60;%@ taglib uri=&#34;http://primefaces.prime.com.tr/ui&#34; prefix=&#34;p&#34; %&#62;

 &#60;!DOCTYPE HTML PUBLIC &#34;-//W3C//DTD HTML 4.01 Transitional//EN&#34;
 &#34;http://www.w3.org/TR/html4/loose.dtd&#34;&#62;

 &#60;f:view&#62;
 &#60;html&#62;
 &#60;head&#62;
 &#60;meta http-equiv=&#34;Content-Type&#34; content=&#34;text/html; charset=UTF-8&#34;/&#62;
 &#60;title&#62;Hello World&#60;/title&#62;
 &#60;p:resources/&#62;
 &#60;/head&#62;
 &#60;body&#62;
 &#60;h:form id=&#34;helloWorldPageForm&#34;&#62;
 &#60;p:panel id=&#34;primefacesPanel&#34; header=&#34;Hello World&#34;
 footer=&#34;Footer&#34;
 style=&#34;position: relative; width: 500px; &#34; &#62;
 &#60;h:outputText value=&#34;Primefaces is great. My first application using Primefaces&#34;/&#62;
 &#60;/p:panel&#62;
 &#60;/h:form&#62;
 &#60;/body&#62;
 &#60;/html&#62;
 &#60;/f:view&#62;</pre>
<p>By invoking the above code, we had created a Hello World demo application which contains a Primefaces panel, You can also use Richfaces components together with the Primefaces components. I am sure you dont believe, Even the ajax integration part between these libraries works well have a try on it. Now let us have a look on the snap of our Hello World application.</p>
<p><strong>Hello World Application&#8217;s Demo Snap:</strong></p>
<p><strong><img title="Hello World" src="http://technicalbrainwave.wordpress.com/files/2009/11/c92906.jpg" alt="Hello World" width="507" height="105" /></strong></p>
<p>Thatsall folks. I hope this article clearly explains the Setup of Primefaces in a JSF or Facelets projects along with Richfaces library in Netbeans6.x. <em><strong>If you find this article is quite useful, Dont forget to share with me by your valuable comments</strong></em>. Have a joyous code day.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Layouting and Dynamic Includes in Facelets]]></title>
<link>http://technicalbrainwave.wordpress.com/2009/10/18/layouting-and-dynamic-includes-in-facelets/</link>
<pubDate>Sun, 18 Oct 2009 10:14:01 +0000</pubDate>
<dc:creator>Gift Sam</dc:creator>
<guid>http://technicalbrainwave.wordpress.com/2009/10/18/layouting-and-dynamic-includes-in-facelets/</guid>
<description><![CDATA[Introduction A classified web applications necessitate the use of Cascading Style Sheets(CSS), JavaS]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p><strong>Introduction</strong></p>
<p>A classified web applications necessitate the use of Cascading Style Sheets(CSS), JavaScript, together with a server-side framework, such as JavaServer Faces(JSF). This article is consecrated for the peoples who wants to use facelets as an alternative view technology for building JSF applications. This article is splitted in to two-part series, Here you will find out how to make a complete Layout in JSF using facelets. In addition, learn how to include the pages dynamically, so that you can make use of serveral JSF forms more dynamic.<!--more--> Before starting this tutorial, first you need to create and configure facelets for your a web application project, the following link <a href="http://technicalbrainwave.wordpress.com/2009/10/16/jsffaceletsrichfaces-installation-guide/">Facelet installation</a> would be helpful to configure the facelets for your project.</p>
<p><strong><span style="color:#333399;"><span style="color:#000000;">Part1</span> </span>- How to make Layouts in Facelets</strong></p>
<p>After creating and installing facelets prerequisite for your project. Lets move to the part1 where you will learn to make template in facelets. As you all know, you can create a web page template for facelets in xhtml documents. This demo application is constructed by the following templates.</p>
<ol>
<li>layout.xhtml</li>
<li>layout-Client.xhtml</li>
<li>header.xhtml</li>
<li>sideBar.xhtml</li>
<li>footer.xhtml</li>
<li>sample pages like(samplePageOne.xhtml, samplePageTwo.xhtml, samplePage3.xhtml..)</li>
</ol>
<p><em><strong>1.Construct layout.xhtml template<br />
</strong></em></p>
<p>First let us construct a <em><strong>layout.xhtml </strong></em>which is the main layout that holds the template styles for the entire application. This mainLayout.xhtml web page contains header, leftColumn, rightColumn, content and footers in a 3 column elastic layout, <em><strong>You can define your own layout</strong></em>, the reason why I have used 3 column elastic layout here is, since the layout widths are defined in ems, elastic layouts allow your page containers to expand depending on the site visitor&#8217;s text size preference.</p>
<p><em><strong>layout.xhtml</strong></em></p>
<p><em><strong> </strong></em></p>
<pre class="brush: css;">
&#60;?xml version='1.0' encoding='UTF-8' ?&#62;
&#60;?xml version='1.0' encoding='UTF-8' ?&#62;
&#60;!DOCTYPE html PUBLIC &#34;-//W3C//DTD XHTML 1.0 Transitional//EN&#34; &#34;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#34;&#62;
&#60;html xmlns=&#34;http://www.w3.org/1999/xhtml&#34;
 xmlns:ui=&#34;http://java.sun.com/jsf/facelets&#34;
 xmlns:h=&#34;http://java.sun.com/jsf/html&#34;&#62;
 &#60;head&#62;
 &#60;meta http-equiv=&#34;Content-Type&#34; content=&#34;text/html; charset=UTF-8&#34; /&#62;
 &#60;link href=&#34;./css/default.css&#34; rel=&#34;stylesheet&#34; type=&#34;text/css&#34; /&#62;
 &#60;link href=&#34;./css/cssLayout.css&#34; rel=&#34;stylesheet&#34; type=&#34;text/css&#34; /&#62;
 &#60;title&#62;Facelets Template&#60;/title&#62;
 &#60;style type=&#34;text/css&#34; media=&#34;all&#34;&#62;
 body
{
 background-color: #2b3a3c;
 color: #2d2e2e;
 font-family: Arial, Helvetica, sans-serif;
 font-size: .8em;
 line-height: 1.2em;
 margin: 0 0 0 0; /* Sets the margin properties for an element using shorthand notation (top, right, bottom, left) */
 padding: 0 0 0 0; /* Sets the padding properties for an element using shorthand notation (top, right, bottom, left) */
 text-align: center; /* Centers the page content container in IE 5 browsers. */
 }
 #outerWrapper
{
 background-color: #fff;
 margin: 0 auto 0 auto; /* Sets the margin properties for an element using shorthand notation (top, right, bottom, left) */
 text-align: left; /* Redefines the text alignment defined by the body element. */
 width: 80em;
 }
 #outerWrapper #header
{
 background-color: #8ab573;
 border-bottom: solid 1px #628152; /* Sets the bottom border properties for an element using shorthand notation */
 font-size: 1.5em;
 font-weight: bold;
 line-height: 1.7em;
 padding: 10px 10px 10px 10px; /* Sets the padding properties for an element using shorthand notation (top, right, bottom, left) */
 }
 #outerWrapper #contentWrapper #rightColumn
{
 background-color: #eef6ed;
 border-left: solid 1px #8ab573; /* Sets the left border properties for an element using shorthand notation */
 float: right;
 padding: 10px; /* Sets the padding properties for an element using shorthand notation (top, right, bottom, left) */
 width: 14em;
 height: 200px;
 }
 #outerWrapper #contentWrapper #leftColumn
{
 background-color: #eef6ed;
 border-right: solid 1px #8ab573; /* Sets the right border properties for an element using shorthand notation */
 float: left;
 padding: 10px; /* Sets the padding properties for an element using shorthand notation (top, right, bottom, left) */
 width: 14em;
 height: 200px;
 }
 #outerWrapper #contentWrapper #content
{
 margin: 0 16em 0 16em; /* Sets the margin properties for an element using shorthand notation (top, right, bottom, left) */
 padding: 10px 10px 10px 10px; /* Sets the padding properties for an element using shorthand notation (top, right, bottom, left) */
 }
 #outerWrapper #contentWrapper .clearFloat
{
 clear: both;
 display: block;
 }
 #outerWrapper #footer
{
 background-color: #8ab573;
 border-bottom: solid 1px #628152; /* Sets the bottom border properties for an element using shorthand notation */
 font-size: 1.5em;
 font-weight: bold;
 line-height: 1.7em;
 padding: 10px 10px 10px 10px; /* Sets the padding properties for an element using shorthand notation (top, right, bottom, left) */
 }
 &#60;/style&#62;
 &#60;/head&#62;
 &#60;body&#62;
 &#60;div id=&#34;outerWrapper&#34;&#62;
     &#60;div id=&#34;header&#34;&#62;
         &#60;ui:insert name=&#34;header&#34;/&#62;
     &#60;/div&#62;
     &#60;div id=&#34;contentWrapper&#34;&#62;
         &#60;div id=&#34;rightColumn&#34;&#62;
             &#60;ui:insert name=&#34;rightColumn&#34;/&#62;
         &#60;/div&#62;
         &#60;div id=&#34;leftColumn&#34;&#62;
             &#60;ui:insert name=&#34;leftColumn&#34;/&#62;
         &#60;/div&#62;
         &#60;div id=&#34;content&#34;&#62;
             &#60;ui:insert name=&#34;content&#34;/&#62;
         &#60;/div&#62;
     &#60;br /&#62;
     &#60;/div&#62;
         &#60;div id=&#34;footer&#34;&#62;
             &#60;ui:insert name=&#34;footer&#34;/&#62;
         &#60;/div&#62;
 &#60;/div&#62;
 &#60;/body&#62;
&#60;/html&#62;</pre>
<p>&#60;ui:insertag&#62;- this is a templating tag which is used to declare a named                content element to be defined by another Facelet. ui:insert tag can be used                effectively with the ui:define tag.</p>
<p>Now the main layout has been constructed, next let us construct a <em><strong>layout-Client.xhml</strong></em>.</p>
<p><em><strong>2.Construct</strong></em> <em><strong>layout-Client.xhml template</strong></em></p>
<p>This layout-client.xhml template uses three tags,</p>
<p>&#60;ui:composition&#62; tag &#8211; a templating tag that                wraps the content of layout.xhml template. Facelets                view handler will ignore any content                outside the composition tag.</p>
<p>&#60;ui:define&#62; tag -  defines the named content of ui:insert tag in layout.xhtml template</p>
<p>&#60;ui:include&#62; tag &#8211; constructed inside the ui:define tag to include the other templates.</p>
<p><em><strong>layout-Client.xhtml</strong></em></p>
<pre class="brush: css;">
&#60;?xml version='1.0' encoding='UTF-8' ?&#62;
&#60;!DOCTYPE html PUBLIC &#34;-//W3C//DTD XHTML 1.0 Transitional//EN&#34; &#34;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#34;&#62;
&#60;html xmlns=&#34;http://www.w3.org/1999/xhtml&#34;
 xmlns:ui=&#34;http://java.sun.com/jsf/facelets&#34;
 xmlns:f=&#34;http://java.sun.com/jsf/core&#34;
 xmlns:h=&#34;http://java.sun.com/jsf/html&#34;
 xmlns:a4j=&#34;http://richfaces.org/a4j&#34;
 xmlns:rich=&#34;http://richfaces.org/rich&#34;&#62;
 &#60;body&#62;
 &#60;ui:composition template=&#34;./layout.xhtml&#34;&#62;
     &#60;ui:define name=&#34;header&#34;&#62;
         &#60;ui:include src=&#34;./header.xhtml&#34;/&#62;
     &#60;/ui:define&#62;
     &#60;ui:define name=&#34;rightColumn&#34;&#62;
         Ads here
     &#60;/ui:define&#62;
     &#60;ui:define name=&#34;leftColumn&#34;&#62;
        &#60;ui:include src=&#34;./sideBar.xhtml&#34;/&#62;
     &#60;/ui:define&#62;
     &#60;ui:define name=&#34;content&#34;&#62;
         &#60;rich:panel id=&#34;contentRichPanel&#34; style=&#34;position: relative;&#34;&#62;
             &#60;ui:include src=&#34;#{PageViewIdGenerator.includedPage}&#34;/&#62;
         &#60;/rich:panel&#62;
     &#60;/ui:define&#62;
     &#60;ui:define name=&#34;footer&#34;&#62;
         &#60;ui:include src=&#34;./footer.xhtml&#34;/&#62;
     &#60;/ui:define&#62;
 &#60;/ui:composition&#62;
 &#60;/body&#62;
&#60;/html&#62;</pre>
<p><em><strong>3.construct header.xhtml</strong></em></p>
<p>The template header.xhml should be wrapped inside the ui:define tag of layout-Client.xhml template.</p>
<p><em><strong>header.xhtml</strong></em></p>
<pre class="brush: css;">

&#60;?xml version='1.0' encoding='UTF-8' ?&#62;
&#60;!DOCTYPE html PUBLIC &#34;-//W3C//DTD XHTML 1.0 Transitional//EN&#34; &#34;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#34;&#62;
&#60;html xmlns=&#34;http://www.w3.org/1999/xhtml&#34;
 xmlns:ui=&#34;http://java.sun.com/jsf/facelets&#34;
 xmlns:f=&#34;http://java.sun.com/jsf/core&#34;
 xmlns:h=&#34;http://java.sun.com/jsf/html&#34;
 xmlns:a4j=&#34;http://richfaces.org/a4j&#34;
 xmlns:rich=&#34;http://richfaces.org/rich&#34;&#62;
 &#60;body&#62;
 &#60;h:form method=&#34;post&#34;&#62;
     &#60;rich:panel style=&#34;position: relative;width: auto&#34;&#62;
         &#60;h:outputText value=&#34;Sample Demo Page&#34;&#62;&#60;/h:outputText&#62;
     &#60;/rich:panel&#62;
 &#60;/h:form&#62;
 &#60;/body&#62;
&#60;/html&#62;</pre>
<p><em><strong>4.Construct sideBar.xhtml</strong></em></p>
<p>Richfaces component <em><strong>Panel Menu</strong></em> which holds the content page links is used as the side bar. This should be wrapped inside the ui:define tag of  left column or right column(Its up to you) of layout-client.xhtml.</p>
<p><em><strong>sideBar.xhtml</strong></em></p>
<pre class="brush: css;">&#60;?xml version='1.0' encoding='UTF-8' ?&#62;
&#60;!DOCTYPE html PUBLIC &#34;-//W3C//DTD XHTML 1.0 Transitional//EN&#34; &#34;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#34;&#62;
&#60;html xmlns=&#34;http://www.w3.org/1999/xhtml&#34;
 xmlns:ui=&#34;http://java.sun.com/jsf/facelets&#34;
 xmlns:f=&#34;http://java.sun.com/jsf/core&#34;
 xmlns:h=&#34;http://java.sun.com/jsf/html&#34;
 xmlns:a4j=&#34;http://richfaces.org/a4j&#34;
 xmlns:rich=&#34;http://richfaces.org/rich&#34;&#62;
 &#60;body&#62;
 &#60;h:form id=&#34;sideBarId&#34;&#62;
 &#60;!-- Richfaces panel menu --&#62;
     &#60;rich:panelMenu styleClass=&#34;panelMenu&#34; mode=&#34;none&#34; iconExpandedGroup=&#34;disc&#34; iconCollapsedGroup=&#34;disc&#34;
      iconExpandedTopGroup=&#34;chevronUp&#34; iconGroupTopPosition=&#34;right&#34;
      iconCollapsedTopGroup=&#34;chevronDown&#34; expandSingle=&#34;true&#34;&#62;
     &#60;!-- Group1 --&#62;
     &#60;rich:panelMenuGroup id=&#34;group1Id&#34; label=&#34;Group1&#34;&#62;
     &#60;!-- Page1 --&#62;
         &#60;rich:panelMenuItem&#62;
             &#60;h:commandLink id=&#34;page1LinkId&#34; value=&#34;Page1&#34;
                            action=&#34;#{PageViewIdGenerator.sideBarAction}&#34;&#62;
             &#60;f:param id=&#34;page1ParamId&#34; name=&#34;pageViewId&#34; value=&#34;Page1&#34;/&#62;
             &#60;/h:commandLink&#62;
         &#60;/rich:panelMenuItem&#62;
     &#60;!-- Page1 Ends --&#62;
     &#60;!-- Page2 --&#62;
         &#60;rich:panelMenuItem&#62;
              &#60;h:commandLink id=&#34;page2LinkId&#34; value=&#34;Page2&#34;
                             action=&#34;#{PageViewIdGenerator.sideBarAction}&#34;&#62;
              &#60;f:param id=&#34;page2ParamId&#34; name=&#34;pageViewId&#34; value=&#34;Page2&#34;/&#62;
              &#60;/h:commandLink&#62;
         &#60;/rich:panelMenuItem&#62;
     &#60;!-- Page2 Ends --&#62;
     &#60;!-- Page3 --&#62;
         &#60;rich:panelMenuItem&#62;
             &#60;h:commandLink id=&#34;page3LinkId&#34; value=&#34;Page3&#34;
                            action=&#34;#{PageViewIdGenerator.sideBarAction}&#34;&#62;
             &#60;f:param id=&#34;page3ParamId&#34; name=&#34;pageViewId&#34; value=&#34;Page3&#34;/&#62;
             &#60;/h:commandLink&#62;
         &#60;/rich:panelMenuItem&#62;
     &#60;!-- Page3 Ends --&#62;
     &#60;!-- Page4 --&#62;
         &#60;rich:panelMenuItem&#62;
             &#60;h:commandLink id=&#34;page4LinkId&#34; value=&#34;Page4&#34;
                            action=&#34;#{PageViewIdGenerator.sideBarAction}&#34;&#62;
             &#60;f:param id=&#34;page4ParamId&#34; name=&#34;pageViewId&#34; value=&#34;Page4&#34;/&#62;
             &#60;/h:commandLink&#62;
         &#60;/rich:panelMenuItem&#62;
         &#60;!-- Page4 Ends --&#62;
         &#60;!-- Page5 --&#62;
         &#60;rich:panelMenuItem&#62;
             &#60;a4j:commandLink id=&#34;page5Linkid&#34; value=&#34;Page5&#34;
                              action=&#34;#{PageViewIdGenerator.sideBarAction}&#34;&#62;
             &#60;f:param id=&#34;page5Param&#34; name=&#34;pageViewId&#34; value=&#34;Page5&#34;/&#62;
             &#60;/a4j:commandLink&#62;
         &#60;/rich:panelMenuItem&#62;
         &#60;!-- Page5 Ends --&#62;
     &#60;/rich:panelMenuGroup&#62;
     &#60;!-- End of Group1 --&#62;
     &#60;!-- Group2 --&#62;
     &#60;rich:panelMenuGroup id=&#34;group2Id&#34; label=&#34;Group2&#34;&#62;
         &#60;!-- define group2 codes here--&#62;
     &#60;/rich:panelMenuGroup&#62;
     &#60;!-- End of Group2 --&#62;
     &#60;!-- Group3 --&#62;
     &#60;rich:panelMenuGroup id=&#34;group3Id&#34; label=&#34;Group3&#34;&#62;
         &#60;!-- define group2 codes here--&#62;
     &#60;/rich:panelMenuGroup&#62;
     &#60;!-- End of Group3 --&#62;
     &#60;/rich:panelMenu&#62;
 &#60;/h:form&#62;
 &#60;/body&#62;
&#60;/html&#62;</pre>
<p><em><strong>5.Construct footer.xhtml</strong></em></p>
<p>The template footer.xhml should be wrapped inside the ui:define tag of layout-Client.xhml template.</p>
<p><em><strong>footer.xhml</strong></em></p>
<pre class="brush: css;">&#60;?xml version='1.0' encoding='UTF-8' ?&#62;
&#60;!DOCTYPE html PUBLIC &#34;-//W3C//DTD XHTML 1.0 Transitional//EN&#34; &#34;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#34;&#62;
&#60;html xmlns=&#34;http://www.w3.org/1999/xhtml&#34;
 xmlns:ui=&#34;http://java.sun.com/jsf/facelets&#34;
 xmlns:f=&#34;http://java.sun.com/jsf/core&#34;
 xmlns:h=&#34;http://java.sun.com/jsf/html&#34;
 xmlns:a4j=&#34;http://richfaces.org/a4j&#34;
 xmlns:rich=&#34;http://richfaces.org/rich&#34;&#62;
 &#60;body&#62;
 &#60;h:form method=&#34;post&#34;&#62;
     &#60;rich:panel&#62;
         &#60;h:outputText value=&#34;Footer text&#34;/&#62;
     &#60;/rich:panel&#62;
 &#60;/h:form&#62;
 &#60;/body&#62;
&#60;/html&#62;</pre>
<p><em><strong>6. Construct sample pages</strong></em></p>
<p>Create your own required templates which is to be dynamically included in the content of the layout-Client.xhtml template. But now, I have mentioned some sample pages for the reference.</p>
<p><em><strong>samplePageOne.xhml</strong></em></p>
<pre class="brush: css;">

&#60;?xml version='1.0' encoding='UTF-8' ?&#62;
&#60;!DOCTYPE html PUBLIC &#34;-//W3C//DTD XHTML 1.0 Transitional//EN&#34; &#34;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#34;&#62;
&#60;html xmlns=&#34;http://www.w3.org/1999/xhtml&#34;
 xmlns:ui=&#34;http://java.sun.com/jsf/facelets&#34;
 xmlns:f=&#34;http://java.sun.com/jsf/core&#34;
 xmlns:h=&#34;http://java.sun.com/jsf/html&#34;
 xmlns:a4j=&#34;http://richfaces.org/a4j&#34;
 xmlns:rich=&#34;http://richfaces.org/rich&#34;&#62;
 &#60;body&#62;
 &#60;h:form&#62;
     &#60;h:outputLabel value=&#34;Hello this is Page One&#34;/&#62;
 &#60;/h:form&#62;
 &#60;/body&#62;
&#60;/html&#62;</pre>
<p><em><strong>samplePageTwo.xhml</strong></em></p>
<pre class="brush: css;">

&#60;?xml version='1.0' encoding='UTF-8' ?&#62;
 &#60;!DOCTYPE html PUBLIC &#34;-//W3C//DTD XHTML 1.0 Transitional//EN&#34; &#34;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#34;&#62;
 &#60;html xmlns=&#34;http://www.w3.org/1999/xhtml&#34;
 xmlns:ui=&#34;http://java.sun.com/jsf/facelets&#34;
 xmlns:f=&#34;http://java.sun.com/jsf/core&#34;
 xmlns:h=&#34;http://java.sun.com/jsf/html&#34;
 xmlns:a4j=&#34;http://richfaces.org/a4j&#34;
 xmlns:rich=&#34;http://richfaces.org/rich&#34;&#62;
 &#60;body&#62;
 &#60;h:form&#62;
     &#60;h:outputLabel value=&#34;Hello this is Page Two&#34;/&#62;
 &#60;/h:form&#62;
 &#60;/body&#62;
 &#60;/html&#62;</pre>
<p>So far we have created xhtml documents like header, sideBar, rightColumn and the footer which is to be included statically in the layout.xhml web page. Now let us see how the samplePageOne.xhml(Page1) and samplePageTwo.xhtml(Page2) links of sideBar are dynamically included in the content of layout-Client.xhtml.</p>
<p><strong><span style="color:#000000;">Part2</span>-Dynamic Include</strong></p>
<p>Dynamic include can be accomplished with use of the <em><strong>f:param tag defined in the </strong><strong>sideBar</strong></em><em><strong>.xhtml</strong></em>, where we can easily find the clicked link of sideBar. So that the page will be dynamically included in the content of layout.xhtml. we need to construct a backing bean and to configure the managed bean in the faces-config.xml to invoke this.</p>
<p><em><strong>faces-config.xml Configuration</strong></em></p>
<pre class="brush: css;">
&#60;managed-bean&#62;
 &#60;managed-bean-name&#62;PageViewIdGenerator&#60;/managed-bean-name&#62;
 &#60;managed-bean-class&#62;com.layout.PageViewIdGenerator&#60;/managed-bean-class&#62;
 &#60;managed-bean-scope&#62;session&#60;/managed-bean-scope&#62;
&#60;/managed-bean&#62;</pre>
<p>The pertinent backing bean code look like,</p>
<p><em><strong>PageViewIdGenerator.java</strong></em></p>
<pre class="brush: css;">

package com.layout;

import javax.faces.context.FacesContext;
/**
 * @author giftsam
 */
public class PageViewIdGenerator
{
private String includedPage = &#34;/samplePageTwo.xhtml&#34;;

public String sideBarAction()
{
           /**
           * Get the request parameter map from the context, so that we can find which link of the side is clicked
           */
           FacesContext context = FacesContext.getCurrentInstance();
           String selectedPageViewId =
                  context.getExternalContext().getRequestParameterMap().get(&#34;pageViewId&#34;);

           if (selectedPageViewId.equalsIgnoreCase(&#34;page1&#34;))
           {
               includedPage = &#34;/samplePageOne.xhtml&#34;;
           }
           else if (selectedPageViewId.equalsIgnoreCase(&#34;page2&#34;))
           {
               includedPage = &#34;/samplePageTwo.xhtml&#34;;
           }
           else if (selectedPageViewId.equalsIgnoreCase(&#34;page3&#34;))
           {
               includedPage = &#34;/samplePageThree.xhtml&#34;;
           }
           else if (selectedPageViewId.equalsIgnoreCase(&#34;page4&#34;))
           {
               includedPage = &#34;/samplePageFour.xhtml&#34;;
           }
     return &#34;&#34;;
 }

 /**
 * @return the includedPage
 */
 public String getIncludedPage()
 {
 return includedPage;
 }

 /**
 * @param includedPage the includedPage to set
 */
 public void setIncludedPage(String includedPage)
 {
 this.includedPage = includedPage;
 }
}</pre>
<p>Thatsall folks, now we have created a complete demo application, where samplePageOne.xhml and samplePageTwo.xhtml are included dynamically where as xhtml documents like header, leftColumn, rightColumn and the footer are included statically. Here is the snaps of our sample demo application.</p>
<p><strong>Sample Demo Snaps</strong></p>
<p>Snap1 specifies the dynamic include of samplePageOne when the page1 of sideBar is clicked.</p>
<p><img title="Layout DemoSnap1" src="http://technicalbrainwave.wordpress.com/files/2009/10/layoutdemosnap1.png" alt="Layout DemoSnap1" width="600" height="270" /></p>
<p>Snap2 specifies the dynamic include of samplePageOne when the page2 of sideBar is clicked.</p>
<p><img title="Layout Sample Demo2" src="http://technicalbrainwave.wordpress.com/files/2009/10/layoutsampledemo2.jpg" alt="Layout Sample Demo2" width="600" height="270" /></p>
<p><strong>Conclusion</strong></p>
<p>In this article, we have learned how to constuct a complete layout using facelets as a view technology and also we have learned how to include the pages dynamically, so that you can make use of serveral JSF forms more dynamic. If you find this article is useful to you dont forget to share with me by your valuable comments. Have a joyous code day.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[JSF+Facelets+Richfaces Installation-Guide]]></title>
<link>http://technicalbrainwave.wordpress.com/2009/10/16/jsffaceletsrichfaces-installation-guide/</link>
<pubDate>Fri, 16 Oct 2009 12:07:53 +0000</pubDate>
<dc:creator>Gift Sam</dc:creator>
<guid>http://technicalbrainwave.wordpress.com/2009/10/16/jsffaceletsrichfaces-installation-guide/</guid>
<description><![CDATA[Introduction: Installing facelets together with richfaces is very simple. I used to develope web app]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p><strong>Introduction:</strong></p>
<p>Installing facelets together with richfaces is very simple. I used to develope web applications with JSF and its libraries like richfaces, Icefaces and so on. But I felt, my application have achieved a greater landmark only after implementing facelets. The reason is, facelets contains obliging features like templating(Similarly like struts), Composition components(Reuse can be achieved), also resolves the mismatch between JSF and JSP technologies(Eg: &#60;jsp:param&#62; tag cannot be used in JSF while using &#60;jsp:include&#62; tag) and so on. This article explains the installation of Richfaces and facelets with JSF.<!--more--></p>
<p><strong>Prerequisites:</strong></p>
<ul>
<li>IDE &#8211; Netbeans 6.x or Eclipse(Now Netbeans 6.7 provides the feature for creating facelets projects)</li>
<li>Tomcat 6.x or Glassfish</li>
<li>JDK 1.5 and above</li>
</ul>
<p>Installing facelets can be accomplished by four steps in a web application project. If you are the one who use Netbeans 6.7 IDE which provides the features for creating facelet projects kindly skip the below step1 and step3 and just add the richfaces jars specified in the libraries and configure richfaces in web.xml. Others kindly follow the below steps,</p>
<p><strong>Step1:</strong></p>
<p>In step1, download and ensure that your projects WEB-INF/lib directory contains the below jar files.</p>
<p><em><strong>Libraries:</strong></em></p>
<ul>
<li>commons-beanutils.jar</li>
<li>commons-collections.jar</li>
<li>commons-digester.jar</li>
<li>commons-logging.jar</li>
<li>el-ri.jar</li>
<li>jhighlight-1.0.jar</li>
<li>jsf-api.jar</li>
<li>jsf-facelets.jar</li>
<li>jsf-impl.jar</li>
<li>jstl.jar</li>
<li>richfaces-api-3.3.1.GA.jar</li>
<li>richfaces-impl-3.3.1.GA.jar</li>
<li>richfaces-ui-3.3.1.GA.jar</li>
</ul>
<p><strong>Step2:</strong></p>
<p>Step2 clearly explains how to configure the web.xml for the facelet projects. Your web.xml file should contains the following configurations for the JSF+Facelets+Richfaces Installations.</p>
<p><em><strong>web.xml configuration:</strong></em></p>
<pre class="brush: css;">

&#60;?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34;?&#62;

&#60;web-app version=&#34;2.5&#34; xmlns=&#34;http://java.sun.com/xml/ns/javaee&#34; xmlns:xsi=&#34;http://www.w3.org/2001/XMLSchema-instance&#34; xsi:schemaLocation=&#34;http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd&#34;&#62;

&#60;context-param&#62;
&#60;param-name&#62;com.sun.faces.verifyObjects&#60;/param-name&#62;
&#60;param-value&#62;true&#60;/param-value&#62;
&#60;/context-param&#62;
&#60;context-param&#62;
&#60;param-name&#62;com.sun.faces.validateXml&#60;/param-name&#62;
&#60;param-value&#62;true&#60;/param-value&#62;
&#60;/context-param&#62;
&#60;context-param&#62;
&#60;param-name&#62;javax.faces.DEFAULT_SUFFIX&#60;/param-name&#62;
&#60;param-value&#62;.xhtml&#60;/param-value&#62;
&#60;/context-param&#62;
&#60;context-param&#62;
&#60;param-name&#62;facelets.DEVELOPMENT&#60;/param-name&#62;
&#60;param-value&#62;false&#60;/param-value&#62;
&#60;/context-param&#62;
&#60;context-param&#62;
&#60;param-name&#62;facelets.SKIP_COMMENTS&#60;/param-name&#62;
&#60;param-value&#62;true&#60;/param-value&#62;
&#60;/context-param&#62;
&#60;!-- Richfaces Configuration--&#62;
&#60;context-param&#62;
&#60;param-name&#62;org.richfaces.SKIN&#60;/param-name&#62;
&#60;param-value&#62;wine&#60;/param-value&#62;
&#60;/context-param&#62;
&#60;context-param&#62;
&#60;param-name&#62;org.ajax4jsf.VIEW_HANDLERS&#60;/param-name&#62;
&#60;param-value&#62;com.sun.facelets.FaceletViewHandler&#60;/param-value&#62;
&#60;/context-param&#62;
&#60;filter&#62;
&#60;display-name&#62;RichFaces Filter&#60;/display-name&#62;
&#60;filter-name&#62;richfaces&#60;/filter-name&#62;
&#60;filter-class&#62;org.ajax4jsf.Filter&#60;/filter-class&#62;
&#60;/filter&#62;
&#60;filter-mapping&#62;
&#60;filter-name&#62;richfaces&#60;/filter-name&#62;
&#60;servlet-name&#62;Faces Servlet&#60;/servlet-name&#62;
&#60;dispatcher&#62;REQUEST&#60;/dispatcher&#62;
&#60;dispatcher&#62;FORWARD&#60;/dispatcher&#62;
&#60;dispatcher&#62;INCLUDE&#60;/dispatcher&#62;
&#60;/filter-mapping&#62;
&#60;servlet&#62;
&#60;servlet-name&#62;Faces Servlet&#60;/servlet-name&#62;
&#60;servlet-class&#62;javax.faces.webapp.FacesServlet&#60;/servlet-class&#62;
&#60;load-on-startup&#62;1&#60;/load-on-startup&#62;
&#60;/servlet&#62;
&#60;servlet-mapping&#62;
&#60;servlet-name&#62;Faces Servlet&#60;/servlet-name&#62;
&#60;url-pattern&#62;*.jsf&#60;/url-pattern&#62;
&#60;/servlet-mapping&#62;
&#60;session-config&#62;
&#60;session-timeout&#62;
30
&#60;/session-timeout&#62;
&#60;/session-config&#62;
&#60;welcome-file-list&#62;
&#60;welcome-file&#62;index.jsp&#60;/welcome-file&#62;
&#60;/welcome-file-list&#62;
&#60;/web-app&#62;</pre>
<p><strong>Step3:</strong></p>
<p>Step3 explains the faces-config configurations.</p>
<p><em><strong>faces-config configuration:</strong></em></p>
<pre class="brush: css;">&#60;application&#62;
&#60;view-handler&#62;
com.sun.facelets.FaceletViewHandler
&#60;/view-handler&#62;
&#60;/application&#62;</pre>
<p>Now you have completed the installation successfully and next you need create web pages in xhtml documents and you should specify the taglibs in XML namespaces instead of JSP taglibs.<br />
<strong></strong></p>
<p><strong>Step4:</strong></p>
<p>Create a xhtml document and your web page should contain the taglibs as stated in sample.xhtml, so that you can use the rich faces components together with facelets.<br />
<em><strong></strong></em></p>
<p><em><strong>sample.xhtml</strong></em></p>
<pre class="brush: css;">
&#60;?xml version='1.0' encoding='UTF-8' ?&#62;
&#60;!DOCTYPE html PUBLIC &#34;-//W3C//DTD XHTML 1.0 Transitional//EN&#34; &#34;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#34;&#62;
&#60;html xmlns=&#34;http://www.w3.org/1999/xhtml&#34;
xmlns:ui=&#34;http://java.sun.com/jsf/facelets&#34;
xmlns:f=&#34;http://java.sun.com/jsf/core&#34;
xmlns:h=&#34;http://java.sun.com/jsf/html&#34;
xmlns:a4j=&#34;http://richfaces.org/a4j&#34;
xmlns:rich=&#34;http://richfaces.org/rich&#34;&#62;
&#60;body&#62;
&#60;h:form method=&#34;post&#34;&#62;
&#60;rich:panel&#62;
&#60;h:outputText value=&#34;Sample Text&#34;&#62;&#60;/h:outputText&#62;
&#60;/rich:panel&#62;
&#60;/h:form&#62;
&#60;/body&#62;
&#60;/html&#62;</pre>
<p>Thatsall folks. I hope this article clearly explains the installation of Facelets and Richfaces with JSF. Some may say, this article is only about installation, but I want to get in to the action!!. Dont worry just follow the link <a href="http://technicalbrainwave.wordpress.com/2009/10/18/layouting-and-dynamic-includes-in-facelets/">Layouting and Dynamic include in Facelets</a> , which will help you to construct templates and dynamic include using Facelets. <em><strong>If you find this article is quite useful, Dont forget to share with me by your valuable comments</strong></em>. Have a joyous code day.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Using ui:insert to include children]]></title>
<link>http://digitaljoel.wordpress.com/2009/09/28/using-uiinsert-to-include-children/</link>
<pubDate>Tue, 29 Sep 2009 04:20:26 +0000</pubDate>
<dc:creator>digitaljoel</dc:creator>
<guid>http://digitaljoel.wordpress.com/2009/09/28/using-uiinsert-to-include-children/</guid>
<description><![CDATA[Let&#8217;s say you have a custom facelets component that wraps an h:selectOneListbox. As a part of ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Let&#8217;s say you have a custom facelets component that wraps an h:selectOneListbox.  As a part of using this component, you read the list of items that should be displayed in the list from a database table.  Your bean reads the results of the database query and creates listItems, that are then passed back to the h:selectOneListbox, through your my:customListbox component.  For instance:</p>
<pre class="brush: xml;">
            &#60;my:customListbox
              fieldName=&#34;itemValue&#34;
              entity=&#34;#{myBean}&#34;
              items=&#34;#{myDatabaseBean.listItems}&#34; /&#62;
</pre>
<p>In this example, the value of the h:selectOne would be set in myBean.setItemValue, and the list of selectItems would be returned from myDatabaseBean.getListItems.</p>
<p>Now, you decide that you want to provide some defaults for the lists that are in your UI, but not in the database.  You could modify myDatabaseBean.getListItems to manually add a custom default selectItem.  The value of the defaultItem could be null, or empty string, that way, when the list is displayed, if myBean.getItemValue returns null or empty string, the default value would be selected in the UI.  Pretty slick, except for you have to write java in EVERY instance where you are creating your listItems from the database.   Now, add in internationalization and your database bean now has to use the correct resource bundle to read the default value display string.  That&#8217;s not real difficult, but it&#8217;s just more java code that has to be introduced everywhere you are creating those lists.</p>
<p>So, is there another way?  Here&#8217;s what I did.</p>
<p>In my customListbox component I included a well placed, anonymous ui:insert.  This magically made my composition include the children of my customListbox in place of the unnamed ui:insert.  For instance, within customListbox.xhtml my h:selectOneListbox now looks like this:</p>
<pre class="brush: xml;">
    &#60;h:selectOneListbox value=&#34;#{entity[fieldName]}&#34;&#62;
      &#60;ui:insert /&#62;
      &#60;f:selectItems value=&#34;#{items}&#34; /&#62;
    &#60;/h:selectOneListbox&#62;
</pre>
<p>Then I can include multiple f:selectItem elements as a child of my:customListbox such as:</p>
<pre class="brush: xml;">
&#60;my:customListbox
    fieldName=&#34;itemValue&#34;
    entity=&#34;#{myBean}&#34;
    items=&#34;#{myDatabaseBean.listItems}&#34; &#62;
    &#60;f:selectItem itemValue=&#34;&#34; itemLabel=&#34;#{bundle.defaultBlahValue}&#34; /&#62;
&#60;/my:customListbox&#62;
</pre>
<p>Now, I&#8217;ve been able to add a custom default value to my custom listbox with a single line in xhtml, and a single resource bundle value, and no java.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[JSF Tips and Tricks]]></title>
<link>http://rajivas.wordpress.com/2009/09/19/jsf-tips-and-tricks/</link>
<pubDate>Sat, 19 Sep 2009 18:52:48 +0000</pubDate>
<dc:creator>rajivas</dc:creator>
<guid>http://rajivas.wordpress.com/2009/09/19/jsf-tips-and-tricks/</guid>
<description><![CDATA[Even though at surface JSF may seem easier framework to workwith it is not. After using it for a whi]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p style="margin-bottom:0;">Even though at surface JSF may seem easier framework to workwith it is not.  After using it for a while  a new deveoper may encounter a problem which may seem trivial in other frameworks or servlet/JSP implementation but very difficult  to achieve the  same result in it.</p>
<p style="margin-bottom:0;">
<p style="margin-bottom:0;">For example handling UnchekedException at JSP/View layer is very simple like just adding an ErrorPage attribute in JSP or global exception tag in Struts. To do the same in JSF-Facelets we may need to write customActionListener/delegation servlet but  these are not standards.</p>
<p style="margin-bottom:0;">
<p style="margin-bottom:0;">
<p style="margin-bottom:0;">Since JSP servlet development is request/response based to the JSF Event/Component based architecture it is bit difficult to adopt. JSF is similar to Swing so a Swing developer may find it very easy.</p>
<p style="margin-bottom:0;">
<p style="margin-bottom:0;">
<p style="margin-bottom:0;">Using Facelets as View in JSF application may contribute to further complications to the regular JSP-Struts Developer.</p>
<p style="margin-bottom:0;">
<p style="margin-bottom:0;">
<p style="margin-bottom:0;">Use RichFaces or MyFaces, as these frameworks provide rich UI components along with AJAX support out of the box developing professional looking application is a breeze.</p>
<p style="margin-bottom:0;">
<p style="margin-bottom:0;"><strong>Uses of  Facelets:</strong> It provides templating feature simlar to tiles.  It is faster than JSP.</p>
<p style="margin-bottom:0;">We can avoid using JSTL and scriptlets completely in Facelets.</p>
<p style="margin-bottom:0;">nstead of using c:if use rendered attribute to optionally display a block of html/Facelet code.</p>
<p style="margin-bottom:0;">To iterate over a list or collection use h:dataTable or h:colum instead of using c:forEach</p>
<p style="margin-bottom:0;">Unified EL is evaluated at runtime where as JSTL and EL tags are evaluated at compile time.</p>
<p style="margin-bottom:0;">
<p style="margin-bottom:0;"><strong>Writing directly to response stream in JSF</strong></p>
<p style="margin-bottom:0;"><strong><br />
</strong></p>
<p style="margin-bottom:0;font-weight:normal;">Writing to a response stream directly in JSF is not recommended but there are instances where we need this feature like report generation.  If we need to export PDF or any binary files in a JSF application  the code would be as below.</p>
<p style="margin-bottom:0;font-weight:normal;">
<p style="margin-bottom:0;"><span style="font-family:Courier New,monospace;"><strong><span style="color:#7f0055;">public</span><span style="color:#000000;"> </span><span style="color:#7f0055;">void</span><span style="color:#000000;"> writeToResponse(String headerType,</span></strong></span></p>
<p style="margin-bottom:0;" align="LEFT"><span style="color:#000000;"><span style="font-family:Courier New,monospace;"> ByteArrayOutputStream bos,String reportType) {</span></span></p>
<p style="margin-bottom:0;"><span style="color:#000000;"><span style="font-family:Courier New,monospace;"><strong>FacesContext faces = FacesContext.<em>getCurrentInstance</em>();</strong></span></span></p>
<p style="margin-bottom:0;" align="LEFT"><span style="color:#000000;"><span style="font-family:Courier New,monospace;"> HttpServletResponse resp = (HttpServletResponse) faces.getExternalContext().getResponse();</span></span></p>
<p style="margin-bottom:0;" align="LEFT"><span style="font-family:Courier New,monospace;"><span style="color:#000000;"> </span><span style="color:#7f0055;"><strong>try</strong></span><span style="color:#000000;"> { </span></span></p>
<p style="margin-bottom:0;" align="LEFT"><span style="color:#000000;"><span style="font-family:Courier New,monospace;">resp.setContentType(headerType);</span></span></p>
<p style="margin-bottom:0;" align="LEFT"><span style="font-family:Courier New,monospace;"><span style="color:#000000;"> resp.setHeader(</span><span style="color:#2a00ff;">&#8220;Content-Disposition&#8221;</span><span style="color:#000000;">, </span><span style="color:#2a00ff;">&#8220;inline;filename=&#8221;</span><span style="color:#000000;"> + </span><span style="color:#0000c0;">reportName</span><span style="color:#000000;"> + </span><span style="color:#2a00ff;">&#8220;.&#8221;</span><span style="color:#000000;"> + reportType );</span></span></p>
<p style="margin-bottom:0;" align="LEFT"><span style="color:#000000;"><span style="font-family:Courier New,monospace;">bos.writeTo(sos);</span></span></p>
<p style="margin-bottom:0;" align="LEFT"><span style="color:#000000;"><span style="font-family:Courier New,monospace;"> sos.flush();</span></span></p>
<p style="margin-bottom:0;" align="LEFT"><span style="font-family:Courier New,monospace;"><span style="color:#000000;"> faces.responseComplete();</span><span style="color:#3f7f5f;">// without this response write error will come</span></span></p>
<p style="margin-bottom:0;" align="LEFT"><span style="font-family:Courier New,monospace;"><span style="color:#000000;"> } </span><span style="color:#7f0055;"><strong>catch</strong></span><span style="color:#000000;"> (IOException e) {</span></span></p>
<p style="margin-bottom:0;" align="LEFT"><span style="color:#000000;"><span style="font-family:Courier New,monospace;"> </span></span></p>
<p style="margin-bottom:0;" align="LEFT"><span style="color:#000000;"><span style="font-family:Courier New,monospace;"> e.printStackTrace();</span></span></p>
<p style="margin-bottom:0;" align="LEFT"><span style="color:#000000;"><span style="font-family:Courier New,monospace;"> } </span></span></p>
<p style="margin-bottom:0;" align="LEFT"><span style="color:#000000;"> <span style="font-family:Courier New,monospace;"><strong>}</strong></span></span></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[JSF - Aplicação rich:editor + Facelets]]></title>
<link>http://serjaum.wordpress.com/2009/09/15/jsf-aplicacao-pratica-utilizando-richeditor/</link>
<pubDate>Tue, 15 Sep 2009 01:37:36 +0000</pubDate>
<dc:creator>serjaumfantin</dc:creator>
<guid>http://serjaum.wordpress.com/2009/09/15/jsf-aplicacao-pratica-utilizando-richeditor/</guid>
<description><![CDATA[Neste post irei demonstrar a utilização do componente rich:editor que faz parte da biblioteca de com]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p><span style="color:#000000;">Neste post irei demonstrar a utilização do componente <a href="http://livedemo.exadel.com/richfaces-demo/richfaces/editor.jsf?c=editor&#38;tab=usage">rich:editor</a> que faz parte da biblioteca de componentes RichFaces.</span></p>
<p><span style="color:#000000;">O rich:editor é um componente usado para a criação de um editor em páginas. Seu uso é relativamente simples e o resultado é impressionante.</span></p>
<p><span style="color:#000000;">A aplicação consiste num cadastro de Rascunhos onde o usuário poderá cadastrar e remover seus rascunhos de uma forma prática e simples. Para gerenciar as sessões/transações do Hibernate criei um serlvet filter <a href="https://www.hibernate.org/43.html">Open Session In View</a> fazendo papel de um interceptador, que será executado a cada request e response.</span></p>
<p><span style="color:#000000;">Utilizarei <a href="http://tomcat.apache.org/">Tomcat</a>, <a href="https://www.hibernate.org/">Hibernate</a> e <a href="http://www.mysql.com/">MySQL</a> para a persistência de dados e disponilizarei o projeto para download.</span></p>
<h2>Estrutura do projeto</h2>
<p style="text-align:center;"><img class="aligncenter size-full wp-image-843" title="rich_editor" src="http://serjaum.wordpress.com/files/2009/09/rich_editor.png" alt="rich_editor" width="280" height="500" /></p>
<h2>Versões utilizadas</h2>
<ul>
<li><span style="color:#000000;">Eclipse 3.4.1</span></li>
<li><span style="color:#000000;">JDK 1.6</span></li>
<li><span style="color:#000000;">Tomcat 6.0.18</span></li>
<li><span style="color:#000000;">MyFaces 1.2.5</span></li>
<li><span style="color:#000000;">RichFaces 3.3.1</span></li>
<li><span style="color:#000000;">Hibernate Annotations 3.4.0</span></li>
<li><span style="color:#000000;">Hibernate 3.3.1</span></li>
<li><span style="color:#000000;">MySQL 5</span></li>
<li><span style="color:#000000;">MySQL Query Browser 1.2</span></li>
</ul>
<h2>Códigos</h2>
<p><strong>Rascunho.java: </strong></p>
<blockquote>
<pre>package br.com.serjaum.modelo;

@Entity
@Table(name="rascunho")
public class Rascunho implements Serializable{

 private static final long serialVersionUID = -6142163109498247473L;

 @Id
 @GeneratedValue(strategy=GenerationType.IDENTITY)
 @Column(name="RASCUNHO_ID")
 private Long id;

 @Column(name="titulo")
 private String titulo;

 @Temporal(TemporalType.DATE)
 @Column(name="data")
 private Date data = new Date();    

 @Lob
 @Column(name="conteudo")
 private String conteudo;

...
}</pre>
</blockquote>
<p><!--more--><strong>RascunhoMB.java: </strong></p>
<blockquote>
<pre>package br.com.serjaum.mb;

public class RascunhoMB implements Serializable {

 private static final long serialVersionUID = -7138652046367400871L;

 private Long id;

 private Rascunho rascunho = new Rascunho();

 public RascunhoMB(){
 System.out.println(" &#62;&#62;&#62;&#62;&#62;&#62;&#62;&#62;&#62;&#62;&#62;&#62;&#62;&#62;&#62;&#62;&#62;&#62;&#62;&#62; Construtor do RASCUNHO_MB &#60;&#60;&#60;&#60;&#60;&#60;&#60;&#60;&#60;&#60;&#60;&#60;&#60;&#60;&#60;&#60;&#60;&#60;");

 if(this.rascunho == null){
 this.rascunho = new Rascunho();
 }
 }

 public String save(){
 Session session = HibernateUtil.currentSession();
 RascunhoDAO rascunhoDAO = new RascunhoDAO(session, Rascunho.class);

 rascunhoDAO.save(this.rascunho);

 this.rascunho = new Rascunho();
 return "toIndex";
 }

 public String delete(){
 Session session = HibernateUtil.currentSession();
 RascunhoDAO rascunhoDAO = new RascunhoDAO(session, Rascunho.class);

 this.rascunho = rascunhoDAO.load(this.id);
 rascunhoDAO.delete(this.rascunho);
 this.rascunho = new Rascunho(); 

 return "removeSucesso";
 }

 public String merge(){
 Session session = HibernateUtil.currentSession();
 RascunhoDAO rascunhoDAO = new RascunhoDAO(session, Rascunho.class);
 rascunhoDAO.merge(this.rascunho);
 this.rascunho = new Rascunho(); 

 return "atualizaSucesso";
 }

 public String load(){
 Session session = HibernateUtil.currentSession();
 RascunhoDAO rascunhoDAO = new RascunhoDAO(session, Rascunho.class);

 this.rascunho = rascunhoDAO.load(this.id);

 return "pesquisaSucesso";
 }

 public String pesquisaByTitulo(){
 Session session = HibernateUtil.currentSession();
 RascunhoDAO rascunhoDAO = new RascunhoDAO(session, Rascunho.class);

 this.rascunho = rascunhoDAO.pesquisaRascunhoByTitulo(this.rascunho.getTitulo());

 return "pesquisaByTituloSucesso";
 }

 public String exibeRascunho(){
 Session session = HibernateUtil.currentSession();
 RascunhoDAO rascunhoDAO = new RascunhoDAO(session, Rascunho.class);

 this.rascunho = rascunhoDAO.load(this.id);

 return "toRascunho";
 }

 public List&#60;Rascunho&#62; getRascunhos(){
 Session session = HibernateUtil.currentSession();
 RascunhoDAO rascunhoDAO = new RascunhoDAO(session, Rascunho.class);

 return rascunhoDAO.list();
 }

 public Long getId() {
 return id;
 }

 public void setId(Long id) {
 this.id = id;
 }

 public Rascunho getRascunho() {
 return rascunho;
 }

 public void setRascunho(Rascunho rascunho) {
 this.rascunho = rascunho;
 }
}</pre>
</blockquote>
<p><strong>cadastraRascunho.xhtml: </strong></p>
<blockquote>
<pre>&#60;?xml version="1.0" encoding="ISO-8859-1"?&#62;
&#60;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&#62;
&#60;html xmlns="http://www.w3.org/1999/xhtml"
 xmlns:ui="http://java.sun.com/jsf/facelets"
 xmlns:h="http://java.sun.com/jsf/html"
 xmlns:f="http://java.sun.com/jsf/core"
 xmlns:a4j="http://richfaces.org/a4j"
 xmlns:rich="http://richfaces.org/rich"&#62;
 &#60;head&#62;
 &#60;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /&#62;
 &#60;/head&#62;

 &#60;a4j:keepAlive beanName="rascunhoMB" /&#62;

 &#60;ui:composition template="/template/template.xhtml"&#62;
 &#60;ui:define name="corpo"&#62;
 &#60;h:form&#62;
 &#60;rich:messages /&#62;

 &#60;fieldset&#62;
 &#60;legend&#62;Rascunho&#60;/legend&#62;
 &#60;h:panelGrid columns="1"&#62;
 &#60;h:outputLabel for="titulo" value="Título "/&#62;
 &#60;h:inputText id="titulo" value="#{rascunhoMB.rascunho.titulo }" required="true" requiredMessage="Preencha o Título do Rascunho" styleClass="edit" size="35" /&#62;

 &#60;h:outputLabel for="conteudo" value="Conteúdo "  /&#62;
 &#60;rich:editor id="conteudo" theme="advanced" value="#{rascunhoMB.rascunho.conteudo}" required="true" requiredMessage="Preencha o Conteúdo do Rascunho" height="300" width="700"/&#62;
 &#60;/h:panelGrid&#62;

 &#60;a4j:commandButton value="Salvar " action="#{rascunhoMB.save}" styleClass="botoes"/&#62;
 &#60;h:commandButton value="Voltar " action="toIndex" immediate="true" styleClass="botoes"/&#62;
 &#60;/fieldset&#62;
 &#60;/h:form&#62;
 &#60;/ui:define&#62;
 &#60;/ui:composition&#62;
&#60;/html&#62;</pre>
</blockquote>
<p><strong>rascunho.xhtml: </strong></p>
<blockquote>
<pre>&#60;?xml version="1.0" encoding="ISO-8859-1"?&#62;
&#60;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&#62;
&#60;html xmlns="http://www.w3.org/1999/xhtml"
 xmlns:ui="http://java.sun.com/jsf/facelets"
 xmlns:h="http://java.sun.com/jsf/html"
 xmlns:f="http://java.sun.com/jsf/core"
 xmlns:a4j="http://richfaces.org/a4j"
 xmlns:rich="http://richfaces.org/rich"&#62;
 &#60;head&#62;
 &#60;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /&#62;
 &#60;/head&#62;

 &#60;a4j:keepAlive beanName="rascunhoMB" /&#62;

 &#60;ui:composition template="/template/template.xhtml"&#62;
 &#60;ui:define name="corpo"&#62;
 &#60;h:form&#62;
 &#60;rich:messages /&#62;

 &#60;fieldset&#62;
 &#60;legend&#62;Rascunho&#60;/legend&#62;
 &#60;h:panelGrid columns="2"&#62;
 &#60;h:outputLabel for="titulo" value="Título "  /&#62;
 &#60;h:outputLabel id="titulo" readonly="true" value="#{rascunhoMB.rascunho.titulo}" style=" width : 254px;"/&#62;

 &#60;h:outputLabel for="data" value="Data "  /&#62;
 &#60;h:outputLabel id="data" readonly="true" value="#{rascunhoMB.rascunho.data}" style=" width : 254px;"&#62;
 &#60;f:convertDateTime pattern="dd/MM/yyyy" /&#62;
 &#60;/h:outputLabel&#62;
 &#60;/h:panelGrid&#62;    

 &#60;h:panelGrid columns="1"&#62;
 &#60;rich:editor theme="advanced" autoResize="true" value="#{rascunhoMB.rascunho.conteudo}" height="300" width="822" readonly="true"/&#62;
 &#60;/h:panelGrid&#62;                

 &#60;a4j:commandButton value="Salvar " action="#{rascunhoMB.save}" styleClass="botoes"/&#62;
 &#60;h:commandButton value="Voltar " action="toGerenciaRascunhos" immediate="true" styleClass="botoes"/&#62;
 &#60;/fieldset&#62;
 &#60;/h:form&#62;
 &#60;/ui:define&#62;
 &#60;/ui:composition&#62;
&#60;/html&#62;</pre>
</blockquote>
<h2><span style="color:#888888;">Importando o projeto</span></h2>
<ol>
<li><span style="color:#000000;">Baixe o projeto completo &#62;&#62;<a href="http://www.4shared.com/file/132691995/170230d9/rich_editor_facelets.html">aqui</a>&#60;&#60;;</span></li>
<li><span style="color:#000000;">Descompacte o projeto no seu <em>workspace</em>;</span></li>
<li><span style="color:#000000;">No Eclipse vá em: File –&#62; Import –&#62; General – Existing Projects into Workspace –&#62; Next –&#62; Selecione o projeto descompactado no workspace –&#62; Finish.</span></li>
</ol>
<h2><span style="color:#888888;">Criando o banco de dados</span></h2>
<ol>
<li><span style="color:#000000;">Com o MySQL instalado e configurado com usuário: <strong>root</strong> e senha: <strong>root</strong> crie um novo schema com o nome de <strong><em>jsf</em></strong>.</span></li>
<li><span style="color:#000000;">Execute a classe <em>br.com.serjaum.util.<strong>GerarTabelas.java. </strong>E</em>ssa classe criará as tabelas que foram mapeadas no arquivo <em>hibernate.cfg.xml</em>, no caso a classe <strong>Rascunho</strong> terá uma tabela correspondente com o nome de <strong>rascunho</strong> no nosso banco de dados.</span></li>
</ol>
<h2><span style="color:#888888;">Resultado</span></h2>
<p style="text-align:center;"><span style="color:#888888;"><img class="aligncenter size-full wp-image-853" title="resultado1" src="http://serjaum.wordpress.com/files/2009/09/resultado11.png" alt="resultado1" width="622" height="521" /></span></p>
<p style="text-align:center;"><span style="color:#888888;"><img class="aligncenter size-full wp-image-854" title="resultado2" src="http://serjaum.wordpress.com/files/2009/09/resultado21.png" alt="resultado2" width="622" height="521" /></span></p>
<p style="text-align:center;"><span style="color:#888888;"><br />
</span></p>
<p style="text-align:left;"><span style="color:#888888;"><span style="color:#000000;">Até o próximo post!</span><br />
</span></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[JSF - Migrando CRUD para Facelets]]></title>
<link>http://serjaum.wordpress.com/2009/09/03/jsf-migrando-crud-para-facelets/</link>
<pubDate>Thu, 03 Sep 2009 02:54:12 +0000</pubDate>
<dc:creator>serjaumfantin</dc:creator>
<guid>http://serjaum.wordpress.com/2009/09/03/jsf-migrando-crud-para-facelets/</guid>
<description><![CDATA[Neste post irei fazer a migração da nossa aplicação JSF completa utilizando RichFaces + Hibernate + ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p><span style="color:#000000;">Neste post irei fazer a migração da </span><span style="color:#000000;"><a href="http://serjaum.wordpress.com/2009/08/27/jsf-%E2%80%93-tutorial-richfaces-hibernate-mysql-%E2%80%93-crud-completo-parte-final/">nossa aplicação JSF completa</a> utilizando <a href="http://www.jboss.org/jbossrichfaces/">RichFaces</a> + <a href="https://www.hibernate.org/">Hibernate</a> + <a href="http://www.mysql.com/">MySQL</a> na prática</span><span style="color:#000000;"> para <a href="https://facelets.dev.java.net/">Facelets</a>. </span></p>
<p><span style="color:#000000;">Algumas das características do Facelets: </span></p>
<ul>
<li><span style="color:#000000;">Utilização do XHTML como camada de visão da aplicação;
<p></span></li>
<li><span style="color:#000000;">Permite a criação de componentes reutilizáveis;
<p></span></li>
<li><span style="color:#000000;">Aumenta a performance da aplicação de 30% até 50% comparado com JSP, pois não usa a compilação para servlet;</span></li>
<li><span style="color:#000000;">Criação simplificada de templates;
<p></span></li>
<li><span style="color:#000000;">Uso de código JSF em tags HTML com o atributo <em>jsfc </em>(não é muito recomendado)</span><span style="color:#000000;">;</span></li>
<li><span style="color:#000000;">Camada de visão padrão para o JSF 2.0;
<p></span></li>
</ul>
<p><span style="color:#000000;">Mais informações <a href="https://facelets.dev.java.net/nonav/docs/dev/docbook.html#intro">&#62;&#62;aqui&#60;&#60;</a>.</span></p>
<h2>Versões utilizadas</h2>
<ul>
<li><span style="color:#000000;">Eclipse 3.4.1</span></li>
<li><span style="color:#000000;">JDK 1.6</span></li>
<li><span style="color:#000000;">Tomcat 6.0.18</span></li>
<li><span style="color:#000000;">MyFaces 1.2.5</span></li>
<li><span style="color:#000000;">RichFaces 3.3.1</span></li>
<li><span style="color:#000000;">Hibernate Annotations 3.4.0</span></li>
<li><span style="color:#000000;">Hibernate 3.3.1</span></li>
<li><span style="color:#000000;">MySQL 5</span></li>
<li><span style="color:#000000;">JUnit 4.5</span></li>
<li><span style="color:#000000;">Caelum Stella 1.2</span></li>
</ul>
<h2>Estrutura do projeto</h2>
<p style="text-align:center;"><img class="aligncenter size-full wp-image-820" title="crud_facelets" src="http://serjaum.wordpress.com/files/2009/09/crud_facelets.png" alt="crud_facelets" width="285" height="627" /></p>
<p><!--more--></p>
<h2>Códigos</h2>
<p><strong>atualizaPessoa.xhtml: </strong></p>
<blockquote>
<pre>&#60;?xml version="1.0" encoding="UTF-8" ?&#62;
&#60;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&#62;
&#60;html xmlns="http://www.w3.org/1999/xhtml"
 xmlns:ui="http://java.sun.com/jsf/facelets"
 xmlns:h="http://java.sun.com/jsf/html"
 xmlns:f="http://java.sun.com/jsf/core"
 xmlns:a4j="http://richfaces.org/a4j"
 xmlns:stella="http://stella.caelum.com.br/faces"
 xmlns:rich="http://richfaces.org/rich"&#62;
 &#60;head&#62;
 &#60;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&#62;
 &#60;/head&#62;

 &#60;a4j:keepAlive beanName="pessoaMB" /&#62;

 &#60;ui:composition template="/template/template.xhtml"&#62;
 &#60;ui:define name="corpo"&#62;
 &#60;h:form&#62;
 &#60;rich:messages /&#62;

 &#60;fieldset&#62;&#60;legend&#62;Atualização de Dados&#60;/legend&#62; 

 &#60;rich:dataTable value="#{pessoaMB.pessoas}" var="fisica" rows="10" id="fisicas" width="100%" cellspacing="0" cellpadding="0" border="1"&#62;
 &#60;h:column&#62;
 &#60;f:facet name="header"&#62;
 &#60;h:outputText value="NOME" /&#62;
 &#60;/f:facet&#62;
 &#60;h:outputText value="#{fisica.nome}" /&#62;
 &#60;/h:column&#62;

 &#60;h:column&#62;
 &#60;f:facet name="header"&#62;
 &#60;h:outputText value="E-MAIL" /&#62;
 &#60;/f:facet&#62;
 &#60;h:outputText value="#{fisica.email}" /&#62;
 &#60;/h:column&#62;

 &#60;h:column&#62;
 &#60;f:facet name="header"&#62;
 &#60;h:outputText value="CPF" /&#62;
 &#60;/f:facet&#62;
 &#60;h:outputText value="#{fisica.cpf}" /&#62;
 &#60;/h:column&#62;

 &#60;h:column&#62;
 &#60;f:facet name="header"&#62;
 &#60;h:outputText value="DATA NASC." /&#62;
 &#60;/f:facet&#62;
 &#60;h:outputText value="#{fisica.dataNascimento}"&#62;
 &#60;f:convertDateTime pattern="dd/MM/yyyy" /&#62;
 &#60;/h:outputText&#62;
 &#60;/h:column&#62;

 &#60;h:column&#62;
 &#60;f:facet name="header"&#62;
 &#60;h:outputText value="CELULAR" /&#62;
 &#60;/f:facet&#62;
 &#60;h:outputText value="#{fisica.telefoneCelular}" /&#62;
 &#60;/h:column&#62;

 &#60;h:column&#62;
 &#60;f:facet name="header"&#62;
 &#60;h:outputText value="Exclusão"/&#62;
 &#60;/f:facet&#62;

 &#60;a4j:commandLink reRender="panelGridInputs"&#62;
 &#60;h:outputText value="Selecionar"/&#62;
 &#60;f:setPropertyActionListener  value="#{fisica}" target="#{pessoaMB.pessoa}"/&#62;
 &#60;/a4j:commandLink&#62;

 &#60;/h:column&#62;

 &#60;f:facet name="footer"&#62;
 &#60;rich:datascroller /&#62;
 &#60;/f:facet&#62;
 &#60;/rich:dataTable&#62;

 &#60;rich:messages/&#62;

 &#60;a4j:region id="regiaoAjax"&#62;
 &#60;a4j:status id="sts"&#62;
 &#60;f:facet name="start"&#62;
 &#60;h:graphicImage value="/images/ajax-loader.gif" /&#62;
 &#60;/f:facet&#62;
 &#60;/a4j:status&#62;
 &#60;/a4j:region&#62;

 &#60;h:panelGrid columns="2" id="panelGridInputs"&#62;
 &#60;h:outputLabel for="nome" value="Nome "  /&#62;
 &#60;h:inputText id="nome" value="#{pessoaMB.pessoa.nome}" style=" width : 254px;"/&#62;

 &#60;h:outputLabel for="email" value="E-mail "  /&#62;
 &#60;h:inputText id="email" value="#{pessoaMB.pessoa.email}" style=" width : 249px;"&#62;
 &#60;f:validator validatorId="emailValidator"/&#62;
 &#60;/h:inputText&#62;

 &#60;h:outputLabel for="cpf" value="CPF "  /&#62;
 &#60;h:inputText id="cpf" validatorMessage="CPF inválido!" value="#{pessoaMB.pessoa.cpf}" size="60" style=" width : 106px;"&#62;
 &#60;rich:jQuery selector="#cpf" query="mask('999.999.999-99')" timing="onload"/&#62;
 &#60;stella:validateCPF formatted="true"/&#62;
 &#60;/h:inputText&#62;

 &#60;h:outputLabel for="senha" value="Senha "  /&#62;
 &#60;h:inputSecret id="senha" value="#{pessoaMB.pessoa.senha}" size="30"/&#62;

 &#60;h:outputLabel for="dataNasc" value="Data Nascimento: "  /&#62;
 &#60;h:inputText id="dataNasc" validatorMessage="Data de nascimento com formato inválido!" value="#{pessoaMB.pessoa.dataNascimento}" size="60" style=" width : 75px;"&#62;
 &#60;f:convertDateTime pattern="dd/MM/yyyy" /&#62;
 &#60;rich:jQuery selector="#dataNasc" query="mask('99/99/9999')" timing="onload"/&#62;
 &#60;/h:inputText&#62; 

 &#60;h:outputLabel for="telCel" value="Tel. Celular "  /&#62;
 &#60;h:inputText id="telCel" value="#{pessoaMB.pessoa.telefoneCelular}"&#62;
 &#60;rich:jQuery selector="#telCel" query="mask('(99) 9999-9999')" timing="onload"/&#62;
 &#60;/h:inputText&#62;

 &#60;a4j:commandButton value="Atualizar" action="#{pessoaMB.merge}" styleClass="botoes" status="sts" reRender="fisicas"/&#62;
 &#60;a4j:commandButton value="Voltar" immediate="true" action="toIndex" styleClass="botoes"/&#62;
 &#60;/h:panelGrid&#62;
 &#60;/fieldset&#62;
 &#60;/h:form&#62;
 &#60;/ui:define&#62;
 &#60;/ui:composition&#62;
&#60;/html&#62;</pre>
</blockquote>
<p><strong>cadastraPessoa.xhtml:</strong></p>
<blockquote>
<pre>&#60;?xml version="1.0" encoding="UTF-8" ?&#62;
&#60;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&#62;
&#60;html xmlns="http://www.w3.org/1999/xhtml"
 xmlns:ui="http://java.sun.com/jsf/facelets"
 xmlns:h="http://java.sun.com/jsf/html"
 xmlns:f="http://java.sun.com/jsf/core"
 xmlns:a4j="http://richfaces.org/a4j"
 xmlns:stella="http://stella.caelum.com.br/faces"
 xmlns:rich="http://richfaces.org/rich"&#62;
 &#60;head&#62;
 &#60;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&#62;
 &#60;/head&#62;

 &#60;a4j:keepAlive beanName="pessoaMB" /&#62;

 &#60;ui:composition template="/template/template.xhtml"&#62;
 &#60;ui:define name="corpo"&#62;
 &#60;h:form&#62;
 &#60;rich:messages /&#62;

 &#60;fieldset&#62;
 &#60;legend&#62;Cadastro de Pessoa&#60;/legend&#62;
 &#60;a4j:region id="regiaoAjax"&#62;
 &#60;a4j:status id="sts"&#62;
 &#60;f:facet name="start"&#62;
 &#60;h:graphicImage value="/images/ajax-loader.gif" /&#62;
 &#60;/f:facet&#62;
 &#60;/a4j:status&#62;
 &#60;/a4j:region&#62;

 &#60;h:panelGrid columns="2" id="inputs"&#62;
 &#60;h:outputLabel for="nome" value="Nome "  /&#62;
 &#60;h:inputText id="nome" value="#{pessoaMB.pessoa.nome}" styleClass="edit" size="40" /&#62;

 &#60;h:outputLabel for="email" value="E-mail "  /&#62;
 &#60;h:inputText id="email" value="#{pessoaMB.pessoa.email}" required="true" requiredMessage="Campo e-mail obrigatório!" styleClass="edit" size="30"&#62;
 &#60;f:validator validatorId="emailValidator"/&#62;
 &#60;/h:inputText&#62;

 &#60;h:outputLabel for="senha" value="Senha "  /&#62;
 &#60;h:inputSecret id="senha" value="#{pessoaMB.pessoa.senha}" required="true" requiredMessage="Campo senha obrigatório!" styleClass="edit" size="30"/&#62;

 &#60;h:outputLabel for="cpf" value="CPF "  /&#62;
 &#60;h:inputText id="cpf" value="#{pessoaMB.pessoa.cpf}" styleClass="edit" size="11"&#62;
 &#60;rich:jQuery selector="#cpf" query="mask('999.999.999-99')" timing="onload"/&#62;
 &#60;stella:validateCPF formatted="true"/&#62;
 &#60;/h:inputText&#62;

 &#60;h:outputLabel for="dataNasc" value="Data Nascimento "  /&#62;
 &#60;h:inputText id="dataNasc" validatorMessage="Data de nascimento com formato inválido!" value="#{pessoaMB.pessoa.dataNascimento}" styleClass="edit" size="10" &#62;
 &#60;f:convertDateTime pattern="dd/MM/yyyy" /&#62;
 &#60;rich:jQuery selector="#dataNasc" query="mask('99/99/9999')" timing="onload"/&#62;
 &#60;/h:inputText&#62;

 &#60;h:outputLabel for="telCel" value="Tel. Celular "  /&#62;
 &#60;h:inputText id="telCel" value="#{pessoaMB.pessoa.telefoneCelular}" styleClass="edit" size="10"&#62;
 &#60;rich:jQuery selector="#telCel" query="mask('(99) 9999-9999')" timing="onload"/&#62;
 &#60;/h:inputText&#62;

 &#60;a4j:commandButton value="Inserir" action="#{pessoaMB.save}" status="sts" reRender="inputs" styleClass="botoes"/&#62;
 &#60;a4j:commandButton value="Voltar" immediate="true" action="toIndex" styleClass="botoes"/&#62;
 &#60;/h:panelGrid&#62;
 &#60;/fieldset&#62;
 &#60;/h:form&#62;
 &#60;/ui:define&#62;
 &#60;/ui:composition&#62;
&#60;/html&#62;</pre>
</blockquote>
<p><strong>pesquisaPessoa.xhtml:</strong></p>
<blockquote>
<pre>&#60;?xml version="1.0" encoding="UTF-8" ?&#62;
&#60;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&#62;
&#60;html xmlns="http://www.w3.org/1999/xhtml"
 xmlns:ui="http://java.sun.com/jsf/facelets"
 xmlns:h="http://java.sun.com/jsf/html"
 xmlns:f="http://java.sun.com/jsf/core"
 xmlns:a4j="http://richfaces.org/a4j"
 xmlns:stella="http://stella.caelum.com.br/faces"
 xmlns:rich="http://richfaces.org/rich"&#62;
 &#60;head&#62;
 &#60;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&#62;
 &#60;/head&#62;

 &#60;a4j:keepAlive beanName="pessoaMB" /&#62;

 &#60;ui:composition template="/template/template.xhtml"&#62;
 &#60;ui:define name="corpo"&#62;
 &#60;h:form&#62;
 &#60;rich:messages /&#62;

 &#60;fieldset&#62;
 &#60;legend&#62;Pesquisa de Pessoas&#60;/legend&#62;
 &#60;h:panelGrid columns="2"&#62;

 &#60;h:outputLabel for="nomeLabel" value="Digite o nome: " /&#62;
 &#60;h:inputText id="nomeInput" value="#{pessoaMB.pessoa.nome}" style=" width : 321px;" /&#62;

 &#60;h:commandButton value="Pesquisar" action="#{pessoaMB.pesquisaByNome}" styleClass="botoes"/&#62;
 &#60;h:commandButton value="Voltar" immediate="true" action="toIndex" styleClass="botoes"/&#62;
 &#60;/h:panelGrid&#62;

 &#60;h:panelGrid columns="2" id="panelGridInputs"&#62;
 &#60;h:outputLabel for="nome" value="Nome "  /&#62;
 &#60;h:inputText id="nome" readonly="true" value="#{pessoaMB.pessoa.nome}" style=" width : 254px;"/&#62;

 &#60;h:outputLabel for="email" value="E-mail "  /&#62;
 &#60;h:inputText id="email" readonly="true" value="#{pessoaMB.pessoa.email}" style=" width : 249px;"/&#62;

 &#60;h:outputLabel for="cpf" value="CPF "  /&#62;
 &#60;h:inputText id="cpf" readonly="true" validatorMessage="CPF inválido!" value="#{pessoaMB.pessoa.cpf}" size="60" style=" width : 106px;"/&#62;

 &#60;h:outputLabel for="dataNasc" value="Data Nascimento: "  /&#62;
 &#60;h:inputText id="dataNasc" readonly="true" validatorMessage="Data de nascimento com formato inválido!" value="#{pessoaMB.pessoa.dataNascimento}" size="60" style=" width : 75px;"&#62;
 &#60;f:convertDateTime pattern="dd/MM/yyyy" /&#62;
 &#60;/h:inputText&#62; 

 &#60;h:outputLabel for="telCel" value="Tel. Celular "  /&#62;
 &#60;h:inputText id="telCel" readonly="true" value="#{pessoaMB.pessoa.telefoneCelular}" /&#62;
 &#60;/h:panelGrid&#62;
 &#60;/fieldset&#62;
 &#60;/h:form&#62;
 &#60;/ui:define&#62;
 &#60;/ui:composition&#62;
&#60;/html&#62;</pre>
</blockquote>
<p><strong>removePessoa.xhtml</strong></p>
<blockquote>
<pre>&#60;?xml version="1.0" encoding="UTF-8" ?&#62;
&#60;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&#62;
&#60;html xmlns="http://www.w3.org/1999/xhtml"
 xmlns:ui="http://java.sun.com/jsf/facelets"
 xmlns:h="http://java.sun.com/jsf/html"
 xmlns:f="http://java.sun.com/jsf/core"
 xmlns:a4j="http://richfaces.org/a4j"
 xmlns:stella="http://stella.caelum.com.br/faces"
 xmlns:rich="http://richfaces.org/rich"&#62;
 &#60;head&#62;
 &#60;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&#62;
 &#60;/head&#62;

 &#60;a4j:keepAlive beanName="pessoaMB" /&#62;

 &#60;ui:composition template="/template/template.xhtml"&#62;
 &#60;ui:define name="corpo"&#62;
 &#60;h:form&#62;
 &#60;rich:messages /&#62;
 &#60;fieldset&#62;&#60;legend&#62;Remoção de Pessoas&#60;/legend&#62;
 &#60;rich:dataTable value="#{pessoaMB.pessoas}" var="fisica" rows="10" id="fisicas" width="100%" cellspacing="0" cellpadding="0" border="1"&#62;
 &#60;h:column&#62;
 &#60;f:facet name="header"&#62;
 &#60;h:outputText value="NOME" /&#62;
 &#60;/f:facet&#62;
 &#60;h:outputText value="#{fisica.nome}" /&#62;
 &#60;/h:column&#62;

 &#60;h:column&#62;
 &#60;f:facet name="header"&#62;
 &#60;h:outputText value="E-MAIL" /&#62;
 &#60;/f:facet&#62;
 &#60;h:outputText value="#{fisica.email}" /&#62;
 &#60;/h:column&#62;

 &#60;h:column&#62;
 &#60;f:facet name="header"&#62;
 &#60;h:outputText value="CPF" /&#62;
 &#60;/f:facet&#62;
 &#60;h:outputText value="#{fisica.cpf}" /&#62;
 &#60;/h:column&#62;

 &#60;h:column&#62;
 &#60;f:facet name="header"&#62;
 &#60;h:outputText value="DATA NASC." /&#62;
 &#60;/f:facet&#62;
 &#60;h:outputText value="#{fisica.dataNascimento}"&#62;
 &#60;f:convertDateTime pattern="dd/MM/yyyy" /&#62;
 &#60;/h:outputText&#62;
 &#60;/h:column&#62;

 &#60;h:column&#62;
 &#60;f:facet name="header"&#62;
 &#60;h:outputText value="CELULAR" /&#62;
 &#60;/f:facet&#62;
 &#60;h:outputText value="#{fisica.telefoneCelular}" /&#62;
 &#60;/h:column&#62;

 &#60;h:column&#62;
 &#60;f:facet name="header"&#62;
 &#60;h:outputText value="Exclusão"/&#62;
 &#60;/f:facet&#62;

 &#60;a4j:commandLink action="#{pessoaMB.delete}" status="sts" reRender="fisicas" &#62;
 &#60;h:outputText value="Excluir"/&#62;
 &#60;f:setPropertyActionListener value="#{fisica.id}" target="#{pessoaMB.id}" /&#62;
 &#60;/a4j:commandLink&#62;
 &#60;/h:column&#62;

 &#60;f:facet name="footer"&#62;
 &#60;rich:datascroller /&#62;
 &#60;/f:facet&#62;
 &#60;/rich:dataTable&#62;

 &#60;a4j:region id="regiaoAjax"&#62;
 &#60;a4j:status id="sts"&#62;
 &#60;f:facet name="start"&#62;
 &#60;h:graphicImage value="/images/ajax-loader.gif" /&#62;
 &#60;/f:facet&#62;
 &#60;/a4j:status&#62;
 &#60;/a4j:region&#62;

 &#60;h:commandButton value="Voltar" immediate="true" action="toIndex" styleClass="botoes"/&#62;
 &#60;/fieldset&#62;
 &#60;/h:form&#62;
 &#60;/ui:define&#62;
 &#60;/ui:composition&#62;
&#60;/html&#62;</pre>
</blockquote>
<p><strong>login.xhtml:</strong></p>
<blockquote>
<pre>&#60;?xml version="1.0" encoding="UTF-8" ?&#62;
&#60;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&#62;
&#60;html xmlns="http://www.w3.org/1999/xhtml"
 xmlns:ui="http://java.sun.com/jsf/facelets"
 xmlns:h="http://java.sun.com/jsf/html"
 xmlns:f="http://java.sun.com/jsf/core"
 xmlns:a4j="http://richfaces.org/a4j"
 xmlns:stella="http://stella.caelum.com.br/faces"
 xmlns:rich="http://richfaces.org/rich"&#62;
 &#60;head&#62;
 &#60;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&#62;
 &#60;/head&#62;

 &#60;a4j:keepAlive beanName="pessoaMB" /&#62;

 &#60;ui:composition template="/template/template.xhtml"&#62;
 &#60;ui:define name="corpo"&#62;
 &#60;h:form&#62;
 &#60;rich:messages /&#62;
 &#60;fieldset&#62;
 &#60;h:panelGrid columns="2"&#62;
 &#60;h:outputText value="E-mail" styleClass="rotulos" /&#62;
 &#60;h:inputText id="email" value="#{pessoaMB.pessoa.email}" styleClass="edit" size="25"&#62;
 &#60;f:validator validatorId="emailValidator" /&#62;
 &#60;/h:inputText&#62;    

 &#60;h:outputLabel for="senha" value="Senha" styleClass="rotulos"/&#62;
 &#60;h:inputSecret id="senha" styleClass="edit" validatorMessage="A senha deve ter no mínimo 6 caracteres!" value="#{pessoaMB.pessoa.senha}" size="25"&#62;
 &#60;f:validateLength minimum="6"/&#62;
 &#60;/h:inputSecret&#62;
 &#60;h:commandButton id="botao" value="Entrar" action="#{pessoaMB.login}" /&#62;
 &#60;/h:panelGrid&#62;
 &#60;/fieldset&#62;
 &#60;/h:form&#62;
 &#60;/ui:define&#62;
 &#60;/ui:composition&#62;
&#60;/html&#62;</pre>
</blockquote>
<p><strong>template.xhtml:</strong></p>
<blockquote>
<pre>&#60;?xml version="1.0" encoding="UTF-8"?&#62;
&#60;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&#62;
&#60;html xmlns="http://www.w3.org/1999/xhtml"
 xmlns:ui="http://java.sun.com/jsf/facelets"
 xmlns:h="http://java.sun.com/jsf/html"
 xmlns:f="http://java.sun.com/jsf/core"
 xmlns:a4j="http://richfaces.org/a4j"
 xmlns:stella="http://stella.caelum.com.br/faces"
 xmlns:rich="http://richfaces.org/rich"&#62;

&#60;head&#62;
 &#60;link rel="StyleSheet" type="text/css" href="/jsf/style/estilos.css" media="screen" /&#62;
 &#60;script type="text/javascript" src="/jsf/resources/jquery.maskedinput-1.2.1.js"&#62;&#60;/script&#62;

 &#60;title&#62;
 &#60;ui:insert name="pageTitle"&#62;
 &#60;h:outputText value="CRUD Facelets "/&#62;
 &#60;/ui:insert&#62;
 &#60;/title&#62;
&#60;/head&#62;

&#60;body&#62;
 &#60;div id="topo"&#62;
 &#60;ui:insert name="topo"&#62;
 Topo do CRUD Facelets
 &#60;/ui:insert&#62;
 &#60;/div&#62;

 &#60;div id="corpo"&#62;
 &#60;ui:insert name="corpo"&#62;
 Conteúdo
 &#60;/ui:insert&#62;
 &#60;/div&#62;

 &#60;div id="rodape"&#62;
 &#60;ui:insert name="rodape"&#62;
 &#60;hr/&#62;
 Rodapé CRUD Facelets
 &#60;/ui:insert&#62;
 &#60;/div&#62;
&#60;/body&#62;
&#60;/html&#62;</pre>
</blockquote>
<p><strong>web.xml:</strong></p>
<blockquote>
<pre>&#60;?xml version="1.0" encoding="UTF-8"?&#62;
&#60;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"&#62;
 &#60;display-name&#62;crud_facelets&#60;/display-name&#62;
 &#60;welcome-file-list&#62;
 &#60;welcome-file&#62;index.html&#60;/welcome-file&#62;
 &#60;welcome-file&#62;index.htm&#60;/welcome-file&#62;
 &#60;welcome-file&#62;index.jsp&#60;/welcome-file&#62;
 &#60;/welcome-file-list&#62;
 &#60;context-param&#62;
 &#60;param-name&#62;javax.faces.DEFAULT_SUFFIX &#60;/param-name&#62;
 &#60;param-value&#62;.xhtml &#60;/param-value&#62;
&#60;/context-param&#62;
&#60;context-param&#62;
 &#60;param-name&#62;facelets.DEVELOPMENT &#60;/param-name&#62;
 &#60;param-value&#62;true &#60;/param-value&#62;
&#60;/context-param&#62;
&#60;context-param&#62;
 &#60;param-name&#62;com.sun.faces.validateXml &#60;/param-name&#62;
 &#60;param-value&#62;false &#60;/param-value&#62;
&#60;/context-param&#62;
 &#60;context-param&#62;
 &#60;param-name&#62;com.sun.faces.verifyObjects &#60;/param-name&#62;
 &#60;param-value&#62;true &#60;/param-value&#62;
&#60;/context-param&#62;
 &#60;servlet&#62;
 &#60;servlet-name&#62;Faces Servlet&#60;/servlet-name&#62;
 &#60;servlet-class&#62;javax.faces.webapp.FacesServlet&#60;/servlet-class&#62;
 &#60;load-on-startup&#62;1&#60;/load-on-startup&#62;
 &#60;/servlet&#62;
 &#60;servlet-mapping&#62;
 &#60;servlet-name&#62;Faces Servlet&#60;/servlet-name&#62;
 &#60;url-pattern&#62;*.jsf&#60;/url-pattern&#62;
 &#60;url-pattern&#62;*.faces&#60;/url-pattern&#62;
 &#60;/servlet-mapping&#62;

 &#60;context-param&#62;
 &#60;param-name&#62;org.ajax4jsf.SKIN&#60;/param-name&#62;
 &#60;param-value&#62;blueSky&#60;/param-value&#62;
 &#60;/context-param&#62;
 &#60;filter&#62;
 &#60;display-name&#62;Ajax4jsf Filter&#60;/display-name&#62;
 &#60;filter-name&#62;ajax4jsf&#60;/filter-name&#62;
 &#60;filter-class&#62;org.ajax4jsf.Filter&#60;/filter-class&#62;
 &#60;/filter&#62;
 &#60;filter-mapping&#62;
 &#60;filter-name&#62;ajax4jsf&#60;/filter-name&#62;
 &#60;servlet-name&#62;Faces Servlet&#60;/servlet-name&#62;
 &#60;dispatcher&#62;REQUEST&#60;/dispatcher&#62;
 &#60;dispatcher&#62;FORWARD&#60;/dispatcher&#62;
 &#60;dispatcher&#62;INCLUDE&#60;/dispatcher&#62;
 &#60;/filter-mapping&#62;

 &#60;filter&#62;
 &#60;display-name&#62;AuthFilter&#60;/display-name&#62;
 &#60;filter-name&#62;AuthFilter&#60;/filter-name&#62;
 &#60;filter-class&#62;br.com.serjaum.filtro.AuthFilter&#60;/filter-class&#62;
 &#60;/filter&#62;
 &#60;filter-mapping&#62;
 &#60;filter-name&#62;AuthFilter&#60;/filter-name&#62;
 &#60;url-pattern&#62;/*&#60;/url-pattern&#62;
 &#60;/filter-mapping&#62;

 &#60;context-param&#62;
 &#60;param-name&#62;facelets.SKIP_COMMENTS&#60;/param-name&#62;
 &#60;param-value&#62;true&#60;/param-value&#62;
 &#60;/context-param&#62;
&#60;/web-app&#62;</pre>
</blockquote>
<h2><span style="color:#888888;">Importando o projeto</span></h2>
<ol>
<li><span style="color:#000000;">Baixe o projeto completo &#62;&#62;<a href="http://www.4shared.com/file/129956073/8efb0e4/crud_facelets.html">aqui</a>&#60;&#60;;</span></li>
<li><span style="color:#000000;">Descompacte o projeto no seu <em>workspace</em>;</span></li>
<li><span style="color:#000000;">No Eclipse vá em: File –&#62; Import –&#62; General – Existing Projects into Workspace –&#62; Next –&#62; Selecione o projeto descompactado no workspace –&#62; Finish.</span></li>
</ol>
<h2><span style="color:#888888;">Criando o banco de dados</span></h2>
<ol>
<li><span style="color:#000000;">Com o MySQL instalado e configurado com usuário: <strong>root</strong> e senha: <strong>root</strong> crie um novo schema com o nome de <strong><em>jsf</em></strong>.</span></li>
<li><span style="color:#000000;">Execute a classe <em>br.com.serjaum.util.<strong>GerarTabelas.java. </strong>E</em>ssa classe criará as tabelas que foram mapeadas no arquivo <em>hibernate.cfg.xml</em>, no caso a classe <strong><em>Pessoa</em></strong> terá uma tabela correspondente com o nome de <strong><em>pessoa</em></strong> no nosso banco de dados.</span></li>
</ol>
<h2><span style="color:#888888;">Resultado</span></h2>
<p style="text-align:center;"><span style="color:#888888;"><img class="aligncenter size-full wp-image-829" title="resultado_facelets" src="http://serjaum.wordpress.com/files/2009/09/resultado_facelets1.png" alt="resultado_facelets" width="617" height="497" /></span></p>
<p><span style="color:#888888;"> </span></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Passing action methods in Facelets using array notation]]></title>
<link>http://digitaljoel.wordpress.com/2009/08/25/passing-action-methods-in-facelets-using-array-notation/</link>
<pubDate>Tue, 25 Aug 2009 03:21:30 +0000</pubDate>
<dc:creator>digitaljoel</dc:creator>
<guid>http://digitaljoel.wordpress.com/2009/08/25/passing-action-methods-in-facelets-using-array-notation/</guid>
<description><![CDATA[When I was first learning facelets, I often ran into a problem when I was passing an action method i]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>When I was first learning facelets, I often ran into a problem when I was passing an action method into an included facelet file.  For instance, I had file1.xhtml, which would include my custom tag component file2.xhtml (defined within my taglib.xml file.)  file2.xhtml had a commandLink or commandPrompt that needed an action.  Since I would re-use file2.xhtml and allow it to call different actions, I needed a way to pass the action method to file2.</p>
<p>The first thought was to include it as an attribute of my component.</p>
<pre class="brush: xml;">
&lt;myns:mytag
   myActionAttribute=&quot;${mybean.myaction}&quot; /&gt;
</pre>
<p>and then within file2, which in this case is mapped to mytag:</p>
<pre class="brush: xml;">
&lt;h:commandLink value=&quot;${mybean.myValue}&quot; action=&quot;${myActionAttribute}&quot; /&gt;
</pre>
<p>When I tried to execute this, faces would complain to me that mybean had no myaction property.  I knew it did and would be endlessly frustrated by this.<br />
The answer is to reference the action method using array notation.  On any bean referenced in facelets you can reference the properties using dot notation, as in ${mybean.myaction}, OR you can also reference it using array notation, such as ${mybean["myaction"]}.<br />
I never did dig in far enough in order to figure out exactly what was going on under the hood, but I&#8217;m guessing ${mybean.myaction} was actually evaluated before being sent to mytag.  In order to avoid this, pass the bean, and then pass the action method as a string to the component, such as:</p>
<pre class="brush: xml;">
&lt;myns:mytag
   myActionController=&quot;${mybean}&quot;
   myActionMethod=&quot;myaction&quot; /&gt;
</pre>
<p>Notice that the method is just a string.  Then in your component, reference it in array notation ( how many times can I say array notation! )</p>
<pre class="brush: xml;">
&lt;h:commandLink value=&quot;${mybean.myValue}&quot; action=&quot;${myActionController[myActionMethod]}&quot; /&gt;
</pre>
<p>Notice that the method is NOT quoted.  myActionMethod will be replaced by the String value passed in the value of the attribute, and that method on the bean will be called as the action of the commandLink.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[MyFaces 2.0 is now trunk]]></title>
<link>http://matthiaswessendorf.wordpress.com/2009/07/17/myfaces-2-0-is-now-trunk/</link>
<pubDate>Fri, 17 Jul 2009 06:31:57 +0000</pubDate>
<dc:creator>matthiaswessendorf</dc:creator>
<guid>http://matthiaswessendorf.wordpress.com/2009/07/17/myfaces-2-0-is-now-trunk/</guid>
<description><![CDATA[The Apache MyFaces project started to work an implementation of the new JavaServer Faces 2.0 spec pr]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>The Apache MyFaces project started to work an implementation of the new JavaServer Faces 2.0 spec pretty <a href="http://matthiaswessendorf.wordpress.com/2008/08/29/myfaces-goes-jsf-20/">early</a>. The Apache/JSF <a href="http://matthiaswessendorf.wordpress.com/2008/12/03/myfaces-20-a-community-driven-jsf-20-implementation/">community is driving</a> this new effort. All recently added committers actually contributed stuff to MyFaces 2.0.</p>
<p>Now, there is also another important step into the JSF 2.0 adaption. Apache MyFaces has made its 2.0 effort to become <a href="https://svn.apache.org/repos/asf/myfaces/core/trunk/">trunk</a>. This happened a few weeks ago; before the JSF 1.1 stuff was trunk. Well, we still support JSF 1.2 and JSF 1.1 (there haven&#8217;t been JSF RI releases for JSF 1.1 in a while) and continue support for these types, as they are in use.</p>
<p>However, JSF 2.0 brings a lot of new stuff to the table &#8211; and this spec (and its features) is really important to keep JSF alive. The MyFaces community honors that by making it TRUNK.</p>
<p>Good time! Now do a svn check-out and start contributing to it! <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[JSF Tri State Checkbox]]></title>
<link>http://digitaljoel.wordpress.com/2009/07/07/jsf-tri-state-checkbox/</link>
<pubDate>Tue, 07 Jul 2009 05:05:00 +0000</pubDate>
<dc:creator>digitaljoel</dc:creator>
<guid>http://digitaljoel.wordpress.com/2009/07/07/jsf-tri-state-checkbox/</guid>
<description><![CDATA[In my work with JSF I found that I needed a tri-state checkbox.  In my case, the checkbox represente]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>In my work with JSF I found that I needed a tri-state checkbox.  In my case, the checkbox represented whether or not a decorator was added to all selected objects, no selected objects, or some of the selected objects.  This corresponded to checked, unchecked, or partially checked.</p>
<p>When I was looking for something that would fit my needs I found a Javascript implementation at <a title="Shams' Blog" href="http://shamsmi.blogspot.com/2008/12/tri-state-checkbox-using-javascript.html" target="_blank">Shams&#8217; Blog</a> which is a bit of a different use case than what I was looking for, but has some good points and useful images.</p>
<p>I created the following facelet file that manages state transitions and image management for the JSF tri state checkbox.  My control doesn&#8217;t handle the nested selection like you&#8217;ll see in Sham&#8217;s blog, but it fills the needs stated above.</p>
<pre class="brush: xml;">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html
    xmlns=&quot;http://www.w3.org/1999/xhtml&quot;
    xmlns:ui=&quot;http://java.sun.com/jsf/facelets&quot;
    xmlns:h=&quot;http://java.sun.com/jsf/html&quot;
    xmlns:f=&quot;http://java.sun.com/jsf/core&quot;
    xmlns:c=&quot;http://java.sun.com/jstl/core&quot; &gt;

&lt;!--
  An input component that is represented as a checkbox with three states.  Checked, Unchecked, and Intermediate.

  Required attributes:
    checkedValue - the value that should be set for this component when the checkbox is checked
    uncheckedValue - the value that should be set for this component when the checkbox is unchecked
    intermediateValue - the value that should be set for this component when the checkbox is in the intermediate state.
    value - bean property to hold the value.  Should evaluate to checkedValue, uncheckedValue, or intermediateValue the first time.
    controller - controller that implements the value change listener.
    key - key value to pass as an attribute of the control that contains the checkbox value.
    valueChangeListener - change listener for value of this checkbox component.
 --&gt;

&lt;ui:composition&gt;

  &lt;script type=&quot;text/javascript&quot;&gt;
    function setCheckValue( img, next, newVal )
    {
      img.css('display', 'none');
      img.siblings('[id$='+next+']').css('display','inline');
      img.siblings('[id$=triStateCheck]').val(newVal);
    }
  &lt;/script&gt;

  &lt;h:graphicImage
    id=&quot;trueValue&quot;
    url=&quot;/images/ico_checked.gif&quot;
    style=&quot;display: #{value == checkedValue ? 'inline' : 'none'}&quot;
    onmouseover=&quot;jQuery(this).attr('src','/images/ico_checked_highlighted.gif')&quot;
    onmouseout=&quot;jQuery(this).attr('src','/images/ico_checked.gif')&quot;
    onclick=&quot;setCheckValue( jQuery(this), 'falseValue', '#{uncheckedValue}')&quot;
    rendered=&quot;#{(empty rendered) ? true : rendered}&quot; /&gt;
  &lt;h:graphicImage
    id=&quot;falseValue&quot;
    style=&quot;display: #{value == uncheckedValue ? 'inline' : 'none'}&quot;
    onmouseover=&quot;jQuery(this).attr( 'src', '/images/ico_unchecked_highlighted.gif' )&quot;
    onmouseout=&quot;jQuery(this).attr('src', '/images/ico_unchecked.gif')&quot;
    url=&quot;/images/ico_unchecked.gif&quot;
    onclick=&quot;setCheckValue( jQuery(this),
        '#{value == intermediateValue ? 'intermediateValue' : 'trueValue'}',
        '#{value == intermediateValue ? intermediateValue : checkedValue}')&quot;
    rendered=&quot;#{(empty rendered) ? true : rendered}&quot; /&gt;
  &lt;h:graphicImage
    id=&quot;intermediateValue&quot;
    style=&quot;display: #{value == intermediateValue ? 'inline' : 'none'}&quot;
    onmouseover=&quot;jQuery(this).attr( 'src', '/images/ico_intermediate_highlighted.gif' )&quot;
    onmouseout=&quot;jQuery(this).attr('src', '/images/ico_intermediate.gif')&quot;
    url=&quot;/images/ico_intermediate.gif&quot;
    onclick=&quot;setCheckValue( jQuery(this), 'trueValue', '#{checkedValue}')&quot;
    rendered=&quot;#{(empty rendered) ? true : rendered}&quot; /&gt;

  &lt;h:inputHidden
    id=&quot;triStateCheck&quot;
    value=&quot;#{value}&quot;
    valueChangeListener=&quot;#{controller[valueChangeListener]}&quot;&gt;
    &lt;f:attribute name=&quot;key&quot; value=&quot;#{key}&quot; /&gt;
  &lt;/h:inputHidden&gt;

&lt;/ui:composition&gt;
&lt;/html&gt;
</pre>
<p>The control starts with a very simple script that uses jquery.</p>
<pre class="brush: jscript;">
    function setCheckValue( img, next, newVal )
    {
      img.css('display', 'none');
      img.siblings('[id$='+next+']').css('display','inline');
      img.siblings('[id$=triStateCheck]').val(newVal);
    }
</pre>
<p>The script takes three parameters.  The current image, the next image, and the new value.  It then hides the current image, shows the new image, and sets the value of the control to the new value.</p>
<p>Each image in the control has a couple of Javascript event handlers.  One to show the highlighted version of the current image on mouseover, and another to show the regular version on mouse out.  Finally, a third to transition to the next state and set the value on click.  You&#8217;ll notice that in the falseValue image, the onclick is a bit longer than the others.</p>
<pre class="brush: jscript;">
    onclick=&quot;setCheckValue( jQuery(this),
        '#{value == intermediateValue ? 'intermediateValue' : 'trueValue'}',
        '#{value == intermediateValue ? intermediateValue : checkedValue}')&quot;
</pre>
<p>This is because if the value doesn&#8217;t start at intermediate, then we don&#8217;t ever want to hit the intermediate value in transitions.  For instance, if the value starts at true or false, the checkbox will function just like a normal checkbox, toggling only between true and false.  If the checkbox starts at the intermediate value, then it will go from intermediate to true, then to false, then back to intermediate on subsequent clicks.  If this is not the desired behavior, then the conditional statements in the onclick can be removed so that it always goes to intermediate.</p>
<p>The final interesting part of the control is the hidden field that holds the value of the checkbox.</p>
<pre class="brush: xml;">
  &lt;h:inputHidden
    id=&quot;triStateCheck&quot;
    value=&quot;#{value}&quot;
    valueChangeListener=&quot;#{controller[valueChangeListener]}&quot;&gt;
    &lt;f:attribute name=&quot;key&quot; value=&quot;#{key}&quot; /&gt;
  &lt;/h:inputHidden&gt;
</pre>
<p>This inputHidden control contains the current value of the checkbox.  The value is set initially, and then changed through javascript when the checkboxes are clicked.  When debugging, it can be helpful to change the inputHidden to a simple input text control so you can inspect it and see the value change.  The control will call a value change listener which can use the key attribute to determine which entity the checkbox belongs to.  This is valuable when you are stamping the checkboxes ( as in a ui:repeat ) so you know which entity in the collection had the checkbox changed.</p>
<p>In order to use the control, simply save the text to a file and include a pointer to it in your JSF taglib definition.  You can modify the image paths for your needs and set the other attributes as they are commented at the top of the file.</p>
<p>Suggestions on how to improve this control?  I&#8217;d love to hear them.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Conditionally printing HTML tags in JSF Facelets]]></title>
<link>http://depressedprogrammer.wordpress.com/2009/06/08/conditionally-printing-html-tags-in-jsf-facelets/</link>
<pubDate>Mon, 08 Jun 2009 17:20:00 +0000</pubDate>
<dc:creator>Arsenalist</dc:creator>
<guid>http://depressedprogrammer.wordpress.com/2009/06/08/conditionally-printing-html-tags-in-jsf-facelets/</guid>
<description><![CDATA[This took me a bit to figure out so I thought I&#8217;d post it. Say you&#8217;re using JSF and want]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>This took me a bit to figure out so I thought I&#8217;d post it.</p>
<p>Say you&#8217;re using JSF and want to conditionally print some HTML tags in your Facelet that could, technically speaking, result in non well-formed markup.  You can&#8217;t really do it.  Printing something like <code></code> is illegal as it&#8217;ll complain about the &#60; and &#62; characters being in there.  Using the  tag doesn&#8217;t work either, even if you wrap the content in a CDATA element.  Problem is that it&#8217;s preventing you from writing non well-formed markup in any which way.</p>
<p>One of the solutions is to force the rendering kit to not analyze the output for &#8220;well-formedness&#8221; by passing the HTML markup in a variable.  </p>
<p>In your <em>facelet.xhtml</em></p>
<pre class="brush: xml;">
&lt;h:outputText escape=&quot;false&quot;
              rendered=&quot;#{someCondition}&quot;
              value=&quot;#{messages['lessThan'].concat('ul').concat(messages['greaterThan'])}&quot;/&gt;
</pre>
<p>In <em>messages.properties</em></p>
<pre>
lessThan=&#60;
greaterThan=&#62;
</pre>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Curso online grátis de JSF! Exadel e RedHat]]></title>
<link>http://alyssontmv.wordpress.com/2009/05/01/curso-online-gratis-de-jsf-exadel-e-redhat/</link>
<pubDate>Fri, 01 May 2009 03:20:18 +0000</pubDate>
<dc:creator>Alysson Vasconcelos</dc:creator>
<guid>http://alyssontmv.wordpress.com/2009/05/01/curso-online-gratis-de-jsf-exadel-e-redhat/</guid>
<description><![CDATA[Olá pessoal, Recebi um e-mail da RedHat e Exadel informando sobre um curso online gratuito sobre JSF]]></description>
<content:encoded><![CDATA[Olá pessoal, Recebi um e-mail da RedHat e Exadel informando sobre um curso online gratuito sobre JSF]]></content:encoded>
</item>
<item>
<title><![CDATA[Realworld JSF Application Story]]></title>
<link>http://ahoehma.wordpress.com/2009/04/27/realworld-jsf-application-story/</link>
<pubDate>Mon, 27 Apr 2009 10:30:00 +0000</pubDate>
<dc:creator>Andreas Höhmann</dc:creator>
<guid>http://ahoehma.wordpress.com/2009/04/27/realworld-jsf-application-story/</guid>
<description><![CDATA[Vielleicht hatte ich es in einem früheren Posting schonmal erwähnt, ich arbeite momentan für Siemens]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Vielleicht hatte ich es in einem früheren Posting schonmal erwähnt, ich arbeite momentan für Siemens an einem Web 2.0 Projekt und das ist jetzt fertig <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> .</p>
<p>Los ging es November 2007 und nun konnten wir planmässig im April 2009 live gehen. Wir konnten dabei all die wunderbaren &#8220;neuen&#8221; Technologien einsetzen und ausprobieren, u.a. JSF und damit eine funktionsfähige (also den Anforderungen des Kunden voll entsprechende) und zugleich performante &#8220;Web 2.0&#8243; Applikation bauen. Die Applikation nimmt sich dem Thema &#8220;Sicherheitstechnik&#8221; (für die Auskenner: <span><span style="color:black;">ISO 13849-1 und IEC 62061) an.</span></span></p>
<p><span><span style="color:black;">Mal kurz zu den verwendeten &#8220;Technologien/Frameworks/Tools/Ideen&#8221;:</span></span></p>
<ul>
<li><span><span style="color:black;">Daten ziehen wir aus einer SAP Knowledgebase (selbst gestrickt) und aus einer Datenbank via OpenJPA</span></span></li>
<li><span><span style="color:black;"> Services/Manager sind &#8220;normale&#8221; Javaklassen (Stichwort Design-Pattern),<br />
als Kleber verwenden wir Spring (Stichwort Dependency Injection)</span></span></li>
<li><span><span style="color:black;">UI mit JBoss Richfaces (Stichwort Ajax), JSF + Facelets (Stichwort Xhtml-Template), jQuery, CSS, etc.<br />
</span></span></li>
<li><span><span style="color:black;">Buildsystem, Projektseiten mit Maven2</span></span></li>
<li><span><span style="color:black;">Continues Integration via TeamCity und Maven2</span></span></li>
<li><span><span style="color:black;">Tests hauptsächlich mit TestNG aber teilweise auch mit JUnit</span></span></li>
<li><span><span style="color:black;">Laden/Speichern von Benutzerdaten via XStream (FileupLoad via Tomahawk), das alles noch Versionskompatibel, d.h. selbsgestrickte XML-Transformationskette für DomainModell-Updates<br />
</span></span></li>
<li><span><span style="color:black;">PDF Reportgenerierung mit iText</span></span></li>
<li><span><span style="color:black;">Anbindung an Siemens &#8220;Single Sign On&#8221; System via Spring Security, Webservices<br />
</span></span></li>
</ul>
<p>Im Rückblick kann ich sagen, dass eigentlich alles ohne größere Probleme miteinander funktioniert hat<br />
&#8230; so soll es sein <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p><a title="Safety Evaluation Tool" href="https://www.automation.siemens.com/cd/safety/html_00/produkte/si_normen/tool.htm" target="_blank">https://www.automation.siemens.com/cd/safety/html_00/produkte/si_normen/tool.htm</a></p>
<p>(Für die Applikation muss man sich registrieren)</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[J2SE fashion]]></title>
<link>http://sebasjm.wordpress.com/2009/04/20/j2se-fashion/</link>
<pubDate>Mon, 20 Apr 2009 14:50:12 +0000</pubDate>
<dc:creator>Sebastian Javier Marchano</dc:creator>
<guid>http://sebasjm.wordpress.com/2009/04/20/j2se-fashion/</guid>
<description><![CDATA[Buenas, habrán notado que tuve un pico de blogs y ahora bajo un poco&#8230; no crean que esto va a t]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Buenas, habrán notado que tuve un pico de blogs y ahora bajo un poco&#8230; no crean que esto va a terminar tan rápido. Simplemente estuve trabajando en algunas cosillas que por supuesto tienen que ver con esta bitácora. </p>
<p>Una de ellas es tener un mirror del blog en inglés, también en wordpresss.</p>
<p>Y otra es que me envicié portando la <a href="https://javaserverfaces.dev.java.net/">implementación de Sun</a> de <a href="http://jcp.org/en/jsr/detail?id=127">JSF</a> para J2SE =D . See, hay una nueva moda, cuestionar JEE y preguntar porque estas funcionalidades no lo puedo tener en mis aplicaciones. Esto empezó con Context and Dependecy Injection for Java ( aka jsr-299 ( aka WebBeans ) ) que con mucha lógica dijeron &#8220;Gavin, ¿Qué tiene que ver contextos y DI con JSF y EJB?&#8221; o <a href="http://seamframework.org/Community/WebBeansInNonWebEnvironment">algo similar</a>, ahora me toca a mi seguir con la moda.</p>
<p>Me hice la pregunta ( hace tiempo ya, pero no tengo pruebas =P ) ¿Por qué no puedo utilizar las ventajas de la <a href="http://en.wikipedia.org/wiki/Declarative_programming">programación declarativa</a> en mis aplicaciones desktops y dejar de romperme la cabeza ( aka marote ) en pensar si voy a usar Swing, SWT o similares? Por cierto para tener en cuenta, parece que <a href="http://www.sun.com/third-party/global/oracle/index.jsp">Sun bajó los brazos</a> en este area.</p>
<p>Y el proyecto está avanzando, ayer casi logro levantar un ejemplo pero el spec de JSF parece estar muy ligado al paquete <em>javax.servlet.http</em> y voy a tener que hacer un poco de magia negra, pero de la buena. En cuanto tenga un ejemplo se los muestro, la idea es definir las vistas con JSF/Facelets y implementar un RenderKit para dibujar con la tecnología que queramos. Una vez superado eso agregar Seam, aunque sería óptimo tener una versión GA de OWB ó WB para entonces.</p>
<p> </p>
<p>Salut</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[J2EE expert looking for job]]></title>
<link>http://spillerlaszlo.wordpress.com/2009/04/20/j2ee-expert-looking-for-job/</link>
<pubDate>Mon, 20 Apr 2009 09:58:12 +0000</pubDate>
<dc:creator>Spiller László</dc:creator>
<guid>http://spillerlaszlo.wordpress.com/2009/04/20/j2ee-expert-looking-for-job/</guid>
<description><![CDATA[Gained 6 years of deep experience as a Java developer. His main projects were: Design and developmen]]></description>
<content:encoded><![CDATA[Gained 6 years of deep experience as a Java developer. His main projects were: Design and developmen]]></content:encoded>
</item>
<item>
<title><![CDATA[Why Facelets matters]]></title>
<link>http://jklausen.wordpress.com/2009/04/16/why-facelets-matters/</link>
<pubDate>Thu, 16 Apr 2009 08:00:31 +0000</pubDate>
<dc:creator>Jeppe Klausen</dc:creator>
<guid>http://jklausen.wordpress.com/2009/04/16/why-facelets-matters/</guid>
<description><![CDATA[When developing with JSF you pretty soon gets tired of trying to make easy readable and flexible tem]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>When developing with JSF you pretty soon gets tired of trying to make easy readable and flexible templates. This is where Facelets come to the rescue!</p>
<p>Facelets is basically a templating framework, which enables you to improve flexibility and maintainability in your web application. It fits very nicely together with JSF.</p>
<p>When constructing master templates you want there are several things you want to be able to do, here are some of the possibilities:</p>
<ol>
<li>including headers and footers</li>
<li>defining content sections</li>
<li>specifying title per page</li>
<li>loading message bundles</li>
</ol>
<p>Below are some examples of this that you can put in your template.xhtml file.</p>
<p><strong>1. Including headers and footers</strong></p>
<pre class="brush: xml;">
&lt;ui:include src=&quot;header.xhtml&quot;&gt;
  &lt;!-- It's even possible to pass parameters
         and you can you can use EL expression as always
  --&gt;
  &lt;ui:param name=&quot;headerTitle&quot; value=&quot;#{headerImg}&quot; /&gt;
&lt;/ui:include&gt;
</pre>
<p><strong>2. Defining content sections</strong></p>
<pre class="brush: xml;">
  &lt;ui:insert name=&quot;body&quot; /&gt;
</pre>
<p><strong>3. Specifying title per page</strong></p>
<pre class="brush: xml;">
  &lt;title&gt;
    &lt;ui:insert name=&quot;title&quot;&gt;Default title&lt;/ui:insert&gt;
  &lt;/title&gt;
</pre>
<p><strong>4. Loading message bundles</strong></p>
<pre class="brush: xml;">
   &lt;f:loadBundle var=&quot;msg&quot; basename=&quot;dk.sompackage.MyBundle&quot; /&gt;
</pre>
<p>Now when combining these simple techniques, you can quite easy create the first template.<br />
Next step is to create the first page using the newly created template:</p>
<p><strong>MyFirstPage.xhtml:</strong></p>
<pre class="brush: xml;">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;ui:composition xmlns=&quot;http://www.w3.org/1999/xhtml&quot;
      xmlns:ui=&quot;http://java.sun.com/jsf/facelets&quot;
      xmlns:h=&quot;http://java.sun.com/jsf/html&quot;
      xmlns:f=&quot;http://java.sun.com/jsf/core&quot;
      template=&quot;/layout/template.xhtml&quot;&gt;
	&lt;!-- Title of the page --&gt;
	&lt;ui:param name=&quot;title&quot; value=&quot;My title&quot; /&gt;

	&lt;!-- This defines the content section --&gt;
	&lt;ui:define name=&quot;body&quot;&gt;
		&lt;!-- Here goes all the content --&gt;
        &lt;/ui:define&gt;
&lt;/ui:composition&gt;
</pre>
<p>When fiddling a bit around with some of these techniques you&#8217;ll soon find out, that it is easy to create complex features and still keep the flexibility and you&#8217;re still able to reuse your code. Next step is to create custom components and put them in a taglib.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[(Really) Simple Steps to use myfaces and facelets in JSF based app]]></title>
<link>http://parasjain01.wordpress.com/2009/04/12/really-simple-steps-to-user-myfaces-and-facelets-in-jsf/</link>
<pubDate>Sun, 12 Apr 2009 12:55:52 +0000</pubDate>
<dc:creator>Paras</dc:creator>
<guid>http://parasjain01.wordpress.com/2009/04/12/really-simple-steps-to-user-myfaces-and-facelets-in-jsf/</guid>
<description><![CDATA[Coming soon]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Coming soon</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Icefaces, Null Pointer caused by DOMResponseWriter]]></title>
<link>http://hobione.wordpress.com/2009/04/07/icefaces-null-pointer-caused-by-domresponsewriter/</link>
<pubDate>Tue, 07 Apr 2009 21:19:37 +0000</pubDate>
<dc:creator>HobiOne</dc:creator>
<guid>http://hobione.wordpress.com/2009/04/07/icefaces-null-pointer-caused-by-domresponsewriter/</guid>
<description><![CDATA[I was using Icefaces 1.7.2 with Jsf 1.2_04 javax.faces.FacesException: Problem in renderResponse: /W]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>I was using Icefaces 1.7.2 with Jsf 1.2_04</p>
<pre class="brush: xml;">
javax.faces.FacesException: Problem in renderResponse: /WEB-INF/facelets/template.xhtml  Not Found in
ExternalContext as a Resource
Error code 500
</pre>
<p>When I took off the template.xhtml, I got this.<br />
javax.faces.FacesException: Problem in renderResponse: null</p>
<pre class="brush: xml;">
INFO: 08:19:37,173 ERROR D2DFaceletViewHandler:292 - Problem in renderResponse: null
&lt;pre&gt;java.lang.NullPointerException
    at com.icesoft.faces.context.DOMResponseWriter.enhanceAndFixDocument(DOMResponseWriter.java:270)
    at com.icesoft.faces.context.DOMResponseWriter.endDocument(DOMResponseWriter.java:159)
 </pre>
<p>Upgraded to JSF 1.2_07 and Facelets 1.1.14. Did not help.</p>
<p><strong><span style="color:#008000;">Solution:</span></strong> I was missing filepath.  Instead of /WEB-INF/facelets/template.xhtml, I had to add ../WEB-INF/facelets/template.xhtml and it worked.</p>
<p>Thanks to Arran from Icefaces.com for his support.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Adding Facelets and Seam UI to your application]]></title>
<link>http://sheilapollard.wordpress.com/2009/04/02/adding-facelets-and-seam-ui-to-your-application/</link>
<pubDate>Thu, 02 Apr 2009 15:38:17 +0000</pubDate>
<dc:creator>Sheila</dc:creator>
<guid>http://sheilapollard.wordpress.com/2009/04/02/adding-facelets-and-seam-ui-to-your-application/</guid>
<description><![CDATA[It&#8217;s generally recommended in seam applications that Facelets be used instead of JSP.  JSP pag]]></description>
<content:encoded><![CDATA[It&#8217;s generally recommended in seam applications that Facelets be used instead of JSP.  JSP pag]]></content:encoded>
</item>
<item>
<title><![CDATA[Template for JSF/Richfaces,Spring,Hibernate]]></title>
<link>http://laurentbouin.wordpress.com/2009/02/05/template-for-jsfrichfacesspringhibernate/</link>
<pubDate>Thu, 05 Feb 2009 10:49:48 +0000</pubDate>
<dc:creator>laurentbouin</dc:creator>
<guid>http://laurentbouin.wordpress.com/2009/02/05/template-for-jsfrichfacesspringhibernate/</guid>
<description><![CDATA[Next step, based on the previous post, adding some persistance with Hibernate. For this sample i wil]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Next step, based on the <a title="See the previous post" href="http://laurentbouin.wordpress.com/2009/01/05/template-for-jsfrichfaces-projects/" target="_blank">previous post</a>, adding some persistance with Hibernate.</p>
<p>For this sample i will use <a href="http://hsqldb.org/" target="_blank">HSQLDB</a> for the &#8220;in memory&#8221; feature.</p>
<p>The sample app allow you to create &#8220;Users&#8221; containing just a username and Id.</p>
<h4>Frameworks:</h4>
<ul>
<li>Spring &#8211; 2.5.3</li>
<li>Hibernate &#8211; 3.2.1.ga</li>
<li>Hibernate-annotations &#8211; 3.3.0.ga</li>
<li>HSQLDB &#8211; 1.8.0.7</li>
<li>JSF &#8211; 1.2_04-p02</li>
<li>Richfaces &#8211; 3.2.2.SR1</li>
<li>Facelets &#8211; 1.1.14</li>
</ul>
<h3>The Value Object:</h3>
<blockquote><p><strong>package</strong> com.lb.jwitter;</p>
<p><strong>import</strong> java.io.Serializable;</p>
<p><strong>import</strong> javax.persistence.Entity;</p>
<p><strong>import</strong> javax.persistence.GeneratedValue;</p>
<p><strong>import</strong> javax.persistence.Id;</p>
<p><strong>import</strong> javax.persistence.Table;</p>
<p><strong></strong></p>
<p><strong>@Entity</strong></p>
<p><strong>@Table (name=&#8221;UTILISATEURS&#8221;)</strong></p>
<p><strong>public class</strong> User <strong>implements</strong> Serializable {</p>
<p><strong>private static final long </strong>serialVersionUID = -1989579066723007050L;</p>
<p><strong>private</strong> Long id;</p>
<p><strong>private</strong> String username;</p>
<p><strong>@Id</strong></p>
<p><strong>@GeneratedValue</strong></p>
<p><strong>public</strong> Long getId() {</p>
<p>return id;</p>
<p>}</p>
<p><strong>public void</strong> setId(Long id) {</p>
<p>this.id = id;</p>
<p>}</p>
<p><strong>public</strong> String getUsername() {</p>
<p><strong>return</strong> username;</p>
<p>}</p>
<p><strong>public void</strong> setUsername(String username) {</p>
<p>this.username = username;</p>
<p>}</p>
<p>}</p></blockquote>
<p><code>@Entity</code> : Declares the value object as an entity managed by the persistance API.</p>
<p><code>@Table</code> : Defines the table&#8217;s name in which the entities will be stored.</p>
<p><code>@Id</code> : Declares the variable behind the getter as the primary key for the entity.</p>
<p><code>@GeneratedValue</code> : The primary key will be generated automaticaly.</p>
<h4>References</h4>
<ul>
<li><a href="http://hibernate.org/397.html" target="_blank">Hibernate Entity Manager</a></li>
<li><a href="http://java.sun.com/javaee/technologies/persistence.jsp" target="_blank">Sun &#8211; Java persistence API</a></li>
<li><a href="http://www.jcp.org/en/jsr/detail?id=220" target="_blank">JSR 220: EJB 3.0 </a></li>
</ul>
<h3>Writing the <acronym title="Data Access Object">DAO</acronym> :</h3>
<blockquote><p><strong>import</strong> java.util.List;</p>
<p><strong>import</strong> org.apache.commons.logging.Log;</p>
<p><strong>import</strong> org.apache.commons.logging.LogFactory;</p>
<p><strong>import</strong> org.hibernate.SessionFactory;</p>
<p><strong>import</strong> org.hibernate.criterion.Projections;</p>
<p><strong>import</strong> org.hibernate.criterion.Restrictions;</p>
<p><strong>import</strong> org.springframework.beans.factory.annotation.Autowired;</p>
<p><strong>import</strong> org.springframework.beans.factory.annotation.Qualifier;</p>
<p><strong>import</strong> org.springframework.stereotype.Repository;</p>
<p><strong>import</strong> com.lb.jwitter.User;</p>
<p><strong>import</strong> com.lb.utils.orm.hibernate.HibernateGenericDao;</p>
<p><strong>@Repository</strong></p>
<p><strong>public class</strong> UserHibernateDao extends HibernateGenericDao&#60;User, Long&#62; <strong>implements</strong> UserDaoInterface {</p>
<p><strong>private</strong> Log log = LogFactory.getLog(UserHibernateDao.class);</p>
<p><strong>@Autowired</strong></p>
<p><strong>public</strong> UserHibernateDao(<strong>@Qualifier(&#8220;sessionFactory&#8221;)</strong> SessionFactory sessionFactory) {</p>
<p><strong>super</strong>(sessionFactory);</p>
<p>}</p>
<p><strong>public</strong> List&#60;User&#62; findAll() {</p>
<p><strong>return</strong> getSession().createCriteria(User.<strong>class</strong>).list();</p>
<p>}</p>
<p>}</p></blockquote>
<p>I wrote a class HibernateGenericDao to implements the CRUD methods, you can find it in the source code.</p>
<h3>The Service with Autowired DAO</h3>
<blockquote><p><strong>import</strong> java.io.Serializable;</p>
<p><strong>import</strong> java.util.List;</p>
<p><strong>import</strong> org.apache.commons.logging.Log;</p>
<p><strong>import</strong> org.apache.commons.logging.LogFactory;</p>
<p><strong>import</strong> org.springframework.beans.factory.annotation.Autowired;</p>
<p><strong>import</strong> org.springframework.stereotype.Service;</p>
<p><strong>import</strong> org.springframework.transaction.annotation.Transactional;</p>
<p>import com.lb.jwitter.User;</p>
<p>import com.lb.jwitter.hibernate.UserDaoInterface;</p>
<p><strong>@Service</strong>(&#8220;userService&#8221;)</p>
<p><strong>@Transactional</strong></p>
<p><strong>public class </strong>UserService <strong>implements</strong> UserServiceInterface,Serializable{</p>
<p><strong>private</strong> Log log = LogFactory.getLog(UserService.class);</p>
<p><strong>@Autowired</strong></p>
<p><strong>private</strong> UserDaoInterface userDao;</p>
<p><strong>public</strong> List&#60;User&#62; findAll(){</p>
<p>List&#60;User&#62; result = getUserDao().findAll();</p>
<p>log.info(&#8220;Number of user in DB:: &#8220;+result.size());</p>
<p><strong>return</strong> result;</p>
<p>}</p>
<p><strong>public</strong> UserDaoInterface getUserDao() {</p>
<p><strong>return</strong> userDao;</p>
<p>}</p>
<p>/**</p>
<p>* @param userDao the userDao to set</p>
<p>*/</p>
<p><strong>public</strong> <strong>void</strong> setUserDao(UserDaoInterface userDao) {</p>
<p>this.userDao = userDao;</p>
<p>}</p>
<p>}</p></blockquote>
<h3>Writing the Managed Bean</h3>
<blockquote><p>import java.io.Serializable;<br />
import java.util.List;</p>
<p>import javax.faces.application.FacesMessage;<br />
import javax.faces.component.UIComponent;<br />
import javax.faces.context.FacesContext;<br />
import javax.faces.validator.ValidatorException;</p>
<p>import org.apache.commons.logging.Log;<br />
import org.apache.commons.logging.LogFactory;<br />
import org.springframework.beans.factory.annotation.Autowired;<br />
import org.springframework.beans.factory.annotation.Qualifier;<br />
import org.springframework.context.annotation.Scope;<br />
import org.springframework.stereotype.Component;</p>
<p>import com.lb.jwitter.User;<br />
import com.lb.jwitter.service.UserServiceInterface;</p>
<p><strong>@Component<br />
@Qualifier</strong>(&#8220;userBean&#8221;)<br />
<strong>@Scope</strong>(&#8220;session&#8221;)<br />
<strong>public class</strong> UserBean implements Serializable {</p>
<p>private Log log = LogFactory.getLog(UserBean.class);</p>
<p><strong>@Autowired<br />
private</strong> UserServiceInterface userService;</p>
<p><strong>public</strong> List&#60;User&#62; getAllUsers(){<br />
<strong>return</strong> this.userService.findAll();<br />
}</p>
<p><strong>public</strong> UserServiceInterface getUserService() {<br />
<strong>return</strong> userService;<br />
}</p>
<p>/**<br />
* @param userService the userService to set<br />
*/<br />
public void setUserService(UserServiceInterface userService) {<br />
this.userService = userService;<br />
}</p>
<p>}</p></blockquote>
<p><a href="http://web.me.com/laurentbouin/Mon_Mac_et_Moi/Blog/Entr%C3%A9es/2008/10/10_I%E2%80%99m_a_MAc,_so_i_live_in_NY_City_files/jwitter.zip">Download the source code</a></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Accessing Map Entries With Dot Notation]]></title>
<link>http://digitaljoel.wordpress.com/2009/02/05/accessing-map-entries-with-dot-notation/</link>
<pubDate>Thu, 05 Feb 2009 03:03:00 +0000</pubDate>
<dc:creator>digitaljoel</dc:creator>
<guid>http://digitaljoel.wordpress.com/2009/02/05/accessing-map-entries-with-dot-notation/</guid>
<description><![CDATA[This may be something that is old news to everyone else in facelets, but I just found out that you c]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>This may be something that is old news to everyone else in facelets, but I just found out that you can access map entries using dot notation in facelets code.  Where is this handy?</p>
<p>Let&#8217;s say you have a facelets component that you wrote to display certain properties of a complex java object.  The component looks something like this.</p>
<pre class="brush: xml;">
&lt;ui:composition&gt;
    &lt;!-- various styling, action, etc. --&gt;

    &lt;h:outputText value=&quot;#{entity.myValue}&quot; /&gt;
    &lt;h:outputText value=&quot;#{entity.yourValue}&quot; /&gt;

    &lt;!-- various styling, actions, etc. --&gt;
&lt;/ui:composition&gt;
</pre>
<p>You now decide that you like the formatting and actions in this component and want to use it with something else.  You don&#8217;t want to add myValue and yourValue to your other entity, nor do you want to create a facade or container class that just contains those properties that you are using in the facelets component.</p>
<p>One solution would be to create a map that contains the values you need for the component.  This doesn&#8217;t require a new concrete Java object and allows you to re-use the facelets component.</p>
<p>So, in the facelets page or component that includes your custom component you could do the following</p>
<pre class="brush: xml;">
&lt;z:myComponent entity=&quot;#{myBean.propertyMap}&quot; /&gt;
</pre>
<p>And in your controller bean or whatever, you could have a simple method</p>
<pre class="brush: java;">
public Map&lt;String, String&gt; getPropertyMap()
{
    // get your entity
    Map&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();
    map.put( &quot;myValue&quot;, myEntity.getSomethingForMyValue() );
    map.put( &quot;yourValue&quot;, myEntity.getSomethingForYourValue() );
    return map;
}
</pre>
<p>Now, the awesome magic is that the facelets component above will be able to reference the map values by name using dot notation in the component.  It doesn&#8217;t care if the &#8220;entity&#8221; you pass in is a simple map, or a Java object with proper getters and setters for the properties.</p>
</div>]]></content:encoded>
</item>

</channel>
</rss>
