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.UIStyle;
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.StyleTagDeclaration}.
33   */
34  public final class StyleTag extends TobagoELTag {
35    private static final Logger LOG = LoggerFactory.getLogger(StyleTag.class);
36    private javax.el.ValueExpression  style;
37    private javax.el.ValueExpression  file;
38  
39    @Override
40    public String getComponentType() {
41      return UIStyle.COMPONENT_TYPE;
42    }
43    @Override
44    public String getRendererType() {
45      return "Style";
46    }
47  
48    @Override
49    protected void setProperties(final UIComponent uiComponent) {
50      super.setProperties(uiComponent);
51      final UIStyle component = (UIStyle) uiComponent;
52      final FacesContext context = FacesContext.getCurrentInstance();
53      final Application application = context.getApplication();
54      if (style != null) {
55        component.setValueExpression("style", style);
56      }
57  
58      if (file != null) {
59        component.setValueExpression("file", file);
60      }
61  
62    }
63  
64    public javax.el.ValueExpression getStyle() {
65      return style;
66    }
67  
68    public void setStyle(final javax.el.ValueExpression style) {
69      this.style = style;
70    }
71  
72    public javax.el.ValueExpression getFile() {
73      return file;
74    }
75  
76    public void setFile(final javax.el.ValueExpression file) {
77      this.file = file;
78    }
79  
80  
81    @Override
82    public int doAfterBody() throws javax.servlet.jsp.JspException {
83      final String content = bodyContent.getString();
84      bodyContent.clearBody();
85      if (StringUtils.isNotBlank(content)) {
86        final UIStyle component = (UIStyle) getComponentInstance();
87        component.setStyle(content.trim());
88      }
89      return super.doAfterBody();
90    }
91  
92    @Override
93    public void release() {
94      super.release();
95      style = null;
96      file = null;
97    }
98  }