Thursday, February 25, 2010

Book Review - NetBeans Ruby and Rails IDE with JRuby


I decided to write a quick review on the NetBeans Ruby and Rails IDE with JRuby book from Apress. The book is focused on NetBeans 6.5 and JRuby development. This is not a limitation on the book however. The book is really an introduction to how to use NetBeans to do Ruby development. The latest version of NetBeans (6.8) has a number of additional features (enhancements) over the version detailed in this book. Perhaps the authors can do an up-to-date version of the book to cover the latest enhancements. If not, perhaps I will consider taking up the mantle.

I really loved the book. I would give it 4/5 stars which if you have read my reviews is a brutal rating to get.

I performed a baseline install of NetBeans 6.5 including the plugins required for doing JRuby/Ruby development as noted in the book. The book follows along perfectly with the installer and IDE. I guess you could call this book the reference to the IDE for JRuby/Ruby development.

The first chapter details the installation and configuration of the IDE. The explanation is spot on, but NetBeans is also really to install and configure.

The second chapter covers your basic "Hello World" from both a basic JRuby project and from JRuby on Rails (JRoR).

The third chapter covers configuration of JRuby using the NetBeans gem manager, setting up servers, and configuring databases for use with the development environment. The section on gems with native extensions, and replacements is very helpful.

Chapters four and five cover Ruby and Rails projects in more detail. It demonstrates a number of the capabilities that the IDE.  I really like the Rails Console and example of how to use it.

Chapter six covers editing files and the capabilities that the IDE provides including code completion. This was the first real mainstream IDE to provide JRuby/Ruby code completion. It does it beautifully.

Chapter seven covers debugging and testing. The authors do a great job of explaining why NetBeans should be your choice of IDE for doing Ruby development.

JRuby itself is the topic of chapter eight. There is an example of how to use JRuby in Java projects. This is really cool. However, it should be noted that you need to make some changes for it to work on JSE5. This is noted on Page 136, but the code needs a slight modification to use JRubyScriptEngineManager instead of ScriptEngineManager.

Chapter nine covers Ruby on Rails (RoR) deployments using warbler. I have found warbler to be a great  tool and use it extensively to deploy applications to GlassFish v 2.x.

Chapter ten is all about the IDE. It shows the user a number of customizations available to make NetBeans customized to your style.  This is no small accomplishment. The NetBeans team have made a really great IDE and made it extremely flexible. This flexibility did not sacrifice simplicity. Eclipse is flexible too, but a a severe penalty to ease.

In summary, if you are thinking of trying JRuby, or Ruby development, and you want to give NetBeans a try, this is the book to buy 4/5 stars.

Errata

There is not much to report. My only real gripe is that the Mac short-cut keys are incorrect in a number of places. However, you will figure it out immediately. If it says <cmd> and it does not work... try <ctrl>.

(Page 43)  Item #2 refers to a diagram which is not correct. The diagram which it refers to is not in the book.

(Page 133) The diagram JVM arguments are incorrect. The correct argument is listed under the input box as part of the inline help.

Wednesday, February 24, 2010

How to contribute to the Maven books

A friend of mine from the JUG community wrote a really neat article which explains (in depth I might add) on how to contribute to the Maven community by updating and fixing issues in the Maven books. A link to his article is listed below.

How to contribute to the Maven books

Tuesday, February 23, 2010

Book Review - GlassFish Administration

I was offered the opportunity to review the GlassFish Administration book by Xuekun Kou from Packt Publishing. The book focuses on GlassFish version 2.1.1, but does have some coverage of version 3 (V3). The book is a smaller digest of a number of books published by Oracle (Sun) and the GlassFish document team.

The book breaks down into ten chapters on version 2.1.1, and an eleventh chapter on version 3. I am not sure where I stand on this book. I really don't like references to certain features in the table of contents which would lead you to believe it has some depth on the subject. Later you discover that it refers you to the actual "official" publications I noted above. I think that if you give it a sub-chapter designation, it must actually have some depth. I really found the book to cover most of the subjects in a shallow manner.

My other pet peeve is when code is included (or not included) in a book which does not work, or is shallowly offered without explanation. For example, there is a code example for security, but no explanation, or setup instructions. The other issue is where the book refers to the code, but it does not exist in the format in the book. There are numerous examples of this as you will note below.

