<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-36773632</atom:id><lastBuildDate>Fri, 26 Apr 2013 02:34:52 +0000</lastBuildDate><category>logging</category><category>JPA</category><category>nexus</category><category>quartz</category><category>JSP</category><category>JUG</category><category>books</category><category>BSD License</category><category>phpLDAPadmin</category><category>Java.net</category><category>development</category><category>community</category><category>maven</category><category>JAX-RS</category><category>HTTPD</category><category>SJSAS</category><category>open source</category><category>Apple</category><category>Web</category><category>JSE6</category><category>EJB</category><category>stackoverflow</category><category>Collections</category><category>facelets</category><category>OSCON</category><category>JRuby</category><category>Jython</category><category>spring</category><category>JAXB</category><category>License</category><category>Solaris</category><category>Solaris 10</category><category>CDI</category><category>Persistence</category><category>Apache</category><category>Resin</category><category>JSE5</category><category>JSR-314</category><category>Jersey</category><category>anti-patterns</category><category>JEE5</category><category>Web Server</category><category>PrimeFaces</category><category>jQuery</category><category>OCP</category><category>mySQL</category><category>JSR-344</category><category>CSS</category><category>Subversion</category><category>Javascript</category><category>Rails</category><category>example</category><category>movable type</category><category>JSTL</category><category>Design</category><category>IIS</category><category>concurrency</category><category>wordpress</category><category>LDAP</category><category>OpenSolaris</category><category>Drupal</category><category>SELF</category><category>Netbeans</category><category>Tomcat</category><category>woodstock</category><category>JDK7</category><category>hsqldb</category><category>icefaces</category><category>FindBugs</category><category>JEE6</category><category>Eclipse</category><category>RoR</category><category>JSF</category><category>SunOne</category><category>Internet Explorer</category><category>JSR-292</category><category>blogging</category><category>Apache2</category><category>Redmine</category><category>AOP</category><category>JavaEE</category><category>JDK6</category><category>Architecture</category><category>POI</category><category>Xcode</category><category>AJAX</category><category>glassfish</category><category>SCJP</category><category>Mojarra</category><category>Security</category><category>JSR-295</category><category>template</category><category>Oracle</category><category>JavaOne</category><category>Programming</category><category>OS X</category><category>Swing</category><category>JNDI</category><category>commons</category><category>frameworks</category><category>MIT License</category><category>wicket</category><category>plugin</category><category>JSR-311</category><category>Presentation</category><category>Grails</category><category>source control</category><category>SSL</category><category>Ruby on Rails</category><category>JSON</category><category>Quercus</category><category>Guice</category><category>tapestry</category><category>CACert</category><category>EL</category><category>Tomahawk</category><category>JSR-296</category><category>IDEA</category><category>Xwiki</category><category>REST</category><category>patterns</category><category>GreenJUG</category><category>tutorial</category><category>GAE</category><category>Java</category><category>RichFaces</category><category>Google</category><category>thread</category><category>JDBC</category><category>JavaFX</category><category>App Engine</category><category>PHP</category><category>JCP</category><category>certification</category><category>IntelliJ</category><category>pragmatic</category><category>JavaDB</category><category>Apache Derby</category><category>Visual JSF</category><category>Ruby</category><category>Active Directory</category><category>OpenDS</category><category>article</category><category>TLS</category><category>maps</category><category>JSE7</category><category>Caucho</category><category>mercurial</category><category>AD</category><category>OpenJDK</category><title>Java Evangelist John Yeary's Blog</title><description /><link>http://javaevangelist.blogspot.com/</link><managingEditor>noreply@blogger.com (John Yeary)</managingEditor><generator>Blogger</generator><openSearch:totalResults>322</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/JavaEvangelistJohnYearysBlog" /><feedburner:info uri="javaevangelistjohnyearysblog" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><geo:lat>34.762693</geo:lat><geo:long>-82.24512</geo:long><creativeCommons:license>http://creativecommons.org/licenses/by-sa/3.0/</creativeCommons:license><image><link>http://creativecommons.org/licenses/by-sa/3.0/</link><url>http://creativecommons.org/images/public/somerights20.gif</url><title>Some Rights Reserved</title></image><feedburner:emailServiceId>JavaEvangelistJohnYearysBlog</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><item><guid isPermaLink="false">tag:blogger.com,1999:blog-36773632.post-2080711410024187425</guid><pubDate>Thu, 25 Apr 2013 22:22:00 +0000</pubDate><atom:updated>2013-04-25T21:34:52.526-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">example</category><category domain="http://www.blogger.com/atom/ns#">JSR-314</category><category domain="http://www.blogger.com/atom/ns#">JavaEE</category><category domain="http://www.blogger.com/atom/ns#">JSF</category><category domain="http://www.blogger.com/atom/ns#">tutorial</category><category domain="http://www.blogger.com/atom/ns#">glassfish</category><category domain="http://www.blogger.com/atom/ns#">Mojarra</category><category domain="http://www.blogger.com/atom/ns#">Netbeans</category><category domain="http://www.blogger.com/atom/ns#">JEE6</category><title>JSF Tip of the Day: Reading Authorization Header in JSF</title><description>After I did the JAX-RS Tip of the Day today, I wondered about reading the authorization header from JSF. The technique is the same as the JAX-RS version, but the methods are different depending on what is available to the JSF application. The JAX-RS &lt;code&gt;Base64&lt;/code&gt; class is not part of the web profile in Java EE 6. It will be part of Java EE 7 so you could use it. I chose to add the comments in the code below, but decided that I would use the &lt;code&gt;com.sun.misc.Base64Decoder&lt;/code&gt; which is currently available in Java SE 6 and 7.&lt;br /&gt;
&lt;script class="brush: java" type="syntaxhighlighter"&gt;&lt;![CDATA[
   /**
     * This method examines the request headers for an authorization header. If
     * the header is found, this will return the base64 decoded values of the
     * username, and password.  
     *
     * @param facesContext The context to get the request headers from.  
     * @return an array containing the username and password, or {@code null}.  
     * @throws IOException if the authorization header can not be parsed.  
     */
    public String[] getAuthorization(final FacesContext facesContext) throws IOException {
        String[] decoded = null;
        ExternalContext ec = facesContext.getExternalContext();
        Map&lt;String, String&gt; map = ec.getRequestHeaderMap();
        String authorization = map.get("authorization");

        if (authorization != null &amp;&amp; !authorization.isEmpty()) {
            // There is a space between "Basic" and the Base 64 encoded string.
            authorization = authorization.substring("Basic ".length());
            /*
             * This would work if JAX-RS (Jersey) was available, but it is not part of
             * Web Profile in EE 6, but will work in EE 7 since JAX-RS 2.0
             * is part of the profile.
             */
            // decoded = Base64.base64Decode(authorization).split(":");

            /*
             * This mechanism relies on sun.misc.BASE64Decoder that is an internal
             * proprietary API and may be removed in a future release.
             */
            // decoded = new String(new BASE64Decoder().decodeBuffer(authorization)).split(":");

            /*
             * This method uses a class from the Java API for XML Binding (JAXB) to parse. This is
             * available in Java EE 5 and 6.
             */
            decoded = new String(DatatypeConverter.parseBase64Binary(authorization), "UTF-8").split(":");
        }
        return decoded;
    }
]]&gt;&lt;/script&gt;
&lt;strong&gt;UPDATE:&lt;/strong&gt; I got a suggestion on Google+ from +Thomas Darimont who mentioned using &lt;code&gt;DatatypeConverter.parseBase64Binary()&lt;/code&gt; from the Java API for XML Binding (JAXB). I confirmed that it is available in Java EE 5 and 6. It is also in the Web Profile in Java EE 6.&lt;img src="http://feeds.feedburner.com/~r/JavaEvangelistJohnYearysBlog/~4/8hrzoeOuaiU" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/JavaEvangelistJohnYearysBlog/~3/8hrzoeOuaiU/jsf-tip-of-day-reading-authorization.html</link><author>noreply@blogger.com (John Yeary)</author><thr:total>0</thr:total><gd:extendedProperty name="commentSource" value="1" /><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD" /><feedburner:origLink>http://javaevangelist.blogspot.com/2013/04/jsf-tip-of-day-reading-authorization.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-36773632.post-8758995368271054472</guid><pubDate>Thu, 25 Apr 2013 12:23:00 +0000</pubDate><atom:updated>2013-04-25T07:23:43.389-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">example</category><category domain="http://www.blogger.com/atom/ns#">Programming</category><category domain="http://www.blogger.com/atom/ns#">JavaEE</category><category domain="http://www.blogger.com/atom/ns#">REST</category><category domain="http://www.blogger.com/atom/ns#">JEE5</category><category domain="http://www.blogger.com/atom/ns#">tutorial</category><category domain="http://www.blogger.com/atom/ns#">Jersey</category><category domain="http://www.blogger.com/atom/ns#">glassfish</category><category domain="http://www.blogger.com/atom/ns#">JAX-RS</category><category domain="http://www.blogger.com/atom/ns#">Netbeans</category><category domain="http://www.blogger.com/atom/ns#">JSR-311</category><category domain="http://www.blogger.com/atom/ns#">JEE6</category><title>JAX-RS Tip of the Day: How Do I Read the Authorization Header?</title><description>I was looking for a simple method to read the &lt;code&gt;HttpHeaders&lt;/code&gt; to determine the username and password for a request. I didn't find a quick answer so I wrote a simple utility method that will return the Base 64 decoded values from the &lt;code&gt;authorization&lt;/code&gt; header.&lt;br /&gt;
&lt;br /&gt;
&lt;script type="syntaxhighlighter" class="brush: java"&gt;&lt;![CDATA[
    /**
     * This method examines the request {@link HttpHeaders} for an authorization
     * header. If the header is found, this will return the base64 decoded
     * values of the username, and password.
     *
     * @param headers The headers to be examined.
     * @return an array containing the username and password, or {@code null} if
     * the authorization header was not present.
     */
    public String[] getAuthorization(HttpHeaders headers) {
        String[] decoded = null;
        List&lt;String&gt; header = headers.getRequestHeader("authorization");
        if (header != null) {
            String authorization = header.get(0);
            // There is a space between "Basic" and the Base 64 encoded string.
            authorization = authorization.substring("Basic ".length());
            decoded = Base64.base64Decode(authorization).split(":");
        }
        return decoded;
    }
]]&gt;&lt;/script&gt;&lt;img src="http://feeds.feedburner.com/~r/JavaEvangelistJohnYearysBlog/~4/osrv_D46NjY" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/JavaEvangelistJohnYearysBlog/~3/osrv_D46NjY/jax-rs-tip-of-day-how-do-i-read.html</link><author>noreply@blogger.com (John Yeary)</author><thr:total>0</thr:total><gd:extendedProperty name="commentSource" value="1" /><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD" /><feedburner:origLink>http://javaevangelist.blogspot.com/2013/04/jax-rs-tip-of-day-how-do-i-read.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-36773632.post-8146281512325619725</guid><pubDate>Thu, 11 Apr 2013 12:16:00 +0000</pubDate><atom:updated>2013-04-11T07:16:46.475-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">example</category><category domain="http://www.blogger.com/atom/ns#">PrimeFaces</category><category domain="http://www.blogger.com/atom/ns#">JSR-314</category><category domain="http://www.blogger.com/atom/ns#">JavaEE</category><category domain="http://www.blogger.com/atom/ns#">JSF</category><category domain="http://www.blogger.com/atom/ns#">tutorial</category><category domain="http://www.blogger.com/atom/ns#">glassfish</category><category domain="http://www.blogger.com/atom/ns#">Mojarra</category><category domain="http://www.blogger.com/atom/ns#">RichFaces</category><category domain="http://www.blogger.com/atom/ns#">Netbeans</category><category domain="http://www.blogger.com/atom/ns#">JEE6</category><title>JSF 2.x Tip of the Day: RichFaces 4.3.x Charts in JSF using JSFlot, JFreeCharts, and PrimeFaces</title><description>&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-EzWcptXkWx4/UWXnXkBZHTI/AAAAAAAADyE/v1VjVavs-ks/s1600/RichFacesPrimeFacesChartExamples.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="228" src="http://4.bp.blogspot.com/-EzWcptXkWx4/UWXnXkBZHTI/AAAAAAAADyE/v1VjVavs-ks/s640/RichFacesPrimeFacesChartExamples.png" width="640" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Sexy PrimeFaces Charts in RichFaces&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;h1&gt;
Introduction&lt;/h1&gt;
I was asked to look at various charting solutions for JSF. Specifically, I was asked for some choices for use with RichFaces 4.3.1. I knew that PrimeFaces has really good chart components already so I knew it might be kind of fun to integrate them if possible. I was also aware of JFreeChart which will work, but produces some... rather ugly charts. Finally, someone had suggested that I look at jsflot. This was a very promising solution. This project is a proof of concept which demonstrates integration between projects, and technologies.&lt;br /&gt;
&lt;h1&gt;
Requirements&lt;/h1&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://code.google.com/p/jsflot/"&gt;jsflot&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://netbeans.org/"&gt;NetBeans&lt;/a&gt; This is required for the sample database, although you could create your own data.&lt;/li&gt;
&lt;/ul&gt;
The jsflot framework is currently not Mavenized, so if you are going to run my example code, you will need to download it from the link above, and install it in Maven using the command below.
&lt;script class="brush: shell" type="syntaxhighlighter"&gt;&lt;![CDATA[
mvn install:install-file -Dfile=jsflot-0.7.0.jar -DgroupId=org.jsflot -DartifactId=jsflot -Dversion=0.7.0 -Dpackaging=jar -Dsource=jsflot-0.7.0-src.zip
]]&gt;&lt;/script&gt;
&lt;br /&gt;
&lt;h1&gt;
Code&lt;/h1&gt;
The code for this &lt;a href="http://netbeans.org/"&gt;NetBeans&lt;/a&gt; &lt;a href="http://maven.apache.org/"&gt;Maven&lt;/a&gt; project can be found on &lt;a href="http://bitbucket.org/"&gt;BitBucket&lt;/a&gt; here: &lt;a href="http://code.bluelotussoftware.com/chart-demo"&gt;chart-demo&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
This is the bean that provides the data models for the charting solutions. There are a number of chart demos in the project. The two charts above are just examples.&lt;br /&gt;
&lt;h2&gt;
ChartBean.java&lt;/h2&gt;
&lt;script class="brush: java" type="syntaxhighlighter"&gt;&lt;![CDATA[
package com.bluelotussoftware.example.jsf;

import com.bluelotussoftware.example.model.Customer;
import com.bluelotussoftware.example.model.Product;
import com.bluelotussoftware.example.model.PurchaseOrder;
import com.bluelotussoftware.example.ssb.CustomerFacade;
import com.bluelotussoftware.example.ssb.ProductFacade;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.context.FacesContext;
import javax.imageio.ImageIO;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.JFreeChart;
import org.jfree.data.general.DefaultPieDataset;
import org.jfree.data.general.PieDataset;
import org.jsflot.components.FlotChartRendererData;
import org.jsflot.xydata.XYDataList;
import org.jsflot.xydata.XYDataPoint;
import org.jsflot.xydata.XYDataSetCollection;
import org.primefaces.model.DefaultStreamedContent;
import org.primefaces.model.StreamedContent;
import org.primefaces.model.chart.BubbleChartModel;
import org.primefaces.model.chart.BubbleChartSeries;
import org.primefaces.model.chart.CartesianChartModel;
import org.primefaces.model.chart.ChartSeries;
import org.primefaces.model.chart.MeterGaugeChartModel;
import org.primefaces.model.chart.PieChartModel;

/**
 *
 * @author John Yeary
 * @version 1.0
 */
@ManagedBean
@RequestScoped
public class ChartBean {

    private Map&lt;Integer, Map&lt;String, Number&gt;&gt; CustomerPurchasesByYearTotals = new HashMap&lt;Integer, Map&lt;String, Number&gt;&gt;();
    private double totalSales;
    //PrimeFaces
    private PieChartModel pieChartModel;
    private CartesianChartModel cartesianChartModel;
    private BubbleChartModel bubbleChartModel;
    private MeterGaugeChartModel meterGaugeChartModel;
    //JSFlot
    private XYDataList series1DataList = new XYDataList();
    private XYDataList series2DataList = new XYDataList();
    private XYDataList series3DataList = new XYDataList();
    private FlotChartRendererData chartData;
    private StreamedContent streamedContent;
    @EJB
    private CustomerFacade cf;
    @EJB
    private ProductFacade pf;

    /**
     * Creates a new instance of ChartBean
     */
    public ChartBean() {
    }

    @PostConstruct
    private void initialize() throws IOException {
        bubbleChartModel = new BubbleChartModel();
        cartesianChartModel = new CartesianChartModel();
        pieChartModel = new PieChartModel(getSalesByCustomer());
        createCartesianChartModel();
        createBubbleModel();
        createMeterGaugeModel();

        //JFreeChart  
        JFreeChart jfreechart = ChartFactory.createPieChart("Products", getPartsDataset(), true, false, false);
        String path = FacesContext.getCurrentInstance().getExternalContext().getRealPath("/");
        File chartFile = new File(path + "dynamichart.png");
        ChartUtilities.saveChartAsPNG(chartFile, jfreechart, 600, 400);
        streamedContent = new DefaultStreamedContent(new FileInputStream(chartFile), "image/png");


        chartData = new FlotChartRendererData();

        for (int i = 0; i &lt;= 100; i++) {
            NumberFormat nf = NumberFormat.getNumberInstance();
            nf.setMaximumFractionDigits(3);

            series1DataList.addDataPoint(new XYDataPoint(i, Math.random() * 10, "Point: " + i));
            series2DataList.addDataPoint(new XYDataPoint(i, Math.random() * 10, "Point: " + i));
            series3DataList.addDataPoint(new XYDataPoint(i, Math.random() * 10));
        }
        series1DataList.setLabel("Series 1");
        series2DataList.setLabel("Series 2");
        series3DataList.setLabel("Series 3");
    }

    public PieChartModel getPieChartModel() {
        return pieChartModel;
    }

    public BubbleChartModel getBubbleChartModel() {
        return bubbleChartModel;
    }

    public CartesianChartModel getCartesianChartModel() {
        return cartesianChartModel;
    }

    public MeterGaugeChartModel getMeterGaugeChartModel() {
        return meterGaugeChartModel;
    }

    private Map&lt;String, Number&gt; getSalesByCustomer() {
        Map&lt;String, Number&gt; salesByCustomer = new HashMap&lt;String, Number&gt;();

        List&lt;customer&gt; customers = cf.findAll();

        for (Customer c : customers) {
            double sales = 0.0;
            for (PurchaseOrder p : c.getPurchaseOrderCollection()) {
                sales += p.getProductId().getPurchaseCost().doubleValue() * p.getQuantity();
            }
            salesByCustomer.put(c.getName(), sales);
        }
        return salesByCustomer;
    }

    private void createCartesianChartModel() {
        Calendar cal = Calendar.getInstance();
        List&lt;customer&gt; customers = cf.findAll();
        List&lt;integer&gt; customersLessThan10K = new ArrayList&lt;integer&gt;();
        List&lt;integer&gt; customersGreaterThan10K = new ArrayList&lt;integer&gt;();
        Collections.sort(customers);

        for (Customer c : customers) {
            double sales = 0.0;

            for (PurchaseOrder p : c.getPurchaseOrderCollection()) {
                cal.setTime(p.getSalesDate());
                double vx = p.getProductId().getPurchaseCost().doubleValue() * p.getQuantity();
                addOrUpdate(c.getCustomerId(), String.valueOf(cal.get(Calendar.YEAR)), vx);
                sales += vx;
            }

            if (sales &lt; 10000.00) {
                customersLessThan10K.add(c.getCustomerId());
            } else {
                customersGreaterThan10K.add(c.getCustomerId());
            }
            totalSales += sales;
        }

        Map&lt;Object, Number&gt; lt10k = new HashMap&lt;Object, Number&gt;();
        Map&lt;Object, Number&gt; gt10k = new HashMap&lt;Object, Number&gt;();

        for (Integer i : customersLessThan10K) {
            populateMap(lt10k, CustomerPurchasesByYearTotals.get(i));
        }

        for (Integer i : customersGreaterThan10K) {
            populateMap(gt10k, CustomerPurchasesByYearTotals.get(i));
        }

        ChartSeries customersLessThan10k = new ChartSeries("Customers with Sales &lt; 10K");
        customersLessThan10k.setData(lt10k);
        ChartSeries customersGreaterThan10k = new ChartSeries("Customers with Sales &gt; 10K");
        customersGreaterThan10k.setData(gt10k);
        cartesianChartModel.addSeries(customersLessThan10k);
        cartesianChartModel.addSeries(customersGreaterThan10k);
    }

    private void addOrUpdate(Integer customerId, String year, Number value) {
        Map&lt;String, Number&gt; map = CustomerPurchasesByYearTotals.get(customerId);

        if (map == null) {
            map = new HashMap&lt;String, Number&gt;();
            CustomerPurchasesByYearTotals.put(customerId, map);
        }
        Number n = map.get(year);

        if (n == null) {
            map.put(year, value);
        } else {
            map.put(year, (map.get(year).doubleValue() + value.doubleValue()));
        }
    }

    private void populateMap(Map&lt;Object, Number&gt; map, Map&lt;String, Number&gt; data) {
        if (data == null) {
            return;
        }
        for (String key : data.keySet()) {
            Number n = map.get((Object) key);
            if (n == null) {
                map.put((Object) key, data.get(key));
            } else {
                map.put((Object) key, n.doubleValue() + data.get(key).doubleValue());
            }
        }
    }

    private void createBubbleModel() {
        for (Product p : pf.findAll()) {
            bubbleChartModel.add(new BubbleChartSeries(
                    p.getDescription(), //label
                    p.getQuantityOnHand(), // x
                    p.getMarkup().intValue(), //y 
                    p.getPurchaseCost().intValue() //radius
                    ));
        }
    }

    private void createMeterGaugeModel() {
        List&lt;number&gt; intervals = new ArrayList&lt;number&gt;() {
            {
                add(200000);
                add(400000);
                add(600000);
                add(800000);
            }
        };
//        meterGaugeChartModel = new MeterGaugeChartModel("Sales", totalSales, intervals); //PrimeFaces 3.3+
        meterGaugeChartModel = new MeterGaugeChartModel(Double.valueOf(totalSales), intervals); //PrimeFaces 3.4+
    }

    public XYDataSetCollection getChartSeries() {
        XYDataSetCollection collection = new XYDataSetCollection();
        XYDataList currentSeries1DataList = new XYDataList();
        XYDataList currentSeries2DataList = new XYDataList();
        XYDataList currentSeries3DataList = new XYDataList();

        for (int i = 0; i &lt;= 10; i++) {
            long startTime = 1196463600000l;
            if (chartData.getMode().equalsIgnoreCase("Time")) {
                XYDataPoint p1 = new XYDataPoint(series1DataList.get(i).getX(),
                        series1DataList.get(i).getY(), series1DataList.get(i).getPointLabel());
                p1.setX(startTime + (p1.getX().doubleValue() * 1000 * 60));

                XYDataPoint p2 = new XYDataPoint(series2DataList.get(i).getX(),
                        series2DataList.get(i).getY(), series2DataList.get(i).getPointLabel());
                p2.setX(startTime + (p2.getX().doubleValue() * 1000 * 60));

                XYDataPoint p3 = new XYDataPoint(series3DataList.get(i).getX(),
                        series3DataList.get(i).getY(), series3DataList.get(i).getPointLabel());
                p3.setX(startTime + (p3.getX().doubleValue() * 1000 * 60));

                currentSeries1DataList.addDataPoint(p1);
                currentSeries2DataList.addDataPoint(p2);
                currentSeries3DataList.addDataPoint(p3);
            } else {
                currentSeries1DataList.addDataPoint(series1DataList.get(i));
                currentSeries2DataList.addDataPoint(series2DataList.get(i));
                currentSeries3DataList.addDataPoint(series3DataList.get(i));
            }
        }
        currentSeries1DataList.setLabel(series1DataList.getLabel());
        currentSeries1DataList.setFillLines(series1DataList.isFillLines());
        currentSeries1DataList.setMarkerPosition(series1DataList.getMarkerPosition());
        currentSeries1DataList.setMarkers(series1DataList.isMarkers());
        currentSeries1DataList.setShowDataPoints(series1DataList.isShowDataPoints());
        currentSeries1DataList.setShowLines(series1DataList.isShowLines());

        currentSeries2DataList.setLabel(series2DataList.getLabel());
        currentSeries2DataList.setFillLines(series2DataList.isFillLines());
        currentSeries2DataList.setMarkerPosition(series2DataList.getMarkerPosition());
        currentSeries2DataList.setMarkers(series2DataList.isMarkers());
        currentSeries2DataList.setShowDataPoints(series2DataList.isShowDataPoints());
        currentSeries2DataList.setShowLines(series2DataList.isShowLines());

        currentSeries3DataList.setLabel(series3DataList.getLabel());
        currentSeries3DataList.setFillLines(series3DataList.isFillLines());
        currentSeries3DataList.setMarkerPosition(series3DataList.getMarkerPosition());
        currentSeries3DataList.setMarkers(series3DataList.isMarkers());
        currentSeries3DataList.setShowDataPoints(series3DataList.isShowDataPoints());
        currentSeries3DataList.setShowLines(series3DataList.isShowLines());

        collection.addDataList(currentSeries1DataList);
        collection.addDataList(currentSeries2DataList);
        collection.addDataList(currentSeries3DataList);
        return collection;
    }

    public FlotChartRendererData getChartData() {
        return chartData;
    }

    public void setChartData(FlotChartRendererData chartData) {
        this.chartData = chartData;
    }

    public XYDataList getSeries1DataList() {
        return series1DataList;
    }

    public void setSeries1DataList(XYDataList series1DataList) {
        this.series1DataList = series1DataList;
    }

    public XYDataList getSeries2DataList() {
        return series2DataList;
    }

    public void setSeries2DataList(XYDataList series2DataList) {
        this.series2DataList = series2DataList;
    }

    public XYDataList getSeries3DataList() {
        return series3DataList;
    }

    public void setSeries3DataList(XYDataList series3DataList) {
        this.series3DataList = series3DataList;
    }

    public void generateChartMethod(OutputStream out, Object data) throws IOException {
        JFreeChart chart = ChartFactory.createPieChart3D("Products", getPartsDataset(), false, false, false);
        BufferedImage buffImg = chart.createBufferedImage(600, 400, BufferedImage.TYPE_INT_RGB, null);
        ImageIO.write(buffImg, "png", out);
    }

    private PieDataset getPartsDataset() {
        DefaultPieDataset dataset = new DefaultPieDataset();
        double totalCost = 0.0;
        List&lt;product&gt; products = pf.findAll();
        for (Product p : products) {
            totalCost += p.getPurchaseCost().doubleValue();
        }
        for (Product p : products) {
            dataset.setValue(p.getDescription(), (p.getPurchaseCost().doubleValue() / totalCost));
        }
        return dataset;
    }

    public StreamedContent getStreamedContent() {
        return streamedContent;
    }
}
]]&gt;&lt;/script&gt;&lt;img src="http://feeds.feedburner.com/~r/JavaEvangelistJohnYearysBlog/~4/XxO2dz_L7t4" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/JavaEvangelistJohnYearysBlog/~3/XxO2dz_L7t4/jsf-2x-tip-of-day-richfaces-43x-charts.html</link><author>noreply@blogger.com (John Yeary)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/-EzWcptXkWx4/UWXnXkBZHTI/AAAAAAAADyE/v1VjVavs-ks/s72-c/RichFacesPrimeFacesChartExamples.png" height="72" width="72" /><thr:total>0</thr:total><gd:extendedProperty name="commentSource" value="1" /><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD" /><feedburner:origLink>http://javaevangelist.blogspot.com/2013/04/jsf-2x-tip-of-day-richfaces-43x-charts.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-36773632.post-7176210692383516644</guid><pubDate>Wed, 10 Apr 2013 14:36:00 +0000</pubDate><atom:updated>2013-04-10T09:38:31.619-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">example</category><category domain="http://www.blogger.com/atom/ns#">JSR-314</category><category domain="http://www.blogger.com/atom/ns#">JavaEE</category><category domain="http://www.blogger.com/atom/ns#">JSF</category><category domain="http://www.blogger.com/atom/ns#">tutorial</category><category domain="http://www.blogger.com/atom/ns#">glassfish</category><category domain="http://www.blogger.com/atom/ns#">Mojarra</category><category domain="http://www.blogger.com/atom/ns#">Netbeans</category><category domain="http://www.blogger.com/atom/ns#">JEE6</category><title>JSF 2.x Tip of the Day: Post Exception Back Button</title><description>&lt;h1&gt;
Introduction&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://images-onepick-opensocial.googleusercontent.com/gadgets/proxy?container=onepick&amp;amp;gadget=a&amp;amp;rewriteMime=image%2F*&amp;amp;url=http%3A%2F%2Fwww.cr-cath.pvt.k12.ia.us%2Flasalle%2FResources%2FRev%2520War%2520Websites%2FJosh%2520Michael%2520Zack%2520Rev%2520War%2FZack%2520Rev%2520War%2Fimages%2FBack%2520Button.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"&gt;&lt;img border="0" height="182" src="http://images-onepick-opensocial.googleusercontent.com/gadgets/proxy?container=onepick&amp;amp;gadget=a&amp;amp;rewriteMime=image%2F*&amp;amp;url=http%3A%2F%2Fwww.cr-cath.pvt.k12.ia.us%2Flasalle%2FResources%2FRev%2520War%2520Websites%2FJosh%2520Michael%2520Zack%2520Rev%2520War%2FZack%2520Rev%2520War%2Fimages%2FBack%2520Button.jpg" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/h1&gt;
This is hopefully one simple example of how to make a "back" button when an exception occurs, and sends you to an exception page. The question becomes "How do I get back to the page where the exception occurred?" The navigation back to the offending page is possible, but you want to make sure that you handle the exception, or you may get into a cycle.&lt;br /&gt;
&lt;br /&gt;
A solution was suggested to me by my friend &lt;a href="http://blog.eisele.net/"&gt;Markus Eisele&lt;/a&gt; using an ExceptionHandler in JSF. I had used exception handlers in the past, and thought that it was a simple and elegant idea. The code I am providing below &lt;b&gt;DOES NOT&lt;/b&gt; handle the exception. This is specific to your implementation. This is just a handler that sits on top of your exception hierarchy, and provides a&amp;nbsp;convenient mechanism to navigate back.
&lt;br /&gt;
&lt;h1&gt;
Code&lt;/h1&gt;
The example code for the &lt;a href="http://netbeans.org/"&gt;NetBeans&lt;/a&gt; &lt;a href="http://maven.apache.org/"&gt;Maven&lt;/a&gt; project can be downloaded from &lt;a href="http://bitbucket.org/"&gt;BitBucket&lt;/a&gt; here: &lt;a href="http://code.bluelotussoftware.com/exception-handler-navigation-button"&gt;exception-handler-navigation-button&lt;/a&gt;
&lt;br /&gt;
&lt;br /&gt;
You will need to register the factory below in the &lt;code&gt;faces-config.xml&lt;/code&gt; file.
&lt;br /&gt;
&lt;h2&gt;
GeneralExceptionHandlerFactory.java&lt;/h2&gt;
&lt;hr /&gt;
&lt;script class="brush: java" type="syntaxhighlighter"&gt;&lt;![CDATA[
package com.bluelotussoftware.jsf.exception.handler;

import javax.faces.context.ExceptionHandler;
import javax.faces.context.ExceptionHandlerFactory;

/**
 *
 * @author John Yeary
 * @version 1.0
 */
public class GeneralExceptionHandlerFactory extends ExceptionHandlerFactory {

    private ExceptionHandlerFactory parent;

    public GeneralExceptionHandlerFactory(final ExceptionHandlerFactory parent) {
        this.parent = parent;
    }

    @Override
    public ExceptionHandler getExceptionHandler() {
        ExceptionHandler result = parent.getExceptionHandler();
        result = new GeneralExceptionHandler(result);
        return result;
    }
}
]]&gt;&lt;/script&gt;

