View Javadoc

1   /*
2    * $Id: ClientDataTag.java,v 1.17 2011/06/16 09:29:41 jbmeslin Exp $
3    * 
4    */
5   package org.rcfaces.core.internal.taglib;
6   
7   import javax.el.ValueExpression;
8   import javax.faces.component.UIComponent;
9   import javax.faces.webapp.UIComponentClassicTagBase;
10  import javax.servlet.jsp.JspException;
11  import javax.servlet.jsp.tagext.Tag;
12  import javax.servlet.jsp.tagext.TagSupport;
13  
14  import org.rcfaces.core.internal.manager.IClientDataManager;
15  
16  /**
17   * 
18   * @author Olivier Oeuillot (latest modification by $Author: jbmeslin $)
19   * @version $Revision: 1.17 $ $Date: 2011/06/16 09:29:41 $
20   */
21  public class ClientDataTag extends TagSupport implements Tag {
22      private static final String REVISION = "$Revision: 1.17 $";
23  
24      private static final long serialVersionUID = -7633749361412060360L;
25  
26      protected String name;
27  
28      protected ValueExpression value;
29  
30      public  void setName(String name) {
31          this.name = name;
32      }
33  
34      public  void setValue(ValueExpression value) {
35          this.value = value;
36      }
37  
38      public int doStartTag() throws JspException {
39  
40          // Locate our parent UIComponentTag
41          UIComponentClassicTagBase tag = UIComponentClassicTagBase
42                  .getParentUIComponentClassicTagBase(pageContext);
43          if (tag == null) { // PENDING - i18n
44              throw new JspException("Not nested in a UIComponentTag");
45          }
46  
47          // Nothing to do unless this tag created a component
48          if (!tag.getCreated()) {
49              return (SKIP_BODY);
50          }
51  
52          // FacesContext facesContext = FacesContext.getCurrentInstance();
53          // Application application = facesContext.getApplication();
54  
55          UIComponent component = tag.getComponentInstance();
56          if ((component instanceof IClientDataManager) == false) {
57              throw new JspException(
58                      "Component does not implement IClientDataManager");
59  
60          }
61  
62          IClientDataManager clientDataCapability = (IClientDataManager) component;
63  
64          clientDataCapability.setClientData(name, value);
65  
66          return (SKIP_BODY);
67  
68      }
69  
70      /**
71       * <p>
72       * Release references to any acquired resources.
73       */
74      public void release() {
75          name = null;
76          value = null;
77  
78          super.release();
79      }
80  
81  }