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.extension;
21  
22  import org.apache.myfaces.tobago.apt.annotation.ExtensionTag;
23  import org.apache.myfaces.tobago.apt.annotation.Tag;
24  import org.apache.myfaces.tobago.apt.annotation.TagAttribute;
25  import org.apache.myfaces.tobago.apt.annotation.UIComponentTagAttribute;
26  import org.apache.myfaces.tobago.component.Facets;
27  import org.apache.myfaces.tobago.internal.taglib.LabelTag;
28  import org.apache.myfaces.tobago.internal.taglib.SeparatorTag;
29  
30  import javax.faces.webapp.FacetTag;
31  import javax.servlet.jsp.JspException;
32  
33  /**
34   * Renders a separator.
35   * <br />
36   * Short syntax of:
37   * <p/>
38   * <pre>
39   * &lt;tc:separator>
40   *   &lt;f:facet name="label">
41   *     &lt;tc:label value="label"/>
42   *   &lt;/f:facet>
43   * &lt;/tc:separator>
44   * </pre>
45   */
46  @Tag(
47      name = "separator")
48  @ExtensionTag(
49      baseClassName = "org.apache.myfaces.tobago.internal.taglib.component.SeparatorTag",
50      componentType = "org.apache.myfaces.tobago.Separator",
51      rendererType = "Separator",
52      faceletHandler = "org.apache.myfaces.tobago.facelets.extension.SeparatorExtensionHandler")
53  public class SeparatorExtensionTag extends TobagoExtensionBodyTagSupport {
54    
55    private javax.el.ValueExpression binding;
56    private javax.el.ValueExpression rendered;
57    private javax.el.ValueExpression label;
58  
59    private SeparatorTag separatorTag;
60    private FacetTag facetTag;
61    private LabelTag labelTag;
62  
63    @Override
64    public int doStartTag() throws JspException {
65      separatorTag = new SeparatorTag();
66      separatorTag.setPageContext(pageContext);
67      separatorTag.setParent(getParent());
68      if (binding != null) {
69        separatorTag.setBinding(binding);
70      }
71      if (rendered != null) {
72        separatorTag.setRendered(rendered);
73      }
74      facetTag = new FacetTag();
75      facetTag.setPageContext(pageContext);
76      facetTag.setParent(separatorTag);
77      facetTag.setName(Facets.LABEL);
78  
79      facetTag.doStartTag();
80      labelTag = new LabelTag();
81      labelTag.setPageContext(pageContext);
82      labelTag.setParent(facetTag);
83      if (label != null) {
84        labelTag.setValue(label);
85      }
86      labelTag.setJspId(nextJspId());
87      labelTag.doStartTag();
88      return super.doStartTag();
89    }
90  
91    @Override
92    public int doEndTag() throws JspException {
93      labelTag.doEndTag();
94      facetTag.doEndTag();
95      separatorTag.doEndTag();
96      return super.doEndTag();
97    }
98  
99    @Override
100   public void release() {
101     super.release();
102     binding = null;
103     rendered = null;
104     label = null;
105     separatorTag = null;
106     facetTag = null;
107     labelTag = null;
108   }
109 
110   /**
111    * The value binding expression linking this
112    * component to a property in a backing bean.
113    */
114   @TagAttribute
115   @UIComponentTagAttribute(type = "javax.faces.component.UIComponent")
116   public void setBinding(final javax.el.ValueExpression binding) throws JspException {
117     this.binding = binding;
118   }
119   
120   /**
121    * Flag indicating whether or not this component should be rendered
122    * (during Render Response Phase), or processed on any subsequent form submit.
123    */
124   @TagAttribute
125   @UIComponentTagAttribute(type = "boolean", defaultValue = "true")
126   public void setRendered(final javax.el.ValueExpression rendered) {
127     this.rendered = rendered;
128   }
129 
130   /**
131    * Text value to display as label.
132    * If text contains an underscore the next character is used as accesskey.
133    */
134   @TagAttribute
135   @UIComponentTagAttribute()
136   public void setLabel(final javax.el.ValueExpression label) {
137     this.label = label;
138   }
139 }