&lt;h2&gt;
GeneralExceptionHandler.java&lt;/h2&gt;
&lt;hr /&gt;
&lt;script class="brush: java" type="syntaxhighlighter"&gt;&lt;![CDATA[
package com.bluelotussoftware.jsf.exception.handler;

import java.util.Iterator;
import java.util.logging.Logger;
import javax.faces.FacesException;
import javax.faces.context.ExceptionHandler;
import javax.faces.context.ExceptionHandlerWrapper;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.faces.event.ExceptionQueuedEvent;
import javax.faces.event.ExceptionQueuedEventContext;
import javax.servlet.http.HttpServletRequest;

/**
 *
 * @author John Yeary
 * @version 1.0
 */
public class GeneralExceptionHandler extends ExceptionHandlerWrapper {

    private ExceptionHandler parent;
    private static final Logger LOG = Logger.getLogger(GeneralExceptionHandler.class.getName());

    public GeneralExceptionHandler(final ExceptionHandler parent) {
        this.parent = parent;
    }

    @Override
    public ExceptionHandler getWrapped() {
        return parent;
    }

    @Override
    public void handle() throws FacesException {
        for (Iterator&lt;exceptionqueuedevent&gt; i = getUnhandledExceptionQueuedEvents().iterator(); i.hasNext();) {
            ExceptionQueuedEvent event = i.next();
            ExceptionQueuedEventContext eqec = (ExceptionQueuedEventContext) event.getSource();
            Throwable throwable = eqec.getException();

            if (throwable instanceof FacesException) {
                FacesContext fc = FacesContext.getCurrentInstance();
                ExternalContext ec = fc.getExternalContext();
                HttpServletRequest request = (HttpServletRequest) ec.getRequest();
                String originalRequestURI = request.getRequestURI();
                String encodedURL = ec.encodeRedirectURL(originalRequestURI, null);
                ec.getSessionMap().put("com.bluelotussoftware.jsf.exception.handler.GeneralExceptionHandler.URL", encodedURL);
            }
        }
        parent.handle();
    }
}
]]&gt;&lt;/script&gt;

