<?xml version="1.0" encoding="UTF-8"?> <rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
><channel><title>OcpSoft &#187; Java</title> <atom:link href="http://ocpsoft.com/cat/java/feed/" rel="self" type="application/rss+xml" /><link>http://ocpsoft.com</link> <description>&#34;Simple Software&#34;</description> <lastBuildDate>Tue, 27 Jul 2010 15:07:50 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.0</generator> <item><title>How to JSF 2.0:  &#8211; render components outside of the form</title><link>http://ocpsoft.com/java/jsf2-java/how-to-jsf-2-0-render-components-outside-of-the-form/</link> <comments>http://ocpsoft.com/java/jsf2-java/how-to-jsf-2-0-render-components-outside-of-the-form/#comments</comments> <pubDate>Mon, 10 May 2010 04:48:00 +0000</pubDate> <dc:creator>Lincoln</dc:creator> <category><![CDATA[JSF2]]></category> <category><![CDATA[Seam]]></category><guid
isPermaLink="false">http://ocpsoft.com/?p=1320</guid> <description><![CDATA[Here&#8217;s a simple tip for all of you AJAX lovers using JSF 2.0. It is possible to render components that live outside of the form where your AJAX tag lives; actually, it&#8217;s possible to render any component by using it&#8217;s fully-qualified component ID. Just prefix the target ID with the naming-container separator character, usually &#8220;:&#8221;, [...]]]></description> <content:encoded><![CDATA[<p>Here&#8217;s a simple tip for all of you AJAX lovers using JSF 2.0. It <b>is</b> possible to render components that live outside of the form where your AJAX tag lives; actually, it&#8217;s possible to render any component by using it&#8217;s fully-qualified component ID.</p><p>Just prefix the target ID with the naming-container separator character, usually &#8220;:&#8221;, and provide the full name of the component as it is rendered on the HTML page.</p><p><div
class="wp_syntax"><div
class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;f:ajax</span> <span style="color: #000066;">execute</span>=<span style="color: #ff0000;">&quot;validatePasswords password @this&quot;</span> <span style="color: #000066;">render</span>=<span style="color: #ff0000;">&quot;:messages&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div><p><span
id="more-1320"></span></p><p> Your component ID would look something like, <code>:namingContainer:myComponent</code>. Where the first &#8220;:&#8221; tells JSF that you want to start looking for the component at the UIViewRoot instance, or the very top level of the component tree.</p><h4>Here&#8217;s a more full fledged example:</h4><p><div
class="wp_syntax"><div
class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;html</span> <span style="color: #000066;">xml:lang</span>=<span style="color: #ff0000;">&quot;en&quot;</span> <span style="color: #000066;">lang</span>=<span style="color: #ff0000;">&quot;en&quot;</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/1999/xhtml&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;h:messages</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;messages&quot;</span> <span style="color: #000066;">globalOnly</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;h4<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Select a username and password<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/h4<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;h:form</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;registerForm&quot;</span> <span style="color: #000066;">prependId</span>=<span style="color: #ff0000;">&quot;false&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;h:inputText</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;username&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;#{registerBean.username}&quot;</span> <span style="color: #000066;">required</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;h:inputText</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;email&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;#{registerBean.email}&quot;</span> <span style="color: #000066;">required</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;h:inputSecret</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;password&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;#{registerBean.password}&quot;</span> <span style="color: #000066;">required</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;s:validateForm</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;validatePasswords&quot;</span> <span style="color: #000066;">fields</span>=<span style="color: #ff0000;">&quot;password1=password password2=passwordConfirm&quot;</span> <span style="color: #000066;">validatorId</span>=<span style="color: #ff0000;">&quot;passwordConfirm&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;h:inputSecret</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;passwordConfirm&quot;</span></span>
<span style="color: #009900;">		<span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;#{registerBean.passwordConfirm}&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;f:ajax</span> <span style="color: #000066;">execute</span>=<span style="color: #ff0000;">&quot;validatePasswords password @this&quot;</span> <span style="color: #000066;">render</span>=<span style="color: #ff0000;">&quot;:messages&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/h:inputSecret<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;h:commandButton</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;submit&quot;</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;submitRegister&quot;</span> <span style="color: #000066;">action</span>=<span style="color: #ff0000;">&quot;#{registerBean.doRegister}&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;Create my account&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/h:form<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/html<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div><p> Notice how the AJAX tag references the &#8220;:messages&#8221; component outside of the form &#8211; it&#8217;s as easy as that!</p><p><div
class="wp_syntax"><div
class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;f:ajax</span> <span style="color: #000066;">execute</span>=<span style="color: #ff0000;">&quot;validatePasswords password @this&quot;</span> <span style="color: #000066;">render</span>=<span style="color: #ff0000;">&quot;:messages&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div><p>As an extra treat, this form is also using the <a
href="http://ocpsoft.com/java/jsf-2-0-cross-field-form-validation-simpl-in-reality/">multiple-component validation</a> feature from <a
target="_blank" href="http://seamframework.org/Seam3/FacesModule">Seam</a>, otherwise known as Cross-field validation, or XVal.</p><p>That&#8217;s all for today &#8212; enjoy, and as always. Happy coding!</p> ]]></content:encoded> <wfw:commentRss>http://ocpsoft.com/java/jsf2-java/how-to-jsf-2-0-render-components-outside-of-the-form/feed/</wfw:commentRss> <slash:comments>12</slash:comments> </item> <item><title>JSF 2.0 Cross-field Form Validation &#8211; Simple in Reality</title><link>http://ocpsoft.com/java/jsf-2-0-cross-field-form-validation-simpl-in-reality/</link> <comments>http://ocpsoft.com/java/jsf-2-0-cross-field-form-validation-simpl-in-reality/#comments</comments> <pubDate>Wed, 05 May 2010 14:55:50 +0000</pubDate> <dc:creator>Lincoln</dc:creator> <category><![CDATA[Java]]></category> <category><![CDATA[OpenSource]]></category> <category><![CDATA[Seam]]></category><guid
isPermaLink="false">http://ocpsoft.com/?p=1254</guid> <description><![CDATA[I&#8217;d like to start by saying that using JSF by itself can sometimes feel trying to pull your own teeth out with a pair of tweezers, but there&#8217;s hope. JSF was designed to be a platform of extensions &#8211; a foundation for building web-frameworks, and that it&#8217;s done very well. JSF 2.0 addresses most of [...]]]></description> <content:encoded><![CDATA[<p>I&#8217;d like to start by saying that using JSF by itself can sometimes feel trying to pull your own teeth out with a pair of tweezers, but there&#8217;s hope. JSF was designed to be a platform of extensions &#8211; a foundation for building web-frameworks, and that it&#8217;s done very well. JSF 2.0 addresses most of the concerns about usability (so there&#8217;s less tooth pulling,) and provides even more extensibility. That&#8217;s where <a
target="_blank" href="http://seamframework.org/Seam3/FacesModule">Seam Faces</a> comes in, that&#8217;s where <a
href="http://ocpsoft.com/prettyfaces/">PrettyFaces</a> comes in.</p><p>On many occasions you might find yourself  needing to compare the values of multiple input fields on a given page submit: confirming a password; re-enter password;  address lookups; and so on. Performing cross-field form validation is simple &#8211; just place Seam&#8217;s  &lt;s:validateForm&gt; component in the form you wish to validate, then attach your custom Validator.<br
/> <span
id="more-1254"></span><br
/> I&#8217;d like to introduce you to Seam&#8217;s intuitive answer, taken directly out of the <a
target="_blank" href="http://docs.jboss.org/seam/3/faces/reference/snapshot/en-US/html_single/#validateForm">reference manual</a>. If you want to try it out, you can <a
target="_blank" href="http://seamframework.org/Seam3/FacesModule">check out</a> the source or use a snapshot:</p><div
class="wp_syntax"><div
class="code"><pre class="xml" style="font-family:monospace;">        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.jboss.seam.faces<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>seam-faces<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${seam-faces-version}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div><h2>Seam Faces&#8217; &lt;s:validateForm&gt;</h2><div
class="wp_syntax"><div
class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;h:form</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;locationForm&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
     <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;h:inputText</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;city&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;#{bean.city}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
     <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;h:inputText</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;state&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;#{bean.state}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
     <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;h:inputText</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;zip&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;#{bean.zip}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
     <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;h:commandButton</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;submit&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;Submit&quot;</span> <span style="color: #000066;">action</span>=<span style="color: #ff0000;">&quot;#{bean.submitPost}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;s:validateForm</span> <span style="color: #000066;">validatorId</span>=<span style="color: #ff0000;">&quot;locationValidator&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/h:form<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div><p>The corresponding Validator for the example above would look  something like this:</p><div