If you have gotten this far in my review, you must wonder if the book has any redeeming value. Yes, it does. As an experienced GlassFish administrator, there are a lot of topics that are covered in too little detail for me, but as a new administrator, the book is a good starting place. I was expecting more advanced coverage of some topics, but this is material for a book on Advanced GlassFish Administration. This book offers would be GlassFish administrators a look into all the functionality that it offers.

I would give it a 3/5 stars for advanced administrators. This book is a very good book for starting administrators which probably should be 3.5/5 stars.

Chapter Summaries

Chapter one covers the basic installation which is no real surprise. The information is essentially the same as found on the GlassFish project web site. There is a nice section on how to do silent installs which is not really covered on the site.

Chapter two is a high-level overview of the server architecture. This is where the book shines. The information and illustrations are great. The author has done a great job covering the architecture with very good explanations.

The third chapter provides the reader with information on the application deployment capabilities of GlassFish. The explanation on the ease of development functionality is very good. It covers items like dynamic reload and command-line deployment options. This is a good introduction to the CLI portion of GlassFish which makes it easy to script for your particular OS. This chapter also includes installing JRuby and Grails based applications. The Grails example is really cool and worked like a champion.

The fourth chapter covers container configuration and basic services. I believe that the section on configuring HTTP listeners should have been covered prior to virtual servers because of the dependency. This chapter is very shallow. It shows you how to configure these services from both the Admin Console and CLI, but gives really nothing in way of explanation of the options available.

The fourth chapter concludes with a confusing explanation of the Application Client Container. It seems very out of place and should be re-written with a code example.

Chapter five discusses how to configure (JNDI) resources within GlassFish. This is a very important topic. The author does a good job of explaining how to configure the various resources from JDBC to external JNDI resources. There are not too many good examples on how to configure external resources. There are a number of command-line example errors, but fortunately GlassFish really does a great job of making correction suggestions.

Chapter six covers JMS specifically Open MQ and Apache ActiveMQ. It is really well done and covers an import aspect of modern application servers. The asynchronous transaction is becoming more important especially when combined with AJAX technologies which allow web applications to continue to respond to user input while actions are occurring in the background. This chapter also covers the imqadmin console.

One of the best aspects of chapter six is its coverage of Apache ActiveMQ. I prefer to use Open MQ (included in GlassFish), but the chapter shows how to integrate external JMS resources into GlassFish. GlassFish includes a generic JMS JCA adapter which is used to integrate Apache ActiveMQ.

Chapter seven covers security and securing GlassFish. I was disappointed that there were no examples of client certificate authentication. I was also disappointed that the only coverage on certificates was based on self-signed, and there was absolutely no coverage of NSS security. The Java ACC support is incomplete especially without an example. The only really redeeming section in the chapter was the use of password aliases fro encrypting application resources.