&lt;h1&gt;
Usage&lt;/h1&gt;
Here is an example of how to use it from an exception page.
&lt;script class="brush: xhtml" type="syntaxhighlighter"&gt;&lt;![CDATA[
 &lt;h:commandButton value="Previous Page" action="#{indexBean.navigate()}"/&gt;
]]&gt;&lt;/script&gt;
&lt;script class="brush: java" type="syntaxhighlighter"&gt;&lt;![CDATA[
 public String navigate() throws IOException {
        String redirectURL = (String) FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("com.bluelotussoftware.jsf.exception.handler.GeneralExceptionHandler.URL");
        FacesContext.getCurrentInstance().getExternalContext().redirect(redirectURL);
        return null;
    }
]]&gt;&lt;/script&gt;&lt;img src="http://feeds.feedburner.com/~r/JavaEvangelistJohnYearysBlog/~4/6z0NKBCGcP0" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/JavaEvangelistJohnYearysBlog/~3/6z0NKBCGcP0/jsf-2x-tip-of-day-post-exception-back.html</link><author>noreply@blogger.com (John Yeary)</author><thr:total>0</thr:total><gd:extendedProperty name="commentSource" value="1" /><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD" /><feedburner:origLink>http://javaevangelist.blogspot.com/2013/04/jsf-2x-tip-of-day-post-exception-back.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-36773632.post-3165759883693956049</guid><pubDate>Tue, 09 Apr 2013 16:15:00 +0000</pubDate><atom:updated>2013-04-09T11:15:21.606-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">example</category><category domain="http://www.blogger.com/atom/ns#">PrimeFaces</category><category domain="http://www.blogger.com/atom/ns#">JSR-314</category><category domain="http://www.blogger.com/atom/ns#">JavaEE</category><category domain="http://www.blogger.com/atom/ns#">JSF</category><category domain="http://www.blogger.com/atom/ns#">tutorial</category><category domain="http://www.blogger.com/atom/ns#">glassfish</category><category domain="http://www.blogger.com/atom/ns#">Mojarra</category><category domain="http://www.blogger.com/atom/ns#">Netbeans</category><category domain="http://www.blogger.com/atom/ns#">JEE6</category><title>JSF 2.x Tip of the Day: PrimeFaces Chart Coding Exam</title><description>&lt;table cellpadding="0" cellspacing="0" class="tr-caption-container" style="float: right; margin-left: 1em; text-align: right;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-YHSOMOezu34/UWQ9cQPYr_I/AAAAAAAADxk/0tE7bx7giwc/s1600/PrimeFacesPieChart.png" imageanchor="1" style="clear: right; margin-bottom: 1em; margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" src="http://4.bp.blogspot.com/-YHSOMOezu34/UWQ9cQPYr_I/AAAAAAAADxk/0tE7bx7giwc/s1600/PrimeFacesPieChart.png" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;PrimeFaces Pie Chart&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;h1&gt;
Background&lt;/h1&gt;
I have been asked to interview a number of engineers over the last couple of years. We were interested in hiring an engineer with a background in JSF specifically &lt;a href="http://primefaces.org/"&gt;PrimeFaces&lt;/a&gt;, Java EE 6, and &lt;a href="http://netbeans.org/"&gt;NetBeans&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
Basically I wanted someone...like me.&lt;br /&gt;
&lt;br /&gt;
I came into work one day, and I was told that I needed to interview someone in about an hour about a position. The person claimed experience in all of the aforementioned technologies. I needed to come up with a coding exam idea for them. Tick tock tick tock.&lt;br /&gt;
&lt;br /&gt;
I decided to create a&amp;nbsp;&lt;a href="http://netbeans.org/"&gt;NetBeans&lt;/a&gt;&amp;nbsp;project using the sample Java DB database, JPA, EJB facades, and a JSF front end using&amp;nbsp;&lt;a href="http://primefaces.org/"&gt;PrimeFaces&lt;/a&gt;&amp;nbsp;with a pie chart. The whole process took about 7 minutes to create. When the engineer arrived, I showed him the result and said "I want to see the same results", and explained that I used the sample database from NetBeans.&lt;br /&gt;
&lt;br /&gt;
The engineer was successful and created something similar in about 30 minutes, and additionally showed me up by adding percentage tags to the chart. We hired him after the interview. I am glad to say he is an integral part of our team today.&lt;br /&gt;
&lt;h1&gt;
Coding Exam&lt;/h1&gt;
What do I want?&lt;br /&gt;
&lt;br /&gt;
Please create a JSF application using&amp;nbsp;&lt;a href="http://primefaces.org/"&gt;PrimeFaces&lt;/a&gt;&amp;nbsp;that displays a pie chart using data provided. The application must be developed using&amp;nbsp;&lt;a href="http://netbeans.org/"&gt;NetBeans&lt;/a&gt;&amp;nbsp;and Java EE 6 technologies. The example data is provided using the sample Java DB database in&amp;nbsp;&lt;a href="http://netbeans.org/"&gt;NetBeans&lt;/a&gt;&amp;nbsp; We would like to have a pie chart that shows sales totals by customer as a percentage of all sales. You have 1 hour to complete the code, and will be required to explain your design decisions, and results.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Note:&lt;/b&gt; I just showed them the pie chart that was generated in the browser and not the actual code. I don't want to sway the candidates decision making, or give them hints on how to solve the problem.&lt;br /&gt;
&lt;br /&gt;
Here is the code for the project: &lt;a href="http://code.bluelotussoftware.com/primefacescodingexam"&gt;PrimeFacesCodingExam&lt;/a&gt;&lt;br /&gt;
&lt;h1&gt;
Conclusion&lt;/h1&gt;
Even if you don't use this in a coding exam, it is a good example of combining Java EE technologies using&amp;nbsp;&lt;a href="http://netbeans.org/"&gt;NetBeans&amp;nbsp;&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="http://primefaces.org/"&gt;PrimeFaces&lt;/a&gt;.&lt;img src="http://feeds.feedburner.com/~r/JavaEvangelistJohnYearysBlog/~4/gkeBeMuIj4I" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/JavaEvangelistJohnYearysBlog/~3/gkeBeMuIj4I/jsf-2x-tip-of-day-primefaces-chart.html</link><author>noreply@blogger.com (John Yeary)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/-YHSOMOezu34/UWQ9cQPYr_I/AAAAAAAADxk/0tE7bx7giwc/s72-c/PrimeFacesPieChart.png" height="72" width="72" /><thr:total>2</thr:total><gd:extendedProperty name="commentSource" value="1" /><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD" /><feedburner:origLink>http://javaevangelist.blogspot.com/2013/04/jsf-2x-tip-of-day-primefaces-chart.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-36773632.post-5179921154616001508</guid><pubDate>Sun, 07 Apr 2013 03:40:00 +0000</pubDate><atom:updated>2013-04-06T22:40:53.797-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">example</category><category domain="http://www.blogger.com/atom/ns#">JavaEE</category><category domain="http://www.blogger.com/atom/ns#">JEE5</category><category domain="http://www.blogger.com/atom/ns#">tutorial</category><category domain="http://www.blogger.com/atom/ns#">JEE6</category><title>Java EE @WebFilter Filters</title><description>&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://images.mnn.com/sites/default/files/editorial/shutterstock_42905923.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"&gt;&lt;img border="0" height="181" src="http://images.mnn.com/sites/default/files/editorial/shutterstock_42905923.jpg" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;
I got an email from a developer a couple of days ago that was complaining that the filters he implemented were not executing on the url patterns he had set. The email was not explicit enough for me to determine if the ordering was an issue too. I created a simple project that shows how to use @WebFilter (Servlet Filters). I was going to dispose of the code, but I thought it might have some redeeming qualities for those who may need a working example.&lt;br /&gt;
&lt;br /&gt;
I have commented out the @WebFilter annotations so that the web.xml controls the ordering. If you uncomment the @WebFilter annotations, you will need to comment the lines in the web.xml. Doing so will produce the same issues reported to me about execution and ordering.&lt;br /&gt;
&lt;br /&gt;
Here is the &lt;a href="http://netbeans.org/"&gt;NetBeans&lt;/a&gt; project using &lt;a href="http://maven.apache.org/"&gt;Apache Maven&lt;/a&gt;: &lt;a href="http://commondatastorage.googleapis.com/bluelotussoftware/code/zsolt-filter-example.zip"&gt;zsolt-filter-example&lt;/a&gt;. I didn't want to put in a repo since it was not really a planned project.&lt;img src="http://feeds.feedburner.com/~r/JavaEvangelistJohnYearysBlog/~4/DyR31gwJrd4" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/JavaEvangelistJohnYearysBlog/~3/DyR31gwJrd4/java-ee-webfilter-filters.html</link><author>noreply@blogger.com (John Yeary)</author><thr:total>0</thr:total><gd:extendedProperty name="commentSource" value="1" /><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD" /><feedburner:origLink>http://javaevangelist.blogspot.com/2013/04/java-ee-webfilter-filters.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-36773632.post-1837065912703894497</guid><pubDate>Sun, 07 Apr 2013 00:35:00 +0000</pubDate><atom:updated>2013-04-06T19:35:09.650-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">example</category><category domain="http://www.blogger.com/atom/ns#">JSR-314</category><category domain="http://www.blogger.com/atom/ns#">JavaEE</category><category domain="http://www.blogger.com/atom/ns#">JSF</category><category domain="http://www.blogger.com/atom/ns#">tutorial</category><category domain="http://www.blogger.com/atom/ns#">glassfish</category><category domain="http://www.blogger.com/atom/ns#">Mojarra</category><category domain="http://www.blogger.com/atom/ns#">Netbeans</category><category domain="http://www.blogger.com/atom/ns#">JEE6</category><title>JSF 2.x Tip of the Day: JSF Expression Language (EL) Keywords and Implicit Objects</title><description>A friend of mine asked me if there was a list of reserved words in EL and JSF. He had previously looked for it, and after some Google searching I didn't find a comprehensive list anywhere. I decided to create one for him and anyone else who may need it. If you are aware of any other keywords, please post a comment and I will add them to the listings.
&lt;br/&gt;&lt;br/&gt;
&lt;table&gt;
&lt;caption&gt;&lt;b&gt;Expression Language (EL) Reserved Keywords&lt;/b&gt;&lt;/caption&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Value&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;and&lt;/td&gt;
&lt;td&gt;Logical operator alternative to (&amp;amp;&amp;amp;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;false&lt;/td&gt;
&lt;td&gt;Boolean literal&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;le&lt;/td&gt;
&lt;td&gt;Relation operator less than or equal to alternative to (&amp;lt;=)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;not&lt;/td&gt;
&lt;td&gt;Logical operator reverse alternative to (!)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;div&lt;/td&gt;
&lt;td&gt;Arithmetic operator division alternative to (/)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ge&lt;/td&gt;
&lt;td&gt;Relational operator greater or equal to alternative to (&amp;gt;=)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;lt&lt;/td&gt;
&lt;td&gt;Relational operator less than alternative to (&amp;lt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;null&lt;/td&gt;
&lt;td&gt;Null literal&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;empty&lt;/td&gt;
&lt;td&gt;The empty operator is a prefix operation that can be used to determine whether a value is null or empty.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;gt&lt;/td&gt;
&lt;td&gt;Relational operator greater than alternative to (&amp;gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;mod&lt;/td&gt;
&lt;td&gt;Arithmetic operator modulo alternative to (%)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;or&lt;/td&gt;
&lt;td&gt;Logical operator alternative to (||)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;eq&lt;/td&gt;
&lt;td&gt;Logical operator alternative to (==)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;instanceof&lt;/td&gt;
&lt;td&gt;Java Keyword to do a Class comparison between Objects&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ne&lt;/td&gt;
&lt;td&gt;Relational operator not equal alternative to (!=)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;true&lt;/td&gt;
&lt;td&gt;Boolean literal&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;br/&gt;&lt;br/&gt;
&lt;table&gt;
&lt;caption&gt;&lt;b&gt;JSF 2.x Expression Language (EL) Implicit Objects&lt;/b&gt;&lt;/caption&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Value&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;application&lt;/td&gt;
&lt;td&gt;This provides user access to the &lt;code&gt;ApplicationContext&lt;/code&gt; implementation of &lt;code&gt;&lt;a href="http://docs.oracle.com/javaee/6/api/javax/servlet/ServletContext.html"&gt;ServletContext&lt;/a&gt;&lt;/code&gt; that represents a web application's execution environment.&lt;br/&gt;&lt;b&gt;Note:&lt;/b&gt; This is not related to the JSF &lt;code&gt;&lt;a href="http://javaserverfaces.java.net/nonav/docs/2.1/javadocs/javax/faces/application/Application.html"&gt;Application&lt;/a&gt;&lt;/code&gt; object.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;applicationScope&lt;/td&gt;
&lt;td&gt;Maps application-scoped variable names to their values.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;cc&lt;/td&gt;
&lt;td&gt;Implicit EL object that provides access to the JSF Composite Component. &lt;code&gt;cc&lt;/code&gt; refers to the top level composite component processed at the time of evaluation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;component&lt;/td&gt;
&lt;td&gt;Implicit EL object representing &lt;code&gt;&lt;a href="http://javaserverfaces.java.net/nonav/docs/2.1/javadocs/javax/faces/component/UIComponent.html"&gt;javax.faces.component.UIComponent&lt;/a&gt;&lt;/code&gt;for the current component.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;cookie&lt;/td&gt;
&lt;td&gt;Maps a cookie name to a single cookie.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;facesContext&lt;/td&gt;
&lt;td&gt;The FacesContext instance for the current request.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;flash&lt;/td&gt;
&lt;td&gt;Provides user access to the EL implicit &lt;code&gt;&lt;a href="http://javaserverfaces.java.net/nonav/docs/2.1/javadocs/javax/faces/context/Flash.html"&gt;javax.faces.context.Flash&lt;/a&gt;&lt;/code&gt; object. It may additional obtained via #{facesContext.externalContext.flash}. The implementation must ensure that the flash is usable from both JSP and from Facelets for JSF 2.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;header&lt;/td&gt;
&lt;td&gt;Maps a request header name to a single value.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;headerValues&lt;/td&gt;
&lt;td&gt;Maps a request header name to an array of values.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;initParam&lt;/td&gt;
&lt;td&gt;Maps a context initialization parameter name to a single value.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;param&lt;/td&gt;
&lt;td&gt;Maps a request parameter name to a single value.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;paramValues&lt;/td&gt;
&lt;td&gt;Maps a request parameter name to an array of values.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;request&lt;/td&gt;
&lt;td&gt;EL implicit object for current request.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;requestScope&lt;/td&gt;
&lt;td&gt;Maps request-scoped variable names to their values.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;resource&lt;/td&gt;
&lt;td&gt;EL implicit object for &lt;code&gt;&lt;a href="http://javaserverfaces.java.net/nonav/docs/2.1/javadocs/javax/faces/application/ResourceHandler.html"&gt;javax.faces.application.ResourceHandler&lt;/a&gt;&lt;/code&gt;.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;session&lt;/td&gt;
&lt;td&gt;Provides EL access to the current &lt;code&gt;&lt;a href="http://docs.oracle.com/javaee/6/api/javax/servlet/http/HttpSession.html"&gt;HttpSession&lt;/a&gt;&lt;code&gt; object.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;sessionScope&lt;/td&gt;
&lt;td&gt;Maps session-scoped variable names to their values.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;view&lt;/td&gt;
&lt;td&gt;Provides access to the &lt;code&gt;&lt;a href="http://javaserverfaces.java.net/nonav/docs/2.1/javadocs/javax/faces/component/UIViewRoot.html"&gt;javax.faces.component.UIViewRoot&lt;/a&gt;&lt;/code&gt; for the current instance.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;viewScope&lt;/td&gt;
&lt;td&gt;Maps view-scoped variable names to their values.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;img src="http://feeds.feedburner.com/~r/JavaEvangelistJohnYearysBlog/~4/Uy5r4yRDRQs" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/JavaEvangelistJohnYearysBlog/~3/Uy5r4yRDRQs/jsf-2x-tip-of-day-jsf-expression.html</link><author>noreply@blogger.com (John Yeary)</author><thr:total>0</thr:total><gd:extendedProperty name="commentSource" value="1" /><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD" /><feedburner:origLink>http://javaevangelist.blogspot.com/2013/04/jsf-2x-tip-of-day-jsf-expression.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-36773632.post-8735239854919307822</guid><pubDate>Tue, 02 Apr 2013 16:00:00 +0000</pubDate><atom:updated>2013-04-02T11:00:17.414-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">example</category><category domain="http://www.blogger.com/atom/ns#">JSR-314</category><category domain="http://www.blogger.com/atom/ns#">JavaEE</category><category domain="http://www.blogger.com/atom/ns#">JSF</category><category domain="http://www.blogger.com/atom/ns#">tutorial</category><category domain="http://www.blogger.com/atom/ns#">glassfish</category><category domain="http://www.blogger.com/atom/ns#">Mojarra</category><category domain="http://www.blogger.com/atom/ns#">RichFaces</category><category domain="http://www.blogger.com/atom/ns#">Netbeans</category><category domain="http://www.blogger.com/atom/ns#">JEE6</category><title>JSF 2.x Tip of the Day: RichFaces &lt;rich:tree /&gt; Component Examples</title><description>&lt;table cellpadding="0" cellspacing="0" class="tr-caption-container" style="float: right; margin-left: 1em; text-align: right;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-RCY3MrSnyrs/UVr7R_Q_yAI/AAAAAAAADvs/6Icw9HhJvJA/s1600/RichFacesCustomModelTree.png" imageanchor="1" style="clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="320" src="http://4.bp.blogspot.com/-RCY3MrSnyrs/UVr7R_Q_yAI/AAAAAAAADvs/6Icw9HhJvJA/s320/RichFacesCustomModelTree.png" width="268" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Custom TreeModel and TreeNode&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
I have some code that I originally wrote for a proof of concept for doing some &lt;a href="http://www.jboss.org/richfaces"&gt;RichFaces&lt;/a&gt; &lt;code&gt;&lt;a href="http://docs.jboss.org/richfaces/latest_4_X/vdldoc/rich/tree.html"&gt;&amp;lt;rich:tree /&amp;gt;&lt;/a&gt;&lt;/code&gt; examples. The modified code in these examples demonstrate how to use custom &lt;code&gt;&lt;a href="http://docs.jboss.org/richfaces/4.3.X/4.3.1.Final/javadoc/richfaces-components-api/org/richfaces/model/TreeNode.html"&gt;TreeNode&lt;/a&gt;&lt;/code&gt;, and &lt;code&gt;&lt;a href="http://docs.jboss.org/richfaces/4.3.X/4.3.1.Final/javadoc/richfaces-components-api/org/richfaces/model/TreeDataModel.html"&gt;TreeDataModel&lt;/a&gt;&lt;/code&gt; implementations to make really nice and functional trees. The code for my generic &lt;code&gt;TypedTreeNode&lt;/code&gt; and &lt;code&gt;TreeNodesSequenceKeyModel&lt;/code&gt; are fully functional and can be used out of the box as the basis of your own tree implementations.&lt;br /&gt;
&lt;br /&gt;
The examples include the model provided by &lt;a href="http://www.jboss.org/richfaces"&gt;RichFaces&lt;/a&gt;, my custom model (&lt;code&gt;TreeNodesSequenceKeyModel&lt;/code&gt;), and a custom implementation of a node. The custom node is generic so you can pass in any object you like. I chose to use text, but you could use a more complex object.&lt;br /&gt;
&lt;br /&gt;
The custom model, custom node, and tree are shown in the image on the right. This also has events being shown when a node is selected, or toggled.&lt;br /&gt;
&lt;br /&gt;
The project was developed using &lt;a href="http://netbeans.org/"&gt;NetBeans&lt;/a&gt; along with &lt;a href="http://maven.apache.org/"&gt;Apache Maven&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
The &lt;a href="http://mercurial.selenic.com/"&gt;Mercurial&lt;/a&gt; project can be found on &lt;a href="http://bitbucket.org/"&gt;BitBucket&lt;/a&gt; here: &lt;a href="http://code.bluelotussoftware.com/richfaces-tree"&gt;richfaces-tree&lt;/a&gt;
&lt;br /&gt;
&lt;h1&gt;
Code&lt;/h1&gt;
&lt;h2&gt;
TypedTreeNode.java&lt;/h2&gt;
&lt;hr /&gt;
&lt;script class="brush: java" type="syntaxhighlighter"&gt;&lt;![CDATA[
/*
 * Copyright 2011-2013 Blue Lotus Software, LLC.
 * Copyright 2011-2013 John Yeary.
 *
 * JBoss, Home of Professional Open Source
 * Copyright 2010, Red Hat, Inc. and individual contributors
 * by the @authors tag. See the copyright.txt in the distribution for a
 * full listing of individual contributors.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */
/*
 *  $Id: TypedTreeNode.java,v 1ccd4cbef29f 2013/04/02 03:12:02 jyeary $
 */
package com.bluelotussoftware.example.jsf.richfaces;

import com.google.common.collect.Iterators;
import java.io.Serializable;
import java.util.*;
import org.richfaces.model.TreeNode;

/**
 * This {@code TreeNode} implementation is based on the work done by the JBoss
 * RichFaces team for RichFaces 3 and 4. It is a simple practical implementation
 * that uses a generic type {@code T} to hold the data for the node.
 *
 * @author Nick Belaevski
 * @author John Yeary
 * @version 1.0
 */
public class TypedTreeNode&lt;t&gt; implements TreeNode, Serializable {

    private T data;
    private LinkedHashMap&lt;Object, TypedTreeNode&lt;t&gt;&gt; children = new LinkedHashMap&lt;Object, TypedTreeNode&lt;t&gt;&gt;();
    private List&lt;object&gt; keys = new ArrayList&lt;object&gt;();

    public TypedTreeNode() {
    }

    public TypedTreeNode(T data) {
        this.data = data;
    }

    @Override
    public TypedTreeNode&lt;t&gt; getChild(Object key) {
        return children.get(key);
    }

    @Override
    public int indexOf(Object key) {
        return keys.indexOf(key);
    }

    @Override
    public Iterator&lt;object&gt; getChildrenKeysIterator() {
        if (isLeaf()) {
            return Iterators.emptyIterator();
        }
        return Iterators.unmodifiableIterator(keys.iterator());
    }

    @Override
    public boolean isLeaf() {
        return children.isEmpty();
    }

    @Override
    public void addChild(Object key, TreeNode child) {
        addChild(-1, key, child);
    }

    @Override
    public void insertChild(int idx, Object key, TreeNode child) {
        addChild(idx, key, child);
    }

    @Override
    public void removeChild(Object key) {
        children.remove(key);
        keys.remove(key);
    }

    ///////////////////////////
    // Non Interface Methods //
    ///////////////////////////
    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public List&lt;object&gt; getKeys() {
        return Collections.unmodifiableList(keys);
    }

    @SuppressWarnings("unchecked")
    private void addChild(int idx, Object key, TreeNode child) {
        if (child instanceof TypedTreeNode) {
            if (idx != -1) {
                keys.add(idx, key);
            } else {
                keys.add(key);
            }
            children.put(key, (TypedTreeNode&lt;t&gt;) child);
        } else {
            throw new ClassCastException("The child is not a TreeNodeImpl&lt;t&gt;class object.");
        }
    }

    public LinkedHashMap&lt;Object, TypedTreeNode&lt;t&gt;&gt; getChildren() {
        return children;
    }
}
]]&gt;&lt;/script&gt;

&lt;br /&gt;
&lt;h2&gt;
TreeNodesSequenceKeyModel.java&lt;/h2&gt;
&lt;hr /&gt;
&lt;script class="brush: java" type="syntaxhighlighter"&gt;&lt;![CDATA[
/*
 * Copyright (C) 2011-2013  Blue Lotus Software, LLC.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */
/*
 * $Id: TreeNodesSequenceKeyModel.java,v 2106162b4c89 2013/04/02 13:17:25 jyeary $
 */
package com.bluelotussoftware.example.jsf.richfaces;

import java.util.Iterator;
import javax.faces.convert.Converter;
import org.richfaces.convert.StringSequenceRowKeyConverter;
import org.richfaces.model.NodesTreeSequenceKeyModel;
import org.richfaces.model.TreeDataModelTuple;
import org.richfaces.model.iterators.ClassicTreeNodeTuplesIterator;

/**
 *
 * @author John Yeary
 * @version 1.0
 */
public class TreeNodesSequenceKeyModel&lt;v&gt; extends NodesTreeSequenceKeyModel&lt;TypedTreeNode&lt;v&gt;&gt; {

    private static final Converter DEFAULT_CONVERTER = new StringSequenceRowKeyConverter();

    @Override
    protected TypedTreeNode&lt;v&gt; setupChildContext(Object key) {
        return getData().getChild(key);
    }

    @Override
    public Object getWrappedData() {
        return getRootNode();
    }

    @Override
    public void setWrappedData(Object data) {
        setRootNode((TypedTreeNode&lt;v&gt;) data);
    }

    @Override
    public boolean isLeaf() {
        return getData().isLeaf();
    }

    @Override
    public Iterator&lt;treedatamodeltuple&gt; children() {
        return new ClassicTreeNodeTuplesIterator(getData(), getRowKey());
    }

    @Override
    public Converter getRowKeyConverter() {
        return DEFAULT_CONVERTER;
    }
}
]]&gt;&lt;/script&gt;&lt;img src="http://feeds.feedburner.com/~r/JavaEvangelistJohnYearysBlog/~4/01CVJexpHPw" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/JavaEvangelistJohnYearysBlog/~3/01CVJexpHPw/jsf-2x-tip-of-day-richfaces-component.html</link><author>noreply@blogger.com (John Yeary)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/-RCY3MrSnyrs/UVr7R_Q_yAI/AAAAAAAADvs/6Icw9HhJvJA/s72-c/RichFacesCustomModelTree.png" height="72" width="72" /><thr:total>0</thr:total><gd:extendedProperty name="commentSource" value="1" /><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD" /><feedburner:origLink>http://javaevangelist.blogspot.com/2013/04/jsf-2x-tip-of-day-richfaces-component.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-36773632.post-3747838413471050479</guid><pubDate>Mon, 01 Apr 2013 05:00:00 +0000</pubDate><atom:updated>2013-04-01T00:00:08.984-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">example</category><category domain="http://www.blogger.com/atom/ns#">Java</category><category domain="http://www.blogger.com/atom/ns#">JDK7</category><category domain="http://www.blogger.com/atom/ns#">tutorial</category><category domain="http://www.blogger.com/atom/ns#">Netbeans</category><title>Determining What Classes are Loaded by ClassLoaders</title><description>I saw a question posted a couple of months ago on stackoverflow, or a forum. I can't remember where I saw it actually. The question was how do I determine what classes are currently loaded by the &lt;code&gt;ClassLoader&lt;/code&gt; when an application is loaded and running. A number of folks posted various solutions like using &lt;code&gt;java -verbose&lt;/code&gt; which are of limited help. Another solution was to get using something like &lt;code&gt;ClassLoader.getSystemClassLoader();&lt;/code&gt;. The latter looks very promising, but is wrong. I knew that there are a number of classes that are loaded that this would not display.&lt;br /&gt;
&lt;br /&gt;
Ssssh... I will show you how I know.&lt;br /&gt;
&lt;br /&gt;
The problem and solution is surprisingly non-trivial. I thought I would come up with a solution like the one above in 5 minutes. I did come up with one above in about that much time. It turns out to be incorrect.&lt;br /&gt;
&lt;br /&gt;
The solution is to use a Java agent to instrument the JVM and see what it is loading. I am sure a number of you have seen the &lt;code&gt;-javaagent:&lt;jarpath&gt;[=&lt;options&gt;]&lt;/options&gt;&lt;/jarpath&gt;&lt;/code&gt; flag for the VM and wondered what is that for. I am going to show you.&lt;br /&gt;
&lt;br /&gt;
First some results:&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;&lt;b&gt;&lt;span style="font-size: large;"&gt;all length -&amp;gt; 815
system length -&amp;gt; 163
appLoader length -&amp;gt; 163
classes size -&amp;gt; 61&lt;/span&gt;&lt;/b&gt;
&lt;/pre&gt;
&lt;br /&gt;
The first value &lt;b&gt;all&lt;/b&gt; indicates all of the classes loaded by the JVM. That is a lot of classes. This is via an Instrumentation agent.&lt;br /&gt;
&lt;br /&gt;
The second value &lt;b&gt;system&lt;/b&gt; indicates all of the classes loaded by the System &lt;code&gt;ClassLoader&lt;/code&gt;. This is significantly less than loaded by the JVM. This is via an Instrumentation agent.&lt;br /&gt;
&lt;br /&gt;
The third value is the &lt;b&gt;appLoader&lt;/b&gt; which is the application classloader. It matches the System, but this may not always be the case. This is via an Instrumentation agent.&lt;br /&gt;
&lt;br /&gt;
Finally, the last value &lt;b&gt;classes&lt;/b&gt; is what you get from the &lt;code&gt;ClassLoader&lt;/code&gt; without instrumentation. It is a paltry amount of the total classes loaded.
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;So which one is right?&lt;/b&gt; Good question... Here is an answer only a parent, or teacher can give. &lt;b&gt;"It depends."&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
If I am looking at everything being loaded to check for something forensically I would use the 815 and look at what these classes are and where they came from. If I am checking which classes are loaded to help with reflection, I would look at the 61.&lt;br /&gt;
&lt;br /&gt;
If you have read this far, then you want the code to look at. I have split it into a couple of &lt;a href="http://netbeans.org/"&gt;NetBeans&lt;/a&gt; &lt;a href="http://maven.apache.org/"&gt;Maven&lt;/a&gt; projects hosted on &lt;a href="http://bitbucket.org/"&gt;BitBucket&lt;/a&gt; using &lt;a href="http://mercurial.selenic.com/"&gt;Mercurial&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://code.bluelotussoftware.com/instrumentation-agent"&gt;instrumentation-agent&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://code.bluelotussoftware.com/find-classes-classloader"&gt;find-classes-classloader&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;h1&gt;Code&lt;/h1&gt;
&lt;h2&gt;InstrumentationAgent.java&lt;/h2&gt;
&lt;hr/&gt;
&lt;script type="syntaxhighlighter" class="brush: java"&gt;&lt;![CDATA[
package com.bluelotussoftware.instrumentation.agent;

import java.lang.instrument.Instrumentation;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * This provides a
 * &lt;code&gt;javaagent&lt;/code&gt; instrumentation for the VM. This class provides
 * convenience methods for getting the classes loaded by the VM.
 *
 * @author John Yeary
 * @version 1.0
 */
public class InstrumentationAgent {

    private static final Logger log = Logger.getLogger(InstrumentationAgent.class.getName());
    private static Instrumentation instrumentation;

    /**
     * This method loads the agent prior to invoking the main method.
     *
     * @param agentArgs Arguments to be passed to the agent.
     * @param inst Instrumentation (agent).
     * @throws Exception if any {@code Exception} occurs while calling the
     * method and creating the agent.
     */
    public static void premain(String agentArgs, Instrumentation inst) throws Exception {
        log.log(Level.INFO, "premain() method called with agentArgs {0} and inst {1}", new Object[]{agentArgs, inst.getClass()});
        InstrumentationAgent.instrumentation = inst;
    }

    /**
     * This method is used to set the agent on the main method after the JVM is
     * already running.
     *
     * @param agentArgs Arguments to be passed to the agent.
     * @param inst Instrumentation (agent).
     */
    public static void agentmain(String agentArgs, Instrumentation inst) {
        log.log(Level.INFO, "agentmain() method called with agentArgs {0} and inst {1}", new Object[]{agentArgs, inst.getClass()});
        InstrumentationAgent.instrumentation = inst;
    }

    /**
     * This method returns the wrapped instrument (agent).
     *
     * @return The wrapped agent.
     */
    public static Instrumentation getInstrumentation() {
        return instrumentation;
    }

    /**
     * Returns an array of all classes currently loaded by the JVM.
     *
     * @return an array containing all the classes loaded by the JVM,
     * zero-length if there are none.
     */
    public static Class[] getAllLoadedClasses() {
        return instrumentation.getAllLoadedClasses();
    }

    /**
     * Returns an array of all classes for which
     * {@link ClassLoader#getSystemClassLoader()} is an initiating loader.
     *
     * @return an array containing all the classes for which
     * {@link ClassLoader#getSystemClassLoader()} is an initiating loader,
     * zero-length if there are none.
     */
    public static Class[] getSystemClassLoaderInitiatedClasses() {
        return instrumentation.getInitiatedClasses(ClassLoader.getSystemClassLoader());
    }

    /**
     * Returns an array of all classes for which loader is an initiating loader.
     * If the supplied loader is null, classes initiated by the bootstrap class
     * loader are returned.
     *
     * @param classLoader the loader whose initiated class list will be
     * returned.
     * @return an array containing all the classes for which loader is an
     * initiating loader, zero-length if there are none
     */
    public static Class[] getClassLoaderInitiatedClasses(final ClassLoader classLoader) {
        return instrumentation.getInitiatedClasses(classLoader);
    }

    /**
     * Static initialization method to load the {@link Instrumentation} if it
     * has not already been loaded.
     */
    public static void initialize() {
        log.log(Level.INFO, "initialize() method called.");
        if (instrumentation == null) {
            log.log(Level.INFO, "Instrumentation was null calling AgentLoader.");
            AgentLoader.loadAgent();
        }
    }
}
]]&gt;&lt;/script&gt;
&lt;h2&gt;AgentLoader.java&lt;/h2&gt;
&lt;hr/&gt;
&lt;script type="syntaxhighlighter" class="brush: java"&gt;&lt;![CDATA[
package com.bluelotussoftware.instrumentation.agent;

import com.sun.tools.attach.AgentInitializationException;
import com.sun.tools.attach.AgentLoadException;
import com.sun.tools.attach.AttachNotSupportedException;
import com.sun.tools.attach.VirtualMachine;
import java.io.IOException;
import java.lang.management.ManagementFactory;

/**
 *
 * This class is responsible for dynamically loading the instrumentation agent
 * jar.
 *
 * @author John Yeary
 * @version 1.0
 */
public class AgentLoader {

    /**
     * This method returns the path to the {@link Instrumentation} agent located
     * in the .m2 repository.
     *
     * @return Path to the agent jar.
     */
    private static String getAgentPath() {
        return new StringBuilder().append(System.getProperty("user.home"))
                .append("/.m2/repository/com/bluelotussoftware/instrumentation-agent/1.0/instrumentation-agent-1.0.jar")
                .toString();
    }

    /**
     * Static method for loading an agent into the currently running JVM.
     */
    public static void loadAgent() {
        String runtimeMXBeanName = ManagementFactory.getRuntimeMXBean().getName();
        int endIndex = runtimeMXBeanName.indexOf('@');
        String pid = runtimeMXBeanName.substring(0, endIndex);

        try {
            VirtualMachine vm = VirtualMachine.attach(pid);
            vm.loadAgent(getAgentPath());
            vm.detach();
        } catch (AttachNotSupportedException | IOException | AgentLoadException | AgentInitializationException e) {
            throw new RuntimeException(e);
        }
    }
}
]]&gt;&lt;/script&gt;
&lt;h2&gt;App.java&lt;/h2&gt;
&lt;hr/&gt;
&lt;script type="syntaxhighlighter" class="brush: java"&gt;&lt;![CDATA[
package com.bluelotussoftware.example;

import com.bluelotussoftware.instrumentation.agent.InstrumentationAgent;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * 
 * @author John Yeary &lt;jyeary@bluelotussoftware.com&gt;
 * @version 1.0
 */
@SuppressWarnings("UseOfObsoleteCollectionType")
public class App {

    static {
        InstrumentationAgent.initialize();
    }

    public static void main(String[] args) throws ClassNotFoundException {
        App app = new App();
        
        Class[] all = InstrumentationAgent.getAllLoadedClasses();
        System.out.println("all length -&gt; " + all.length);


        Class[] system = InstrumentationAgent.getSystemClassLoaderInitiatedClasses();
        System.out.println("system length -&gt; " + system.length);


        Class[] appLoader = InstrumentationAgent.getClassLoaderInitiatedClasses(App.class.getClassLoader());
        System.out.println("appLoader length -&gt; " + appLoader.length);


        List&lt;String&gt; classes = app.getLoadedClasses(ClassLoader.getSystemClassLoader());
        System.out.println("classes size -&gt; " + classes.size());

        for (String s : classes) {
            System.out.println(s);
        }
    }

    public List&lt;String&gt; getLoadedClasses(final ClassLoader classLoader) {
        List&lt;String&gt; classNames = null;
        try {
            Field f = ClassLoader.class.getDeclaredField("classes");
            f.setAccessible(true);
            List&lt;Class&gt; classes = new ArrayList&lt;&gt;((Vector&lt;Class&gt;) f.get(classLoader));
            classNames = new ArrayList&lt;&gt;(classes.size());
            for (Class c : classes) {
                classNames.add(c.getCanonicalName());
            }
            return classNames;
        } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException ex) {
            Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex);
        }
        return classNames;
    }
}
]]&gt;&lt;/script&gt;

&lt;b&gt;Note:&lt;/b&gt; I had to put the tools.jar in my Maven repository to make it easy to add as a library.
&lt;h1&gt;References&lt;/h1&gt;
We can not achieve success alone. It is on the shoulders of giants that we see further. I used an example from Dhruba Bandopadhyay to figure out some of the instrumentation process.

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://dhruba.name/2010/02/07/creation-dynamic-loading-and-instrumentation-with-javaagents/"&gt;Creation, dynamic loading and instrumentation with javaagents - Dhruba Bandopadhyay&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;img src="http://feeds.feedburner.com/~r/JavaEvangelistJohnYearysBlog/~4/EL6pOJcltJI" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/JavaEvangelistJohnYearysBlog/~3/EL6pOJcltJI/determining-what-classes-are-loaded-by.html</link><author>noreply@blogger.com (John Yeary)</author><thr:total>0</thr:total><gd:extendedProperty name="commentSource" value="1" /><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD" /><feedburner:origLink>http://javaevangelist.blogspot.com/2013/04/determining-what-classes-are-loaded-by.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-36773632.post-6545340345615629156</guid><pubDate>Mon, 25 Mar 2013 15:58:00 +0000</pubDate><atom:updated>2013-03-25T10:58:39.690-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">example</category><category domain="http://www.blogger.com/atom/ns#">JSR-314</category><category domain="http://www.blogger.com/atom/ns#">JavaEE</category><category domain="http://www.blogger.com/atom/ns#">JSF</category><category domain="http://www.blogger.com/atom/ns#">tutorial</category><category domain="http://www.blogger.com/atom/ns#">glassfish</category><category domain="http://www.blogger.com/atom/ns#">Mojarra</category><category domain="http://www.blogger.com/atom/ns#">RichFaces</category><category domain="http://www.blogger.com/atom/ns#">Netbeans</category><category domain="http://www.blogger.com/atom/ns#">JEE6</category><title>JSF 2.1 Tip of the Day: RichFaces 4.3.x Drag and Drop</title><description>&lt;table cellpadding="0" cellspacing="0" class="tr-caption-container" style="float: right; margin-left: 1em; text-align: right;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/-DHnwjW7Udlw/UVBzTubByEI/AAAAAAAADuE/Og6vIsDWF6k/s1600/MultipleTargetPanels.png" imageanchor="1" style="clear: right; margin-bottom: 1em; margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="400" src="http://4.bp.blogspot.com/-DHnwjW7Udlw/UVBzTubByEI/AAAAAAAADuE/Og6vIsDWF6k/s400/MultipleTargetPanels.png" width="380" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Multiple DnD Targets&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
The Primefaces version of my drag-n-drop (DnD) for JSF has been very popular. I didn't want my friends at Red Hat feeling left out. I did a couple of examples using drag-n-drop with the same arrow demo as the Primefaces example: &lt;a href="http://javaevangelist.blogspot.com/2013/03/jsf-21x-tip-of-day-primefaces-35-drag-n.html"&gt;JSF 2.1.x Tip of the Day: Primefaces 3.5 &amp;lt;p:ring/&amp;gt; Drag-N-Drop Example&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
I did have a little more fun with using Java to &lt;code&gt;clone&lt;/code&gt; some of the arrows so that you could see how to use them multiple times.
&lt;br /&gt;
&lt;h1&gt;
Requirements&lt;/h1&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://javaserverfaces.java.net/download.html"&gt;Mojarra 2.1.20&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.jboss.org/richfaces/download/stable"&gt;richfaces-core-api 4.3.1.Final&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.jboss.org/richfaces/download/stable"&gt;richfaces-core-impl 4.3.1.Final&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.jboss.org/richfaces/download/stable"&gt;richfaces-components-api 4.3.1.Final&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.jboss.org/richfaces/download/stable"&gt;richfaces-components-ui 4.3.1.Final&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;
Details&lt;/h1&gt;
The project was developed using &lt;a href="http://netbeans.org/"&gt;NetBeans 7.3&lt;/a&gt; and &lt;a href="http://maven.apache.org/"&gt;Apache Maven&lt;/a&gt;. The &lt;a href="http://mercurial.selenic.com/"&gt;Mercurial&lt;/a&gt; project can be found on &lt;a href="http://bitbucket.org/"&gt;BitBucket&lt;/a&gt; here: &lt;a href="http://code.bluelotussoftware.com/richfaces-dnd-examples"&gt;richfaces-dnd-examples&lt;/a&gt;
&lt;br /&gt;
&lt;h2&gt;
Code&lt;/h2&gt;
&lt;hr /&gt;
&lt;script class="brush: xhtml" type="syntaxhighlighter"&gt;&lt;![CDATA[
&lt;?xml version='1.0' encoding='UTF-8' ?&gt;
&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:a4j="http://richfaces.org/a4j"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:rich="http://richfaces.org/rich"&gt;
    &lt;h:head&gt;
        &lt;title&gt;Multiple Target Panels&lt;/title&gt;
    &lt;/h:head&gt;
    &lt;h:body&gt;
        &lt;h1&gt;
Multiple Target Panels&lt;/h1&gt;
&lt;p&gt;
This example has both vertical and horizontal arrow stacks. The Horizontal target removes the arrow from the source.&lt;br/&gt; 
            The Vertical target clones the arrow and allows multiple arrows of the same name. 
        &lt;/p&gt;
&lt;h:form id="form1"&gt;
            &lt;rich:dragIndicator id="dragIndicator1"/&gt;
            &lt;h:panelGrid columns="2"&gt;

                &lt;rich:panel id="target"&gt;
                    &lt;f:facet name="header"&gt;
                        &lt;h:outputText value="Target Panel"/&gt;
                    &lt;/f:facet&gt;

                    &lt;h:panelGrid id="panelGrid1" columns="2"&gt;
                        &lt;h:outputText value="Horizontal Arrow Column" rendered="#{arrowBean.target.size() eq 0}"/&gt;
                        &lt;rich:dataGrid id="hArrowPanel"
                                       columns="#{arrowBean.target.size() lt 10 ? arrowBean.target.size() : 10 }"
                                       elements="10" value="#{arrowBean.target}" var="hArrow"&gt;
                            &lt;a4j:outputPanel id="outputPanel4"&gt;
                                &lt;h:graphicImage id="graphicImage4" alt="#{hArrow.name}" value="#{resource['images:arrow-md.png']}"/&gt;
                                &lt;h:outputText id="outputText4" value="#{hArrow.name}"/&gt;
                            &lt;/a4j:outputPanel&gt;
                        &lt;/rich:dataGrid&gt;
                        &lt;h:graphicImage id="graphicImage2" alt="bullseye" height="100" width="100"  value="#{resource['images:bullseye.jpg']}"&gt;
                            &lt;rich:dropTarget  id="dropTarget1"
                                              acceptedTypes="a"
                                              dropValue="hArrow"
                                              dropListener="#{arrowListener.processDrop}"
                                              render="source,target"/&gt;
                        &lt;/h:graphicImage&gt;
                    &lt;/h:panelGrid&gt;

                    &lt;h:panelGrid id="panelGrid2" columns="1"&gt;
                        &lt;h:outputText value="Vertical Arrow Column (Clone)" rendered="#{arrowBean.serialTarget.size() eq 0}"/&gt;
                        &lt;rich:dataGrid id="vArrowPanel" columns="1" value="#{arrowBean.serialTarget}" var="vArrow" 
                                       elements="10" rendered="#{arrowBean.serialTarget.size() gt 0}"&gt;
                            &lt;a4j:outputPanel id="outputPanel3"&gt;
                                &lt;h:graphicImage id="graphicImage3" alt="#{vArrow.name}" value="#{resource['images:arrow-md.png']}"/&gt;
                                &lt;h:outputText id="outputText3" value="#{vArrow.name}"/&gt;
                            &lt;/a4j:outputPanel&gt;
                        &lt;/rich:dataGrid&gt;
                        &lt;h:graphicImage id="graphicImage5" alt="bullseye" height="100" width="100"  value="#{resource['images:bullseye.jpg']}"&gt;
                            &lt;rich:dropTarget  id="dropTarget2"
                                              acceptedTypes="a"
                                              dropValue="s"
                                              dropListener="#{arrowListener.processDrop}"
                                              render="source,target"/&gt;
                        &lt;/h:graphicImage&gt;
                    &lt;/h:panelGrid&gt;
                &lt;/rich:panel&gt;

                &lt;rich:panel id="source"&gt;
                    &lt;f:facet name="header"&gt;
                        &lt;h:outputText value="Arrows"/&gt;
                    &lt;/f:facet&gt;
                    &lt;rich:dataTable id="sourceDataTable" value="#{arrowBean.source}" var="arrow"&gt;
                        &lt;rich:column id="column1"&gt;
                            &lt;a4j:outputPanel id="sourcePanel"&gt;
                                &lt;rich:dragSource id="dragSource1" type="a" dragValue="#{arrow}"/&gt;
                                &lt;h:graphicImage id="graphicImage1" alt="#{arrow.name}" value="#{resource['images:arrow-md.png']}"/&gt;
                                &lt;h:outputText id="outputText1" value="#{arrow.name}"/&gt;
                            &lt;/a4j:outputPanel&gt;
                        &lt;/rich:column&gt;
                    &lt;/rich:dataTable&gt;
                &lt;/rich:panel&gt;
            &lt;/h:panelGrid&gt;

            &lt;h:panelGroup&gt;
                &lt;h:button outcome="index" value="Home"/&gt;
                &lt;a4j:commandButton action="#{arrowBean.reset()}" value="Reset" render="target source"/&gt;
            &lt;/h:panelGroup&gt;
        &lt;/h:form&gt;
    &lt;/h:body&gt;
&lt;/html&gt;
]]&gt;&lt;/script&gt;&lt;img src="http://feeds.feedburner.com/~r/JavaEvangelistJohnYearysBlog/~4/B7B037GeJ4s" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/JavaEvangelistJohnYearysBlog/~3/B7B037GeJ4s/jsf-21-tip-of-day-richfaces-43x-drag.html</link><author>noreply@blogger.com (John Yeary)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/-DHnwjW7Udlw/UVBzTubByEI/AAAAAAAADuE/Og6vIsDWF6k/s72-c/MultipleTargetPanels.png" height="72" width="72" /><thr:total>0</thr:total><gd:extendedProperty name="commentSource" value="1" /><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD" /><feedburner:origLink>http://javaevangelist.blogspot.com/2013/03/jsf-21-tip-of-day-richfaces-43x-drag.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-36773632.post-3830437669534501722</guid><pubDate>Mon, 25 Mar 2013 13:23:00 +0000</pubDate><atom:updated>2013-03-25T08:23:38.506-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">mercurial</category><category domain="http://www.blogger.com/atom/ns#">source control</category><title>Patterns for Scaling Mercurial and Git</title><description>I just finished reading over the Refcard&amp;nbsp;&lt;a href="http://refcardz.dzone.com/refcardz/git-patterns-and-anti-patterns"&gt;Git Patterns and Anti-PatternsScaling from Workgroup to Enterprise&lt;/a&gt; by Luca Milanesio from GerritForge. He has done a great job describing patterns and anti-patterns that don't just apply to Git, but any distributed source control system. The obvious focus of this Refcard is Git, but the patterns are essentially the same sans the commands.&lt;br /&gt;
&lt;br /&gt;
I thought that the card was well done, and is a nice and easy read.&lt;img src="http://feeds.feedburner.com/~r/JavaEvangelistJohnYearysBlog/~4/naJ2gn6TTM0" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/JavaEvangelistJohnYearysBlog/~3/naJ2gn6TTM0/patterns-for-scaling-mercurial-and-git.html</link><author>noreply@blogger.com (John Yeary)</author><thr:total>0</thr:total><gd:extendedProperty name="commentSource" value="1" /><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD" /><feedburner:origLink>http://javaevangelist.blogspot.com/2013/03/patterns-for-scaling-mercurial-and-git.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-36773632.post-974104336438497348</guid><pubDate>Sat, 23 Mar 2013 03:54:00 +0000</pubDate><atom:updated>2013-03-22T22:54:16.548-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">example</category><category domain="http://www.blogger.com/atom/ns#">PrimeFaces</category><category domain="http://www.blogger.com/atom/ns#">JSR-314</category><category domain="http://www.blogger.com/atom/ns#">JavaEE</category><category domain="http://www.blogger.com/atom/ns#">JSF</category><category domain="http://www.blogger.com/atom/ns#">tutorial</category><category domain="http://www.blogger.com/atom/ns#">glassfish</category><category domain="http://www.blogger.com/atom/ns#">Mojarra</category><category domain="http://www.blogger.com/atom/ns#">Netbeans</category><category domain="http://www.blogger.com/atom/ns#">JEE6</category><title>JSF 2.1.x Tip of the Day: Primefaces 3.5 &lt;p:ring/&gt; Drag-N-Drop Example</title><description>&lt;table cellpadding="0" cellspacing="0" class="tr-caption-container" style="float: left; margin-right: 1em; text-align: left;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-aC5ppfXb06U/UU0gfhdzeaI/AAAAAAAADcw/j0qGGTK1yx0/s1600/IMG_0260.JPG" imageanchor="1" style="clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="239" src="http://1.bp.blogspot.com/-aC5ppfXb06U/UU0gfhdzeaI/AAAAAAAADcw/j0qGGTK1yx0/s320/IMG_0260.JPG" width="320" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Camp Old Indian&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
I was trying to come up with an example to demonstrate &lt;code&gt;&amp;lt;p:ring /&amp;gt;&lt;/code&gt; along with Drag-and-Drop (DnD). I had an idea of using a target to drop things on. I was sitting in my living room watching my youngest son creating a world on little big planet, and I remembered his first time shooting a bow. He had a perfect bullseye.&lt;br /&gt;
&lt;br /&gt;
I decided that I would drag-n-drop arrows in honor of my son. I mentioned the idea to him, and he loved it. So here it is... a useful example that was fun to create. In this example, I will demonstrate the &lt;code&gt;&amp;lt;p:ring /&amp;gt;&lt;/code&gt;, and &lt;code&gt;&amp;lt;p:fieldSet /&amp;gt;&lt;/code&gt; components primarily. I have added some effects to a &lt;code&gt;&amp;lt;p:dialog /&amp;gt;&lt;/code&gt; if you select an arrow and dismiss it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h1&gt;
Requirements&lt;/h1&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://primefaces.org/"&gt;PrimeFaces 3.5&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://javaserverfaces.java.net/"&gt;Mojarra 2.1.20&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
I used &lt;a href="http://netbeans.org/"&gt;NetBeans 7.3&lt;/a&gt; to develop the &lt;a href="http://maven.apache.org/"&gt;Apache Maven&lt;/a&gt; based project. The &lt;a href="http://mercurial.selenic.com/"&gt;Mercurial&lt;/a&gt; project can be found on &lt;a href="http://bitbucket.org/"&gt;BitBucket&lt;/a&gt; here: &lt;a href="http://code.bluelotussoftware.com/primefaces-ring-dnd"&gt;primefaces-ring-dnd&lt;/a&gt;.
&lt;br /&gt;
&lt;h1&gt;
Example&lt;/h1&gt;
&lt;h2&gt;
index.xhtml&lt;/h2&gt;
&lt;hr /&gt;
&lt;script class="brush: xhtml" type="syntaxhighlighter"&gt;&lt;![CDATA[
&lt;?xml version='1.0' encoding='UTF-8' ?&gt;
&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
&lt;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:p="http://primefaces.org/ui"&gt;
    &lt;h:head&gt;
        &lt;title&gt;Arrow Panel&lt;/title&gt;
    &lt;/h:head&gt;
    &lt;h:body&gt;
        &lt;h:form id="form1"&gt;

            &lt;p:ring id="arrowRing" var="arrow" value="#{indexBean.arrows}"&gt;
                &lt;p:commandLink id="arrowLink" update=":form1:arrowDetails" oncomplete="arrowDialog.show()"&gt;
                    &lt;p:graphicImage value="#{resource['images:arrow-md.png']}"/&gt;
                    &lt;h:outputText value="#{arrow.name}"/&gt;
                    &lt;f:setPropertyActionListener value="#{arrow}" target="#{indexBean.selectedArrow}" /&gt;
                &lt;/p:commandLink&gt;
                &lt;p:draggable for="arrowLink" helper="clone" /&gt;
            &lt;/p:ring&gt;

            &lt;p:outputPanel id="bullseyePanel" style="width: 100%; margin-left: auto;margin-right: auto;"&gt;
                &lt;p:graphicImage id="bullseye" name="bullseye.jpg" library="images" style="margin-left: auto;margin-right: auto;"/&gt;
                &lt;p:fieldset id="arrowFieldSet" toggleable="true" legend="Fired Arrows" collapsed="true" &gt;
                    &lt;p:panel id="firedArrows"&gt;
                        &lt;p:dataGrid id="firedArrowGrid" value="#{indexBean.firedArrows}" var="arrow" columns="1" 
                                    rendered="#{not empty indexBean.firedArrows}" &gt;
                            &lt;p:column&gt;
                                &lt;p:commandLink id="dp" update=":form1:arrowDetails" oncomplete="arrowDialog.show()" title="View Detail"&gt;
                                    &lt;p:graphicImage value="#{resource['images:arrow-md.png']}"/&gt;
                                    &lt;f:setPropertyActionListener value="#{arrow}" target="#{indexBean.selectedArrow}" /&gt;
                                &lt;/p:commandLink&gt;
                            &lt;/p:column&gt;
                            &lt;p:column headerText="Name"&gt;
                                &lt;h:outputText value="#{arrow.name} - "/&gt;
                            &lt;/p:column&gt;
                            &lt;p:column headerText="Description"&gt;
                                &lt;h:outputText value="#{arrow.description}"/&gt;
                            &lt;/p:column&gt;
                        &lt;/p:dataGrid&gt;
                    &lt;/p:panel&gt;
                &lt;/p:fieldset&gt;
            &lt;/p:outputPanel&gt;

            &lt;p:droppable for="bullseye" tolerance="touch" datasource="arrowRing"&gt;
                &lt;p:ajax listener="#{indexBean.onArrowDrop}" update="arrowRing firedArrows"/&gt;
            &lt;/p:droppable&gt;

            &lt;p:dialog header="Arrow Details" widgetVar="arrowDialog" width="800" height="250" 
                      modal="true" showEffect="fade" hideEffect="explode"&gt;
                &lt;p:outputPanel id="arrowDetails" style="text-align:center;" layout="block"&gt;
                    &lt;p:graphicImage value="#{resource['images:arrow-md.png']}"/&gt;
                    &lt;h:panelGrid  columns="2" cellpadding="5"&gt;
                        &lt;h:outputLabel for="id" value="ID: " /&gt;
                        &lt;h:outputText id="id" value="#{indexBean.selectedArrow.id}" /&gt;
                        &lt;h:outputLabel for="name" value="Name: " /&gt;
                        &lt;h:outputText id="name" value="#{indexBean.selectedArrow.name}" /&gt;
                        &lt;h:outputLabel for="description" value="Description: " /&gt;
                        &lt;h:outputText id="description" value="#{indexBean.selectedArrow.description}" /&gt;
                    &lt;/h:panelGrid&gt;
                &lt;/p:outputPanel&gt;
            &lt;/p:dialog&gt;
        &lt;/h:form&gt;
    &lt;/h:body&gt;
&lt;/html&gt;
]]&gt;&lt;/script&gt;

&lt;br /&gt;
&lt;h2&gt;
IndexBean.java&lt;/h2&gt;
&lt;hr /&gt;
&lt;script class="brush: java" type="syntaxhighlighter"&gt;&lt;![CDATA[
package com.bluelotussoftware.example.jsf;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import org.primefaces.event.DragDropEvent;

/**
 *
 * @author John Yeary
 * @version 1.0
 */
@ManagedBean
@ViewScoped
public class IndexBean implements Serializable {

    private List&lt;arrow&gt; arrows;
    private List&lt;arrow&gt; firedArrows;
    private Arrow selectedArrow;

    public IndexBean() {
        arrows = new ArrayList&lt;arrow&gt;(10);
        firedArrows = new ArrayList&lt;arrow&gt;(10);

        for (long n = 0; n &lt; 10L; n++) {
            arrows.add(new Arrow(n, "Arrow " + n, "I am an Arrow. There are many arrows like me, but I am number #" + n));
        }
    }

    public Arrow getSelectedArrow() {
        return selectedArrow;
    }

    public void setSelectedArrow(Arrow selectedArrow) {
        this.selectedArrow = selectedArrow;
    }

    public List&lt;Arrow&gt; getArrows() {
        return arrows;
    }

    public void setFiredArrows(List&lt;arrow&gt; firedArrows) {
        this.firedArrows = firedArrows;
    }

    public List&lt;arrow&gt; getFiredArrows() {
        return firedArrows;
    }

    public void onArrowDrop(DragDropEvent ddEvent) {
        Arrow arrow = ((Arrow) ddEvent.getData());
        firedArrows.add(arrow);
        arrows.remove(arrow);
    }
}
]]&gt;&lt;/script&gt;

&lt;br /&gt;
&lt;h2&gt;
Arrow.java&lt;/h2&gt;
&lt;hr /&gt;
&lt;script class="brush: java" type="syntaxhighlighter"&gt;&lt;![CDATA[
package com.bluelotussoftware.example.jsf;

import java.io.Serializable;

/**
 *
 * @author John Yeary
 * @version 1.0
 */
public class Arrow implements Cloneable, Serializable {

    private long id;
    private String name;
    private String description;

    public Arrow() {
    }

    public Arrow(long id, String name, String description) {
        this.id = id;
        this.name = name;
        this.description = description;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    protected Arrow clone() throws CloneNotSupportedException {
        return (Arrow) super.clone();
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Arrow other = (Arrow) obj;
        if (this.id != other.id) {
            return false;
        }
        if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 5;
        hash = 83 * hash + (int) (this.id ^ (this.id &gt;&gt;&gt; 32));
        hash = 83 * hash + (this.name != null ? this.name.hashCode() : 0);
        hash = 83 * hash + (this.description != null ? this.description.hashCode() : 0);
        return hash;
    }
}
]]&gt;&lt;/script&gt;

&lt;br /&gt;
&lt;h1&gt;
Conclusion&lt;/h1&gt;
This is a very simple example of what you can do with a Primefaces, Mojarra, and Netbeans.
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-N6mzgouYQqs/UU0mbO13UmI/AAAAAAAADc4/oO0QCzE33gw/s1600/ArrowPanel.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="360" src="http://3.bp.blogspot.com/-N6mzgouYQqs/UU0mbO13UmI/AAAAAAAADc4/oO0QCzE33gw/s640/ArrowPanel.png" width="640" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Arrow Ring and Target&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;img src="http://feeds.feedburner.com/~r/JavaEvangelistJohnYearysBlog/~4/5ZyBr9YMxh8" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/JavaEvangelistJohnYearysBlog/~3/5ZyBr9YMxh8/jsf-21x-tip-of-day-primefaces-35-drag-n.html</link><author>noreply@blogger.com (John Yeary)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/-aC5ppfXb06U/UU0gfhdzeaI/AAAAAAAADcw/j0qGGTK1yx0/s72-c/IMG_0260.JPG" height="72" width="72" /><thr:total>0</thr:total><gd:extendedProperty name="commentSource" value="1" /><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD" /><feedburner:origLink>http://javaevangelist.blogspot.com/2013/03/jsf-21x-tip-of-day-primefaces-35-drag-n.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-36773632.post-8100200528923859720</guid><pubDate>Fri, 22 Mar 2013 13:03:00 +0000</pubDate><atom:updated>2013-03-22T08:03:27.812-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">AD</category><category domain="http://www.blogger.com/atom/ns#">mercurial</category><category domain="http://www.blogger.com/atom/ns#">IIS</category><category domain="http://www.blogger.com/atom/ns#">source control</category><category domain="http://www.blogger.com/atom/ns#">Active Directory</category><title>Installing Mercurial 2.5.2 on IIS 7.5 and Python 2.7 64-bit</title><description>I have been given a great opportunity to move our current source control system from ClearCase to Mercurial. This includes using Active Directory for authentication and authorization. There are a number of great blog posts which helped me along the way. Please see the References at the bottom of the blog. However, I found that none of them were complete, or used older versions of the software.&lt;br /&gt;
&lt;h1&gt;
Prerequisites&lt;/h1&gt;
&lt;ul&gt;
&lt;li&gt;Microsoft Windows 2008 Server R2, or Microsoft Windows 7&lt;br /&gt;
&lt;strong&gt;Note:&lt;/strong&gt; If you are using Active Directory, the server must be a part of the domain.
&lt;/li&gt;
&lt;li&gt;Internet Information Server (IIS) 7.5&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.python.org/ftp/python/2.7.3/python-2.7.3.amd64.msi"&gt;Python 2.7.3 (X86-64)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://mercurial.selenic.com/release/windows/mercurial-2.5.2.win-amd64-py2.7.exe"&gt;Mercurial 2.5.2 (X86-64)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;
Installation Process&lt;/h1&gt;
&lt;h2&gt;
Install Python&lt;/h2&gt;
Download and install &lt;a href="http://www.python.org/ftp/python/2.7.3/python-2.7.3.amd64.msi"&gt;Python 2.7.3 X86-64&lt;/a&gt; using the installer.
&lt;br /&gt;
&lt;h2&gt;
Install Mercurial&lt;/h2&gt;
Download and install &lt;a href="http://mercurial.selenic.com/release/windows/mercurial-2.5.2.win-amd64-py2.7.exe"&gt;Mercurial 2.5.2 (X86-64)&lt;/a&gt; for use with Python 2.7.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Note:&lt;/strong&gt; Do not install &lt;a href="http://bitbucket.org/tortoisehg/files/downloads/tortoisehg-2.7.1-hg-2.5.2-x64.msi"&gt;TortoiseHg&lt;/a&gt;. It is not required, and these directions will not work.
&lt;br /&gt;
&lt;h2&gt;
Install Internet Information Server (IIS)&lt;/h2&gt;
Using the Server Manager on Windows 2008 Server R2, you need to add a role to install IIS. It is not as intuitive as it should be. On other versions of Windows, you would add it as a service.
&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;Add a Server Role.&lt;br /&gt;
&lt;a href="http://2.bp.blogspot.com/-Q_MnYtcLBB8/UUteI0TlQPI/AAAAAAAADQM/4kHdNA7-wUg/s1600/selectRole.png" imageanchor="1"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/-Q_MnYtcLBB8/UUteI0TlQPI/AAAAAAAADQM/4kHdNA7-wUg/s320/selectRole.png" /&gt;&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Select IIS Role.&lt;br /&gt;
&lt;a href="http://4.bp.blogspot.com/-6-DBGCOTMG8/UUteWYPWmRI/AAAAAAAADQU/fZZNfaJgNmk/s1600/IISRole.png" imageanchor="1"&gt;&lt;img border="0" src="http://4.bp.blogspot.com/-6-DBGCOTMG8/UUteWYPWmRI/AAAAAAAADQU/fZZNfaJgNmk/s320/IISRole.png" /&gt;&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Select Role Services.&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;i&gt;Application Development&lt;/i&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;CGI&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;ISAPI Extensions&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;ISAPI Filters&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;i&gt;Security&lt;/i&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Basic Authentication&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Windows Authentication&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Request Filtering&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;a href="http://3.bp.blogspot.com/-KZzvuwsPNWY/UUtgSkRwjrI/AAAAAAAADQc/BoTSxnUBQdw/s1600/IISOptions.png" imageanchor="1"&gt;&lt;img border="0" src="http://3.bp.blogspot.com/-KZzvuwsPNWY/UUtgSkRwjrI/AAAAAAAADQc/BoTSxnUBQdw/s320/IISOptions.png" /&gt;&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Installation Complete&lt;br /&gt;
&lt;a href="http://4.bp.blogspot.com/-8na3l6eV9Lw/UUtgj1-1bVI/AAAAAAAADQk/06E-MK8U0fU/s1600/InstallSuccess.png" imageanchor="1"&gt;&lt;img border="0" src="http://4.bp.blogspot.com/-8na3l6eV9Lw/UUtgj1-1bVI/AAAAAAAADQk/06E-MK8U0fU/s320/InstallSuccess.png" /&gt;&lt;/a&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;
Install and Configure CGI (hgweb.cgi)&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;Clone the mercurial repository, and copy the &lt;strong&gt;hgweb.cgi&lt;/strong&gt; application to located in the project root to &lt;strong&gt;C:\Python27\Lib\site-packages\mercurial\hgweb&lt;/strong&gt;.
&lt;pre&gt;hg clone http://selenic.com/repo/hg
&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;Create a &lt;strong&gt;hgweb.config&lt;/strong&gt; in &lt;strong&gt;C:\Python27\Lib\site-packages\mercurial\hgweb&lt;/strong&gt;. Here is an example file:&lt;br /&gt;
&lt;pre&gt;[web]
encoding = UTF-8
allow_push = *
push_ssl = False
contact = John Yeary
allowzip = True

[paths]
test = C:\repos\test
&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;Modify the &lt;strong&gt;hgweb.cgi&lt;/strong&gt; file to use the new configuration.&lt;br /&gt;
&lt;pre&gt;#!/usr/bin/env python
#
# An example hgweb CGI script, edit as necessary
# See also http://mercurial.selenic.com/wiki/PublishingRepositories

# Path to repo or hgweb config to serve (see 'hg help hgweb')
config = "hgweb.config"


# Uncomment and adjust if Mercurial is not installed system-wide
# (consult "installed modules" path from 'hg debuginstall'):
#import sys; sys.path.insert(0, "/path/to/python/lib")

# Uncomment to send python tracebacks to the browser if an error occurs:
#import cgitb; cgitb.enable()

from mercurial import demandimport; demandimport.enable()
from mercurial.hgweb import hgweb, wsgicgi
application = hgweb(config)
wsgicgi.launch(application)
&lt;/pre&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;
Setup IIS Python CGI Handler&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;Add a Virtual Directory to the Default Web Site&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Alias: &lt;strong&gt;hg&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Physical Path: &lt;strong&gt;C:\Python27\Lib\site-packages\mercurial\hgweb&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;a href="http://1.bp.blogspot.com/-08Qhk4uU4yE/UUtlcT4i4uI/AAAAAAAADQs/3zJ_P7Unl98/s1600/CreateHgVirtualDirectory.png" imageanchor="1"&gt;&lt;img border="0" src="http://1.bp.blogspot.com/-08Qhk4uU4yE/UUtlcT4i4uI/AAAAAAAADQs/3zJ_P7Unl98/s320/CreateHgVirtualDirectory.png" /&gt;&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Select Handler Mapping from the newly created &lt;strong&gt;hg&lt;/strong&gt; virtual directory.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Actions --&amp;gt; Add Script Map&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Set the following parameters:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Request Path: &lt;strong&gt;*.cgi&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Executable: &lt;strong&gt;C:\Python27\python.exe -u "%s"&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Name: &lt;strong&gt;Python&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;a href="http://2.bp.blogspot.com/-wpnOWjS9xnk/UUtnO3UJ_MI/AAAAAAAADQ0/2Id_yNKZG9A/s1600/CGIScript.png" imageanchor="1"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/-wpnOWjS9xnk/UUtnO3UJ_MI/AAAAAAAADQ0/2Id_yNKZG9A/s320/CGIScript.png" /&gt;&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Restart IIS Server&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;
Create Mercurial Test Repository&lt;/h2&gt;
&lt;pre&gt;c:\&amp;gt;mkdir repos

c:\&amp;gt;cd repos

c:\repos&amp;gt;mkdir test

c:\repos&amp;gt;cd test

c:\repos\test&amp;gt;hg init

c:\repos\test&amp;gt;echo "THIS IS A TEST FILE" &amp;gt; README

c:\repos\test&amp;gt;hg add README

c:\repos\test&amp;gt;hg commit -u jyeary -m "Initial Import"

c:\repos\test&amp;gt;hg summary
parent: 0:d5c9f65c740a tip
 Initial Import
branch: default
commit: (clean)
update: (current)
&lt;/pre&gt;
&lt;h2&gt;
Test Configuration&lt;/h2&gt;
Using a browser, go to &lt;a href="http://localhost/hg/hgweb.cgi"&gt;http://localhost/hg/hgweb.cgi&lt;/a&gt;. You should see the following: &lt;br /&gt;
&lt;a href="http://2.bp.blogspot.com/-hd_ZdS-42hs/UUtqeF5Vw1I/AAAAAAAADQ8/7hk1dinPQtg/s1600/TestRepositoryIndex.png" imageanchor="1"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/-hd_ZdS-42hs/UUtqeF5Vw1I/AAAAAAAADQ8/7hk1dinPQtg/s320/TestRepositoryIndex.png" /&gt;&lt;/a&gt;
&lt;br /&gt;
Here is the changeset for the initial import&lt;br /&gt;
&lt;a href="http://1.bp.blogspot.com/-2hxsGLXpz88/UUtqip8eMpI/AAAAAAAADRE/aH_F2bWWieY/s1600/Changeset.png" imageanchor="1"&gt;&lt;img border="0" src="http://1.bp.blogspot.com/-2hxsGLXpz88/UUtqip8eMpI/AAAAAAAADRE/aH_F2bWWieY/s320/Changeset.png" /&gt;&lt;/a&gt;
&lt;br /&gt;
&lt;h2&gt;
URL Rewrite (OPTIONAL)&lt;/h2&gt;
If you want a cleaner URL for users, you will want to "prettify" your URLs. Luckily, Microsoft has a &lt;a href="http://www.iis.net/downloads/microsoft/url-rewrite"&gt;URL Rewrite&lt;/a&gt; plugin for IIS. You will want to install it from the link provided.&lt;br /&gt;
Here is the configuration for our application:
&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;Select URL Rewrite from the &lt;strong&gt;hg&lt;/strong&gt; virtual directory.&lt;/li&gt;
&lt;li&gt;Create a new blank rule.&lt;br /&gt;
&lt;a href="http://2.bp.blogspot.com/-cF4KccKVRsY/UUtsV-pCY5I/AAAAAAAADRM/P44wYhjS6bk/s1600/AddNewRule.png" imageanchor="1"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/-cF4KccKVRsY/UUtsV-pCY5I/AAAAAAAADRM/P44wYhjS6bk/s320/AddNewRule.png" /&gt;&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Create a Rule with the following parameters:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Name: &lt;strong&gt;hgweb.cgi&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Match URL:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Using: &lt;strong&gt;Wildcards&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Pattern: &lt;strong&gt;*&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Conditions&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Add Condition&lt;/li&gt;
&lt;li&gt;Condition Input: &lt;strong&gt;{REQUEST_FILENAME}&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Check if input string: &lt;strong&gt;Is Not A File&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;a href="http://4.bp.blogspot.com/-C6c1DEl0WfU/UUtwRa7bn9I/AAAAAAAADRU/-yC3SzxF99s/s1600/AddCondition.png" imageanchor="1"&gt;&lt;img border="0" src="http://4.bp.blogspot.com/-C6c1DEl0WfU/UUtwRa7bn9I/AAAAAAAADRU/-yC3SzxF99s/s320/AddCondition.png" /&gt;&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Action&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Action Type: &lt;strong&gt;Rewrite&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Rewrite URL: &lt;strong&gt;hgweb.cgi/{R:1}&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;a href="http://1.bp.blogspot.com/-dzVPEEgtS0M/UUtwuOjne8I/AAAAAAAADRc/vM8Eh0fIjDg/s1600/URLRewrite.png" imageanchor="1"&gt;&lt;img border="0" src="http://1.bp.blogspot.com/-dzVPEEgtS0M/UUtwuOjne8I/AAAAAAAADRc/vM8Eh0fIjDg/s320/URLRewrite.png" /&gt;&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Apply Changes&lt;/li&gt;
&lt;li&gt;Modify the &lt;strong&gt;hgweb.config&lt;/strong&gt; and add the baseurl attribute.&lt;br /&gt;
&lt;pre&gt;[web]
encoding = UTF-8
baseurl= /hg
allow_push = *
push_ssl = False
contact = John Yeary
allowzip = True

[paths]
test = C:\repos\test
&lt;/pre&gt;
&lt;/li&gt;
&lt;/ol&gt;
The URL should be much easier now &lt;a href="http://localhost/hg/test/"&gt;http://localhost/hg/test/&lt;/a&gt;
&lt;br /&gt;
&lt;h2&gt;
Basic Authentication (Active Directory&amp;gt; for push (OPTIONAL)&lt;/h2&gt;
The default setup from the &lt;strong&gt;hgweb.config&lt;/strong&gt; allows push from all clients. If we want to add more security, we need to specify authentication, and who is allowed to push.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: red;"&gt;&lt;b&gt;Note:&lt;/b&gt; Basic Authentication passes username and password in clear text. You should use Basic Authentication in conjunction with SSL.&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: red;"&gt;&lt;br /&gt;&lt;/span&gt;
In the default configuration provided, you can push back any changes as shown below.
&lt;br /&gt;
&lt;pre&gt;C:\Users\jyeary\Desktop&amp;gt;hg clone http://localhost/hg/test
destination directory: test
requesting all changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files
updating to branch default
1 files updated, 0 files merged, 0 files removed, 0 files unresolved

C:\Users\jyeary\Desktop&amp;gt;cd test

C:\Users\jyeary\Desktop\test&amp;gt;ls
README

C:\Users\jyeary\Desktop\test&amp;gt;touch FILE1

C:\Users\jyeary\Desktop\test&amp;gt;touch FILE2

C:\Users\jyeary\Desktop\test&amp;gt;hg add FILE1

C:\Users\jyeary\Desktop\test&amp;gt;hg add FILE2

C:\Users\jyeary\Desktop\test&amp;gt;hg commit -u jyeary -m "Added files."

C:\Users\jyeary\Desktop\test&amp;gt;hg push
pushing to http://localhost/hg/test
searching for changes
remote: adding changesets
remote: adding manifests
remote: adding file changes
remote: added 1 changesets with 2 changes to 2 files
&lt;/pre&gt;
We will configure our application and the server to use authentication.

&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;Select the &lt;strong&gt;hg&lt;/strong&gt; virtual directory.&lt;/li&gt;
&lt;li&gt;Select Authentication&lt;br /&gt;
&lt;a href="http://4.bp.blogspot.com/-rJ3APw6gRqY/UUxKbBwqaxI/AAAAAAAADRs/4KPcq9rC4iQ/s1600/AuthenticationSelection.png" imageanchor="1"&gt;&lt;img border="0" src="http://4.bp.blogspot.com/-rJ3APw6gRqY/UUxKbBwqaxI/AAAAAAAADRs/4KPcq9rC4iQ/s320/AuthenticationSelection.png" /&gt;&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Select Basic Authentication and Enable it.&lt;br /&gt;
&lt;a href="http://3.bp.blogspot.com/-tiVGaLYvnRU/UUxKpYGco0I/AAAAAAAADR0/lxdWnLS8MSw/s1600/basicAuthenticationEnable.png" imageanchor="1"&gt;&lt;img border="0" src="http://3.bp.blogspot.com/-tiVGaLYvnRU/UUxKpYGco0I/AAAAAAAADR0/lxdWnLS8MSw/s320/basicAuthenticationEnable.png" /&gt;&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Edit the settings for your Active Directory (AD) domain.&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Domain: &lt;strong&gt;THIS IS YOUR AD DOMAIN&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Realm: You can call this anything that you like, I personally use the domain name.&lt;/li&gt;
&lt;/ul&gt;
&lt;a href="http://4.bp.blogspot.com/-yscXQ0nXpeg/UUxLJyNbhrI/AAAAAAAADR8/wYylWiUaC7Y/s1600/basicAuthenticationSettings.png" imageanchor="1"&gt;&lt;img border="0" src="http://4.bp.blogspot.com/-yscXQ0nXpeg/UUxLJyNbhrI/AAAAAAAADR8/wYylWiUaC7Y/s320/basicAuthenticationSettings.png" /&gt;&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;You have set up the authentication, but it still will allow you to push files as demonstrated below.&lt;br /&gt;
&lt;pre&gt;C:\Users\jyeary\Desktop\test&amp;gt;touch FILE3

C:\Users\jyeary\Desktop\test&amp;gt;hg add FILE3

C:\Users\jyeary\Desktop\test&amp;gt;hg commit -u jyeary -m "Added FILE3"

C:\Users\jyeary\Desktop\test&amp;gt;hg push
pushing to http://localhost/hg/test
searching for changes
remote: adding changesets
remote: adding manifests
remote: adding file changes
remote: added 1 changesets with 1 changes to 1 files
&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt; To enable push to require authentication, we need to modify the &lt;strong&gt;hgweb.config&lt;/strong&gt; file. We will modify &lt;code&gt;allow_push = *&lt;/code&gt;, and set it to allow push from only certain individuals.&lt;br /&gt;
&lt;pre&gt;[web]
encoding = UTF-8
baseurl= /hg
allow_push = jyeary
push_ssl = False
contact = John Yeary
allowzip = True

[paths]
test = C:\repos\test
&lt;/pre&gt;
&lt;br /&gt;
Since we have set push to accept only jyeary, it will ask us to authenticate and shown below.&lt;br /&gt;
&lt;pre&gt;C:\Users\jyeary\Desktop\test&amp;gt;touch FILE4

C:\Users\jyeary\Desktop\test&amp;gt;hg add FILE4

C:\Users\jyeary\Desktop\test&amp;gt;hg commit -u jyeary -m "Added FILE4"

C:\Users\jyeary\Desktop\test&amp;gt;hg push
pushing to http://localhost/hg/test
searching for changes
http authorization required
realm: mydomain.com
user: jyeary
password:
remote: adding changesets
remote: adding manifests
remote: adding file changes
remote: added 1 changesets with 1 changes to 1 files
&lt;/pre&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;Enable SSL (OPTIONAL)&lt;/h2&gt;
I am indicating that this is optional, but if you are using Basic Authentication; it really should be required. This shows how to create a simple self-signed certificate. In a production environment, you will want to have a certificate signed by Certification Authoritity (CA).
&lt;ol&gt;
&lt;li&gt;Select the server, and select Server Certificates.&lt;br/&gt;
&lt;a href="http://2.bp.blogspot.com/-p9jiwEl-fF0/UUxPnwpLOAI/AAAAAAAADSE/s48eB3LnPCc/s1600/serverCertificates.png" imageanchor="1" &gt;&lt;img border="0" src="http://2.bp.blogspot.com/-p9jiwEl-fF0/UUxPnwpLOAI/AAAAAAAADSE/s48eB3LnPCc/s320/serverCertificates.png" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Create a self-signed certificate.&lt;br/&gt;
&lt;a href="http://2.bp.blogspot.com/-0ul3x1KjGPk/UUxPy_xqJWI/AAAAAAAADSM/efMARrZdL1w/s1600/selfSigned.png" imageanchor="1" &gt;&lt;img border="0" src="http://2.bp.blogspot.com/-0ul3x1KjGPk/UUxPy_xqJWI/AAAAAAAADSM/efMARrZdL1w/s320/selfSigned.png" /&gt;&lt;/a&gt;
&lt;br/&gt;
&lt;a href="http://1.bp.blogspot.com/-ZRooVcBoJ3g/UUxP7vqXcXI/AAAAAAAADSU/zDjHheVuxaA/s1600/serverCertificates.png" imageanchor="1" &gt;&lt;img border="0" src="http://1.bp.blogspot.com/-ZRooVcBoJ3g/UUxP7vqXcXI/AAAAAAAADSU/zDjHheVuxaA/s320/serverCertificates.png" /&gt;&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Right-click on the Default Web Site, and select Edit Bindings.&lt;/li&gt;
&lt;li&gt;Select Add a Binding&lt;/li&gt;
&lt;li&gt;Add an SSL binding as follows:&lt;br/&gt;
&lt;ul&gt;
&lt;li&gt;Type: &lt;strong&gt;https&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Port: &lt;strong&gt;443&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;SSL Certificate: &lt;strong&gt;selfSigned&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Modify the &lt;strong&gt;hgweb.config&lt;/strong&gt; file, and remove the &lt;code&gt;push_ssl = False&lt;/code&gt; line.&lt;/li&gt;
&lt;li&gt;Test the new configuration by cloning the secured repository&lt;br/&gt;
&lt;strong&gt;Note:&lt;/strong&gt; Unless you add the certificate fingerprint to your hgrc, you will need to use the &lt;code&gt;--insecure&lt;/code&gt; flag with mercurial.&lt;br/&gt;
&lt;pre&gt;
C:\Users\jyeary\Desktop&gt;hg clone --insecure https://localhost/hg/test
warning: localhost certificate with fingerprint e5:32:64:97:6e:10:43:e5:c7:71:92:9f:08:20:e9:4d:54:d6:c3:04 not verified (check hostfingerprints or web.cacerts config setting)

destination directory: test
requesting all changes
adding changesets
adding manifests
adding file changes
added 4 changesets with 5 changes to 5 files
warning: localhost certificate with fingerprint e5:32:64:97:6e:10:43:e5:c7:71:92:9f:08:20:e9:4d:54:d6:c3:04 not verified (check hostfingerprints or web.cacerts config setting)

updating to branch default
5 files updated, 0 files merged, 0 files removed, 0 files unresolved
&lt;/pre&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
Setting up Mercurial is easy to do in a Windows environment. You will gain all of the great benefits from Mercurial along with active directory. It is much easier to setup Mercurial on IIS for use with Active Directory than on a LAMP stack with winbind, or LDAP. If AD is a requirement... this is definitely the solution.
&lt;h1&gt;
References&lt;/h1&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://mercurial.selenic.com/wiki/HgWebInIisOnWindows"&gt;Configuring HgWeb in IIS on Windows&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.jeremyskinner.co.uk/mercurial-on-iis7/"&gt;Setting up a Mercurial server under IIS7 on Windows Server 2008 R2&lt;/a&gt; - I must give credit here. My post is based primarily off of this really good work.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://vampirebasic.blogspot.com/2009/06/running-mercurial-on-windows.html"&gt;Running Mercurial on Windows&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://mercurial.selenic.com/wiki/CACertificates#Manually_bypassing_security_checks_on_self-signed_certificates"&gt;CA Certificates - 5. Manually bypassing security checks on self-signed certificates&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;img src="http://feeds.feedburner.com/~r/JavaEvangelistJohnYearysBlog/~4/FxygZ9Ikhs4" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/JavaEvangelistJohnYearysBlog/~3/FxygZ9Ikhs4/installing-mercurial-252-on-iis-75-and.html</link><author>noreply@blogger.com (John Yeary)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/-Q_MnYtcLBB8/UUteI0TlQPI/AAAAAAAADQM/4kHdNA7-wUg/s72-c/selectRole.png" height="72" width="72" /><thr:total>0</thr:total><gd:extendedProperty name="commentSource" value="1" /><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD" /><feedburner:origLink>http://javaevangelist.blogspot.com/2013/03/installing-mercurial-252-on-iis-75-and.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-36773632.post-4234305263920149430</guid><pubDate>Thu, 14 Mar 2013 12:36:00 +0000</pubDate><atom:updated>2013-03-14T07:36:09.022-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">example</category><category domain="http://www.blogger.com/atom/ns#">PrimeFaces</category><category domain="http://www.blogger.com/atom/ns#">JSR-314</category><category domain="http://www.blogger.com/atom/ns#">JavaEE</category><category domain="http://www.blogger.com/atom/ns#">JSF</category><category domain="http://www.blogger.com/atom/ns#">tutorial</category><category domain="http://www.blogger.com/atom/ns#">glassfish</category><category domain="http://www.blogger.com/atom/ns#">Netbeans</category><category domain="http://www.blogger.com/atom/ns#">JEE6</category><title>JSF Tip of the Day: PrimeFaces 3.0 Tree Drag and Drop Example</title><description>I worked on a proof of concept for a drag and drop enabled &lt;code&gt;&amp;lt;p:tree /&amp;gt;&lt;/code&gt; for a project I was working on. At the time, &lt;a href="http://primefaces.org/"&gt;PrimeFaces&lt;/a&gt; was just starting the path to 3.0, and I was working with a snapshot. The POC was part of a decision making process on which JSF framework, or combination of frameworks to use.&lt;br /&gt;
&lt;br /&gt;
This drag and drop example was part of the the work &lt;a href="http://blog.primefaces.org/?author=1"&gt;Optimus Prime&lt;/a&gt; and his team created as a potential functionality for the &lt;code&gt;&amp;lt;p:tree /&amp;gt;&lt;/code&gt; component. In the final release, this functionality was removed. I still have high hopes that in &lt;a href="http://primefaces.org/"&gt;PrimeFaces&lt;/a&gt; 3.5.+ that it will be added back into the product. It was a cool idea and one that we had hoped to take advantage of in our products.&lt;br /&gt;
&lt;br /&gt;
If you need this functionality currently, and don't mind using a 3.0-SNAPSHOT release, you can have a drag and drop &lt;code&gt;&amp;lt;p:tree /&amp;gt;&lt;/code&gt;. I published this since it was a good example, and I thought someone might need this specific functionality. Otherwise it is code lost in time.&lt;br /&gt;
&lt;br /&gt;
The &lt;a href="http://mercurial.selenic.com/"&gt;Mercurial&lt;/a&gt; project can be pulled from &lt;a href="http://bitbucket.org/"&gt;BitBucket&lt;/a&gt; and was developed using &lt;a href="http://netbeans.org/"&gt;NetBeans&lt;/a&gt; and Apache &lt;a href="http://maven.apache.org/"&gt;Maven&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
The code can be found here:&amp;nbsp;&lt;a href="http://code.bluelotussoftware.com/primefaces-tree-dragdrop-demo"&gt;primefaces-tree-dragdrop-demo&lt;/a&gt;&lt;br /&gt;
&lt;h2&gt;
Example&lt;/h2&gt;
&lt;hr /&gt;
&lt;script class="brush: xhtml" type="syntaxhighlighter"&gt;&lt;![CDATA[
&lt;?xml version='1.0' encoding='UTF-8' ?&gt;
&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.prime.com.tr/ui"&gt;
    &lt;h:head&gt;
        &lt;title&gt;PrimeFaces Tree&lt;/title&gt;
    &lt;/h:head&gt;
    &lt;h:body&gt;
        &lt;h:form id="form1"&gt;
            &lt;p:growl id="messages" showDetail="true"/&gt;
            &lt;p:tree value="#{treeBean.model}"
                    var="node"
                    selectionMode="single"
                    selection="#{treeBean.selectedNode}"
                    update="form1:messages"
                    nodeSelectListener="#{treeBean.onNodeSelect}"
                    dragdrop="true"&gt;
                &lt;p:treeNode type="node"&gt;
                    &lt;h:outputText value="#{node}"/&gt;
                &lt;/p:treeNode&gt;
                &lt;p:treeNode type="leaf"&gt;
                    &lt;h:outputText value="#{node}" /&gt;
                &lt;/p:treeNode&gt;
            &lt;/p:tree&gt;
        &lt;/h:form&gt;
    &lt;/h:body&gt;
&lt;/html&gt;
]]&gt;&lt;/script&gt;

&lt;br /&gt;
&lt;hr /&gt;
&lt;script class="brush: java" type="syntaxhighlighter"&gt;&lt;![CDATA[
/*
 * Copyright 2010-2013 Blue Lotus Software, LLC.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.bluelotussoftware.example.jsf;

import org.primefaces.model.DefaultTreeNode;
import org.primefaces.model.TreeNode;

/**
 *
 * @author John Yeary 
 * @version 1.0
 */
public class TreeNodeImpl extends DefaultTreeNode {

    private static final long serialVersionUID = 5333810777428638968L;

    public TreeNodeImpl(String type, Object data, TreeNode parent) {
        super(type, data, parent);
    }

    public TreeNodeImpl(Object data, TreeNode parent) {
        super(data, parent);
    }

    @Override
    public String getType() {
        if (isLeaf()) {
            return "leaf";
        } else {
            return "node";
        }
    }
}
]]&gt;&lt;/script&gt;

&lt;hr /&gt;
&lt;script class="brush: java" type="syntaxhighlighter"&gt;&lt;![CDATA[
/*
 * Copyright 2010-2013 Blue Lotus Software, LLC.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.bluelotussoftware.example.jsf;

import java.io.Serializable;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import org.primefaces.event.DragDropEvent;
import org.primefaces.event.NodeSelectEvent;
import org.primefaces.model.TreeNode;

/**
 *
 * @author John Yeary
 * @version 1.0
 */
@ManagedBean
@SessionScoped
public class TreeBean implements Serializable {

    private static final long serialVersionUID = 2417620239014385855L;
    private TreeNode root;
    private TreeNode selectedNode;

    public TreeBean() {
        root = new TreeNodeImpl("Root", null);
        TreeNode node0 = new TreeNodeImpl("Segment 0", root);
        TreeNode node1 = new TreeNodeImpl("Segment 1", root);
        TreeNode node2 = new TreeNodeImpl("Segment 2", root);
        TreeNode node00 = new TreeNodeImpl("Segment 0.0", node0);
        TreeNode node01 = new TreeNodeImpl("Segment 0.1", node0);
        TreeNode node10 = new TreeNodeImpl("Segment 1.0", node1);
        TreeNode node11 = new TreeNodeImpl("Segment 1.1", node1);
        TreeNode node000 = new TreeNodeImpl("Segment 0.0.0", node00);
        TreeNode node001 = new TreeNodeImpl("Segment 0.0.1", node00);
        TreeNode node010 = new TreeNodeImpl("Segment 0.1.0", node01);
        TreeNode node100 = new TreeNodeImpl("Segment 1.0.0", node10);
    }

    public TreeNode getModel() {
        return root;
    }

    public TreeNode getSelectedNode() {
        return selectedNode;
    }

    public void setSelectedNode(TreeNode selectedNode) {
        this.selectedNode = selectedNode;
    }

    public void onNodeSelect(NodeSelectEvent event) {
        FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "Selected", event.getTreeNode().getData().toString());
        FacesContext.getCurrentInstance().addMessage("node", msg);
    }

    public void onDragDrop(DragDropEvent event) {
        TreeNode node = (TreeNode) event.getData();
        FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_INFO, "DragDrop", node + " moved to " + node.getParent());
        FacesContext.getCurrentInstance().addMessage(null, message);
    }
}
]]&gt;&lt;/script&gt;&lt;img src="http://feeds.feedburner.com/~r/JavaEvangelistJohnYearysBlog/~4/e-EiBEy6E04" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/JavaEvangelistJohnYearysBlog/~3/e-EiBEy6E04/jsf-tip-of-day-primefaces-30-tree-drag.html</link><author>noreply@blogger.com (John Yeary)</author><thr:total>8</thr:total><gd:extendedProperty name="commentSource" value="1" /><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD" /><feedburner:origLink>http://javaevangelist.blogspot.com/2013/03/jsf-tip-of-day-primefaces-30-tree-drag.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-36773632.post-4271746311155023951</guid><pubDate>Tue, 12 Mar 2013 00:09:00 +0000</pubDate><atom:updated>2013-03-12T07:49:55.737-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">example</category><category domain="http://www.blogger.com/atom/ns#">JSR-314</category><category domain="http://www.blogger.com/atom/ns#">JavaEE</category><category domain="http://www.blogger.com/atom/ns#">JSF</category><category domain="http://www.blogger.com/atom/ns#">tutorial</category><category domain="http://www.blogger.com/atom/ns#">glassfish</category><category domain="http://www.blogger.com/atom/ns#">Mojarra</category><category domain="http://www.blogger.com/atom/ns#">Netbeans</category><category domain="http://www.blogger.com/atom/ns#">JEE6</category><title>JSF 2.x Tip of the Day: What is &lt;h:link  /&gt; and Why Do I Care?</title><description>One of the JSF Components that is new in JSF 2.1 is the &lt;code&gt;&amp;lt;h:link /&amp;gt;&lt;/code&gt; component. This&amp;nbsp;component&amp;nbsp;represents an HTML &lt;code&gt;&amp;lt;a /&amp;gt;&lt;/code&gt; (anchor) tag. In most cases, I would actually recommend using an &lt;code&gt;&amp;lt;a /&amp;gt;&lt;/code&gt; tag over this component. The anchor tag can use Expression Language (EL) which is what most people are after. The &lt;code&gt;&amp;lt;h:link /&amp;gt;&lt;/code&gt; is more overkill than most people need. However, there are a couple of cases where the &lt;code&gt;&amp;lt;h:link /&amp;gt;&lt;/code&gt; really does shine.&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;&lt;code&gt;disabled="true"&lt;/code&gt; attribute renders a &lt;code&gt;&amp;lt;span /&amp;gt;&lt;/code&gt; that can serve as a space holder.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;rendered&lt;/code&gt; attribute can be programmatically controlled using EL, or via binding of the component. You don't need to use JS, or a JS Framework like jquery to hide it. It simply does not render.&lt;/li&gt;
&lt;li&gt;The component can be programatically created using a binding &lt;code&gt;&amp;lt;h:link binding="#{bean.link}" /&amp;gt;&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Built-in support for JSF navigation using the &lt;code&gt;outcome&lt;/code&gt; attribute.&lt;/li&gt;
&lt;li&gt;Supports passing JSF ViewParameters through the use of the &lt;code&gt;includeviewParams&lt;/code&gt; attribute.&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
The real significant disadvantage is that you can't use it like a normal anchor tag and direct the &lt;code&gt;href&lt;/code&gt; to another site without some tricks. In that case you are better off using a &lt;code&gt;&amp;lt;h:commandLink/&amp;gt;&lt;/code&gt; or a plain &lt;code&gt;&amp;lt;a/&amp;gt;&lt;/code&gt; tag.
&lt;br /&gt;
&lt;h2&gt;
References&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/HTML/Element/a"&gt;HTML Anchor Element&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://javaserverfaces.java.net/nonav/docs/2.1/vdldocs/facelets/h/link.html"&gt;JSF 2.1 &amp;lt;h:link /&amp;gt; VDL&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
Examples&lt;/h2&gt;
&lt;hr /&gt;
&lt;script class="brush: xhtml" type="syntaxhighlighter"&gt;&lt;![CDATA[
&lt;?xml version='1.0' encoding='UTF-8' ?&gt;
&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"&gt;
    &lt;f:metadata&gt;
        &lt;f:viewParam name="color" value="color:blue;"/&gt;
    &lt;/f:metadata&gt;
    &lt;h:outputStylesheet name="default.css" library="css"/&gt;
    &lt;h:head&gt;
        &lt;title&gt;Index&lt;/title&gt;
    &lt;/h:head&gt;
    &lt;h:body&gt;
        &lt;a class="formatted" href="faces/other.xhtml"&gt;Other&lt;/a&gt;
        &lt;br/&gt;
        &lt;h:link disabled="true" value="X" styleClass="formatted" 
                outcome="other"/&gt;
        &lt;br/&gt;
        &lt;h:link rendered="false" value="Y" outcome="other"/&gt;
        &lt;br/&gt;
        &lt;h:link value="Press CTRL+ALT+M" accesskey="M" outcome="#{indexBean.requestURL}" 
                styleClass="formatted"/&gt;
        &lt;br/&gt;
        &lt;h:link value="Z" outcome="other" /&gt;
        &lt;br/&gt;
        &lt;h:link accesskey="E" outcome="other" includeViewParams="true"/&gt;
    &lt;/h:body&gt;
&lt;/html&gt;
]]&gt;&lt;/script&gt;
&lt;h2&gt;Project Files&lt;/h2&gt;
&lt;hr/&gt;
Here is the &lt;a href="http://netbeans.org/"&gt;NetBeans 7.3&lt;/a&gt; &lt;a href="http://maven.apache.org/"&gt;Maven&lt;/a&gt; Project: &lt;a href="http://code.bluelotussoftware.com/jsf-link-example"&gt;jsf-link-example&lt;/a&gt;&lt;img src="http://feeds.feedburner.com/~r/JavaEvangelistJohnYearysBlog/~4/ugPrVlp7V28" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/JavaEvangelistJohnYearysBlog/~3/ugPrVlp7V28/jsf-2x-tip-of-day-what-is-and-why-do-i.html</link><author>noreply@blogger.com (John Yeary)</author><thr:total>0</thr:total><gd:extendedProperty name="commentSource" value="1" /><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD" /><feedburner:origLink>http://javaevangelist.blogspot.com/2013/03/jsf-2x-tip-of-day-what-is-and-why-do-i.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-36773632.post-230260432283164783</guid><pubDate>Mon, 11 Mar 2013 17:04:00 +0000</pubDate><atom:updated>2013-03-11T12:04:53.956-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">example</category><category domain="http://www.blogger.com/atom/ns#">JDK6</category><category domain="http://www.blogger.com/atom/ns#">JSE6</category><title>Java 6 File Monitoring Example</title><description>&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://www.hightech-edge.com/wp-content/uploads/cctv-security-surveillance-camera.jpg" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="200" src="http://www.hightech-edge.com/wp-content/uploads/cctv-security-surveillance-camera.jpg" width="200" /&gt;&lt;/a&gt;&lt;/div&gt;
I was asked today how you would monitor a file for changes using Java 6. Since Java 7 has added some great &lt;code&gt;File&lt;/code&gt; handling features that I use, it was a reminder that not everyone is so lucky to use Java 7. I remembered an example from Geosoft (I remembered it because I liked the name). I went looking and I found their example code &lt;a href="http://geosoft.no/software/filemonitor/FileMonitor.java.html"&gt;FileMonitor.java&lt;/a&gt;. It is a simple and elegant solution to monitoring files and directories for changes.&lt;br /&gt;
&lt;br /&gt;
This is by no means a complete example, but does show a simple technique.&lt;img src="http://feeds.feedburner.com/~r/JavaEvangelistJohnYearysBlog/~4/9b2HdtOUZ1g" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/JavaEvangelistJohnYearysBlog/~3/9b2HdtOUZ1g/java-6-file-monitoring-example.html</link><author>noreply@blogger.com (John Yeary)</author><thr:total>2</thr:total><gd:extendedProperty name="commentSource" value="1" /><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD" /><feedburner:origLink>http://javaevangelist.blogspot.com/2013/03/java-6-file-monitoring-example.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-36773632.post-8415470402322539367</guid><pubDate>Fri, 01 Feb 2013 21:08:00 +0000</pubDate><atom:updated>2013-02-01T16:08:16.640-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">JSR-314</category><category domain="http://www.blogger.com/atom/ns#">JavaEE</category><category domain="http://www.blogger.com/atom/ns#">JSF</category><category domain="http://www.blogger.com/atom/ns#">tutorial</category><category domain="http://www.blogger.com/atom/ns#">glassfish</category><category domain="http://www.blogger.com/atom/ns#">Mojarra</category><category domain="http://www.blogger.com/atom/ns#">Netbeans</category><category domain="http://www.blogger.com/atom/ns#">JEE6</category><title>JSF 2.x Tip of the Day: Great Blog Posts Explaining JSTL vs. JSF</title><description>The question comes up quite frequently on various forums, stackoverflow, etc. on JSTL and JSF. I don't want to beat a dead horse so I will leave it to the authors of these posts to explain the differences.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href="http://www.znetdevelopment.com/blogs/2008/10/18/jstl-with-jsffacelets/"&gt;JSTL with JSF/Facelets&lt;/a&gt;&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.ninthavenue.com.au/blog/c:foreach-vs-ui:repeat-in-facelets"&gt;c:forEach vs ui:repeat in Facelets&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://stackoverflow.com/a/5246655/160361"&gt;Finding n-th component nested in a4j:repeat tag in JSF tree&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

If you have any other good posts, please let me know and I will aggregate them here.&lt;img src="http://feeds.feedburner.com/~r/JavaEvangelistJohnYearysBlog/~4/eFv3aEMUTn4" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/JavaEvangelistJohnYearysBlog/~3/eFv3aEMUTn4/jsf-2x-tip-of-day-great-blog-posts.html</link><author>noreply@blogger.com (John Yeary)</author><thr:total>0</thr:total><gd:extendedProperty name="commentSource" value="1" /><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD" /><feedburner:origLink>http://javaevangelist.blogspot.com/2013/02/jsf-2x-tip-of-day-great-blog-posts.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-36773632.post-6950932733004065457</guid><pubDate>Thu, 24 Jan 2013 15:55:00 +0000</pubDate><atom:updated>2013-01-24T10:55:08.852-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">example</category><category domain="http://www.blogger.com/atom/ns#">JSR-314</category><category domain="http://www.blogger.com/atom/ns#">JavaEE</category><category domain="http://www.blogger.com/atom/ns#">JSF</category><category domain="http://www.blogger.com/atom/ns#">tutorial</category><category domain="http://www.blogger.com/atom/ns#">glassfish</category><category domain="http://www.blogger.com/atom/ns#">Mojarra</category><category domain="http://www.blogger.com/atom/ns#">Netbeans</category><category domain="http://www.blogger.com/atom/ns#">JEE6</category><title>JSF 2.x Tip of the Day: AJAX Redirection from @WebFilter (Filter)</title><description>I was working on an application where I needed to have it redirect to a login page when certain conditions exist in the application, e.g. session timeout, etc. A &lt;code&gt;ViewExpiredException&lt;/code&gt; custom exception handler (available in JSF 2.0) can handle this case, but I had a need for another type of "Session" object to be monitored to determine if I should redirect based on its status. The other object was stored in the &lt;code&gt;HttpSession&lt;/code&gt; object as an attribute so I decided to handle it with a &lt;code&gt;Filter&lt;/code&gt; (&lt;code&gt;@WebFilter&lt;/code&gt;).&lt;br /&gt;
&lt;br /&gt;
The first thing is to determine if the request is a &lt;code&gt;partial/ajax&lt;/code&gt; request. If it is a normal post, we can handle it with a &lt;code&gt;HttpResponse.sendRedirect(String location)&lt;/code&gt; mechanism. If it is AJAX, we need to handle it in a completely different manner.

&lt;script class="brush: java" type="syntaxhighlighter"&gt;&lt;![CDATA[
    private boolean isAJAXRequest(HttpServletRequest request) {
        boolean check = false;
        String facesRequest = request.getHeader("Faces-Request");
        if (facesRequest != null &amp;&amp; facesRequest.equals("partial/ajax")) {
            check = true;
        }
        return check;
    }
]]&gt;&lt;/script&gt;

Once I determined that the request was AJAX, I needed to be able to pass the appropriate response back to the JSF page in a format that it could understand. A great tip came from Jim Driscoll's blog: &lt;a href="http://weblogs.java.net/blog/driscoll/archive/2009/05/redirecting_fro.html"&gt;Redirecting from a JSF 2.0 Ajax Request&lt;/a&gt; which gave me the general syntax for what I needed to send back. 
&lt;br/&gt;&lt;br/&gt;&lt;strong&gt;Note:&lt;/strong&gt; This is being intercepted in a Filter so I don't have access to the FacesContext.

Here is a partial code snippet of how to send the redirect. You would need to set the variable &lt;code&gt;TARGET&lt;/code&gt; to go to the desired location.

&lt;script class="brush: java" type="syntaxhighlighter"&gt;&lt;![CDATA[
            String redirectURL = response.encodeRedirectURL(request.getContextPath() + TARGET);

            if (isAJAXRequest(request)) {
                StringBuilder sb = new StringBuilder();
                sb.append("&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;&lt;partial-response&gt;&lt;redirect url=\"").append(redirectURL).append("\"&gt;&lt;/redirect&gt;&lt;/partial-response&gt;");
                response.setHeader("Cache-Control", "no-cache");
                response.setCharacterEncoding("UTF-8");
                response.setContentType("text/xml");
                PrintWriter pw = response.getWriter();
                pw.println(sb.toString());
                pw.flush();
            }
]]&gt;&lt;/script&gt;&lt;img src="http://feeds.feedburner.com/~r/JavaEvangelistJohnYearysBlog/~4/cnBMEdkjkq0" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/JavaEvangelistJohnYearysBlog/~3/cnBMEdkjkq0/jsf-2x-tip-of-day-ajax-redirection-from.html</link><author>noreply@blogger.com (John Yeary)</author><thr:total>2</thr:total><gd:extendedProperty name="commentSource" value="1" /><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD" /><feedburner:origLink>http://javaevangelist.blogspot.com/2013/01/jsf-2x-tip-of-day-ajax-redirection-from.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-36773632.post-3525165157577517695</guid><pubDate>Mon, 14 Jan 2013 18:53:00 +0000</pubDate><atom:updated>2013-01-14T13:53:36.670-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">example</category><category domain="http://www.blogger.com/atom/ns#">JDK7</category><category domain="http://www.blogger.com/atom/ns#">tutorial</category><category domain="http://www.blogger.com/atom/ns#">glassfish</category><category domain="http://www.blogger.com/atom/ns#">Netbeans</category><title>GlassFish 3 Tip of the Day: Using JDK 7 with JSP Code</title><description>A question came up on the&lt;a href="http://netbeans.org/"&gt; NetBeans&lt;/a&gt; J2EE Mailing List about using JDK 7 with GlassFish 3.1.2. Specifically, they were getting the error:&lt;br /&gt;
&lt;blockquote class="tr_bq"&gt;
&lt;span style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 13px;"&gt;org.apache.jasper.&lt;/span&gt;&lt;u style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 13px;"&gt;&lt;/u&gt;&lt;span style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 13px;"&gt;JasperExcept&lt;/span&gt;&lt;wbr style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 13px;"&gt;&lt;/wbr&gt;&lt;span style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 13px;"&gt;ion: PWC6033: Error in Javac compilation for JSP&lt;/span&gt;&lt;br /&gt;
&lt;span style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 13px;"&gt;PWC6197: An error occurred at line: 4 in the jsp file: /index.jsp&lt;/span&gt;&lt;span style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 13px;"&gt;PWC6199: Generated servlet error:&lt;/span&gt;&lt;span style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 13px;"&gt;strings in switch are not supported in -source 1.5&lt;/span&gt;&lt;span style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 13px;"&gt;&amp;nbsp; (use -source 7 or higher to enable strings in switch)&lt;/span&gt;&lt;/blockquote&gt;
&lt;br /&gt;
The fix is quite simple. You must include a &lt;code&gt;glassfish-web.xml&lt;/code&gt; file in your project, and set a couple of properties. &lt;code&gt;compilerSourceVM&lt;/code&gt; and &lt;code&gt;compilerTargetVM&lt;/code&gt;.&lt;br /&gt;
&lt;br /&gt;
Please see the example below for a complete configuration.

&lt;script class="brush: xml" type="syntaxhighlighter"&gt;&lt;![CDATA[
&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd"&gt;
&lt;glassfish-web-app error-url=""&gt;
  &lt;class-loader delegate="true"/&gt;
  &lt;jsp-config&gt;
    &lt;property name="keepgenerated" value="true"&gt;
      &lt;description&gt;Keep a copy of the generated servlet class' java code.&lt;/description&gt;
    &lt;/property&gt;
    &lt;property name="compilerSourceVM" value="7"/&gt;
    &lt;property name="compilerTargetVM" value="7"/&gt;
  &lt;/jsp-config&gt;
&lt;/glassfish-web-app&gt;
]]&gt;&lt;/script&gt;
&lt;br /&gt;
The project will now compile and use JDK7.&lt;img src="http://feeds.feedburner.com/~r/JavaEvangelistJohnYearysBlog/~4/KobHhwsQlOE" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/JavaEvangelistJohnYearysBlog/~3/KobHhwsQlOE/glassfish-3-tip-of-day-using-jdk-7-with.html</link><author>noreply@blogger.com (John Yeary)</author><thr:total>1</thr:total><gd:extendedProperty name="commentSource" value="1" /><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD" /><feedburner:origLink>http://javaevangelist.blogspot.com/2013/01/glassfish-3-tip-of-day-using-jdk-7-with.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-36773632.post-4105317741907742293</guid><pubDate>Fri, 11 Jan 2013 11:00:00 +0000</pubDate><atom:updated>2013-01-11T06:00:03.913-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">example</category><category domain="http://www.blogger.com/atom/ns#">JSR-314</category><category domain="http://www.blogger.com/atom/ns#">JavaEE</category><category domain="http://www.blogger.com/atom/ns#">JSF</category><category domain="http://www.blogger.com/atom/ns#">tutorial</category><category domain="http://www.blogger.com/atom/ns#">RichFaces</category><category domain="http://www.blogger.com/atom/ns#">Netbeans</category><category domain="http://www.blogger.com/atom/ns#">JEE6</category><title>JSF 2.x Tip of the Day: RichFaces Table Sorting (3-position switch design)</title><description>A technique I like to call the three position switch is what I use for sorting on my RichFaces tables. This consists of default (unsorted), ascending, and descending. It is implemented very easily by setting the &lt;code&gt;&amp;lt;rich:column/&amp;gt;&lt;/code&gt; sortOrder attribute to point to our current sort, and using an &lt;code&gt;&amp;lt;a4j:commandLink&amp;gt;&lt;/code&gt; in the header facet to control the sort as shown in the example below. This simple technique makes sorting simple and sexy.
&lt;h2&gt;code&lt;/h2&gt;
&lt;script type="syntaxhighlighter" class="brush: xhtml"&gt;&lt;![CDATA[
                &lt;rich:column sortBy="#{customer.name}" sortOrder="#{complexDataTable.sorting}"&gt;
                    &lt;f:facet name="header"&gt;
                        &lt;a4j:commandLink render="dataTable" value="#{complexDataTable.customerColumnHeader}" action="#{complexDataTable.sort()}"/&gt;
                    &lt;/f:facet&gt;
                    &lt;h:outputText value="#{customer.name}"/&gt;
                &lt;/rich:column&gt;
]]&gt;&lt;/script&gt;
&lt;br/&gt;
&lt;script type="syntaxhighlighter" class="brush: java"&gt;&lt;![CDATA[
    private SortOrder sorting = SortOrder.unsorted;

    public SortOrder getSorting() {
        return sorting;
    }

    public void setSorting(SortOrder sorting) {
        this.sorting = sorting;
    }

    public void sort() {
        switch (sorting) {
            case unsorted: {
                sorting = SortOrder.ascending;
                break;
            }
            case ascending: {
                sorting = SortOrder.descending;
                break;
            }
            case descending: {
                sorting = SortOrder.unsorted;
                break;
            }
        }
    }
]]&gt;&lt;/script&gt;
&lt;br/&gt;
This additional code will let the user know which sorting direction we are currently using.
&lt;br/&gt;
&lt;script type="syntaxhighlighter" class="brush: java"&gt;&lt;![CDATA[
    public String getCustomerColumnHeader() {
        switch (sorting) {
            case unsorted: {
                return "Customer Name";
            }
            default: {
                return "Customer Name (" + sorting + ")";
            }
        }
    }
]]&gt;&lt;/script&gt;&lt;img src="http://feeds.feedburner.com/~r/JavaEvangelistJohnYearysBlog/~4/VFl1Hkj1V3w" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/JavaEvangelistJohnYearysBlog/~3/VFl1Hkj1V3w/jsf-2x-tip-of-day-richfaces-table.html</link><author>noreply@blogger.com (John Yeary)</author><thr:total>3</thr:total><gd:extendedProperty name="commentSource" value="1" /><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD" /><feedburner:origLink>http://javaevangelist.blogspot.com/2013/01/jsf-2x-tip-of-day-richfaces-table.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-36773632.post-4858999068680520747</guid><pubDate>Fri, 11 Jan 2013 08:00:00 +0000</pubDate><atom:updated>2013-01-11T03:00:12.250-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">example</category><category domain="http://www.blogger.com/atom/ns#">JSR-314</category><category domain="http://www.blogger.com/atom/ns#">JavaEE</category><category domain="http://www.blogger.com/atom/ns#">JSF</category><category domain="http://www.blogger.com/atom/ns#">tutorial</category><category domain="http://www.blogger.com/atom/ns#">glassfish</category><category domain="http://www.blogger.com/atom/ns#">Mojarra</category><category domain="http://www.blogger.com/atom/ns#">Netbeans</category><category domain="http://www.blogger.com/atom/ns#">JEE6</category><title>JSF 2.x Tip of the Day: Programmatically Creating a &lt;h:outputText/&gt;</title><description>&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://2008.igem.org/wiki/images/d/db/Pictogram_output.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="198" src="http://2008.igem.org/wiki/images/d/db/Pictogram_output.png" width="200" /&gt;&lt;/a&gt;&lt;/div&gt;
In this tip of the day we create one of the most basic components in our JSF arsenal: &lt;code&gt;&amp;lt;h:outputText&amp;gt;&lt;/code&gt;.
&lt;br /&gt;
This example uses another library called &lt;a href="http://code.bluelotussoftware.com/jsf-utils"&gt;jsf-utils&lt;/a&gt; to handle the heavy lifting.

&lt;script class="brush: java" type="syntaxhighlighter"&gt;&lt;![CDATA[
    public HtmlOutputText createHtmlOutputText(final FacesContext context, final String valueValueExpression, Class&lt;?&gt; valueType) {
        HtmlOutputText text = (HtmlOutputText) context.getApplication().createComponent(HtmlOutputText.COMPONENT_TYPE);
        text.setValueExpression("value", JSFUtils.createValueExpression(valueValueExpression, valueType));
        return text;
    }
]]&gt;&lt;/script&gt;&lt;img src="http://feeds.feedburner.com/~r/JavaEvangelistJohnYearysBlog/~4/-9zyzDs2Lik" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/JavaEvangelistJohnYearysBlog/~3/-9zyzDs2Lik/jsf-2x-tip-of-day-programmatically.html</link><author>noreply@blogger.com (John Yeary)</author><thr:total>0</thr:total><gd:extendedProperty name="commentSource" value="1" /><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD" /><feedburner:origLink>http://javaevangelist.blogspot.com/2013/01/jsf-2x-tip-of-day-programmatically.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-36773632.post-4973998074790631714</guid><pubDate>Fri, 11 Jan 2013 05:00:00 +0000</pubDate><atom:updated>2013-01-11T00:00:12.284-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">example</category><category domain="http://www.blogger.com/atom/ns#">JSR-314</category><category domain="http://www.blogger.com/atom/ns#">JavaEE</category><category domain="http://www.blogger.com/atom/ns#">JSF</category><category domain="http://www.blogger.com/atom/ns#">tutorial</category><category domain="http://www.blogger.com/atom/ns#">RichFaces</category><category domain="http://www.blogger.com/atom/ns#">Netbeans</category><category domain="http://www.blogger.com/atom/ns#">JEE6</category><title>JSF 2.x Tip of the Day: RichFaces Programmatically Creating an &lt;a4j:commandLink/&gt;</title><description>This example of how to create an &lt;code&gt;&amp;lt;a4j:commandLink/&amp;gt;&lt;/code&gt; uses another library called &lt;a href="http://code.bluelotussoftware.com/jsf-utils"&gt;jsf-utils&lt;/a&gt; to handle the heavy lifting.
&lt;br/&gt;&lt;br/&gt;
The method below will create the &lt;code&gt;&amp;lt;a4j:commandLink/&amp;gt;&lt;/code&gt; component, any additional configuration will need to be performed programmatically, or using the tag attributes.
&lt;br/&gt;&lt;br/&gt;
&lt;script type="syntaxhighlighter" class="brush: java"&gt;&lt;![CDATA[
    public UICommandLink createUICommandLink(final FacesContext context, final String value, final String render, final String methodExpression) {
        Class&lt;?&gt;[] clazz = new Class&lt;?&gt;[]{};
        UICommandLink link = (UICommandLink) context.getApplication().createComponent(UICommandLink.COMPONENT_TYPE);
        link.setValue(value);
        link.setRender(render);
        link.setActionExpression(JSFUtils.createMethodExpression(methodExpression, String.class, clazz));
        return link;
    }
]]&gt;&lt;/script&gt;

You would bind it to a backing bean to a &lt;code&gt;UICommandLink&lt;/code&gt; component;
&lt;script type="syntaxhighlighter" class="brush: xhtml"&gt;&lt;![CDATA[
&lt;a4j:commandLink binding="#{indexBean.commandLink1}"/&gt;
]]&gt;&lt;/script&gt;&lt;img src="http://feeds.feedburner.com/~r/JavaEvangelistJohnYearysBlog/~4/SOl2XJ-DGvA" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/JavaEvangelistJohnYearysBlog/~3/SOl2XJ-DGvA/jsf-2x-tip-of-day-richfaces.html</link><author>noreply@blogger.com (John Yeary)</author><thr:total>0</thr:total><gd:extendedProperty name="commentSource" value="1" /><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD" /><feedburner:origLink>http://javaevangelist.blogspot.com/2013/01/jsf-2x-tip-of-day-richfaces.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-36773632.post-807004891150487265</guid><pubDate>Thu, 10 Jan 2013 19:32:00 +0000</pubDate><atom:updated>2013-01-10T18:34:59.237-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">example</category><category domain="http://www.blogger.com/atom/ns#">JSR-314</category><category domain="http://www.blogger.com/atom/ns#">JavaEE</category><category domain="http://www.blogger.com/atom/ns#">JSF</category><category domain="http://www.blogger.com/atom/ns#">tutorial</category><category domain="http://www.blogger.com/atom/ns#">glassfish</category><category domain="http://www.blogger.com/atom/ns#">Mojarra</category><category domain="http://www.blogger.com/atom/ns#">Netbeans</category><category domain="http://www.blogger.com/atom/ns#">JEE6</category><title>JSF 2.x Tip of the Day: Determining the Base URL</title><description>This question has come up a couple of times in the last few days, so I thought I would write a couple of convenience methods to determine the Base URL.
&lt;br/&gt;
&lt;br/&gt;
I added them to my &lt;a href="http://code.bluelotussoftware.com/jsf-utils/"&gt;jsf-utils&lt;/a&gt; project for those who want to use my utilities.
&lt;br/&gt;
&lt;br/&gt;
&lt;script type="syntaxhighlighter" class="brush: java"&gt;&lt;![CDATA[
    /**
     * &lt;p&gt;Determines the Base URL, e.g.,
     * {@literal http://localhost:8080/myApplication} from the
     * {@link FacesContext}.&lt;/p&gt;
     *
     * @param facesContext The {@link FacesContext} to examine.
     * @return the base URL.
     * @throws MalformedURLException if an exception occurs during parsing of
     * the URL.
     * @since 1.3
     */
    public String getBaseURL(final FacesContext facesContext) throws MalformedURLException {
        return getBaseURL(facesContext.getExternalContext());
    }

    /**
     * &lt;p&gt;Determines the Base URL, e.g.,
     * {@literal http://localhost:8080/myApplication} from the
     * {@link ExternalContext}.&lt;/p&gt;
     *
     * @param externalContext The {@link ExternalContext} to examine.
     * @return the base URL.
     * @throws MalformedURLException if an exception occurs during parsing of
     * the URL.
     * @since 1.3
     */
    public String getBaseURL(final ExternalContext externalContext) throws MalformedURLException {
        return getBaseURL((HttpServletRequest) externalContext.getRequest());
    }

    /**
     * &lt;p&gt;Determines the Base URL, e.g.,
     * {@literal http://localhost:8080/myApplication} from the
     * {@link HttpServletRequest}.&lt;/p&gt;
     *
     * @param request The {@link HttpServletRequest} to examine.
     * @return the base URL.
     * @throws MalformedURLException if an exception occurs during parsing of
     * the URL.
     * @see URL
     * @since 1.3
     */
    public String getBaseURL(final HttpServletRequest request) throws MalformedURLException {
        return new URL(request.getScheme(),
                request.getServerName(),
                request.getServerPort(),
                request.getContextPath()).toString();
    }
]]&gt;&lt;/script&gt;&lt;img src="http://feeds.feedburner.com/~r/JavaEvangelistJohnYearysBlog/~4/KrAlCEPAYH0" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/JavaEvangelistJohnYearysBlog/~3/KrAlCEPAYH0/jsf-2x-tip-of-day-determining-base-url.html</link><author>noreply@blogger.com (John Yeary)</author><thr:total>2</thr:total><gd:extendedProperty name="commentSource" value="1" /><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD" /><feedburner:origLink>http://javaevangelist.blogspot.com/2013/01/jsf-2x-tip-of-day-determining-base-url.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-36773632.post-100360922774553831</guid><pubDate>Wed, 09 Jan 2013 21:01:00 +0000</pubDate><atom:updated>2013-01-09T16:01:17.374-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">example</category><category domain="http://www.blogger.com/atom/ns#">JSR-314</category><category domain="http://www.blogger.com/atom/ns#">JavaEE</category><category domain="http://www.blogger.com/atom/ns#">JSF</category><category domain="http://www.blogger.com/atom/ns#">tutorial</category><category domain="http://www.blogger.com/atom/ns#">glassfish</category><category domain="http://www.blogger.com/atom/ns#">Mojarra</category><category domain="http://www.blogger.com/atom/ns#">Netbeans</category><category domain="http://www.blogger.com/atom/ns#">JEE6</category><title>JSF 2.x Tip of the Day: Displaying Content Conditionally by FacesMessage.Severity</title><description>&lt;style type="text/css"&gt;
.nobrtable br { display: none;}
tr {
text-align:center;
} 
table {
width:200px;
border:1px solid #FF0000;
border-collapse:collapse;
cellpadding:10px; 
cellspacing:0px;
}
table th,td{
border:1px solid #FF0000;
}
caption {caption-side:bottom;}
&lt;/style&gt;
Many times we do, or do not want to display content based on whether there are &lt;a href="http://javaserverfaces.java.net/nonav/docs/2.1/javadocs/javax/faces/application/FacesMessage.html"&gt;&lt;code&gt;FacesMessage&lt;/code&gt;&amp;nbsp;&lt;/a&gt;queued to be displayed. The &lt;code&gt;&lt;a href="http://javaserverfaces.java.net/nonav/docs/2.1/javadocs/javax/faces/application/FacesMessage.Severity.html"&gt;FacesMessage.Severity&lt;/a&gt;&lt;/code&gt; can be used to help us determine if messages should be displayed. Please see the table below.
&lt;br /&gt;
&lt;br /&gt;
&lt;div class="nobrtable"&gt;
&lt;table&gt;
&lt;caption&gt;FacesMessage Values&lt;/caption&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Ordinal&lt;/th&gt;
&lt;th&gt;Severity&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;&lt;thead&gt;
&lt;/thead&gt;&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;INFO&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;WARN&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;ERROR&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;FATAL&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
The examples below demonstrate a couple of techniques to determine if a component (in this case a &amp;lt;ui:fragment/&amp;gt; containing a &amp;lt;ui:include/&amp;gt;) should be displayed based on whether&amp;nbsp;&lt;a href="http://javaserverfaces.java.net/nonav/docs/2.1/javadocs/javax/faces/application/FacesMessage.Severity.html" style="font-family: monospace;"&gt;FacesMessage.Severity&lt;/a&gt;&amp;nbsp;are present and if they are not equal to an informational message.
&lt;br /&gt;
&lt;br /&gt;
&lt;script class="brush: xhtml" type="syntaxhighlighter"&gt;&lt;![CDATA[
    &lt;ui:fragment rendered="#{empty facesContext.maximumSeverity or facesContext.maximumSeverity eq FacesMessage.SEVERITY_INFO}" &gt;
        &lt;ui:include src="somePage.xhtml"/&gt;
    &lt;/ui:fragment&gt;
]]&gt;&lt;/script&gt;

This is equivalent to the listing above.
&lt;br /&gt;
&lt;script class="brush: xhtml" type="syntaxhighlighter"&gt;&lt;![CDATA[
    &lt;ui:fragment rendered="#{empty facesContext.maximumSeverity or facesContext.maximumSeverity.ordinal eq 0}" &gt;
        &lt;ui:include src="somePage.xhtml"/&gt;
    &lt;/ui:fragment&gt;
]]&gt;&lt;/script&gt;

This displays if the messages are &lt;strong&gt;WARN&lt;/strong&gt; or less.
&lt;br /&gt;
&lt;script class="brush: xhtml" type="syntaxhighlighter"&gt;&lt;![CDATA[
    &lt;ui:fragment rendered="#{empty facesContext.maximumSeverity or facesContext.maximumSeverity.ordinal le 1}" &gt;
        &lt;ui:include src="somePage.xhtml"/&gt;
    &lt;/ui:fragment&gt;
]]&gt;&lt;/script&gt;&lt;img src="http://feeds.feedburner.com/~r/JavaEvangelistJohnYearysBlog/~4/jkBk7weiMZY" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/JavaEvangelistJohnYearysBlog/~3/jkBk7weiMZY/jsf-2x-tip-of-day-displaying-content.html</link><author>noreply@blogger.com (John Yeary)</author><thr:total>2</thr:total><gd:extendedProperty name="commentSource" value="1" /><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD" /><feedburner:origLink>http://javaevangelist.blogspot.com/2013/01/jsf-2x-tip-of-day-displaying-content.html</feedburner:origLink></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-36773632.post-3685531170118200902</guid><pubDate>Tue, 08 Jan 2013 17:25:00 +0000</pubDate><atom:updated>2013-01-08T12:25:57.635-05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Web</category><category domain="http://www.blogger.com/atom/ns#">stackoverflow</category><category domain="http://www.blogger.com/atom/ns#">AJAX</category><category domain="http://www.blogger.com/atom/ns#">Internet Explorer</category><category domain="http://www.blogger.com/atom/ns#">development</category><category domain="http://www.blogger.com/atom/ns#">jQuery</category><title>Internet Explorer 9 (IE9) Table White Space Issues </title><description>I was tasked with fixing a problem in our product where one of our data tables (HTML) was rendering on IE9 with spaces randomly scattered throughout the table this resulted in the data being in the wrong columns, or headers appearing in the wrong place. I originally thought I might there might be "holes", or null values in my data which was resulting in the error. I was wrong.&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;It is actually a bug in IE9.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
The issue shows up, most often, when using AJAX when there is partial page rendering. It seems according to forum remarks to be focused on white space between table tag elements like line breaks, spaces, or carriage returns. So if you use HTML tidy, you will screw up your output. &lt;b&gt;Nice one Microsoft!&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Fortunately, there are "fixes" out there to help you get along. Here is the fix which I slightly modified from an answer on &lt;a href="http://stackoverflow.com/a/3103269/160361" target="_blank"&gt;stackoverflow&lt;/a&gt;. A shout out goes to &lt;a href="http://stackoverflow.com/users/113999/blago"&gt;Blago&lt;/a&gt; for his recursive function listed below.
&lt;br /&gt;
&lt;script class="brush: js" type="syntaxhighlighter"&gt;&lt;![CDATA[
jQuery.fn.htmlClean = function() {
    this.contents().filter(function() {
        if (this.nodeType != 3) {
            $(this).htmlClean();
            return false;
        }
        else {
            return !/\S/.test(this.nodeValue);
        }
    }).remove();
    return this;
}
]]&gt;&lt;/script&gt;
&lt;br/&gt;
You can implement it this way.
&lt;br/&gt;
&lt;script class="brush: js" type="syntaxhighlighter"&gt;&lt;![CDATA[
$('#myTable').htmlClean();
]]&gt;&lt;/script&gt;
Here are some references on the issue if you are interested.
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://social.msdn.microsoft.com/Forums/en-US/iewebdevelopment/thread/e6f49d52-ec3f-47c5-802e-b80d1a58ed39/"&gt;[Bug]IE9 skips cells when rendering large table from Ajax using jquery&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://social.msdn.microsoft.com/Forums/en-AU/iewebdevelopment/thread/28d78780-c95c-4c35-9695-237ebb912d90"&gt;IE9 table layout apparently affected by whitespace between HTML elements&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://stackoverflow.com/questions/7267014/ie9-table-has-random-rows-which-are-offset-at-random-columns"&gt;IE9 table has random rows which are offset at random columns&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://stackoverflow.com/a/3103269/160361"&gt;Remove whitespace and line breaks between HTML elements using jQuery&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;img src="http://feeds.feedburner.com/~r/JavaEvangelistJohnYearysBlog/~4/StXHrlNRZd4" height="1" width="1"/&gt;</description><link>http://feedproxy.google.com/~r/JavaEvangelistJohnYearysBlog/~3/StXHrlNRZd4/internet-explorer-9-ie9-table-white.html</link><author>noreply@blogger.com (John Yeary)</author><thr:total>0</thr:total><gd:extendedProperty name="commentSource" value="1" /><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD" /><feedburner:origLink>http://javaevangelist.blogspot.com/2013/01/internet-explorer-9-ie9-table-white.html</feedburner:origLink></item></channel></rss>