class="wp_syntax"><div
class="code"><pre class="java" style="font-family:monospace;">@FacesValidator<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;locationValidator&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> LocationValidator <span style="color: #000000; font-weight: bold;">implements</span> Validator
<span style="color: #009900;">&#123;</span>
   @Inject
   Directory directory<span style="color: #339933;">;</span>
&nbsp;
   @Inject
   @InputField
   <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">Object</span> city<span style="color: #339933;">;</span>
&nbsp;
   @Inject
   @InputField
   <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">Object</span> state<span style="color: #339933;">;</span>
&nbsp;
   @Inject
   @InputField
   <span style="color: #000000; font-weight: bold;">private</span> ZipCode zip<span style="color: #339933;">;</span>
&nbsp;
   @Override
   <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> validate<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">final</span> FacesContext context, <span style="color: #000000; font-weight: bold;">final</span> UIComponent comp, <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">Object</span> values<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> ValidatorException
   <span style="color: #009900;">&#123;</span>
      <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>directory.<span style="color: #006633;">exists</span><span style="color: #009900;">&#40;</span>city, state, zip<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
      <span style="color: #009900;">&#123;</span>
         <span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> ValidatorException<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> FacesMessage<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Sorry, that location is not in our database. Please try again.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
   <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div><h2>Tip &#8211; You may inject the correct type directly.</h2><div
class="wp_syntax"><div
class="code"><pre class="java" style="font-family:monospace;">@Inject
@InputField
<span style="color: #000000; font-weight: bold;">private</span> ZipCode zip<span style="color: #339933;">;</span></pre></div></div><p>Notice that the IDs of the inputText components  match the IDs of your Validator @InputFields; each @Inject @InputField member will be injected with  the value of the form input field who&#8217;s ID matches the name of the variable.</p><p>In other words &#8211; the name of the @InputField  annotated member variable will automatically be matched to the ID of the input component, unless overridden by  using a field ID alias (see below.)</p><div
class="wp_syntax"><div
class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;h:form</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;locationForm&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
     <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;h:inputText</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;cityId&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;#{bean.city}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
     <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;h:inputText</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;stateId&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;#{bean.state}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
     <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;h:inputText</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;zip&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;#{bean.zip}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
     <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;h:commandButton</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;submit&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;Submit&quot;</span> <span style="color: #000066;">action</span>=<span style="color: #ff0000;">&quot;#{bean.submitPost}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;s:validateForm</span> <span style="color: #000066;">fields</span>=<span style="color: #ff0000;">&quot;city=cityId state=stateId&quot;</span> <span style="color: #000066;">validatorId</span>=<span style="color: #ff0000;">&quot;locationValidator&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/h:form<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div><p>The field with ID &#8220;zip&#8221; will still be referenced  normally; you need only specify aliases for fields that differ in name from the Validator  @InputFields.</p><h2>Tip &#8211; Using @InputField</h2><p>Using <code>@InputField("customID")</code> with an ID override can also be used to specify a custom ID, instead of using the default: the name of the  field. This gives you the ability to change the name of the private field, without  worrying about changing the name of input fields in the View itself.</p><div
class="wp_syntax"><div
class="code"><pre class="java" style="font-family:monospace;">@Inject
@InputField<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;state&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> sectorTwo<span style="color: #339933;">;</span></pre></div></div><h2>A few last thoughts</h2><p>First, as of the current version, cross-field validation does not work unless you are using the &lt;s:validateForm&gt; component. As soon as a new version of <a
target="_blank" href="http://seamframework.org/Weld/PortableExtensionsPackage">weld-extensions</a> is released, however, this functionality will work even without the &lt;s:validateForm&gt; component, and you&#8217;ll be able to reference cross-fields in any JSF validator!</p><p>For right now, however, you&#8217;ll have to deal with using the component &#8211; but &#8211; it&#8217;s really not that complicated if you think about it <img
src='http://ocpsoft.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> Happy coding!</p> ]]></content:encoded> <wfw:commentRss>http://ocpsoft.com/java/jsf-2-0-cross-field-form-validation-simpl-in-reality/feed/</wfw:commentRss> <slash:comments>3</slash:comments> </item> <item><title>Seam Faces 3.0.0.Alpha3 &#8211; JSF 2.0 just got even easier!</title><link>http://ocpsoft.com/java/seam-faces-3-0-0-alpha2-jsf-2-0-just-got-even-easier/</link> <comments>http://ocpsoft.com/java/seam-faces-3-0-0-alpha2-jsf-2-0-just-got-even-easier/#comments</comments> <pubDate>Fri, 23 Apr 2010 20:16:27 +0000</pubDate> <dc:creator>Lincoln</dc:creator> <category><![CDATA[Java]]></category> <category><![CDATA[Seam]]></category><guid
isPermaLink="false">http://ocpsoft.com/?p=1211</guid> <description><![CDATA[Ever wondered why JSF doesn&#8217;t support bean @Inject-ion in Converters or Validators? Ever wondered how to listen to a single PhaseEvent or ComponentSystemEvent, or filter on events by componentId, or view? Ever wondered why you can&#8217;t just @Inject FacesContext, or NavigationHandler? Well&#8230; now you can, with the brand-new, just-out release of Seam Faces &#8212; 3.0.0.Alpha3 [...]]]></description> <content:encoded><![CDATA[<p>Ever wondered why JSF doesn&#8217;t support bean @Inject-ion in Converters or Validators? Ever wondered how to listen to a single PhaseEvent or ComponentSystemEvent, or filter on events by componentId, or view? Ever wondered why you can&#8217;t just @Inject FacesContext, or NavigationHandler?</p><h4>Well&#8230; now you can, with the brand-new, just-out release of <a
href="http://seamframework.org/Seam3/FacesModule" target="_blank">Seam Faces</a> &#8212; 3.0.0.Alpha3</h4><p><div
class="wp_syntax"><div
class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.jboss.seam.faces<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>seam-faces<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>3.0.0.Alpha3<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div></p><p><span
id="more-1211"></span>(Currently only available through <a
href="http://maven.apache.org" target="_blank">Maven</a>)</p><h1>Sample some features:</h1><p>Focused on harnessing the power of Weld/CDI for Java, Seam Faces 3.0.0 has a good deal to offer, and more is in the works. Take a look below to see some of the powerful new functionality you&#8217;ll be able to deliver with your JSF 2.0 application. (View the latest <a
target="_blank" href="http://docs.jboss.org/seam/3/faces/reference/snapshot/en-US/html_single/">user&#8217;s guide</a>.)</p><h2>No more statics!</h2><p>With Seam Faces, you&#8217;ve got no more statics! Unit test with ease. Seam Faces breaks the static <code>FacesContext.getCurrentInstance().getExternalContext()</code> anti-pattern by <a
href="http://docs.jboss.org/weld/reference/1.0.0/en-US/html_single/#d0e931" target="_blank">producing</a> these artifacts for easy @Inject-ion.</p><div
class="wp_syntax"><div
class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ExampleBean <span style="color: #009900;">&#123;</span>
	@Inject ExternalContext context<span style="color: #339933;">;</span>
	@Inject FacesContext context<span style="color: #339933;">;</span>
	@Inject NavigationHandler handler<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div><p>Now unit tests can draw upon a mock faces context, such as:</p><div
class="wp_syntax"><div
class="code"><pre class="java" style="font-family:monospace;">@RequestScoped <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MockFacesContext <span style="color: #000000; font-weight: bold;">extends</span> FacesContext <span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">// mock stuff here</span>
<span style="color: #009900;">&#125;</span></pre></div></div><p>This works perfectly, for example, if you were using JBoss <a
href="http://community.jboss.org/en/arquillian" target="_blank">Arquillian</a> (the future of integration testing) to do real in-container testing; your test setup would look something like <a
href="http://anonsvn.jboss.org/repos/seam/modules/faces/tags/3.0.0.Alpha3/impl/src/test/java/org/jboss/seam/faces/environment/" target="_blank">this</a>.</p><h2>Converter/Validator Injection:</h2><p>By default, JSF treats Converters and Validators like &#8220;dumb objects.&#8221; It creates and throws them away whenever it pleases. With Seam, you can take back control of these artifacts. Take the following example converter, for instance:</p><p>As you can see below, this class is SessionScoped, meaning the user will retain the same Converter for the duration of the session. In other words: this converter is stateful. It supports @Inject! Not only that, but you can register <a
href="http://docs.jboss.org/weld/reference/1.0.0/en-US/html_single/#interceptors" target="_blank">interceptors</a> and <a
href="http://docs.jboss.org/weld/reference/1.0.0/en-US/html_single/#decorators" target="_blank">decorators</a> on JSF Converters/Validators. They are beans just like any other CDI-managed object!</p><p><strong>Note:</strong> If you do not @Scope your converter/validator, it will not be stateful, and the only enhanced support will be @Inject. @PreDestroy and @PostConstruct lifecycle callbacks will not function &#8211; the bean is not managed by CDI, only injected.</p><div
class="wp_syntax"><div
class="code"><pre class="java" style="font-family:monospace;">@SessionScoped
@FacesConverter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;authorConverter&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> AuthorConverter <span style="color: #000000; font-weight: bold;">implements</span> Converter
<span style="color: #009900;">&#123;</span>
   @Inject
   FacesContext context<span style="color: #339933;">;</span>
