View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  
20  package org.apache.myfaces.tobago.internal.taglib;
21  
22  import org.apache.myfaces.tobago.component.OnComponentCreated;
23  import org.apache.myfaces.tobago.component.OnComponentPopulated;
24  import org.apache.myfaces.tobago.internal.util.StringUtils;
25  
26  import javax.faces.component.UIComponent;
27  import javax.faces.webapp.UIComponentELTag;
28  import javax.servlet.jsp.JspException;
29  
30  
31  public abstract class TobagoELTag extends UIComponentELTag {
32  
33    @Override
34    public int doStartTag() throws JspException {
35      final int result = super.doStartTag();
36      final UIComponent component = getComponentInstance();
37      if (component instanceof OnComponentCreated
38          && component.getAttributes().get(OnComponentCreated.MARKER) == null) {
39        component.getAttributes().put(OnComponentCreated.MARKER, Boolean.TRUE);
40        ((OnComponentCreated) component).onComponentCreated(getFacesContext(), component.getParent());
41      }
42      return result;
43    }
44  
45    @Override
46    public int doEndTag() throws JspException {
47      final UIComponent component = getComponentInstance();
48      final int result = super.doEndTag();
49      if (component instanceof OnComponentPopulated
50          && component.getAttributes().get(OnComponentPopulated.MARKER) == null) {
51        component.getAttributes().put(OnComponentPopulated.MARKER, Boolean.TRUE);
52        ((OnComponentPopulated) component).onComponentPopulated(getFacesContext(), component.getParent());
53      }
54      return result;
55    }
56  
57    public String[] splitList(final String renderers) {
58      return StringUtils.split(renderers, ", ");
59    }
60  
61    /**
62     *
63     * @deprecated Not supported anymore
64     */
65    @Deprecated
66    protected String getBodyContentStr() {
67      final String content = bodyContent.getString();
68      bodyContent.clearBody();
69      return content;
70    }
71  
72    /**
73     *
74     * @deprecated Not supported anymore
75     */
76    @Deprecated
77    protected boolean isBodyContentEmpty() {
78      if (bodyContent != null) {
79        final String content = bodyContent.getString();
80        final String tmp = content.replace('\n', ' ');
81        if (tmp.trim().length() > 0) { // if there are only whitespaces: drop bodyContent
82          return false;
83        }
84      }
85      return true;
86    }
87  }