View Javadoc

1   package org.apache.myfaces.tobago.taglib.extension;
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  import org.apache.myfaces.tobago.apt.annotation.ExtensionTag;
21  import org.apache.myfaces.tobago.apt.annotation.Tag;
22  import org.apache.myfaces.tobago.taglib.decl.AbstractCommandTagDeclaration;
23  import org.apache.myfaces.tobago.internal.taglib.SelectOneRadioTag;
24  import org.apache.myfaces.tobago.internal.taglib.MenuItemTag;
25  import org.apache.myfaces.tobago.taglib.decl.HasConverter;
26  import org.apache.myfaces.tobago.taglib.decl.HasIdBindingAndRendered;
27  import org.apache.myfaces.tobago.taglib.decl.HasLabel;
28  import org.apache.myfaces.tobago.taglib.decl.HasValue;
29  import org.apache.myfaces.tobago.taglib.decl.IsDisabled;
30  
31  import javax.faces.webapp.FacetTag;
32  import javax.servlet.jsp.JspException;
33  import javax.servlet.jsp.tagext.BodyTagSupport;
34  
35  /*
36   * Date: 09.05.2006
37   * Time: 17:41:39
38   */
39  
40  /**
41   * Renders a submenu with select one items (like a radio button).
42   */
43  
44  @Tag(name = "menuRadio", tagExtraInfoClassName = "org.apache.myfaces.tobago.taglib.component.CommandTagExtraInfo")
45  @ExtensionTag(baseClassName = "org.apache.myfaces.tobago.internal.taglib.MenuRadioTag")
46  public class MenuRadioExtensionTag extends BodyTagSupport implements AbstractCommandTagDeclaration,
47      HasIdBindingAndRendered, HasLabel, IsDisabled, HasValue, HasConverter {
48  
49    private String rendered;
50    private String value;
51  
52    private MenuItemTag menuCommandTag;
53    private SelectOneRadioTag selectOneRadio;
54    private FacetTag facetTag;
55    private String action;
56    private String actionListener;
57    private String onclick;
58    private String link;
59    private String disabled;
60    private String binding;
61    private String label;
62    private String immediate;
63    private String transition;
64    private String converter;
65    private String renderedPartially;
66  
67    @Override
68    public int doStartTag() throws JspException {
69  
70      menuCommandTag = new MenuItemTag();
71      menuCommandTag.setPageContext(pageContext);
72      menuCommandTag.setParent(getParent());
73  
74      if (rendered != null) {
75        menuCommandTag.setRendered(rendered);
76      }
77      if (action != null) {
78        menuCommandTag.setAction(action);
79      }
80      if (actionListener != null) {
81        menuCommandTag.setActionListener(actionListener);
82      }
83      if (onclick != null) {
84        menuCommandTag.setOnclick(onclick);
85      }
86      if (link != null) {
87        menuCommandTag.setLink(link);
88      }
89      if (disabled != null) {
90        menuCommandTag.setDisabled(disabled);
91      }
92      if (binding != null) {
93        menuCommandTag.setBinding(binding);
94      }
95      if (label != null) {
96        menuCommandTag.setLabel(label);
97      }
98      if (immediate != null) {
99        menuCommandTag.setImmediate(immediate);
100     }
101     if (transition != null) {
102       menuCommandTag.setTransition(transition);
103     }
104     if (renderedPartially != null) {
105       menuCommandTag.setRenderedPartially(renderedPartially);
106     }
107     menuCommandTag.doStartTag();
108 
109     facetTag = new FacetTag();
110     facetTag.setPageContext(pageContext);
111     facetTag.setParent(menuCommandTag);
112     facetTag.setName(org.apache.myfaces.tobago.TobagoConstants.FACET_ITEMS);
113 
114     facetTag.doStartTag();
115     selectOneRadio = new SelectOneRadioTag();
116     selectOneRadio.setPageContext(pageContext);
117     selectOneRadio.setParent(facetTag);
118     if (converter != null) {
119       selectOneRadio.setConverter(converter);
120     }
121     if (value != null) {
122       selectOneRadio.setValue(value);
123     }
124     selectOneRadio.doStartTag();
125 
126     return super.doStartTag();
127   }
128 
129   @Override
130   public int doEndTag() throws JspException {
131     selectOneRadio.doEndTag();
132     facetTag.doEndTag();
133     menuCommandTag.doEndTag();
134 
135     return super.doEndTag();
136   }
137 
138   public void setAction(String action) {
139     this.action = action;
140   }
141 
142   public void setActionListener(String actionListener) {
143     this.actionListener = actionListener;
144   }
145 
146   public void setOnclick(String onclick) {
147     this.onclick = onclick;
148   }
149 
150   public void setLink(String navigate) {
151     this.link = navigate;
152   }
153 
154   public void setBinding(String binding) throws JspException {
155     this.binding = binding;
156   }
157 
158   public void setRendered(String rendered) {
159     this.rendered = rendered;
160   }
161 
162   public void setDisabled(String disabled) {
163     this.disabled = disabled;
164   }
165 
166   public void setValue(String value) {
167     this.value = value;
168   }
169 
170   public void setLabel(String label) {
171     this.label = label;
172   }
173 
174   public void setImmediate(String immediate) {
175     this.immediate = immediate;
176   }
177 
178   public void setTransition(String transition) {
179     this.transition = transition;
180   }
181 
182   public void setConverter(String converter) {
183     this.converter = converter;
184   }
185 
186   public void setRenderedPartially(String renderedPartially) {
187     this.renderedPartially = renderedPartially;
188   }
189 
190   public void release() {
191     super.release();
192     rendered = null;
193     value = null;
194     action = null;
195     actionListener = null;
196     onclick = null;
197     link = null;
198     disabled = null;
199     binding = null;
200     label = null;
201     immediate = null;
202     transition = null;
203     converter = null;
204     renderedPartially = null;
205     menuCommandTag = null;
206     facetTag = null;
207     selectOneRadio = null;
208   }
209 
210 }