&nbsp;
   @PostConstruct
   <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setup<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
   <span style="color: #009900;">&#123;</span>
      <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;AuthorConverter started up&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
&nbsp;
   @PreDestroy
   <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> shutdown<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
   <span style="color: #009900;">&#123;</span>
      <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;AuthorConverter shutting down&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
&nbsp;
   @Override
   <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">Object</span> getAsObject<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">final</span> FacesContext arg0, <span style="color: #000000; font-weight: bold;">final</span> UIComponent arg1, <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">String</span> name<span style="color: #009900;">&#41;</span>
   <span style="color: #009900;">&#123;</span>
      <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;getAsObject - Context is: &quot;</span> <span style="color: #339933;">+</span> context<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">new</span> Author<span style="color: #009900;">&#40;</span>name<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
&nbsp;
   @Override
   <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> getAsString<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">final</span> FacesContext arg0, <span style="color: #000000; font-weight: bold;">final</span> UIComponent arg1, <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">Object</span> author<span style="color: #009900;">&#41;</span>
   <span style="color: #009900;">&#123;</span>
      <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;getAsString - Context is: &quot;</span> <span style="color: #339933;">+</span> context<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>author <span style="color: #000000; font-weight: bold;">instanceof</span> Author<span style="color: #009900;">&#41;</span>
      <span style="color: #009900;">&#123;</span>
         <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>Author<span style="color: #009900;">&#41;</span> author<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
&nbsp;
      <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div><h2>PhaseEvent Observers</h2><p>Let&#8217;s say you want to observe a JSF PhaseEvent. Now, instead of registering an entire PhaseListener class in faces-config.xml, simply create an <a
href="http://docs.jboss.org/weld/reference/1.0.0/en-US/html_single/#d0e3795" target="_blank">observer method</a>!</p><div
class="wp_syntax"><div
class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> observeBefore<span style="color: #009900;">&#40;</span>@Observes @Before PhaseEvent e<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">// Listens to all phases, before the phase</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> observeAfter<span style="color: #009900;">&#40;</span>@Observes @After @RenderResponse PhaseEvent e<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">// Listens to the RenderResponse phase, after the phase</span>
<span style="color: #009900;">&#125;</span></pre></div></div><p>This gives us an incredible amount of control when listening to specific phases. We no longer have to write boiler-plate code to determine which phases your listener cares about, just filter using @Annotations!</p><h2>Additional Scope Annotations:</h2><p>JSF 2.0 introduced the concept of <code>@javax.faces.bean.ViewScoped </code> and <code>@javax.faces.bean.FlashScoped</code>, but only provided an annotation for the View Scope!</p><p>Seam Faces goes the extra mile, and provides the @FlashScoped annotation, which means that a bean in this scope will be stored in the JSF Flash. @ViewScoped means that the object will be stored in the UIViewRoot, unique for each JSF View/Page.</p><h2>That&#8217;s all for now.</h2><p>There are more features, and more that are coming, but for now &#8212; that should get you started <img
src='http://ocpsoft.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> Try it out; <a
href="http://seamframework.org/Seam3/FacesModule" target="_blank">get involved</a> with the project; tell us what you think!</p> ]]></content:encoded> <wfw:commentRss>http://ocpsoft.com/java/seam-faces-3-0-0-alpha2-jsf-2-0-just-got-even-easier/feed/</wfw:commentRss> <slash:comments>44</slash:comments> </item> <item><title>PrettyTime 1.0.6 Released &#8211; New Languages, Thread-Safety</title><link>http://ocpsoft.com/java/prettytime-1-0-6-released-new-languages-thread-safety/</link> <comments>http://ocpsoft.com/java/prettytime-1-0-6-released-new-languages-thread-safety/#comments</comments> <pubDate>Tue, 20 Apr 2010 16:03:45 +0000</pubDate> <dc:creator>Lincoln</dc:creator> <category><![CDATA[Java]]></category><guid
isPermaLink="false">http://ocpsoft.com/?p=1188</guid> <description><![CDATA[OcpSoft PrettyTime is an open-source time-formatting library for creating human-readable timestamps like, &#8220;in 3 minutes,&#8221; or &#8220;moments ago.&#8221; &#8212; intuitive, easy, extendable. Visit the home page to download and learn more about using PrettyTime. New features in this release: Thread Safety, Java 1.5 compatibility, extra languages. &#60;dependency&#62; &#60;groupId&#62;com.ocpsoft&#60;/groupId&#62; &#60;artifactId&#62;ocpsoft-pretty-time&#60;/artifactId&#62; &#60;version&#62;1.0.6&#60;/version&#62; &#60;/dependency&#62; New Features: Several new [...]]]></description> <content:encoded><![CDATA[<p>OcpSoft PrettyTime is an open-source time-formatting library for creating human-readable timestamps like, &#8220;in 3 minutes,&#8221; or &#8220;moments ago.&#8221; &#8212; intuitive, easy, extendable. Visit the home page to download and learn more about using <a
title="PrettyTime - Elapsed Timestamp Formatting and Conversion for Java (Social, JSF2)" href="http://ocpsoft.com/prettytime/">PrettyTime</a>. New features in this release: Thread Safety, Java 1.5 compatibility, extra languages.<span
id="more-1188"></span></p><div
class="wp_syntax"><div
class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>com.ocpsoft<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>ocpsoft-pretty-time<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1.0.6<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div><h2>New Features:</h2><p>Several new languages are supported out-of-the-box in Version 1.0.6:</p><ul><li><strong>Slovenian</strong> &#8211; Uros Majeric</li><li><strong>Bulgarian</strong> &#8211; Марио Георгиев</li><li><strong>Italian</strong> &#8211; Mirco Attocchi</li><li><a
href="http://ocpsoft.com/prettytime/#i18n">See all supported languages</a> or <a
href="mailto:admin@ocpsoft.com">submit a new translation!</a></li></ul><h4>Thread safety:</h4><p>In addition to new translations &#8212; PrettyTime 1.0.6 is now Thread-Safe (why you would want to share a PrettyTime object is unknown to us, but now you can do it with confidence.)</p><h4>Java Version 1.5 support:</h4><p>PrettyFaces had erroneously been &#8220;updated&#8221; to require Java 1.6; it is now Java 1.5 compliant once more, and can be used on all of your favorite JVMs.</p><h2>Example:</h2><p>A quick intro to PrettyTime using JUnit:</p><div
class="wp_syntax"><div
class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> PrettyTimeTest
<span style="color: #009900;">&#123;</span>
 @Test
 <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> testMinutesFromNow<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span>
 <span style="color: #009900;">&#123;</span>
    PrettyTime p <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> PrettyTime<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Date</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    assertEquals<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;12 minutes from now&quot;</span>, p.<span style="color: #006633;">format</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Date</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1000</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">60</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">12</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>]]></content:encoded> <wfw:commentRss>http://ocpsoft.com/java/prettytime-1-0-6-released-new-languages-thread-safety/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>Using Embedded Glassfish with Maven</title><link>http://ocpsoft.com/java/using-embedded-glassfish-with-maven/</link> <comments>http://ocpsoft.com/java/using-embedded-glassfish-with-maven/#comments</comments> <pubDate>Tue, 23 Mar 2010 18:12:06 +0000</pubDate> <dc:creator>Lincoln</dc:creator> <category><![CDATA[Java]]></category> <category><![CDATA[OpenSource]]></category><guid
