View Javadoc
1   package org.andromda.cartridges.jsf.renderkit;
2   
3   import java.io.IOException;
4   import java.util.UUID;
5   import javax.faces.component.UIComponent;
6   import javax.faces.context.FacesContext;
7   import javax.faces.render.Renderer;
8   import org.andromda.cartridges.jsf.component.TransactionToken;
9   
10  /**
11   * The transaction token renderer (just adds the transaction token value
12   * as an attribute of the parent component so we can skip multi-submits of the same action).
13   *
14   * @author Chad Brandon
15   */
16  public class TransactionTokenRenderer
17      extends Renderer
18  {
19      /**
20       * @see javax.faces.render.Renderer#encodeBegin(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
21       */
22      @SuppressWarnings("unchecked")
23      public void encodeBegin(
24          FacesContext context,
25          UIComponent component)
26          throws IOException
27      {
28          if (component.getParent() != null)
29          {
30              component.getParent().getAttributes().put(TransactionToken.TRANSACTION_TOKEN, UUID.randomUUID().toString());
31          }
32      }
33  }