View Javadoc

1   /*
2    * $Id: ServerDataTag.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.IServerDataManager;
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 ServerDataTag extends TagSupport implements Tag {
22      private static final String REVISION = "$Revision: 1.17 $";
23  
24      private static final long serialVersionUID = 3654291027580195462L;
25  
26      private String name;
27  
28      private ValueExpression value;
29  
30      public final void setName(String name) {
31          this.name = name;
32      }
33  
34      public final 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 IServerDataManager) == false) {
57              throw new JspException(
58                      "Component does not implement IServerDataManager");
59  
60          }
61  
62          IServerDataManager serverDataCapability = (IServerDataManager) component;
63  
64          if (value.isLiteralText() == false) {
65              serverDataCapability.setServerData(name, value);
66  
67          } else {
68              serverDataCapability.setServerData(name, value);
69          }
70  
71          return (SKIP_BODY);
72  
73      }
74  
75      public void release() {
76          name = null;
77          value = null;
78  
79          super.release();
80      }
81  
82  }