<?xml version="1.0"?>
<rss version="2.0">
<channel>
  <title>Darwin&#039;s Theories - seam tag</title>
  <link>http://theories.darwinsys.com:80/tags/seam/</link>
  <description>Call it a Blog if you like -- Ian</description>
  <language>en</language>
  <copyright>Ian Darwin</copyright>
  <lastBuildDate>Sat, 19 Nov 2011 14:35:00 GMT</lastBuildDate>
  <generator>Pebble (http://pebble.sourceforge.net)</generator>
  <docs>http://backend.userland.com/rss</docs>
  
  
  <item>
    <title>Site Modernization</title>
    <link>http://theories.darwinsys.com:80/2009/03/26/1238078940000.html</link>
    
      
        <description>
          Every web site needs to keep improving, and your obd&#039;t servant is no different. I started almost exactly a year ago 
&lt;a href=&#034;http://theories.darwinsys.com/2007/03/23/1174700820000.html&#034;&gt;
by replacing the old blog software with Pebble&lt;/a&gt;.
Then I got busy with real work, and had to put aside site maintenance. 
Around the beginning of this year I was able to modernize both the home page of 
&lt;a href=&#039;http://www.darwinsys.com&#039;&gt;darwinsys.com&lt;/a&gt;
(making it new and graphical) and the layout of 
&lt;a href=&#039;http://www.darwinsys.com/indextxt.jsp&#039;&gt;
the rest of the main site&lt;/a&gt;.
This week, I re-did the 
&lt;a href=&#039;http://www.darwinsys.com/jwf/&#039;&gt;
Java Web Frameworks&lt;/a&gt; site, which has gone from coyote-ugly to fairly modern looking, after being re-implemented using 
&lt;a href=&#039;http://www.seamframework.org/&#039;&gt;the Seam framework&lt;/a&gt;.
So, I am now running Seam (&amp;quot;war deployment&amp;quot; option) on Tomcat in production.&lt;br /&gt;
&lt;br /&gt;
At the same time, I had to upgrade 
&lt;a href=&#034;http://tomcat.apache.org/&#034;&gt;
the Tomcat web server&lt;/a&gt; from 5.5 to 6.0, which went fairly smoothly,
although there may be a few little bits that need a boost.
        </description>
      
      
    
    
    
    <category>Open Source Software</category>
    
    <category>Web</category>
    
    <comments>http://theories.darwinsys.com:80/2009/03/26/1238078940000.html#comments</comments>
    <guid isPermaLink="true">http://theories.darwinsys.com:80/2009/03/26/1238078940000.html</guid>
    <pubDate>Thu, 26 Mar 2009 14:49:00 GMT</pubDate>
  </item>
  
  <item>
    <title>Using Java enums properly in Seam</title>
    <link>http://theories.darwinsys.com:80/2009/01/27/1233094920000.html</link>
    
      
        <description>
          The &lt;a href=&#034;http://www.seamframework.org/&#034;&gt;Seam&lt;/a&gt; documentation covers this now, but it&#039;s a bit short of complete examples. Most of this probably applies to other JSF/JPA deployments too (but please don&#039;t ask me how). To make the list of a given enum&#039;s values available to the view,&amp;nbsp; just add one new annotated method to a &amp;quot;Factories&amp;quot; class. &lt;br /&gt;
&lt;br /&gt;
@Name(&amp;quot;factories&amp;quot;)&lt;br /&gt;
public class Factories {&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; @Factory(&amp;quot;countries&amp;quot;) &lt;br /&gt;
&amp;nbsp; &amp;nbsp; public Country[] getCountries() { &lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; return Country.values(); &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;br /&gt;
&lt;br /&gt;
Because you want to display a user-friendly name in the web form, but store a short and consistent name in the database, the enum must have a &amp;quot;label&amp;quot; or &amp;quot;name&amp;quot; field and a getter method (many enums already do). For example, we&#039;ll display Canada in the drop-down but enter the ISO-3166 country code CA in the database.&lt;br /&gt;
&lt;br /&gt;
/** See ISO-3166 */&lt;br /&gt;
public enum Country { &lt;br /&gt;
&amp;nbsp;&amp;nbsp; CA(&amp;quot;Canada&amp;quot;), &lt;br /&gt;
&amp;nbsp;&amp;nbsp; US(&amp;quot;United States&amp;quot;), &lt;br /&gt;
&amp;nbsp;&amp;nbsp; AF(&amp;quot;Afghanistan&amp;quot;), &lt;br /&gt;
&amp;nbsp;&amp;nbsp; ... &lt;br /&gt;
&amp;nbsp;&amp;nbsp; ; &lt;br /&gt;
&amp;nbsp;&amp;nbsp; private String longName; &lt;br /&gt;
&amp;nbsp;&amp;nbsp; private Country(String longName) { &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.longName = longName; &lt;br /&gt;
&amp;nbsp;&amp;nbsp; } &lt;br /&gt;
&amp;nbsp;&amp;nbsp; public String getLongName() { &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return longName; &lt;br /&gt;
&amp;nbsp;&amp;nbsp; }&amp;nbsp;  &amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp; @Override &lt;br /&gt;
&amp;nbsp;&amp;nbsp; public String toString () { &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return getLongName(); &lt;br /&gt;
&amp;nbsp;&amp;nbsp; } &lt;br /&gt;
&lt;br /&gt;
You typically want to save the string name rather than the ordinal value into the database (especially with Countries where the list order  will change in future as countries split or join!) the @Entity class must be annotated  thusly: &lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; @Column(name=&amp;quot;Country&amp;quot;) &lt;br /&gt;
&amp;nbsp;&amp;nbsp; @Enumerated(EnumType.STRING)&amp;nbsp;&amp;nbsp; // default and only other choice is  ORDINAL &lt;br /&gt;
&amp;nbsp;&amp;nbsp; public Country getCountry() { &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return this.country; &lt;br /&gt;
&amp;nbsp;&amp;nbsp; } &lt;br /&gt;
&lt;br /&gt;
Then, to select it (display a drop-down), you&#039;d use, for example: &lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;h:selectOneMenu  value=&amp;quot;#{register.personalAddress.country}&amp;quot;&amp;gt; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;s:selectItems var=&amp;quot;country&amp;quot;  value=&amp;quot;#{countries}&amp;quot; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; label=&amp;quot;#{country.longName}&amp;quot;  noSelectionLabel=&amp;quot;-- Select --&amp;quot;/&amp;gt; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;s:convertEnum/&amp;gt; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/h:selectOneMenu&amp;gt; &lt;br /&gt;
&lt;br /&gt;
If you&#039;ve used another framework than Seam, there&#039;s a bit of Seam&#039;s beauty: the Seam convertEnum tag fixes the &#039;orrible mess of having your data classes be required to know about UIComponent (can nobody on the JSF standards committee spell &amp;quot;tier violation&amp;quot;?).&lt;br /&gt;
&lt;br /&gt;
To display the current value in a view-only page,&amp;nbsp; you just need, for example, &lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;lt;h:outputText id=&amp;quot;country&amp;quot; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; value=&amp;quot;#{person.personalAddress.country.longName}&amp;quot;/ &amp;gt; &lt;br /&gt;
&lt;br /&gt;
The data must be basically spotless for the enum converter to work, so - if you didn&#039;t have enumerating check constraints on the database from day one - you may e.g., have to &amp;quot;sanitize&amp;quot; the data a little to ensure  there are no non-null but blank&lt;strong class=&#034;moz-txt-star&#034;&gt;&lt;span class=&#034;moz-txt-tag&#034;&gt;&lt;/span&gt;&lt;/strong&gt; values in the database, or convert any lower-case values to upper case to match the enum constants. If not you&#039;ll get strange message like the famous &amp;quot;can&#039;t find resultList&amp;quot; - always check the JBoss console log for a stack trace!&lt;br /&gt;
&lt;br /&gt;
These can be cleaned with SQL like this, using whatever tool you use to feed raw SQL into whatever database you&#039;re using:&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; update address set country = &#039;CA&#039; where country = &#039;&#039; &lt;br /&gt;
Or you could set these values to NULL.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; update address set country = upper(country) &lt;br /&gt;
&lt;br /&gt;
To check the values, you can use SQL similar to this:&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; select distinct(country) from address&lt;br /&gt;
&lt;br /&gt;
Then it all works nicely, as it should, without any need for EntityConverter or for mixing UIComponents into your data layer. Seam rocks!
        </description>
      
      
    
    
    
    <category>Java</category>
    
    <category>Web</category>
    
    <comments>http://theories.darwinsys.com:80/2009/01/27/1233094920000.html#comments</comments>
    <guid isPermaLink="true">http://theories.darwinsys.com:80/2009/01/27/1233094920000.html</guid>
    <pubDate>Tue, 27 Jan 2009 22:22:00 GMT</pubDate>
  </item>
  
  <item>
    <title>Seam Leaves Home (on good terms)</title>
    <link>http://theories.darwinsys.com:80/2008/03/24/1206406680000.html</link>
    
      
        <description>
          In addition to cranking out a new stable release (2.0.1.GA) and a new  early access release (2.1.0.A1), The JBoss Seam framework has been  renamed to &amp;quot;The Seam Framework&amp;quot; and has a new website,  &lt;a href=&#034;http://www.seamframework.org/&#034; class=&#034;moz-txt-link-freetext&#034;&gt;http://www.seamframework.org/&lt;/a&gt;. This represents a &amp;quot;growing up&amp;quot; of sorts,  similar to e.g., Jakarta Tomcat becoming Apache Tomcat, and  differentiates Seam from the many smaller projects that are also part of  JBoss - see the new diagram at &lt;a href=&#034;http://labs.jboss.org/projects/&#034; class=&#034;moz-txt-link-freetext&#034;&gt;http://labs.jboss.org/projects/&lt;/a&gt;, and note  that Seam is right there at the top of the web tier. While still funded  by RedHat/JBoss, with this new domain Seam is obviously being positioned  to compete head-on with similarly-named project The Spring Framework. &lt;br /&gt;
&lt;br /&gt;
As part of &amp;quot;moving out&amp;quot;, Seam has been given a new logo, see &lt;a href=&#034;http://www.seamframework.org/Community/GetASeamIcon&#034; class=&#034;moz-txt-link-freetext&#034;&gt;http://www.seamframework.org/Community/GetASeamIcon&lt;/a&gt;. This is used in their new web site, which is of course running on Seam and available as part of the downloads  (&lt;a href=&#034;http://www.seamframework.org/Download&#034; class=&#034;moz-txt-link-freetext&#034;&gt;http://www.seamframework.org/Download&lt;/a&gt;). Speaking of downloads, if you&#039;re using a version older than 2.0.1.GA, now would be a good time to download and upgrade.&lt;br /&gt;
&lt;br /&gt;
Also, there is a new book about Seam, Seam In Action  (&lt;a href=&#034;http://www.amazon.com/gp/product/1933988401&#034; class=&#034;moz-txt-link-freetext&#034;&gt;http://www.amazon.com/gp/product/1933988401&lt;/a&gt;), which you can now buy in  Early Access (&lt;a href=&#034;http://www.manning.com/dallen/&#034; class=&#034;moz-txt-link-freetext&#034;&gt;http://www.manning.com/dallen/&lt;/a&gt;) - you get EA PDF&#039;s now and  the final version when it&#039;s released, and optionally a paper copy then too. &lt;br /&gt;
&lt;br /&gt;
Finally, JBoss Tools - the all-encompassing Eclipse tools for developing  Seam and Hibernate projects - has been upgraded to 2.0.1.GA. You might  want to download this as well.
        </description>
      
      
    
    
    
    <category>Books</category>
    
    <category>Open Source Software</category>
    
    <category>Java</category>
    
    <category>Web</category>
    
    <category>Internet</category>
    
    <comments>http://theories.darwinsys.com:80/2008/03/24/1206406680000.html#comments</comments>
    <guid isPermaLink="true">http://theories.darwinsys.com:80/2008/03/24/1206406680000.html</guid>
    <pubDate>Tue, 25 Mar 2008 00:58:00 GMT</pubDate>
  </item>
  
  </channel>
</rss>

