View Javadoc

1   // ---------- Attention: Generated code, please do not modify! -----------  
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one or more
5    * contributor license agreements.  See the NOTICE file distributed with
6    * this work for additional information regarding copyright ownership.
7    * The ASF licenses this file to You under the Apache License, Version 2.0
8    * (the "License"); you may not use this file except in compliance with
9    * the License.  You may obtain a copy of the License at
10   *
11   *      http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing, software
14   * distributed under the License is distributed on an "AS IS" BASIS,
15   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   * See the License for the specific language governing permissions and
17   * limitations under the License.
18   */
19  
20  package org.apache.myfaces.tobago.internal.taglib;
21  
22  import javax.faces.application.Application;
23  import javax.faces.component.UIComponent;
24  import javax.faces.context.FacesContext;
25  import org.apache.myfaces.tobago.component.UIScript;
26  import org.apache.myfaces.tobago.internal.util.StringUtils;
27  import org.slf4j.Logger;
28  import org.slf4j.LoggerFactory;
29  
30  /** 
31   * JSP Tag class, generated from template {@code tag1.2.stg} with class 
32   * {@link org.apache.myfaces.tobago.internal.taglib.component.ScriptTagDeclaration}.
33   */
34  public final class ScriptTag extends TobagoELTag {
35    private static final Logger LOG = LoggerFactory.getLogger(ScriptTag.class);
36    private javax.el.ValueExpression  onload;
37    private javax.el.ValueExpression  file;
38    private javax.el.ValueExpression  onunload;
39    private javax.el.ValueExpression  script;
40    private javax.el.ValueExpression  onexit;
41    private javax.el.ValueExpression  onsubmit;
42  
43    @Override
44    public String getComponentType() {
45      return UIScript.COMPONENT_TYPE;
46    }
47    @Override
48    public String getRendererType() {
49      return "Script";
50    }
51  
52    @Override
53    protected void setProperties(final UIComponent uiComponent) {
54      super.setProperties(uiComponent);
55      final UIScript component = (UIScript) uiComponent;
56      final FacesContext context = FacesContext.getCurrentInstance();
57      final Application application = context.getApplication();
58      if (onload != null) {
59        component.setValueExpression("onload", onload);
60      }
61  
62      if (file != null) {
63        component.setValueExpression("file", file);
64      }
65  
66      if (onunload != null) {
67        component.setValueExpression("onunload", onunload);
68      }
69  
70      if (script != null) {
71        component.setValueExpression("script", script);
72      }
73  
74      if (onexit != null) {
75        component.setValueExpression("onexit", onexit);
76      }
77  
78      if (onsubmit != null) {
79        component.setValueExpression("onsubmit", onsubmit);
80      }
81  
82    }
83  
84    public javax.el.ValueExpression getOnload() {
85      return onload;
86    }
87  
88    public void setOnload(final javax.el.ValueExpression onload) {
89      this.onload = onload;
90    }
91  
92    public javax.el.ValueExpression getFile() {
93      return file;
94    }
95  
96    public void setFile(final javax.el.ValueExpression file) {
97      this.file = file;
98    }
99  
100   public javax.el.ValueExpression getOnunload() {
101     return onunload;
102   }
103 
104   public void setOnunload(final javax.el.ValueExpression onunload) {
105     this.onunload = onunload;
106   }
107 
108   public javax.el.ValueExpression getScript() {
109     return script;
110   }
111 
112   public void setScript(final javax.el.ValueExpression script) {
113     this.script = script;
114   }
115 
116   public javax.el.ValueExpression getOnexit() {
117     return onexit;
118   }
119 
120   public void setOnexit(final javax.el.ValueExpression onexit) {
121     this.onexit = onexit;
122   }
123 
124   public javax.el.ValueExpression getOnsubmit() {
125     return onsubmit;
126   }
127 
128   public void setOnsubmit(final javax.el.ValueExpression onsubmit) {
129     this.onsubmit = onsubmit;
130   }
131 
132 
133   @Override
134   public int doAfterBody() throws javax.servlet.jsp.JspException {
135     final String content = bodyContent.getString();
136     bodyContent.clearBody();
137     if (StringUtils.isNotBlank(content)) {
138       final UIScript component = (UIScript) getComponentInstance();
139       component.setScript(content.trim());
140     }
141     return super.doAfterBody();
142   }
143 
144   @Override
145   public void release() {
146     super.release();
147     onload = null;
148     file = null;
149     onunload = null;
150     script = null;
151     onexit = null;
152     onsubmit = null;
153   }
154 }