isPermaLink="false">http://ocpsoft.com/?p=1162</guid> <description><![CDATA[Three steps to add Embedded GlassFish to any existing project POM. (Upcoming &#8211; Part 2: Using Embedded JBoss AS with Maven) Using Embedded Glassfish The Embedded Glassfish project is hosted on java.net, and as it is described, is very simple: &#8220;This project develops APIs and tools around &#8220;embedded GlassFish v3&#8243;. Embedded GFv3 is a delivery [...]]]></description> <content:encoded><![CDATA[<p>Three steps to add Embedded GlassFish to any existing project POM. (Upcoming &#8211; Part 2: Using Embedded JBoss AS with Maven)</p><h3>Using Embedded Glassfish</h3><p>The <a
target="_blank" href="https://embedded-glassfish.dev.java.net/">Embedded Glassfish</a> project is hosted on <a
target="_blank" href="https://embedded-glassfish.dev.java.net/">java.net</a>, and as it is described, is very simple: &#8220;This project develops APIs and tools around &#8220;embedded GlassFish v3&#8243;. Embedded GFv3 is a delivery vehicle of GFv3 so that applications and tools can use GFv3 just as a library, inside their JVM, instead of having GFv3 as the overload of the entire JVM process. (And no, embedded GFv3 is not meant to be run on JavaME.)&#8221;<br
/> <span
id="more-1162"></span></p><h4>1. You&#8217;ll need to add this plugin repository to your POM:</h4><div
class="wp_syntax"><div
class="code"><pre class="xml" style="font-family:monospace;">        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;pluginRepositories<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;pluginRepository<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Glassfish<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>http://download.java.net/maven/glassfish/<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/pluginRepository<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/pluginRepositories<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div><h4>2. Then add the following plugin to your POM:</h4><div
class="wp_syntax"><div
class="code"><pre class="xml" style="font-family:monospace;">          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;build<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;plugins<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.glassfish<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>maven-embedded-glassfish-plugin<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>3.0<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
					<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;goalPrefix<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>glassfish<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/goalPrefix<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
					<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;app<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>test.war<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/app<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
					<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;port<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>8080<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/port<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
					<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;contextRoot<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>test<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/contextRoot<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;executions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
					<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;execution<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
						<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;phase<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>install<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/phase<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
						<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;goals<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
							<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;goal<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>run<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/goal<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
						<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/goals<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
					<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/execution<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/executions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/plugins<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
         <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/build<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div><h4>3. Commands</h4><ul><li><strong>embedded-glasfish:run</strong> &#8211; starts the embedded server if it is not already running and deploys the specfied application. The goal keeps the server running, so the user can make changes in the application, reploy and test iteratively.</li><li><strong>embedded-glassfish:start</strong> &#8211; starts the embedded server with the specified parameters</li><li><strong>embedded-glassfish:deploy</strong> &#8211; deploys the specified application</li><li><strong>embedded-glassfish:undeploy</strong> &#8211; undeploys the application identified by the &#8220;name&#8221; parameter. If no name is specifed all applications are undeployed.</li><li><strong>embedded-glassfish:stop</strong> &#8211; stops the embedded server</li><li><strong>embedded-glassfish:admin</strong> &#8211; executes the specified admin command on the embedded server. For example, you could create a jdbc resource.</li></ul><h3>Reference:</h3><p><a
target="_blank" href="http://blogs.sun.com/sirajg/entry/using_maven_plugin_for_v3">http://blogs.sun.com/sirajg/entry/using_maven_plugin_for_v3</a></p> ]]></content:encoded> <wfw:commentRss>http://ocpsoft.com/java/using-embedded-glassfish-with-maven/feed/</wfw:commentRss> <slash:comments>9</slash:comments> </item> <item><title>Why doesn&#8217;t (JPA, JMS, JTA, EJB, JSF, CDI) work? JEE is &#8220;Too Complicated&#8221;</title><link>http://ocpsoft.com/java/why-doesnt-jpa-jma-jta-ejb-jsf-cdi-work-jee-is-too-complicated/</link> <comments>http://ocpsoft.com/java/why-doesnt-jpa-jma-jta-ejb-jsf-cdi-work-jee-is-too-complicated/#comments</comments> <pubDate>Wed, 17 Mar 2010 16:53:27 +0000</pubDate> <dc:creator>Lincoln</dc:creator> <category><![CDATA[Java]]></category><guid
isPermaLink="false">http://ocpsoft.com/?p=1147</guid> <description><![CDATA[First, before reading this &#8211; you&#8217;re going to be upset with me. You&#8217;re going to disagree. I know &#8212; it&#8217;s OK. You may not even believe me, but you might keep reading because anger inspires action. Stop using Tomcat and wondering why JEE &#8220;doesn&#8217;t work.&#8221; You&#8217;re doing yourself a big disservice. Start thinking about JBoss [...]]]></description> <content:encoded><![CDATA[<p>First, before reading this &#8211; you&#8217;re going to be upset with me. You&#8217;re going to disagree. I know &#8212; it&#8217;s OK. You may not even believe me, but you might keep reading because anger inspires action.</p><h2><span
id="more-1147"></span>Stop using Tomcat and wondering why JEE &#8220;doesn&#8217;t work.&#8221;</h2><p>You&#8217;re doing yourself a big disservice.</p><p>Start thinking about <a
href="http://www.jboss.org/jbossas/downloads.html" target="_blank">JBoss AS 6</a>, or <a
href="https://glassfish.dev.java.net/" target="_blank">GlassFish v3</a> &#8212; Yes, I know, it&#8217;s a &#8220;Full JEE Container,&#8221; &#8212; it&#8217;s &#8220;Heavy,&#8221; but with JEE6, that&#8217;s not a bad thing: It all &#8220;Just works&#8221; and it works really well. Trust me, the reason people have thought Java EE sucks, is because they try to do this stuff on Tomcat, and say &#8220;Why doesn&#8217;t (JPA, JMS, JTA, EJB, JSF, CDI) work?&#8221; Well&#8230; that&#8217;s because Tomcat only gives you Servlet &#8211; the Request/Response lifecycle. So people install all these things manually, or try to, and then say, &#8220;Wow, Java EE is really hard to use, shit, I&#8217;m gonna use Spring or Grails instead.&#8221;</p><p>Tomcat, Jetty, and other &#8220;Servlet Containers&#8221; all have these issues &#8211; that&#8217;s why they are called Servlet Containers. If you really want to build everything from the ground up, piecing in parts of Java EE here and there &#8212; then go for it, but if you want it to work right away, then&#8230; well, I&#8217;ve said my part.</p><p>Ever tried to use Java Mail on Tomcat? I think we&#8217;ve all been there&#8230; you need to steal the JAR from another appserver, or get a 3rd party implementation. Sure, it&#8217;s easy, you <em>can</em> do it&#8230; but why should you have to?</p><p><strong>Please remember when submitting flames:</strong> I do know that there are a lot of legitimate reasons to use Tomcat, it&#8217;s a great Servlet container. If that&#8217;s what you choose, good for you, I think you&#8217;re wasting time if you&#8217;re trying to get bits of JEE to work, though.</p><h2>In my experience.</h2><p>I wrote a <a
title="JSF 2 and Java EE are Easy" href="http://www.javaserverfaces.org/get-started#TOC-Creating-a-JSF-2-and-CDI-project" target="_self">fully functional JSF 2 application in 5 minutes</a>. I created a new web project (Maven, <a
target="_blank" href="http://www.jboss.org/tools/download.html">Jboss Tools eclipse plugin</a> (For easy JBoss AS 6), Netbeans, <a
href="https://glassfishplugins.dev.java.net/eclipse34/index.html" target="_blank">glassfish eclipse plugin</a>, whatever) I created an index.xhtml file, and I was running JSF. Wow, that was easy, right? I even installed <a
href="http://ocpsoft.com/prettyfaces/" target="_blank">PrettyFaces</a> and had Pretty URLs and URL Rewriting working in about 2 minutes &#8211; i <a
href="http://ocpsoft.com/prettyfaces/#in2minutes" target="_blank">recorded a video</a>, only minor edits.</p><p>My WAR file was 5kb &#8212; yes, Kilobytes.</p><p>Now I wanted to use CDI and EJB &#8211; I made a Cron-like scheduler &#8211; idea taken from <a
href="http://adam-bien.com" target="_blank">Adam Bien</a>&#8216;s <a
href="http://projectkenai.com/projects/javaee-patterns" target="_blank">JEE Patterns</a> example &#8211; that sent email notifications to (nobody) &#8220;Subscribers:&#8221;</p><div
class="wp_syntax"><div
class="code"><pre class="java" style="font-family:monospace;">@Singleton
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> SubscriberNotifier <span style="color: #009900;">&#123;</span>
&nbsp;
 <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">Date</span> started <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Date</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
 @Schedule<span style="color: #009900;">&#40;</span>second<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;*/30&quot;</span>, minute<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;*/1&quot;</span>,hour<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;*&quot;</span>, persistent<span style="color: #339933;">=</span><span style="color: #000066; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span>
 <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> sendNotifications<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
 <span style="color: #009900;">&#123;</span>
 <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Notifying users subscribed to posts. First notification sent: &quot;</span>
 <span style="color: #339933;">+</span> <span style="color: #000000; font-weight: bold;">new</span> PrettyTime<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Date</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">format</span><span style="color: #009900;">&#40;</span>started<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div><p