Monitoring is covered in chapter eight. The basics of how to setup the monitoring are covered. There is no significant depth to the chapter. The discussion on call flow monitoring shows an example of an application which is not included in the sample code. It is from the Java EE tutorial (Duke's Bank). The chapter does topically demonstrate additional monitoring tools like JConsole and VisualVM. Both of these tools are included in the JDK, and don't get the coverage they deserve. VisualVM is a NetBeans platform application.

The chapter closes with Enterprise Manager, but refers you to external references. I was not impressed. It should have not even made mention of it, if there was no coverage.

Clustering and High Availability (HA) is covered in chapter nine. I liked chapter nine in general. The explanation of the clustering functionality: node agents, and instances was very good. The author explains in detail how to install the load balancer which needed some detail coverage. The information available online is not very centralized. The explanation on in-memory replication including diagrams is very good. It also explains replication ring and some issues with that are encountered on adjacent instance failures.

HADB should be removed from chapter nine. There is no coverage worth mentioning, and it should have been a cornerstone of the chapter.

Chapter ten covers troubleshooting and performance tuning. Actually that is the title, but it really does not cover performance tuning. The reference is to a commercial support contract Performance Advisor.

That being said, it does cover some additional functionality of tools like VisualVM and introduces jstack. It also covers the Thread Dump Analyzer (TDA) and NetBeans profiler.

Chapter eleven is a topical coverage of GlassFish version 3. It was not finalized at the time of release of this book. The information is generally correct though and will give the reader important aspects of the new release and its capabilities.

Summary

The overall impression of the book was a modest 3/5 stars. The book would be a good starting point for a new administrator, but lacks sufficient detail for an advanced practitioner. If you are looking for a beginning book on GlassFish administration, this is not a bad choice.


Chapter Details and Errata

These are notes, errors, comments, and impressions from the chapters. I suggest that if you encounter any errors in the book, please check here to see if I have addressed them.

Chapter 1

(Page 13) The MaxOS X support should include 10.6.

(Page 22) There should be a note to indicate that silent installs can only be done on file based installs (installer), and not on jar based installs.

Chapter 2

(Page 42) Second paragraph makes mention that you can edit the domain.xml file using a text editor. There should be a warning/note that tells the user should check the domain.xml file using the asadmin command to ensure that the file is syntactically correct.
asadmin verify-domain-xml
(Page 46) Item #4, third paragraph refers to a screen shot which is not present.

(Page 47) The command at the bottom of the page is missing a dash.
asadmin list-commands --help | more
(Page 48) The create-domain code is interactive since not all of the parameters are provided so the example is not correct. If you want to avoid interactively providing user and password information, use the --user XXX and --passwordfile XXX syntax.

(Page 49) The command for starting the newly created domain is incorrect. It includes command line switches that are not valid.
asadmin start-domain domain2

Chapter 3

(Page 58) The redeploy switch is not available on version 2.1.1. It is a GlassFish version 3 switch.

(Page 64) The POJO Web Services refers to code which is not available in the example downloads.

(Page 64) The enterprise example and client code is also missing from the example download code. This is a really too bad. The code would have made a really good example of how to use GlassFish.

(Page 67) I could not get this JRuby example running on GlassFish. It runs in Mongrel, and I believe it is valid code. The issue seems to be with rack and warble. It also should be noted that the MySQL JDBC drivers must be downloaded and installed in the CLASSPATH for this to work. I placed the MySQL drivers in the JRuby installation /lib directory. The rake db:migrate command will not work without them, nor will Mongrel connect to the database.

(Page 69) The PATH is incorrect. It should be
export PATH=$GRAILS_HOME/bin:$PATH

Chapter 4

(Page 75) The CLI example is incorrect. It should be:
asadmin set server.session-config.session-properties.timeout-in-seconds=900
(Page 85, 86, and 87) The 2nd and 3rd paragraphs are duplicated on the following pages.

Chapter 5

(Page 100) The CLI example is incorrect. It should be:
asadmin create-jdbc-resource --connectionpoolid MySQLPool jdbc/DevDS
(Page 104) The CLI example is incorrect. It should be:
asadmin create-javamail-resource --mailhost localhost --mailuser MailUser --fromaddress service@programming-stuff.com mail/MyMail
(Page 108) The CLI example is incorrect. It should be:
asadmin create-jndi-resource --jndilookupname cn=MyResources --restype com.programmingstuff.jndi.RegistryResource --factoryclass com.sun.jndi.ldap.LdapCtxFactory ref/SimpleResource

Chapter 6

The example code for the chapter does not work very well. There is no explanation of how to configure it to work. The included AMQBean code does not work out of the box.

Chapter 7

(Page 140) The LDIF file should have been included in the example code.

Chapter 8

(Page 164) The example is incomplete. The first of two screens is shown, and the discussion does not cover the second (more important) configuration screen.

Chapter 9

(Page 176) Clustering DOES work on Mac OS X.

Chapter 11

(Page 245) The paths in the commands are incorrect, they should be:
$examples/deploy ...
(Page 247, 248,250) The paths and project name are incorrect in the last CLI example on the page. It should be:
cd $examples/deploy/SimpleRails

(Page 250) The second CLI example is incorrect. The command to start embedded GlassFish is:
jruby -S glassfish SimpleRails
(Page 251) The path should be:
$examples/deploy/SimpleGroovy

Sunday, February 14, 2010

Introduction to Apache Maven Presentation

This is an Introduction to Apache Maven presentation that I gave at the Greenville Java Users Group on the 11th of February.

It covers the basics of installing and configuring Apache Maven. It also demonstrates creating three projects from relatively simple to a more complex Apache MyFaces and Facelets example. I also demonstrate the power of using the Jetty plugin to deploy and test our application. Finally I create a project site which contains information gathered from the pom.xml and project files including any unit testing.

Here is a video presentation of the tutorial. The video is approximately 42 minutes long.




Here is the actual presentation.

Saturday, February 13, 2010

Book Review - JSF 1.2 Components

I was offered a chance to review a copy of the JSF 1.2 Components book by Ian Hlavats and published by Packt Publishing. The book covers a number of different JSF frameworks including 1.2 Reference Implementation (RI), Facelets, Apache Tomahawk and Trinidad, ICEfaces, and RichFaces. My overall impression of the book is a 2/5 stars.

Why?

When you are trying to teach someone to use a new technology, the source code must work, and the effort to get it to work should be minimal. This is not the case with the accompanying source code. There are a number of errors in the code that a modern IDE and technical reviewer should catch. This applies to the code examples in the book. The configuration and requirements to use Eclipse for the projects are a shame for anyone wanting to use another IDE. The projects should have been set up to use Apache Maven to make them IDE neutral.

I also do not like partial code examples. I believe that code should stand on its own. If you are going to provide code snippets, then the code provided must be complete and functional. This was not the case.

Chapter Summaries

The first chapter covers the very basics of JSF RI. This is a very shallow introduction to the RI.

Chapter 2 Covers Facelets. It is one of the best explanations I have seen on Facelets and is very easy to understand and follow. This chapter makes the book worth buying if you are interested in Facelets technology.

Chapter 3 on Apache Tomahawk does a good job of representing the framework. There are a lot of great components in Tomahawk (75+) which play nicely with other JSF frameworks.

Chapter 4 covers Apache Trinidad (A.K.A. Oracle ADF Faces). It does a reasonable job of demonstrating the framework, and has inspired me to look a little further into it. I found it very easy to use, and found myself trying other components which were not covered in the book. I do have some issues around the code examples and implementation which I will cover in the detailed section below.

Chapter 5 covers ICEfaces. It is a really good example of some of the things that ICEfaces can do, and the components are very eye catching. My chief complaint with ICEfaces compared with some of the other frameworks is that it is really messy to set up tables, and sorting.

The book fumbles at the finish line. The chapters of the book on Seam (Chapter 6) and Richfaces (Chapter 7) are totally blown. The authors decision to do Seam before RichFaces and not separate the code base was a bad decision. The chapters themselves are not too bad, but the code would not run. Since Chapter 7 depends on Chapter 6 code, the result is a quagmire.

I created a Maven POM for Chapter 6 and set to work on the dependency issues. I had done the same thing for the previous chapters by converting them into Maven projects. This time the project failed to run and there were a number of issues. In fact, too many issues to overcome. I resolved to use the code and instructions provided by the author and the code failed to run as well. I am convinced that the Seam and database portions of the code examples are not configured correctly. After spending a week trying to make it work in both Maven and Eclipse, I quit. It should not require me spending hours trying to make it work. The code is supposed to make it easy for me to get a handle on these technologies and not troubleshoot it.
I can not validate that the code works as the author has written it in the book since the code does not work in the provided examples.

Summary

My overall impression of the book is a 2/5 stars. I really liked some portions of the book, like chapter 2 on facelets, and chapters 3 & 4 on Apache MyFaces component frameworks.

Two chapters (6 & 7) appear to provide some really relevant data, but the sample code provided with the book on which this chapter depends falls short. As a result, I can not really assess Chapter 6. Chapter 7 depends on the successful function of Chapter 6 for the most part, and is really short changed by the failure of the Seam and database connectivity. Some of the sample code for Chapter 6 works so that you can get a glimpse into the power of RichFaces.

I noted that I made a number of the examples into Apache Maven projects. I would offer them out to the public, but the code has no licensing noted in the source, and was really meant for my consumption. If you are the author, publisher, or an interested party, I will provide it to you on request.

I would really like it if Packt would consider requiring all of their sample code be provided in Maven projects. This would make the them IDE neutral, and ensure the quality of the projects by providing exact dependencies.

Chapter Details and Errata

These are notes, errors, comments, and impressions from the chapters. I suggest that if you encounter any errors in the book, please check here to see if I have addressed them.

Chapter 1

(Pages 28-29)
The images on pages 28 and 29 should be swapped. The image on page 29 is for the code snippet on the top of page 28, and vice versa.

(Page 31)
This note should be added to page 31.

Note: Classes which are used as select options <f:selectitem> need to have equals() and hashCode() methods implemented. Otherwise you will get a strange validation error whose description is not indicative of the true root cause of the error.

(Page 32)
The author makes mention of a potential issue with <h:selectManyMenu> having issues on many browsers. I tried it on Firefox 3.5.+ on Mac OS X 10.6 and did not see the issues the author mentions. This may be applicable to earlier versions of Firefox using other operating systems.

Chapter 2

If you are trying the code examples from the book and the html is not formatted correctly, please check the xml namespace in the facelets html tag. It should have the following xmlns in bold added so that it displays html correctly.
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:t="http://myfaces.apache.org/tomahawk">
...
</html>

I would also recommend adding the correct DOCTYPE to the header to make sure that the document is well formed. The Transitional XHTML example is shown below and will work in most applications.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

(Page 51)
The web.xml file has some of the more important information in bold, but really should include descriptions of what these parameters are in the actual web.xml. See the example below which includes descriptions.

web.xml


<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
    <display-name>chapter2</display-name>

    <!-- Optional JSF-RI Parameters to Help Debug -->
    <context-param>
        <param-name>com.sun.faces.verifyObjects</param-name>
        <param-value>true</param-value>
    </context-param>
    <context-param>
        <param-name>com.sun.faces.validateXml</param-name>
        <param-value>true</param-value>
    </context-param>
    
    <!-- Use Documents Saved as *.xhtml -->
    <context-param>
        <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
        <param-value>.xhtml</param-value>
    </context-param>

    <!-- Special Debug Output for Development -->
    <context-param>
        <description>
            Setting this to true will cause the FaceletViewHandler to print out debug information in an easy to use screen
            when an error occurs during the rendering process.
        </description>
        <param-name>facelets.DEVELOPMENT</param-name>
        <param-value>true</param-value>
    </context-param>
    
    <context-param>
        <description>
            A boolean value that tells the compiler to skip comments (default is true).
            Even if you comment out code in your page, the tags will not be compiled but expressions (EL) will be
            treated as if they were inlined-- still compiled and evaluated for output in the document.
            Skipping comments will remove all comments completely from the document.
        </description>
        <param-name>facelets.SKIP_COMMENTS</param-name>
        <param-value>true</param-value>
    </context-param>
    <context-param>
        <description>
            When a page is requested, what interval in seconds should the compiler check for changes.
            If you don't want the compiler to check for changes once the page is compiled, then use a value of -1.
            Setting a low refresh period helps during development to be able to edit pages in a running application.
        </description>
        <param-name>facelets.REFRESH_PERIOD</param-name>
        <param-value>1</param-value>
    </context-param>
    <context-param>
        <description>
            A semicolon (;) delimitted list of resources that Facelets should use. If no resource paths are specified,
            Facelets will handle all requests (DEFAULT). If one or more paths are specified,
            Facelets will only use the ones specified, otherwise fall back on the parent or default ViewHandler (JSP).
            Note, this requires the FacesServlet in your web.xml to be mapped with a prefix for capturing multiple file types ex: /faces/*.
        </description>
        <param-name>facelets.VIEW_MAPPINGS</param-name>
        <param-value>*.xhtml</param-value>
    </context-param>
    <context-param>
        <description>
        The buffer size to set on the response when the ResponseWriter is generated.
        By default the value is -1, which will not assign a buffer size on the response.
        This should be increased if you are using development mode in order to guarantee that the response
        isn't partially rendered when an error is generated.
        </description>
        <param-name>facelets.BUFFER_SIZE</param-name>
        <param-value>8192</param-value>
    </context-param>
   
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.jsf</url-pattern>
        <url-pattern>/faces/*</url-pattern>
    </servlet-mapping>
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
    <welcome-file-list>
        <welcome-file>forward.jsp</welcome-file>
    </welcome-file-list>
</web-app> 

(Pages 56-57)
Note: The output from the debug does not work on facelets 1.1.14 because of a JavaScript error. You must use facelets version 1.1.11, or 1.1.15B1 for the debug to work properly. (See Facelets issue #292 on facelets.dev.java.net.)

(Page 66)
This code sample would not work for me. I needed to add <h:panelGroup> wrappers around the <ui:include> tags in the <h:panelGrid> components.

An alternative to would be to make the customerList a component and not a composition.

(Pages 77-78)
The templateClient02.jsf and templateClient02a.jsf code has a <ui:debug> components shown in the code. These will not work here. It must be in the template for it to work.

(Page 87)
The fourth paragraph has a typo which should be "Facelets and JSP..."

Chapter 3

(Page 97)
The <t:inputCalendar> component does not have a type attribute.

(Page 104)
There should be an explanation why the encoding type (enctype) is required on the <h:form> component. This is something that has been changed from the other examples and could easily be overlooked.

Note: The file:/// syntax will not work on Firefox, or Safari. It may not work on other browsers as well. This is a built-in security feature of those browsers. So this example will not work using those browsers. If you want to be able to actually click on the hyperlinks and have them work, I had to use Lynx. This is a command line browser which does not incorporate this security mechanism.

(Page 116)
The action on <t:commandNavigation> for products does not match the provided code. It should be <t:commandNavigation value="products" action="#{productBean.displayProducts}"/>

(Page 125)
The <t:jscookMenu> theme should be theme="ThemePanel" to match the provided code.

(Page 136)
Note: The <t:dataTable> component must be inside a <h:form> component for the table sorting to work.

Chapter 4


(Page 142)
Note: The installation and configuration section has an example of how to set up Apache Trinidad using facelets. This is contrary to the preferred method which is detailed on the Apache Trinidad Installation page. Below is a copy of my web.xml file which has the correct Apache Trinidad configuration.

web.xml


<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

    <!-- BEGIN Apache Trinidad BEGIN -->

    <context-param>
        <description>
            Note: TrinidadFaceletViewHander must be the alternate view handler if SessionChangeManager is used.
        </description>
        <param-name>org.apache.myfaces.trinidad.ALTERNATE_VIEW_HANDLER</param-name>
        <param-value>org.apache.myfaces.trinidadinternal.facelets.TrinidadFaceletViewHandler</param-value>
    </context-param>
    
    <context-param>
        <description>
            Unfortunately, Facelets provides no hook for plugging the PageResolver into the logic
            handling "facelets.VIEW_MAPPINGS". You should leave "facelets.VIEW_MAPPINGS"
            unset and use "org.apache.myfaces.trinidad.FACELETS_VIEW_MAPPINGS" instead.
        </description>
        <param-name>org.apache.myfaces.trinidad.FACELETS_VIEW_MAPPINGS</param-name>
        <param-value>*.xhtml</param-value>
    </context-param>

    <context-param>
        <description>
            Trinidad also supports an optimized strategy for caching some
            view state at an application level, which significantly improves
            scalability.  However, it makes it harder to develop (updates to
            pages will not be noticed until the server is restarted), and in
            some rare cases cannot be used for some pages (see Trinidad
            documentation for more information)
        </description>
        <param-name>org.apache.myfaces.trinidad.USE_APPLICATION_VIEW_CACHE</param-name>
        <param-value>false</param-value>
    </context-param>

    <context-param>
        <description>
            If this parameter is enabled, Trinidad will automatically
            check the modification date of your JSPs, and discard saved
            state when they change;  this makes development easier,
            but adds overhead that should be avoided when your application
            is deployed
        </description>
        <param-name>org.apache.myfaces.trinidad.CHECK_FILE_MODIFICATION</param-name>
        <param-value>true</param-value>
    </context-param>

    <context-param>
        <description>
            Enables Change Persistence at a session scope.  By default,
            Change Persistence is entirely disabled. The ChangeManager is
            an API, which can persist component modifications (like,
            is a showDetail or tree expanded or collapsed). For providing
            a custom Change Persistence implementation inherit from the
            Trinidad API's ChangeManager class. As the value you have
            to use the fullqualified class name.
        </description>
        <param-name>org.apache.myfaces.trinidad.CHANGE_PERSISTENCE</param-name>
        <param-value>session</param-value>
    </context-param>

    <context-param>
        <param-name>org.apache.myfaces.trinidad.DISABLE_CONTENT_COMPRESSION</param-name>
        <param-value>true</param-value>
    </context-param>

    <!-- Use client-side state saving.  In Trinidad, it is an
       optimized, token-based mechanism that is almost always a
       better choice than the standard JSF server-side state saving. -->
    <context-param>
        <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
        <param-value>client</param-value>
        <!--param-value>server</param-value-->
    </context-param>

    <!-- Trinidad by default uses an optimized client-side state saving
       mechanism. To disable that, uncomment the following -->
  <!--context-param>
    <param-name>org.apache.myfaces.trinidad.CLIENT_STATE_METHOD</param-name>
    <param-value>all</param-value>
  </context-param-->

<!-- END Apache Trinidad END -->

    <filter>
        <filter-name>trinidad</filter-name>
        <filter-class>org.apache.myfaces.trinidad.webapp.TrinidadFilter</filter-class>
    </filter>

    <filter-mapping>
        <filter-name>trinidad</filter-name>
        <servlet-name>Faces Servlet</servlet-name>
    </filter-mapping>

    <!-- Faces Servlet -->
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    </servlet>

    <!-- resource loader servlet -->
    <servlet>
        <servlet-name>resources</servlet-name>
        <servlet-class>org.apache.myfaces.trinidad.webapp.ResourceServlet</servlet-class>
    </servlet>

    <!-- Faces Servlet Mappings -->
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/faces/*</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
        <servlet-name>resources</servlet-name>
        <url-pattern>/adf/*</url-pattern>
    </servlet-mapping>

    <!-- Welcome Files -->
    <welcome-file-list>
        <welcome-file>/forward.jsp</welcome-file>
    </welcome-file-list>

</web-app>


(Page 144)
Note: I also found that a number of examples use <h:form> instead of <tr:form> which is also preferred.

(Page 145)
The component <tr:chooseColor> has a closing tag before the id attribute, and will not work unless it is removed.

(Page 147)
The references to commandButton and outputText should use the tr prefix instead of the h prefix since it is supposed to be demonstrating the Apache Trinidad components and not the RI.

(Page 150)
The <tr:inputListOfValues> has columns="25" in the code.

The <tr:panelGroupLayout> rendered attribute has a coding error in it. It should have a space between ne and null like this rendered="#{productBean.selectedProduct ne null}".

Also this example is incomplete since it does not show, or discuss the pop-up dialog which is part of the component functionality.

(Page 153)
The last paragraph which discusses validating using client side alerting should be a note to stress its importance.

(Page 158)
The facets which are listed under the <tr:statusIndicator> tag have incorrect attributes. They should be name and not message.

(Page 159)
The <tr:poll> component should use the slowPollListener under the pollListener attribute.

(Page 160)
The backingBean component in the first example does not contain slowNumber field.
The second example on the page uses backingBean.pollListener which should actually be backingBean.progressListener.

(Page 165)
The provided code does not contain a styleClass attribute in the <tr:panelGroupLayout> component. Also the <tr:spacer> component has a height of 10 in the provided code.

(Page 166)
The image does match the actual output unless you remove the styleClass attribute from the code.

(Page 167 and 168)
The <tr:commandButton> actionListener does not exist. It should be actionListener="#{productBean.saveSelected}".

(Page 171)
The inlineStyle of the <tr:column> component should have a semi-colon at the end of the value.

(Page 173)
This section was a total failure. The provided code does not work.

(Pages 175 and 177)
This section did not work, nor did the sample code for using XMLMenuModel items.

(Page 191)
The image does not match the code example. The image is for another component dialog.
In addition, the color chooser dialog does not convert the color back correctly. I had to modify the Customer.getFavoriteColorHexValue() to get it to work.
public String getFavoriteColorHexValue() {
String value = null;
if (favoriteColor != null) {
int rgb = favoriteColor.getRGB();
value = Integer.toHexString((rgb & 0xffffff) | 0x1000000).substring(1);
}
return "#" + value;
}

Chapter 5

(Page 196)
The <ice:inputText> for name has an error in the backingBean syntax. It should be value="#{backingBean.name}".

(Page 200)
The components require <f:dateTimeConverter>s to display the values correctly.

(Page 205)
The Toco-Toucan.jpg image name is missing the "-" so the image would not display.

(Pages 212 and 213)
This example is poorly designed and impractical. It displays column numbers at the tops of each column. Who would do that? This should be more practical and show column names for the values in the columns.

(Page 214)
The <ice:commandSortHeader> for birth date should be removed since the code is duplicated.

(Page 215)
The data model UML is not correct. It should be SortableDatamodel <T extends Selectable>.

(Page 216)
The afterPhase method has an argument arg0. This should be phaseEvent which is more descriptive in keeping with a more modern coding style. The code will work, but it is considered bad form.

(Pages 218 and 219)
The <ice:commandSortHeader> for birth date should be removed since the code is duplicated.

(Page 225)
I must admit adding data set paging using ICEfaces is very easy.

(Pages 238-239)
The code here is irrelevant here and should be removed. It is duplicated in the next section on page 239 which actually covers this component.

Chapter 6

(Page 256)
The second paragraph has a typo. It should be "...specified in advance,...".

(Page 275)
The name of the bean should be ShippingCalculatorBean. The t in calculator is missing.

Tuesday, February 09, 2010

NetBeans 6.8 JSR-296 Database Application Example

Here is an example application development video.

Popular Posts