lang="java">I did use <a
href="http://ocpsoft.com/prettytime/" target="_blank">PrettyTime</a> to format the date object into something human-readable, but that&#8217;s not really relevant to JEE. The point is -  I had a background service running, using EJB Scheduling &#8211; with full transactional and persistence support (if I chose to use those) up and running in as little time as it took to write a dumb little class and put two annotations on it. The JEE container automatically picked it up, and started it when I started my application.</p><p
lang="java">And then I thought, &#8220;Wait, when did this get easy?&#8221; EJB used to make my heart shrivel inside my chest.</p><p
lang="java">It&#8217;s all going to get even easier, too, when JBoss Seam 3 Framework starts releasing more of our development modules. I&#8217;m working on the <a
href="http://seamframework.org/Documentation/Seam3Modules#H-FacesLedByLincolnBaxterAndDanAllen" target="_blank">Faces, Servlet, and Internationalization modules</a> personally.</p><p
lang="java"><p>Now that my elevator speech is over <img
src='http://ocpsoft.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> If you already use JSF 1.2, now is the time to upgrade &#8212; migrating to JSF 2.0 should be pretty simple.  All you need to do (unless you use some 3rd party component libraries) is change your XML schema in faces-config.xml, version from 1.2 to 2.0.</p><blockquote><p>&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;UTF-8&#8243;?&gt;<br
/> &lt;faces-config xmlns=&#8221;http://java.sun.com/xml/ns/javaee&#8221;<br
/> xmlns:xsi=&#8221;http://www.w3.org/2001/XMLSchema-instance&#8221;<br
/> xsi:schemaLocation=&#8221;http://java.sun.com/xml/ns/javaee<br
/> http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd&#8221;<br
/> version=&#8221;2.0&#8243;&gt;</p><p>&lt;/faces-config&gt;</p></blockquote><p>And you will be running with JSF2. Once you do that, you should definitely try out <a
href="http://docs.jboss.org/weld/reference/1.0.0/en-US/html/" target="_blank">CDI (Weld)</a> &#8211; it&#8217;s IMPRESSIVE. Trust me&#8230; if you&#8217;ve tried, or heard of Spring &#8211; you&#8217;re going to like this. PS. You can also get use the plug-in for JBoss AS 5 for JBoss AS 6; get it the via &#8220;Install additional server adapters&#8221; link in Eclipse&#8217;s &#8220;New Server&#8221; dialogue.</p><h3>Final thoughts:</h3><p><strong>Note:</strong> As a followup, I&#8217;d also like to add that the <a
target="_blank" href="http://jcp.org">JCP</a> &#8211; &#8220;Java &#8216;Corporate&#8217; Process&#8221; really needs to be re-evaluated. It needs to be placed in the hands of the community in which it was supposed to stand for so long. Oracle has this chance &#8211; and it must not blow it if the good things we all love about Java, JavaEE, the JVM, Tomcat, Grails are going to continue moving forward with healthy competition and innovation.</p><p>I call for the JCP &#8211; &#8220;Java <strong>Community</strong> Process&#8221; to become an independent foundation like Eclipse &#8211; public TCKs, free intellectual property, true community participation (open mailing lists, forums, wikis) &#8211; WITHOUT the need to print and fax a 7 page JSPA document to Sun in SanFran. I&#8217;m calling for a place where Java and JavaEE documentation are provided to, and by, the community &#8211; a site like PHP.net. I&#8217;m <a
target="_blank" href="http://www.google.com/search?q=reform+the+Java+JCP">not the only person</a> asking for this. Oracle &#8211; I&#8217;m holding you accountable for the future of Java, JavaEE, and the JVM.</p><p>In the words of the human torch&#8230;</p><h1 style="text-align: center;">&#8220;FLAME ON!&#8221;</h1> ]]></content:encoded> <wfw:commentRss>http://ocpsoft.com/java/why-doesnt-jpa-jma-jta-ejb-jsf-cdi-work-jee-is-too-complicated/feed/</wfw:commentRss> <slash:comments>80</slash:comments> </item> <item><title>One year&#8217;s time</title><link>http://ocpsoft.com/opensource/one-years-time/</link> <comments>http://ocpsoft.com/opensource/one-years-time/#comments</comments> <pubDate>Thu, 28 Jan 2010 17:53:39 +0000</pubDate> <dc:creator>Derek</dc:creator> <category><![CDATA[JSF]]></category> <category><![CDATA[JSF2]]></category> <category><![CDATA[OCPSoft]]></category> <category><![CDATA[OpenSource]]></category> <category><![CDATA[PrettyFaces]]></category><guid
isPermaLink="false">http://ocpsoft.com/?p=788</guid> <description><![CDATA[It is amazing what can be done in exactly one year&#8217;s time.  January 17th will have been the 2nd anniversary since Lincoln Baxter and I started OcpSoft.  It&#8217;s been one seriously fun, and wild, ride with JavaServer Faces and the open-source community.  I want to take a moment to talk about my partner&#8217;s success story [...]]]></description> <content:encoded><![CDATA[<p>It is amazing what can be done in exactly one year&#8217;s time.  January 17th will have been the 2nd anniversary since Lincoln Baxter and I started OcpSoft.  It&#8217;s been one seriously fun, and wild, ride with <a
href="http://www.javaserverfaces.org">JavaServer Faces</a> and the open-source community.  I want to take a moment to talk about my partner&#8217;s success story and what he has accomplished in just <em>one</em> short year.</p><p><span
id="more-788"></span></p><h3>The Beginning</h3><p>When we started OcpSoft, we were working on what is now <a
title="ScrumShark" href="http://ocpsoft.com/scrumshark/" target="_blank">ScrumShark</a> &#8211; using JSF 1.2 , Hibernate, and many other technologies.  At first it was very overwhelming, challenging to figure out which technologies to use; though, even after we had chosen our technology stack, we fought with poor documentation, lack of support, and integration as we explored new features of the stack.</p><p>During that time Lincoln saw a need for pretty URLs, because what was currently on the market wasn&#8217;t intuitive, and was painful to work with.  The enhancements we requested weren&#8217;t getting approved or were too slow coming, even providing patches.  So Lincoln set out to do it himself, and as he puts it: &#8220;destroyed Thanksgiving 2008.&#8221;</p><h3>PrettyFaces</h3><p>Thanks to <a
href="http://ocpsoft.com/prettyfaces/">PrettyFaces</a>, Lincoln dug-in to JSF and started to really understand the inner workings of both problem and solution; within a few weeks of releasing version one, we were seeing many supporters.  Soon after, Lincoln was contacted by Dan Allen from JBoss/Red Hat, and started assisting him with an enhancement to JSF&#8217;s navigation system.</p><p>During that same time Lincoln convinced us &#8211; at OcpSoft &#8211; to start using JSF 2 Beta to build ScrumShark.  JSF 2 was undergoing continuous changes at that time, and the specification wasn&#8217;t even public, so we were seeing different results in our application every week.  Lincoln started posting the issues on the JSF 2 mailing list, and quickly became known as the JSF 2 tester, bug-finder.  Without <a
title="ScrumShark" href="http://ocpsoft.com/scrumshark/" target="_blank">ScrumShark</a>, and Lincoln willing to take a chance on a bleeding edge technology, I don&#8217;t think the JSF 2 team would have found and fixed all the bugs as fast as they did.  Not too long after this, he joined the JSF Expert Group and was presenting <a
href="http://ocpsoft.com/prettyfaces/jsfsummit-2009-prettyfaces-makes-an-appearance/" target="_blank">PrettyFaces at JSFSummit</a>.</p><h3>Congratulations Lincoln!</h3><p>He just got a job with <a
target="_blank" href="http://jboss.org">JBoss</a> at <a
target="_blank" href="http://www.redhat.com">Red Hat</a>, as a Senior Software Engineer. I am <em>proud </em>of of what my partner and best friend Lincoln has accomplished.</p> ]]></content:encoded> <wfw:commentRss>http://ocpsoft.com/opensource/one-years-time/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>JSF 1.2 Components (Book Review)</title><link>http://ocpsoft.com/opensource/jsf-1-2-components-book-review/</link> <comments>http://ocpsoft.com/opensource/jsf-1-2-components-book-review/#comments</comments> <pubDate>Wed, 20 Jan 2010 06:56:21 +0000</pubDate> <dc:creator>Lincoln</dc:creator> <category><![CDATA[JSF2]]></category> <category><![CDATA[OpenSource]]></category> <category><![CDATA[Technology]]></category> <category><![CDATA[JSF]]></category><guid
isPermaLink="false">http://ocpsoft.com/?p=983</guid> <description><![CDATA[As a vocal blogger, I feel responsible for promoting and sharing the good work of others, whether that be technology, creative work, or in this case: a book. I will take no exception to that philosophy when it comes to the JavaServer Faces framework. For a quick read, try the summary. If you are intrigued, [...]]]></description> <content:encoded><![CDATA[<p>As a vocal blogger, I feel responsible for promoting and sharing the good work of others, whether that be technology, creative work, or in this case: a book. I will take no exception to that philosophy when it comes to the <a
target="_blank" href="http://www.javaserverfaces.org">JavaServer Faces</a> framework. For a quick read, try the summary. If you are intrigued, read on! I hope you find this review valuable.<br
/> <span
id="more-983"></span></p><p><strong>In summary:</strong> I would recommend buying this reference if you are a consumer, designer, UI-developer who is working with existing component libraries, Facelets or JSF 2.0, and not so much focused on creating custom Java-components of your own. I don&#8217;t, for every-day web-site components, see why you would need much more than what is featured between the covers of this book. Ian Hlavats does a fantastic job of making bringing JSF to the everyday development setting.<br
/> <br/></p><table><tr><td><a
target="_blank" href="http://www.packtpub.com/jsf-1-2-components-develop-advanced-ajax-enabled-applications/book?utm_source=ocpsoft.com&#038;utm_medium=bookrev&#038;utm_content=blog&#038;utm_campaign=mdb_002041"><img
src="http://ecx.images-amazon.com/images/I/51zwgyza8HL._SL500_AA240_.jpg"></img></a></td><td><h4><a
target="_blank" href="http://www.packtpub.com/jsf-1-2-components-develop-advanced-ajax-enabled-applications/book?utm_source=ocpsoft.com&#038;utm_medium=bookrev&#038;utm_content=blog&#038;utm_campaign=mdb_002041">JSF 1.2 Components</a></h4><p>By Ian Hlavats<br
/> <br/><br
/> Download Chapter 2: <a
target="_blank" href="http://www.packtpub.com/files/7627-developing-jsf-components-sample-chapter-2-facelets-components.pdf">Facelets Components</a> as a PDF</td></tr></table><p><br/></p><h3>In detail:</h3><p>Initially hesitant to buy a reference on components, I have to admit that I was surprised to learn so much by reading through this book. As a member of the JavaServer Faces 2.0 expert group, and a full-time software engineer, components are not my strong-suit. If you&#8217;re at all like me, then you&#8217;re probably asking yourself the same question I did:</p><p>&#8220;What can I learn in this book that I can&#8217;t find on Google? JavaServer Faces has a huge online community, and there&#8217;s a lot of information available already.&#8221;</p><p>It&#8217;s a valid question, but you should keep reading because this book offers something important that I rarely find in blog entries or wikis: &#8220;features you wouldn&#8217;t think to look for; features that you wish you&#8217;d thought of, or don&#8217;t know how to make yourself.&#8221; I wish I had found this book when I started using JSF, because I&#8217;d probably have been more comfortable, and much more productive with our component side of the life-cycle, so to speak; I discovered features of the framework, and pre-made UI-tools that I wish I&#8217;d known about years ago.</p><h5>Things you&#8217;ll learn about:</h5><p>Modal windows, menus, wizards and workflows, AJAX anything with Ajax4JSF, i18n and localization, gCal-like schedules with Apache Tomahawk, multi-field validation, calendars, charts and graphs, file-uploads, user permissions/security, skinning, styling, and all major component libraries are covered in this book (save PrimeFaces, which gets a mere mention.)</p><p>If you think you&#8217;re looking at &#8220;Just another book on JSF component writing,&#8221; that&#8217;s not entirely the case. This book provides real solutions, real examples on how to get started writing JSF applications using existing component libraries and plug-ins. There are two types of chapters in this book: tutorials and references. The tutorials will get you up and running with a quick example, while the reference sections go in depth on usage of individual components within each library.</p><p>You&#8217;ll also (as a bonus, in my opinion) get some appetite-whetting information on the JBoss Seam framework, which is a user-friendly and business-oriented extension to the Java EE technologies. I didn&#8217;t get a very good picture of all of the concepts until I actually looked at the code samples (downloadable here, or just follow the link in the preface,) but that&#8217;s hardly a strong criticism; though, it may have helped if the code samples were more explicitly, frequently referenced.</p><h5>In the end &#8220;The title doesn&#8217;t lie&#8221;:</h5><ul><li>I haven&#8217;t seen a more comprehensive book on component libraries and component writing made available to date.</li><li>JSF2 component writing has been simplified, but if you want to supplement your app with everyday things like in-place editing, accordions, and more, you&#8217;re going to want good examples; this book provides examples in abundance (even examples of JSF2 EzComp, which is a dream to use. UI like it was meant to be)</li><li>Even if components and UI design are not your strong-point, that is exactly why you should read this book; it makes component-based design easy to understand, and easy to implement.</li></ul><p>The author covers many of the advancements in component writing and simplified configuration that are provided by JSF 2.0, but I would have liked to hear some information on the component behaviors model, and mention of integration with frameworks like CDI (JSR-299) and Spring; however, this is not entirely relevant to component writing, and plenty of information exists on sites like <a
target="_blank" href="http://www.javaserverfaces.org">www.javaserverfaces.org</a> or Google.</p><p>My one complaint is that for a book titled &#8220;JSF 1.2 Components,&#8221; it did not explain, or teach me how to create custom Java-based components, which are essential for complex behavior and interaction at some level. JSF 2.0 has done a good job of making Java-based components unnecessary, but this book is titled JSF 1.2 components, thus, I would have liked to see how to write a Java-based component in JSF 1.2.</p><div
class="featured" style="text-align: center;"> <a
target="_blank" href="http://www.packtpub.com/jsf-1-2-components-develop-advanced-ajax-enabled-applications/book?utm_source=ocpsoft.com&#038;utm_medium=bookrev&#038;utm_content=blog&#038;utm_campaign=mdb_002041">JSF 1.2 Components</a> on Packt Publishing<br
/> Download Chapter 2: <a
target="_blank" href="http://www.packtpub.com/files/7627-developing-jsf-components-sample-chapter-2-facelets-components.pdf">Facelets Components</a> as a PDF</div><h3>End notes:</h3><p> Make sure you check out <a
target="_blank" href="http://www.javaserverfaces.org">www.javaserverfaces.org</a>. It&#8217;s a great starting point and reference for JSF that you will undoubtably bookmark if doing a lot of work, and doing the work with this book. Also check out <a
href="http://ocpsoft.com/prettyfaces/">http://ocpsoft.com/prettyfaces/</a> for more information on Pretty URLs in JSF, and building client-facing JSF web applications.</p> ]]></content:encoded> <wfw:commentRss>http://ocpsoft.com/opensource/jsf-1-2-components-book-review/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>What a wild ride &#8211; My journey through OpenSource / JSF</title><link>http://ocpsoft.com/opensource/what-a-wild-ride-my-journey-through-opensource-jsf/</link> <comments>http://ocpsoft.com/opensource/what-a-wild-ride-my-journey-through-opensource-jsf/#comments</comments> <pubDate>Sat, 19 Dec 2009 23:21:47 +0000</pubDate> <dc:creator>Lincoln</dc:creator> <category><![CDATA[JSF2]]></category> <category><![CDATA[OpenSource]]></category><guid
isPermaLink="false">http://ocpsoft.com/?p=624</guid> <description><![CDATA[It was about one year prior to this article that I wrote “JSF2 is in good hands”, in which I spoke about the upcoming release of JavaServer™ Faces 2, and how the community had changed immensely in the few years I’d been using the tool. There were changes I wanted to make, and started making [...]]]></description> <content:encoded><![CDATA[<p>It was about one year prior to this article that I wrote “<a
href="http://ocpsoft.com/java/jsf2-in-good-hands/" target="_blank">JSF2 is in good hands</a>”, in which I spoke about the upcoming release of <a
href="http://www.javaserverfaces.org" target="_blank">JavaServer™ Faces 2</a>, and how the community had changed immensely in the few years I’d been using the tool. There were changes I wanted to make, and started making them by publishing an open source extension called PrettyFaces.</p><p><a
href="http://ocpsoft.com/prettyfaces/" title="SEO | Dynamic Parameters | Bookmarks | Navigation | JSF | JSF2 | UrlRewrite" target="_blank">PrettyFaces</a> lets you map Pretty URLs to any resource within a JSF-based web-application (eg: /example -> /faces/examples/page.xhtml). While this is stuff that other web-frameworks have been doing for years, (WordPress, Rails/Grails, etc) it’s stuff that has traditionally been hard using JavaServer Faces – until around November 2008, when the first release was published.</p><p>Now, I&#8217;m relatively new to this arena &#8211; I entered the open source community for the first time about four years ago, working on PHP and Perl modules. I&#8217;ve been using it, and appreciating it, for almost my entire life in the industry, but never giving back. I suppose one question that many people ask is, &#8220;Will working on open source software get me anywhere in my career?&#8221;<br
/> <span
id="more-624"></span></p><p><center><br
/><h2>Getting involved</h2><p></center></p><p>My answer is really a simple one, and may not be unique, but for me &#8220;it just doesn&#8217;t matter.&#8221; I do this because I enjoy it. It turns out, however, that working on open source software is not only extremely rewarding for me, but it is also having a big impact on my career. I do what I&#8217;m doing because I have a passion for it, and I think good things happen whenever you follow your passion.</p><p>Prove it? Well… during the first week of December 2009, I attended my first professional conference as a speaker, <a
href="http://jsfsummit.com" target="_blank">JSFSummit 2009</a> by <a
href="http://www.nofluffjuststuff.com/" target="_blank">NFJS</a>, and presented PrettyFaces &#8211; coming nearly one year ago to the day, when I released version 1.0 (now used on production servers around the world!) I consider that having an impact.  In a few months I&#8217;ll be presenting again at the <a
href="http://www.phillyemergingtech.com/speakers/8">Philadelphia Emerging Tech</a> conference (April 8-9, 2010.) These are opportunities I never would have had, if not for my involvement in open source.</p><p>I can only imagine what begins to happen as <a
href="http://ocpsoft.com/scrumshark/" target="_blank" title=" Open Source | Online Agile Project Management Tools">ScrumShark</a>(open source agile project management tools) starts to gain footing. PrettyFaces is one small extension for JSF; with something bigger, more powerful, the sky is the limit.</p><p><center><br
/><h2>Real Rewards</h2><p></center></p><p>For JSFSummit, I was flown to Orlando, stayed at the Loews Portofino Bay Hotel across the street from Universal MGM, and met some of not only the most interested developers, but also the most prominent figures in Java web-technology today. I met folks from Red Hat, SUN, Oracle, Scotia Bank, Children’s Hospital at Harvard, and more. Even more interestingly, I met a few people like myself: young, entrepreneurial, full time developers with a passion for creativity, and producing something for the world.</p><p><a
href="http://www.jsfsummit.com/conference/orlando/2009/12/speakers/cagatay_civici" target="_blank">Cagatay Civici</a> was someone I closely related to. He’s from Turkey, now living in London, only a year older than myself, and has created one of the simplest, most elegant component libraries – PrimeFaces – for JSF and JSF2. Like me, he works in his spare time to create something not just worthwhile, but something nobody else has done before. He does it well, and because he loves it.</p><p>The satin hotel greeted me with appeal of a little faux-Italian Portofino, “how did I get here?” I raced, as my black cap-toe shoe swung open the door to a double queen room with a bathroom big enough for a party. &#8220;Wow&#8230;&#8221;</p><p>I had worked &#8211; hard &#8211; for this, sometimes working as many as 8 hours a night after coming home from my full time job. I have to admit that part of me felt like pushing those double-queen beds together and jumping up and down on them. (There was no jumping, that would be highly unprofessional) After a night of food and conversation with <a
target="_blank" href="http://www.jsfsummit.com/conference/orlando/2009/12/speakers/dan_allen">Dan Allen</a> &#8211; the man who really got me involved in JSF2) and his lovely wife Sarah, I was ready to go for the day-one of the conference. This was the first time we&#8217;d ever met, and I was pumped!</p><div
class="featured"><table
width="100%"><tr><td
width="480px"><img
src="http://ocpsoft.com/wp-content/uploads/2009/12/portafino.jpeg" alt="" title="portafino" width="479" height="333" class="alignnone size-full wp-image-717" /></td><td><center>The hotel, a view from the bridge to Universal Studios. (I had dinner with Dan and Sarah in the white building on the far left.)</center></td></tr></table></div><p><center><br
/><h2>Day 1: Starting out strong</h2><p></center></p><p>My first presentation was on the first full day of the conference: “Seam and RestEasy – You haven&#8217;t seen REST yet,” and let me tell you, before preparing this presentation, I certainly hadn&#8217;t. Seam handles REST in a way that I&#8217;d never thought Java would provide. Dynamic, automatic, CRUD. I gave the first half – on REST principles, and Dan finished up with the Seam stuff – making Seam/REST look like a two-piece, tailored suit. I was amazed, actually, that the presentation went so well, given that we had just met and put it together in a few hours the previous night. (We did work on the slides and demos in advance, though.)</p><p>Talk about a rush – my first professional conference, and I was getting to meet people I&#8217;ve been hearing about in the industry for years: Ed Burns, Jim Driscoll, David Geary, Kito Mann, Andy Schwartz, and so many more.</p><p>I was caught in a summer storm of information, wild, over before I knew it: Holistic testing of JSF applications with Stan Silvert, my first presentation with Dan Allen, Polyglot JavaServer Faces with Kito Mann, Component Framework Primer for JSF with Andy Schwartz, <a
href="http://seamframework.org/Weld" target="_blank">CDI JSR-299/Weld</a> and the future of Seam with Dan Allen.</p><p>I&#8217;ll mention the points that “blew my mind,” and really I have to say that while all the speakers were excellent, the emerging technology that “took my cake&#8221; on day one was CDI. This is a place where Java EE is finally competing with Spring, by providing powerful contexts and dependency injection to the core Java container, even J2SE with Weld. I&#8217;m telling you, Spring is great, but CDI/Weld is serious competition. I plan on switching <a
href="http://ocpsoft.com/scrumshark/" target="_blank">http://scrumshark.com/</a> over from Spring to CDI. Weld took the best parts of Spring and Guice and put them together with the J2EE platform&#8230; wow!</p><p>Another night of drinks, this time with more of the J2EE community out on the patio of the hotel. Time for bed again.</p><p><center><br
/><h2>Day 2: The Main Event</h2><p></center></p><p>This was my day, and I was up bright at early – still, only six hours of sleep. Let me tell you, Jay Zimmerman, owner of the No Fluff Just Stuff conference tour, truly knows how to put on a conference. All meals were provided, incredibly balanced, and equaled only by some of the best restaurants I&#8217;ve been to.</p><p>I started the day off with an egg and sausage wrap, a bowl of fresh fruit, and a cup of coffee. The first session was <a
href="http://www.jsfsummit.com/conference/orlando/2009/12/speakers/david_geary" target="_blank">David Geary</a> – Killer Web apps with JSF2.0 Ajax. “Wow,” I thought, “this guy knows how to present!” I think every other line was a joke, but I wasn&#8217;t sure because he was so clearly explaining all of the topics; I&#8217;d hire him to train at my company any day.</p><p><a
href="http://www.jsfsummit.com/conference/orlando/2009/12/speakers/andy_schwartz" target="_blank">Andy Schwartz</a> presented JSF2 Component Behaviors Deep Dive, and with a whopping 180 slides, my head was packed with info by the end. Behaviors open up a whole new realm of component development. If you&#8217;ve ever played a role-playing game, behaviors are like enhancements that you can add on to any piece of armor or weapon, buffs, blessings, sockets, take your pick: plug-able, reusable behavior. I plan on taking advantage of them myself. Need a reusable javascript confirmation box? Make a behavior, use it on any component.</p><p><center><br
/><h2>PrettyFaces makes an appearance</h2><p></center></p><p>My presentation was the last of the day (read the <a
href="http://ocpsoft.com/prettyfaces/jsfsummit-2009-prettyfaces-makes-an-appearance/" target="_blank">slides</a>,) and let me tell you, I was prepared. For the last two weeks I had rehearsed (or read through my slides) almost every night, and with the Seam &#038; RestEasy presentation under my belt, any nervousness I thought I might have had was long gone. It was <i>ON NOW</i>.</p><p>With good questions from Conference Attendees and <a
href="http://www.javaserverfaces.org/specification/expert-group" target="_blank">JSF Expert Group</a> members alike, discussion was not lacking at any point. People were interested, moreso than I had expected, and I was impressed that several attendees had already been using PrettyFaces in their applications!</p><p>I felt truly rewarded to hear how PrettyFaces had helped solve business problems, and how much people loved using it. I heard, &#8220;It&#8217;s perfectly simple,&#8221; &#8220;It does what I expect,&#8221; and other great feedback.</p><p><center><br
/><h2>Day 3: The Big Goodbye</h2><p></center></p><p>The last day held only three sessions, and I chose &#8220;Rapid RIA Development with <a
href="http://primefaces.org/" target="_blank">PrimeFaces</a>,&#8221; presented by Cagatay Civici. This was truly a treat &#8211; as I mentioed before, Cagatay has started something amazing. Simple components with poweful functionality. A schedule component (that looks GOOD), an entire mock Mac OSX, and over 70 components: a shell console, charts, sliders, pickers, pluggable Ajax Drag &#038; Drop &#8211; all so easy that I felt like I could go write an app in minutes. This was my &#8220;wow&#8221; of the day; I think everyone was impressed.</p><p>Overall, I don&#8217;t think I&#8217;ve had a more exciting week in my career. This conference was almost a total surprise to me. I pushed to get myself in, and I had help, but let me tell you, &#8220;I&#8217;m glad I did it.&#8221; I&#8217;ve been struggling with the idea of, &#8220;Can I really do what I want, professionally,&#8221; and, &#8220;How do I get there?&#8221; And for me, the answers are simple: &#8220;Just do it.&#8221; Do what you love and good things will happen; share your ideas; don&#8217;t give up; make sure you take time to be human; go outside, meet people, make friends. We don&#8217;t have long to make a difference in the world (of ideas, love, music, charity, technology, &#8230;) so it&#8217;s best not to stop for one single moment.</p><p>If there&#8217;s one sentiment I can leave you, reading this far, it would be &#8211; <strong>Chase your passion</strong>.</p><p><center><br
/><h2>The Future Holds&#8230;</h2><p></center></p><p>My plans for the future involve taking Java EE, and turning it into a platform that is simple and intuitive enough to compete with PHP and Ruby for startup businesses. There&#8217;s so much power in Java EE, and I want people to know about it. Among my initiatives, since I&#8217;m already involved in JSF, was to give the new Java standard web-framework a home on the internet, a place where people can go for any information about JSF2: <a
href="http://ocpsoft.com/java/jsf-java/jsf2-engaging-the-community/" target="_blank">www.javaserverfaces.org</a>, and the expert group members have really stepped up behind this site to make it successful.</p><p>Java EE 6 is a revolutionary release of the J2EE platform, and with Bean Validations, JavaServer Faces 2, Contexts and Dependency Injection, and JAX-RS (REST web services,) it&#8217;s never been so powerful. It&#8217;s time to <a
href="http://glassfish.org" target="_blank">take another look</a>. We are already using everything but CDI in <a
href="http://ocpsoft.com/scrumshark/" target="_blank" title=" Open Source | Online Agile Project Management Tools">ScrumShark</a>, but that will be changing soon.</p><p><center><br
/><h2>Other articles looking back at JSFSummit 2009:</h2><p><a
href="http://in.relation.to/Bloggers/JSFSummit2009Postback">http://in.relation.to/Bloggers/JSFSummit2009Postback</a><br
/> <a
href="http://andyschwartz.wordpress.com/2009/12/17/jsf-2-on-the-road/">http://andyschwartz.wordpress.com/2009/12/17/jsf-2-on-the-road/</a><br
/> <a
href="http://in.relation.to/Bloggers/JSFSummitAComponentLibrariesPointOfView">http://in.relation.to/Bloggers/JSFSummitAComponentLibrariesPointOfView</a></p><p></center></p> ]]></content:encoded> <wfw:commentRss>http://ocpsoft.com/opensource/what-a-wild-ride-my-journey-through-opensource-jsf/feed/</wfw:commentRss> <slash:comments>5</slash:comments> </item> <item><title>A winter tale of Java Server Faces</title><link>http://ocpsoft.com/java/jsf2-java/a-classroom-tale-of-jsf2/</link> <comments>http://ocpsoft.com/java/jsf2-java/a-classroom-tale-of-jsf2/#comments</comments> <pubDate>Mon, 14 Dec 2009 15:27:53 +0000</pubDate> <dc:creator>Lincoln</dc:creator> <category><![CDATA[JSF2]]></category><guid
isPermaLink="false">http://ocpsoft.com/?p=628</guid> <description><![CDATA[As a member of the JSF 2 expert group, I&#8217;ve stated that my primary goal is to make JSF, and J2EE, more accessible to the community at large, to reach out and make sure that people&#8217;s voices are heard, and that what we are doing makes sense. I&#8217;ve only been part of the group for [...]]]></description> <content:encoded><![CDATA[<p>As a member of the JSF 2 <a
target="_blank" href="http://www.javaserverfaces.org/">expert group</a>, I&#8217;ve stated that my primary goal is to make JSF, and J2EE, more accessible to the community at large, to reach out and make sure that people&#8217;s voices are heard, and that what we are doing makes sense. I&#8217;ve only been part of the group for a little under a year, but I&#8217;ve met some pretty cool people, and you&#8217;d be surprised at how interested they all are to hear your story.</p><p>Here&#8217;s an email from David Geary (a long-time EG member) to the Expert Group, that I think paints a very nice picture of people&#8217;s reaction to JSF and JSF2, author of Core Java Server Faces (<a
target="_blank" href="http://horstmann.com/corejsf/">Core JSF</a>):<br
/> <span
id="more-628"></span><br
/><center></p><div
class="featured" style="text-align: justify; max-width: 600px;"><div
class="inside"> <i><p>I just got done with two days of training in Quebec City (you can follow my exploits, if you&#8217;re interested, at <a
target="_blank"  href="http://twitter.com/davidgeary">@davidgeary</a>). The first day was advanced JSF 1.2, and I watched students&#8217; eyes glaze over as I covered the complexities of custom components, renderers, converters, and validators. Java code, XML configuration, encoding, decoding, etc. &#8212; you know the drill. One of the developers had used Rails, and he looked downright depressed. But I knew day 2 would be different. Oh yeah.</p><p>Because day 2 was all JSF 2, and it was an entirely different story. I started with an overview of the new features in JSF 2, and then dove deeply into Facelets, templates, composite components, and Ajax. Students were blown away. Blown. Away.</p><p>What was a fairly sullen group on day one turned into a rambunctious group of excited developers on day two. Could they use JSF with WebLogic 10? they wanted to know. What about RichFaces, when will that support JSF 2?, they asked. Until we upgrade to JSF 2, can we do this templating stuff with the open source version of Facelets?. The Rails guy was all smiles. This is pretty cool, eh? I said (eh, if you don&#8217;t know, is Canadian for hunh). Oh yeah, they said. Oh yeah.</p><p>As I was covering JSF 2, I could feel the excitement building in the room. Lots of smiles, lots of laughter, and excited chatting and whispers in the incredibly beautiful language that is Quebec French, between students. It was really phenomenal.</p><p>Early in the morning, the blizzard started. I&#8217;m teaching class, and, out the window, snow is coming down like hell, in all different directions because of the fierce winds that accompanied a major snowstorm that dumped nearly a foot of snow on the ground during class. I started out with 11 students, and by the time I finished class at the end of the day, I had &#8230; 10 students! I&#8217;m telling you, those guys were mesmerized by JSF 2. Even though the weather gave them good reason to leave class early, only one guy, who had kids that he had to pick up because les ecoles etait fermer, left class early.</p><p>I got done with the material, and told them that they were free to go, that they probably should go because of the storm, but that I&#8217;d be happy to answer questions, and even with the intense blizzard raging outside, they all stuck around for another 1/2 hour, brainstorming with me about how they could upgrade from 1.2 to 2.0, given their current situation.</p><p>For me, this training, unlike any other I&#8217;ve ever done, was almost a religious experience. For us, it&#8217;s validation that all the hard work we&#8217;ve put into JSF 2 is paying off.</p><p>A bientot,<br/>David</p><p></i></div></div><p></center></p><p>Now, I &#8211; for one &#8211; find this exciting! This is another great sign that we&#8217;ve done things right with JSF2. The best part is, we are only going to keep improving. Want to get involved? Tweet your suggestion using #jsf2next &#8211; or put issues directly into the JSF2 Issue Tracker (all you need to do is register for, or use your existing java.net account.)</p><p>What does the future hold? That&#8217;s up to you to decide&#8230; For more information on JSF 2 features, a getting started guide, how to give feedback, get involved, and why JSF 2 is a leading web-framework, visit <a
href="www.javaserverfaces.org">www.javaserverfaces.org</a>.</p><p>You can read this email on David&#8217;s blog, here: <a
target="_blank" href="http://davidgearyblog.wordpress.com/">http://davidgearyblog.wordpress.com/</a></p><p><br/></p> ]]></content:encoded> <wfw:commentRss>http://ocpsoft.com/java/jsf2-java/a-classroom-tale-of-jsf2/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> </channel> </rss>
<!-- Served from: ocpsoft.com @ 2010-07-29 17:04:46 by W3 Total Cache -->